@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)
Creates RrdNioBackend object for the given file path.
|
static void |
setSyncPeriod(int syncPeriod)
Sets time between consecutive background synchronizations.
|
static void |
setSyncPoolSize(int syncPoolSize)
Sets the number of synchronizing threads.
|
void |
setSyncThreadPool(RrdSyncThreadPool syncThreadPool)
Deprecated.
Create a custom instance instead
|
void |
setSyncThreadPool(ScheduledExecutorService syncThreadPool)
Deprecated.
Create a custom instance instead
|
canStore, exists, getCanonicalUri, getPath, getUri
addActiveFactories, addFactories, buildGenericUri, checkClosing, exists, findFactory, getBackend, getBackend, getDefaultFactory, getFactory, getName, getRootUri, getScheme, registerAndSetAsDefaultFactory, registerFactory, resolve, setActiveFactories, setDefaultFactory, shouldValidateHeader, shouldValidateHeader
public static final int DEFAULT_SYNC_PERIOD
setSyncPeriod(int)
method.public static final int DEFAULT_SYNC_CORE_POOL_SIZE
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, ScheduledExecutorService syncThreadPool)
syncPeriod
- the sync period, in seconds.syncThreadPool
- If null, disable background sync threadspublic RrdNioBackendFactory(int syncPeriod, RrdSyncThreadPool syncThreadPool)
syncPeriod
- the sync period, in seconds.syncThreadPool
- If null, disable background sync threadspublic static int getSyncPeriod()
setSyncPeriod(int)
method call, defaults to DEFAULT_SYNC_PERIOD
.
See setSyncPeriod(int)
for more information.public static void setSyncPeriod(int syncPeriod)
syncPeriod
- Time in seconds between consecutive background synchronizations.public static int getSyncPoolSize()
setSyncPoolSize(int)
method call, defaults to DEFAULT_SYNC_CORE_POOL_SIZE
.
See setSyncPoolSize(int)
for more information.public static void setSyncPoolSize(int syncPoolSize)
syncPoolSize
- Number of synchronizing threads.@Deprecated public void setSyncThreadPool(RrdSyncThreadPool syncThreadPool)
Setter for the field syncThreadPool
.
syncThreadPool
- the RrdSyncThreadPool to use to sync the memory-mapped files.@Deprecated public void setSyncThreadPool(ScheduledExecutorService syncThreadPool)
Setter for the field syncThreadPool
.
syncThreadPool
- the ScheduledExecutorService that will back the RrdSyncThreadPool used to sync the memory-mapped files.protected RrdBackend open(String path, boolean readOnly) throws IOException
open
in class RrdBackendFactory
IOException
public RrdSyncThreadPool getSyncThreadPool()
RrdSyncThreadPool
or null if syncing is disabledpublic void close() throws IOException
RrdBackendFactory
close
in interface Closeable
close
in interface AutoCloseable
close
in class RrdBackendFactory
IOException
- if the close fails