Package org.apache.camel.impl.engine
Class FileStateRepository
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.impl.engine.FileStateRepository
- All Implemented Interfaces:
AutoCloseable,org.apache.camel.Service,org.apache.camel.ShutdownableService,org.apache.camel.spi.StateRepository<String,,String> org.apache.camel.StatefulService,org.apache.camel.SuspendableService
@ManagedResource(description="File based state repository")
public class FileStateRepository
extends org.apache.camel.support.service.ServiceSupport
implements org.apache.camel.spi.StateRepository<String,String>
This
FileStateRepository class is a file-based implementation of a StateRepository.-
Field Summary
Fields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoStart()protected voiddoStop()static FileStateRepositoryfileStateRepository(File fileStore) Creates a new file based repository using as 1st level cachestatic FileStateRepositoryfileStateRepository(File fileStore, long maxFileStoreSize) Creates a new file based repository using aHashMapas 1st level cache.static FileStateRepositoryfileStateRepository(File store, Map<String, String> cache) Creates a new file based repository using the givenMapas 1st level cache.getCache()longprotected voidLoads the given file store into the 1st level cachevoidreset()Resets and clears the store to force it to reload from filevoidvoidsetFileStore(File fileStore) voidsetMaxFileStoreSize(long maxFileStoreSize) Sets the maximum file size for the file store in bytes.voidprotected voidTrunks the file store when the max store size is hit by rewriting the 1st level cache to the file store.Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Constructor Details
-
FileStateRepository
public FileStateRepository() -
FileStateRepository
-
-
Method Details
-
fileStateRepository
Creates a new file based repository using as 1st level cache- Parameters:
fileStore- the file store
-
fileStateRepository
Creates a new file based repository using aHashMapas 1st level cache.- Parameters:
fileStore- the file storemaxFileStoreSize- the max size in bytes for the fileStore file
-
fileStateRepository
Creates a new file based repository using the givenMapas 1st level cache. Care should be taken to use a suitable underlyingMapto avoid this class being a memory leak.- Parameters:
store- the file storecache- the cache to use as 1st level cache
-
setState
-
getState
-
reset
@ManagedOperation(description="Reset and reloads the file store") public void reset() throws IOExceptionResets and clears the store to force it to reload from file- Throws:
IOException
-
trunkStore
protected void trunkStore()Trunks the file store when the max store size is hit by rewriting the 1st level cache to the file store. -
loadStore
Loads the given file store into the 1st level cache- Throws:
IOException
-
doStart
- Overrides:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doStop
- Overrides:
doStopin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
getFileStore
-
setFileStore
-
getFilePath
-
getCache
-
setCache
-
getMaxFileStoreSize
@ManagedAttribute(description="The maximum file size for the file store in bytes") public long getMaxFileStoreSize() -
setMaxFileStoreSize
@ManagedAttribute(description="The maximum file size for the file store in bytes") public void setMaxFileStoreSize(long maxFileStoreSize) Sets the maximum file size for the file store in bytes. The default is 1mb.
-