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.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.
-
-
Field Summary
Fields Modifier and Type Field Description static String
DATA_FIELD
static int
DEFAULT_MAX_DBS
static int
DEFAULT_SYNC_PERIOD
static String
DOC_TYPE
static String
ID_PREFIX
static String
ID_SEP
static String
NAME
static String
URI_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 boolean
canStore(URI uri)
void
close()
boolean
exists(String path)
Check for existence of a backend.URI
getCanonicalUri(URI uri)
String
getName()
String
getPath(URI uri)
TimeSource
getTimeSource()
URI
getUri(String path)
boolean
isClosed()
boolean
isPersistent()
List<Pair<String,Long>>
list(int maxLength)
List all available databases created by this node nameprotected org.rrd4j.core.RrdBackend
open(String path, boolean readOnly)
Open (or get) a backend.void
remove(String path)
Remove a database.void
removeAll()
Remove all databases created by this node name.void
setPersistent(boolean persistent)
protected boolean
shouldValidateHeader(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:
canStore
in classorg.rrd4j.core.RrdBackendFactory
-
getPath
public String getPath(URI uri)
- Overrides:
getPath
in classorg.rrd4j.core.RrdBackendFactory
-
getCanonicalUri
public URI getCanonicalUri(URI uri)
- Overrides:
getCanonicalUri
in classorg.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 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 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 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:
shouldValidateHeader
in classorg.rrd4j.core.RrdBackendFactory
- Throws:
IOException
-
getName
public String getName()
- Overrides:
getName
in classorg.rrd4j.core.RrdBackendFactory
-
isClosed
public boolean isClosed()
- Specified by:
isClosed
in interfaceSolrCloseable
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classorg.rrd4j.core.RrdBackendFactory
-
-