Exemplo n.º 1
0
    def accessor(self):
        if not self._accessor:
            accessor = graphite_utils.accessor_from_settings(self._settings)
            accessor.connect()
            self._accessor = accessor

        return self._accessor
Exemplo n.º 2
0
 def accessor(self):
     """Return an accessor."""
     if not self._accessor:
         from django.conf import settings as django_settings
         self._accessor = graphite_utils.accessor_from_settings(django_settings)
         self._accessor.connect()
     return self._accessor
Exemplo n.º 3
0
    def test_accessor_from_settings(self):
        import types

        settings = types.ModuleType("settings")
        settings.BG_DRIVER = "memory"
        accessor = bg_graphite_utils.accessor_from_settings(settings)
        self.assertNotEqual(accessor, None)
Exemplo n.º 4
0
 def __init__(self, settings):
     try:
         self._accessor = graphite_utils.accessor_from_settings(settings)
         self._accessor.connect()
     except graphite_utils.ConfigError as e:
         raise carbon_exceptions.CarbonConfigException(e)
     storage_path = graphite_utils.storage_path_from_settings(settings)
     self._cache = metadata_cache.DiskCache(self._accessor, storage_path)
     self._cache.open()
Exemplo n.º 5
0
 def accessor(self):
     """Return an accessor."""
     with self._lock:
         if not self._accessor:
             from django.conf import settings as django_settings
             accessor = graphite_utils.accessor_from_settings(django_settings)
             # If connect() fail it will raise an exception that will be caught
             # by the caller. If the plugin is called again, self._accessor will
             # still be None and a new accessor will be created.
             try:
                 accessor.connect()
             except Exception as e:
                 log.exception("failed to connect()")
                 accessor.shutdown()
                 raise e
             self._accessor = accessor
     return self._accessor
Exemplo n.º 6
0
 def accessor(self):
     """Return an accessor."""
     with self._lock:
         if not self._accessor:
             from django.conf import settings as django_settings
             accessor = graphite_utils.accessor_from_settings(
                 django_settings)
             # If connect() fail it will raise an exception that will be caught
             # by the caller. If the plugin is called again, self._accessor will
             # still be None and a new accessor will be created.
             try:
                 accessor.connect()
             except Exception as e:
                 log.exception("failed to connect()")
                 accessor.shutdown()
                 raise e
             accessor.set_cache(
                 bg_accessor_cache.DjangoCache(self.django_cache()),
                 metadata_ttl=django_settings.FIND_CACHE_DURATION,
                 data_ttl=django_settings.DEFAULT_CACHE_DURATION)
             self._accessor = accessor
     return self._accessor
Exemplo n.º 7
0
    def accessor(self):
        """Return an accessor."""
        with self._lock:
            if not self._accessor:
                from django.conf import settings as django_settings

                accessor = graphite_utils.accessor_from_settings(django_settings)
                # If connect() fail it will raise an exception that will be caught
                # by the caller. If the plugin is called again, self._accessor will
                # still be None and a new accessor will be created.
                try:
                    accessor.connect()
                except Exception as e:
                    log.exception("failed to connect()")
                    accessor.shutdown()
                    raise e
                accessor.set_cache(
                    bg_accessor_cache.DjangoCache(self.django_cache()),
                    metadata_ttl=django_settings.FIND_CACHE_DURATION,
                    data_ttl=django_settings.DEFAULT_CACHE_DURATION,
                )
                self._accessor = accessor
        return self._accessor