java.lang.Object
org.rrd4j.core.RrdBackendFactory
org.rrd4j.core.RrdMemoryBackendFactory
- All Implemented Interfaces:
Closeable, AutoCloseable
@RrdBackendAnnotation(name="MEMORY", shouldValidateHeader=false) public class RrdMemoryBackendFactoryextends RrdBackendFactory
Factory class which creates actual
RrdMemoryBackend objects. Rrd4j's support for in-memory RRDs is still experimental. You should know that all active RrdMemoryBackend objects are held in memory, each backend object stores RRD data in one big byte array. This implementation is therefore quite basic and memory hungry but runs very fast.Calling close() on RrdDb objects does not release any memory at all (RRD data must be available for the next new RrdDb(path) call. To release allocated memory, you'll have to call delete(path) method of this class.
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<String, AtomicReference<ByteBuffer>> Open RRD buffers by RRD ID, held until delete() removes them.Fields inherited from class RrdBackendFactory
cachingAllowed, DEFAULTFACTORY, name, scheme, validateHeaderModifier and TypeFieldDescriptionprotected final booleanWhether this factory's backends may cache data in memory.static final StringDefault backend factory name.protected final StringStorage name this factory reports to RrdDb.protected final StringURI scheme this factory's storage URIs start with.protected final booleanWhether opened files must carry the RRD header.Constructor Summary
ConstructorsConstructorDescriptionA factory holding no open backends; the map starts empty and is filled byopen(String, boolean)as RRDs are opened and released bydelete(String).Method Summary
All MethodsModifier and TypeMethodDescriptionbooleanAccepts only URIs whose scheme matches this backend's memory scheme.booleanRemoves the storage with the given ID from the memory.protected booleanDetermines if a storage with the given path already exists.protected RrdBackendOpens the backend serving a storage path.Methods inherited from class RrdBackendFactory
addActiveFactories, buildGenericUri, checkClosing, close, exists, findFactory, getActiveFactories, getBackend, getBackend, getCanonicalUri, getDefaultFactory, getName, getPath, getRootUri, getScheme, getUri, resolve, setActiveFactories, shouldValidateHeader, shouldValidateHeaderModifier and TypeMethodDescriptionstatic voidaddActiveFactories(RrdBackendFactory... newFactories) /** Add factories to the list of active factories, i.e.static URIbuildGenericUri(String rrdpath) Try to detect an URI from a path.voidCheck that all phantom reference are indeed safely closed.voidclose()A generic close handle, default implementation does nothing.protected booleanDetermines if a storage with the given URI already exists.static RrdBackendFactoryfindFactory(URI uri) For a given URI, try to find a factory that can manage it in the list of active factories.static java.util.stream.Stream<RrdBackendFactory> Return the current active factories as a stream.(package private) RrdBackendgetBackend(RrdDb rrdDb, String path, boolean readOnly) Creates RrdBackend object for the given storage path.(package private) RrdBackendgetBackend(RrdDb rrdDb, URI uri, boolean readOnly) Creates RrdBackend object for the given storage path.getCanonicalUri(URI uri) Ensure that an URI is returned in a non-ambiguous way.static RrdBackendFactory/** /** Returns the default backend factory.getName()Returns the name (primary ID) for the factory.Extract the local path from an URI.protected URIBuilds the root URI for this factory's scheme.The URI scheme that selects this backend, used to build every RRD URI the factory hands out.Transform an path in a valid URI for this backend.protected URITry to match an URI against a root URI using a few rules: scheme must match if they are given.static voidsetActiveFactories(RrdBackendFactory... newFactories) Set the list of active factories, i.e.protected booleanshouldValidateHeader(String path) Determines if the header should be validated.protected booleanshouldValidateHeader(URI uri) Determines if the header should be validated.
Field Details
backends
Open RRD buffers by RRD ID, held until delete() removes them.
Constructor Details
RrdMemoryBackendFactory
public RrdMemoryBackendFactory()A factory holding no open backends; the map starts empty and is filled byopen(String, boolean)as RRDs are opened and released bydelete(String).
Method Details
open
Opens the backend serving a storage path.Creates RrdMemoryBackend object.
- Specified by:
openin classRrdBackendFactory- Parameters:
id- the storage path, relative to this factory's root URIreadOnly- true to open the storage for reading only, false to allow writes- Returns:
- the backend that performs all I/O for the given storage path
canStore
Accepts only URIs whose scheme matches this backend's memory scheme.- Overrides:
canStorein classRrdBackendFactory- Parameters:
uri- the candidate storage URI to test against this factory- Returns:
- false unless a subclass overrides this to recognise its own URIs
exists
Determines if a storage with the given path already exists.Method to determine if a memory storage with the given ID already exists.
- Specified by:
existsin classRrdBackendFactory- Parameters:
id- File system path to probe for.- Returns:
- true if a storage already exists at the given path
delete
Removes the storage with the given ID from the memory.- Parameters:
id- Storage ID, the key this factory registered the storage under- Returns:
- true if a storage was removed, false if the ID was unknown