@RrdBackendAnnotation(name="NIO", shouldValidateHeader=true) public class RrdNioBackendFactory extends RrdFileBackendFactory
RrdNioBackend objects. This is the
default factory since 1.4.0 version.
Each RrdNioBackendFactory is optionally backed by a RrdSyncThreadPool,
which it uses to sync the memory-mapped files to disk. In order to avoid having these threads
live longer than they should, it is recommended that clients create and destroy thread pools at
the appropriate time in their application's life time. Failure to manage thread pools
appropriately may lead to the thread pool hanging around longer than necessary, which in turn may
cause memory leaks.
if sync period is negative, no sync thread will be launched
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_SYNC_CORE_POOL_SIZE
The core pool size for the sync executor.
|
static int |
DEFAULT_SYNC_PERIOD
Period in seconds between consecutive synchronizations when sync-mode is set to
SYNC_BACKGROUND.
|
cachingAllowed, DEFAULTFACTORY, name, scheme, validateHeader| Constructor and Description |
|---|
RrdNioBackendFactory()
Creates a new RrdNioBackendFactory with default settings.
|
RrdNioBackendFactory(int syncPeriod)
Creates a new RrdNioBackendFactory, using a default
RrdSyncThreadPool. |
RrdNioBackendFactory(int syncPeriod,
int syncPoolSize)
Creates a new RrdNioBackendFactory.
|
RrdNioBackendFactory(int syncPeriod,
RrdSyncThreadPool syncThreadPool)
Creates a new RrdNioBackendFactory.
|
RrdNioBackendFactory(int syncPeriod,
ScheduledExecutorService syncThreadPool)
Creates a new RrdNioBackendFactory.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
A generic close handle, default implementation does nothing.
|
static int |
getSyncPeriod()
Returns time between two consecutive background synchronizations.
|
static int |
getSyncPoolSize()
Returns the number of synchronizing threads.
|
RrdSyncThreadPool |
getSyncThreadPool() |
protected RrdBackend |
open(String path,
boolean readOnly) |
static void |
setSyncPeriod(int syncPeriod)
Sets time between consecutive background synchronizations.
|
static void |
setSyncPoolSize(int syncPoolSize)
Sets the number of synchronizing threads.
|
canStore, exists, getCanonicalUri, getPath, getUriaddActiveFactories, buildGenericUri, checkClosing, exists, findFactory, getActiveFactories, getBackend, getBackend, getDefaultFactory, getName, getRootUri, getScheme, resolve, setActiveFactories, shouldValidateHeader, shouldValidateHeaderpublic static final int DEFAULT_SYNC_CORE_POOL_SIZE
public static final int DEFAULT_SYNC_PERIOD
setSyncPeriod(int) method.public RrdNioBackendFactory()
public RrdNioBackendFactory(int syncPeriod)
RrdSyncThreadPool.syncPeriod - the sync period, in seconds. If negative or 0, sync threads are disabled.public RrdNioBackendFactory(int syncPeriod,
int syncPoolSize)
syncPeriod - the sync period, in seconds.syncPoolSize - The number of threads to use to sync the mapped file to disk, if negative
or 0, sync threads are disabled.public RrdNioBackendFactory(int syncPeriod,
RrdSyncThreadPool syncThreadPool)
syncPeriod - the sync period, in seconds.syncThreadPool - If null, disable background sync threadspublic RrdNioBackendFactory(int syncPeriod,
ScheduledExecutorService syncThreadPool)
syncPeriod - the sync period, in seconds.syncThreadPool - If null, disable background sync threadspublic void close()
RrdBackendFactoryclose in interface Closeableclose in interface AutoCloseableclose in class RrdBackendFactorypublic static int getSyncPeriod()
setSyncPeriod(int) method call, defaults to DEFAULT_SYNC_PERIOD. See setSyncPeriod(int) for more information.public static int getSyncPoolSize()
setSyncPoolSize(int)
method call, defaults to DEFAULT_SYNC_CORE_POOL_SIZE. See setSyncPoolSize(int) for more information.public RrdSyncThreadPool getSyncThreadPool()
RrdSyncThreadPool or null if syncing is disabledprotected RrdBackend open(String path, boolean readOnly) throws IOException
Creates RrdNioBackend object for the given file path.
open in class RrdBackendFactoryIOExceptionpublic static void setSyncPeriod(int syncPeriod)
syncPeriod - Time in seconds between consecutive background synchronizations.public static void setSyncPoolSize(int syncPoolSize)
syncPoolSize - Number of synchronizing threads.