Class SolrRrdBackendFactory

  • All Implemented Interfaces:
    Closeable, AutoCloseable, SolrCloseable

    public class SolrRrdBackendFactory
    extends org.rrd4j.core.RrdBackendFactory
    implements SolrCloseable
    RRD backend factory using Solr documents as underlying storage.

    RRD databases are identified by paths in the format solr:dbName. Typically the path will correspond to the name of metric or a group of metrics, eg: solr:QUERY./select.requests

    NOTE: Solr doesn't register instances of this factory in the static registry RrdBackendFactory.registerFactory(RrdBackendFactory) because it's then impossible to manage its life-cycle.

    • Constructor Detail

      • SolrRrdBackendFactory

        public SolrRrdBackendFactory​(SolrClient solrClient,
                                     String collection,
                                     int syncPeriod,
                                     TimeSource timeSource)
        Create a factory.
        Parameters:
        solrClient - SolrClient to use
        collection - collection name where documents are stored (typically this is CollectionAdminParams.SYSTEM_COLL)
        syncPeriod - synchronization period in seconds - how often modified databases are stored as updated Solr documents
        timeSource - time source
    • Method Detail

      • getTimeSource

        public TimeSource getTimeSource()
      • canStore

        public boolean canStore​(URI uri)
        Overrides:
        canStore in class org.rrd4j.core.RrdBackendFactory
      • getPath

        public String getPath​(URI uri)
        Overrides:
        getPath in class org.rrd4j.core.RrdBackendFactory
      • getUri

        public URI getUri​(String path)
        Overrides:
        getUri in class org.rrd4j.core.RrdBackendFactory
      • getCanonicalUri

        public URI getCanonicalUri​(URI uri)
        Overrides:
        getCanonicalUri in class org.rrd4j.core.RrdBackendFactory
      • open

        protected org.rrd4j.core.RrdBackend open​(String path,
                                                 boolean readOnly)
                                          throws IOException
        Open (or get) a backend.
        Specified by:
        open in class org.rrd4j.core.RrdBackendFactory
        Parameters:
        path - backend path (without URI scheme)
        readOnly - if true then the backend will never be synchronized to Solr, and updates will be silently ignored. Read-only backends can be safely closed and discarded after use.
        Returns:
        an instance of Solr backend.
        Throws:
        IOException - on Solr error when retrieving existing data
      • list

        public List<Pair<String,​Long>> list​(int maxLength)
                                           throws IOException
        List all available databases created by this node name
        Parameters:
        maxLength - maximum number of results to return
        Returns:
        list of database names and their last update times, or empty
        Throws:
        IOException - on server errors
      • removeAll

        public void removeAll()
                       throws IOException
        Remove all databases created by this node name.
        Throws:
        IOException - on server error
      • remove

        public void remove​(String path)
                    throws IOException
        Remove a database.
        Parameters:
        path - database path.
        Throws:
        IOException - on Solr exception
      • exists

        public boolean exists​(String path)
                       throws IOException
        Check for existence of a backend.
        Specified by:
        exists in class org.rrd4j.core.RrdBackendFactory
        Parameters:
        path - backend path, without the URI scheme
        Returns:
        true when a backend exists. Note that a backend may exist only in memory if it was created recently within syncPeriod.
        Throws:
        IOException - on Solr exception
      • isPersistent

        public boolean isPersistent()
      • setPersistent

        public void setPersistent​(boolean persistent)
      • shouldValidateHeader

        protected boolean shouldValidateHeader​(String path)
                                        throws IOException
        Overrides:
        shouldValidateHeader in class org.rrd4j.core.RrdBackendFactory
        Throws:
        IOException
      • getName

        public String getName()
        Overrides:
        getName in class org.rrd4j.core.RrdBackendFactory
      • close

        public void close()
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Overrides:
        close in class org.rrd4j.core.RrdBackendFactory