Package org.rrd4j.core
Class RrdSafeFileBackendFactory
java.lang.Object
org.rrd4j.core.RrdBackendFactory
org.rrd4j.core.RrdFileBackendFactory
org.rrd4j.core.RrdRandomAccessFileBackendFactory
org.rrd4j.core.RrdSafeFileBackendFactory
- All Implemented Interfaces:
Closeable
,AutoCloseable
@RrdBackendAnnotation(name="SAFE", shouldValidateHeader=true, cachingAllowed=false) public class RrdSafeFileBackendFactory extends RrdRandomAccessFileBackendFactory
Factory class which creates actual
RrdSafeFileBackend
objects.
Because of locking, each RrdDb can be open only once even from within the JVM. So usage
of the RrdDbPool
is mandatory with this backend.
-
Field Summary
Fields Modifier and Type Field Description static long
LOCK_RETRY_PERIOD
Default time between two consecutive file locking attempts.static long
LOCK_WAIT_TIME
Default time (in milliseconds) this backend will wait for a file lock.Fields inherited from class org.rrd4j.core.RrdBackendFactory
cachingAllowed, DEFAULTFACTORY, name, scheme, validateHeader
-
Constructor Summary
Constructors Constructor Description RrdSafeFileBackendFactory()
Generate a factory using the default system wide lock settingsRrdSafeFileBackendFactory(long lockWaitTime, long lockRetryPeriod)
Generate a factory with custom lock settings -
Method Summary
Modifier and Type Method Description static long
getLockRetryPeriod()
Returns time between two consecutive file locking attempts.static long
getLockWaitTime()
Returns time this backend will wait for a file lock.protected RrdBackend
open(String path, boolean readOnly)
Creates RrdFileBackend object for the given file path.static void
setLockRetryPeriod(long lockRetryPeriod)
Sets time between two consecutive file locking attempts.static void
setLockWaitTime(long lockWaitTime)
Sets time this backend will wait for a file lock.Methods inherited from class org.rrd4j.core.RrdFileBackendFactory
canStore, exists, getCanonicalUri, getPath, getUri
Methods inherited from class org.rrd4j.core.RrdBackendFactory
addActiveFactories, addFactories, buildGenericUri, checkClosing, close, exists, findFactory, getActiveFactories, getBackend, getBackend, getDefaultFactory, getFactory, getName, getRootUri, getScheme, registerAndSetAsDefaultFactory, registerFactory, resolve, setActiveFactories, setDefaultFactory, shouldValidateHeader, shouldValidateHeader
-
Field Details
-
LOCK_WAIT_TIME
public static final long LOCK_WAIT_TIMEDefault time (in milliseconds) this backend will wait for a file lock.- See Also:
- Constant Field Values
-
LOCK_RETRY_PERIOD
public static final long LOCK_RETRY_PERIODDefault time between two consecutive file locking attempts.- See Also:
- Constant Field Values
-
-
Constructor Details
-
RrdSafeFileBackendFactory
public RrdSafeFileBackendFactory()Generate a factory using the default system wide lock settings -
RrdSafeFileBackendFactory
public RrdSafeFileBackendFactory(long lockWaitTime, long lockRetryPeriod)Generate a factory with custom lock settings- Parameters:
lockWaitTime
- wait time in mslockRetryPeriod
- retry period in ms
-
-
Method Details
-
open
Creates RrdFileBackend object for the given file path. Creates RrdSafeFileBackend object for the given file path.- Overrides:
open
in classRrdRandomAccessFileBackendFactory
- Throws:
IOException
-
getLockWaitTime
public static long getLockWaitTime()Returns time this backend will wait for a file lock.- Returns:
- Time (in milliseconds) this backend will wait for a file lock.
-
setLockWaitTime
public static void setLockWaitTime(long lockWaitTime)Sets time this backend will wait for a file lock.- Parameters:
lockWaitTime
- Maximum lock wait time (in milliseconds)
-
getLockRetryPeriod
public static long getLockRetryPeriod()Returns time between two consecutive file locking attempts.- Returns:
- Time (im milliseconds) between two consecutive file locking attempts.
-
setLockRetryPeriod
public static void setLockRetryPeriod(long lockRetryPeriod)Sets time between two consecutive file locking attempts.- Parameters:
lockRetryPeriod
- time (in milliseconds) between two consecutive file locking attempts.
-