Package org.rrd4j.core
Class RrdSyncThreadPool
- java.lang.Object
-
- org.rrd4j.core.RrdSyncThreadPool
-
public class RrdSyncThreadPool extends Object
Thread pool used byRrdNioBackend
instances to periodically sync the mapped file to disk. Note that instances of RrdSyncThreadPool must be disposed of by callingshutdown()
.For ease of use in standalone applications, clients may choose to register a shutdown hook by calling
registerShutdownHook()
. However, in web applications it is best to explicitlyshutdown()
the pool when the application is un-deployed, usually within ajavax.servlet.ServletContextListener
.- Since:
- 2.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
RrdSyncThreadPool.DaemonThreadFactory
Daemon thread factory used by the monitor executors.
-
Constructor Summary
Constructors Constructor Description RrdSyncThreadPool()
Creates a new RrdSyncThreadPool with a default pool size of 6.RrdSyncThreadPool(int syncPoolSize)
Creates a new RrdSyncThreadPool with the given pool size.RrdSyncThreadPool(int syncPoolSize, ThreadFactory threadFactory)
Creates a new RrdSyncThreadPool with the given pool size.RrdSyncThreadPool(ScheduledExecutorService syncExecutor)
Creates a new RrdSyncThreadPool with a user-provided ScheduledExecutorService.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RrdSyncThreadPool
registerShutdownHook()
Registers a shutdown hook that destroys the underlying thread pool when when the JVM is about to quit.(package private) ScheduledFuture<?>
scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)
void
shutdown()
Shuts down this thread pool in an orderly manner.void
unregisterShutdownHook()
Unregisters the shutdown hook installed byregisterShutdownHook()
.
-
-
-
Constructor Detail
-
RrdSyncThreadPool
public RrdSyncThreadPool()
Creates a new RrdSyncThreadPool with a default pool size of 6.
-
RrdSyncThreadPool
public RrdSyncThreadPool(ScheduledExecutorService syncExecutor)
Creates a new RrdSyncThreadPool with a user-provided ScheduledExecutorService.- Parameters:
syncExecutor
- the ScheduledExecutorService to use for sync'ing mapped files to disk
-
RrdSyncThreadPool
public RrdSyncThreadPool(int syncPoolSize)
Creates a new RrdSyncThreadPool with the given pool size.- Parameters:
syncPoolSize
- the number of threads to use to sync the mapped file to disk
-
RrdSyncThreadPool
public RrdSyncThreadPool(int syncPoolSize, ThreadFactory threadFactory)
Creates a new RrdSyncThreadPool with the given pool size. Threads will be created bythreadFactory
.- Parameters:
syncPoolSize
- the number of threads to use to sync the mapped file to diskthreadFactory
- the ThreadFactory to use for creating threads
-
-
Method Detail
-
registerShutdownHook
public RrdSyncThreadPool registerShutdownHook()
Registers a shutdown hook that destroys the underlying thread pool when when the JVM is about to quit.- Returns:
- this
- See Also:
unregisterShutdownHook()
-
unregisterShutdownHook
public void unregisterShutdownHook()
Unregisters the shutdown hook installed byregisterShutdownHook()
. Has no effect if the hook is not currently installed.- See Also:
unregisterShutdownHook()
-
shutdown
public void shutdown()
Shuts down this thread pool in an orderly manner. Has no effect if it has already been called previously.
-
scheduleWithFixedDelay
ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)
-
-