Package org.apache.solr.metrics.rrd
Class SolrRrdBackendFactory
- java.lang.Object
-
- org.rrd4j.core.RrdBackendFactory
-
- org.apache.solr.metrics.rrd.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.requestsNOTE: 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.
-
-
Field Summary
Fields Modifier and Type Field Description static StringDATA_FIELDstatic intDEFAULT_MAX_DBSstatic intDEFAULT_SYNC_PERIODstatic StringDOC_TYPEstatic StringID_PREFIXstatic StringID_SEPstatic StringNAMEstatic StringURI_PREFIX
-
Constructor Summary
Constructors Constructor Description SolrRrdBackendFactory(SolrClient solrClient, String collection, int syncPeriod, TimeSource timeSource)Create a factory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanStore(URI uri)voidclose()booleanexists(String path)Check for existence of a backend.URIgetCanonicalUri(URI uri)StringgetName()StringgetPath(URI uri)TimeSourcegetTimeSource()URIgetUri(String path)booleanisClosed()booleanisPersistent()List<Pair<String,Long>>list(int maxLength)List all available databases created by this node nameprotected org.rrd4j.core.RrdBackendopen(String path, boolean readOnly)Open (or get) a backend.voidremove(String path)Remove a database.voidremoveAll()Remove all databases created by this node name.voidsetPersistent(boolean persistent)protected booleanshouldValidateHeader(String path)-
Methods inherited from class org.rrd4j.core.RrdBackendFactory
addActiveFactories, addFactories, buildGenericUri, checkClosing, exists, findFactory, getDefaultFactory, getFactory, getRootUri, getScheme, registerAndSetAsDefaultFactory, registerFactory, resolve, setActiveFactories, setDefaultFactory, shouldValidateHeader
-
-
-
-
Field Detail
-
DEFAULT_SYNC_PERIOD
public static final int DEFAULT_SYNC_PERIOD
- See Also:
- Constant Field Values
-
DEFAULT_MAX_DBS
public static final int DEFAULT_MAX_DBS
- See Also:
- Constant Field Values
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
URI_PREFIX
public static final String URI_PREFIX
- See Also:
- Constant Field Values
-
ID_SEP
public static final String ID_SEP
- See Also:
- Constant Field Values
-
ID_PREFIX
public static final String ID_PREFIX
- See Also:
- Constant Field Values
-
DOC_TYPE
public static final String DOC_TYPE
- See Also:
- Constant Field Values
-
DATA_FIELD
public static final String DATA_FIELD
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SolrRrdBackendFactory
public SolrRrdBackendFactory(SolrClient solrClient, String collection, int syncPeriod, TimeSource timeSource)
Create a factory.- Parameters:
solrClient- SolrClient to usecollection- collection name where documents are stored (typically this isCollectionAdminParams.SYSTEM_COLL)syncPeriod- synchronization period in seconds - how often modified databases are stored as updated Solr documentstimeSource- time source
-
-
Method Detail
-
getTimeSource
public TimeSource getTimeSource()
-
canStore
public boolean canStore(URI uri)
- Overrides:
canStorein classorg.rrd4j.core.RrdBackendFactory
-
getPath
public String getPath(URI uri)
- Overrides:
getPathin classorg.rrd4j.core.RrdBackendFactory
-
getCanonicalUri
public URI getCanonicalUri(URI uri)
- Overrides:
getCanonicalUriin classorg.rrd4j.core.RrdBackendFactory
-
open
protected org.rrd4j.core.RrdBackend open(String path, boolean readOnly) throws IOException
Open (or get) a backend.- Specified by:
openin classorg.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 IOExceptionRemove 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:
existsin classorg.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:
shouldValidateHeaderin classorg.rrd4j.core.RrdBackendFactory- Throws:
IOException
-
getName
public String getName()
- Overrides:
getNamein classorg.rrd4j.core.RrdBackendFactory
-
isClosed
public boolean isClosed()
- Specified by:
isClosedin interfaceSolrCloseable
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classorg.rrd4j.core.RrdBackendFactory
-
-