public class FileIdempotentRepositoryReadLockStrategy extends ServiceSupport implements GenericFileExclusiveReadLockStrategy<File>, CamelContextAware
IdempotentRepository as the lock strategy. This allows to plugin and use existing
idempotent repositories that for example supports clustering. The other read lock strategies that are using marker files or file locks,
are not guaranteed to work in clustered setup with various platform and file systems.shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending| Constructor and Description |
|---|
FileIdempotentRepositoryReadLockStrategy() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acquireExclusiveReadLock(GenericFileOperations<File> operations,
GenericFile<File> file,
Exchange exchange)
Acquires exclusive read lock to the file.
|
protected String |
asKey(GenericFile<File> file) |
protected void |
doStart()
Implementations override this method to support customized start/stop.
|
protected void |
doStop()
Implementations override this method to support customized start/stop.
|
CamelContext |
getCamelContext()
Get the
CamelContext |
IdempotentRepository<String> |
getIdempotentRepository()
The idempotent repository to use as the store for the read locks.
|
boolean |
isRemoveOnCommit()
Whether to remove the file from the idempotent repository when doing a commit.
|
boolean |
isRemoveOnRollback()
Whether to remove the file from the idempotent repository when doing a rollback.
|
void |
prepareOnStartup(GenericFileOperations<File> operations,
GenericFileEndpoint<File> endpoint)
Allows custom logic to be run on startup preparing the strategy, such as removing old lock files etc.
|
void |
releaseExclusiveReadLockOnAbort(GenericFileOperations<File> operations,
GenericFile<File> file,
Exchange exchange)
Releases the exclusive read lock granted by the acquireExclusiveReadLock method due an abort operation (acquireExclusiveReadLock returned false).
|
void |
releaseExclusiveReadLockOnCommit(GenericFileOperations<File> operations,
GenericFile<File> file,
Exchange exchange)
Releases the exclusive read lock granted by the acquireExclusiveReadLock method due a commit operation (Exchange processing succeeded)
|
void |
releaseExclusiveReadLockOnRollback(GenericFileOperations<File> operations,
GenericFile<File> file,
Exchange exchange)
Releases the exclusive read lock granted by the acquireExclusiveReadLock method due a rollback operation (Exchange processing failed)
|
void |
setCamelContext(CamelContext camelContext)
Injects the
CamelContext |
void |
setCheckInterval(long checkInterval)
Sets the check interval period.
|
void |
setDeleteOrphanLockFiles(boolean deleteOrphanLockFiles)
Sets whether orphan marker files should be deleted upon startup
|
void |
setIdempotentRepository(IdempotentRepository<String> idempotentRepository)
The idempotent repository to use as the store for the read locks.
|
void |
setMarkerFiler(boolean markerFile)
Sets whether marker file should be used or not.
|
void |
setReadLockLoggingLevel(LoggingLevel readLockLoggingLevel)
Sets logging level used when a read lock could not be acquired.
|
void |
setRemoveOnCommit(boolean removeOnCommit)
Whether to remove the file from the idempotent repository when doing a commit.
|
void |
setRemoveOnRollback(boolean removeOnRollback)
Whether to remove the file from the idempotent repository when doing a rollback.
|
void |
setTimeout(long timeout)
Sets an optional timeout period.
|
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendpublic FileIdempotentRepositoryReadLockStrategy()
public void prepareOnStartup(GenericFileOperations<File> operations, GenericFileEndpoint<File> endpoint) throws Exception
GenericFileExclusiveReadLockStrategyprepareOnStartup in interface GenericFileExclusiveReadLockStrategy<File>operations - generic file operationsendpoint - the endpointException - can be thrown in case of errorspublic boolean acquireExclusiveReadLock(GenericFileOperations<File> operations, GenericFile<File> file, Exchange exchange) throws Exception
GenericFileExclusiveReadLockStrategyacquireExclusiveReadLock in interface GenericFileExclusiveReadLockStrategy<File>operations - generic file operationsfile - the fileexchange - the exchangeException - can be thrown in case of errorspublic void releaseExclusiveReadLockOnAbort(GenericFileOperations<File> operations, GenericFile<File> file, Exchange exchange) throws Exception
GenericFileExclusiveReadLockStrategyreleaseExclusiveReadLockOnAbort in interface GenericFileExclusiveReadLockStrategy<File>operations - generic file operationsfile - the fileexchange - the exchangeException - can be thrown in case of errorspublic void releaseExclusiveReadLockOnRollback(GenericFileOperations<File> operations, GenericFile<File> file, Exchange exchange) throws Exception
GenericFileExclusiveReadLockStrategyreleaseExclusiveReadLockOnRollback in interface GenericFileExclusiveReadLockStrategy<File>operations - generic file operationsfile - the fileexchange - the exchangeException - can be thrown in case of errorspublic void releaseExclusiveReadLockOnCommit(GenericFileOperations<File> operations, GenericFile<File> file, Exchange exchange) throws Exception
GenericFileExclusiveReadLockStrategyreleaseExclusiveReadLockOnCommit in interface GenericFileExclusiveReadLockStrategy<File>operations - generic file operationsfile - the fileexchange - the exchangeException - can be thrown in case of errorspublic void setTimeout(long timeout)
GenericFileExclusiveReadLockStrategysetTimeout in interface GenericFileExclusiveReadLockStrategy<File>timeout - period in millispublic void setCheckInterval(long checkInterval)
GenericFileExclusiveReadLockStrategysetCheckInterval in interface GenericFileExclusiveReadLockStrategy<File>checkInterval - interval in millispublic void setReadLockLoggingLevel(LoggingLevel readLockLoggingLevel)
GenericFileExclusiveReadLockStrategysetReadLockLoggingLevel in interface GenericFileExclusiveReadLockStrategy<File>readLockLoggingLevel - LoggingLevelpublic void setMarkerFiler(boolean markerFile)
GenericFileExclusiveReadLockStrategysetMarkerFiler in interface GenericFileExclusiveReadLockStrategy<File>markerFile - true to use marker files.public void setDeleteOrphanLockFiles(boolean deleteOrphanLockFiles)
GenericFileExclusiveReadLockStrategysetDeleteOrphanLockFiles in interface GenericFileExclusiveReadLockStrategy<File>deleteOrphanLockFiles - true to delete files, false to skip this checkpublic CamelContext getCamelContext()
CamelContextAwareCamelContextgetCamelContext in interface CamelContextAwarepublic void setCamelContext(CamelContext camelContext)
CamelContextAwareCamelContextsetCamelContext in interface CamelContextAwarecamelContext - the Camel contextpublic IdempotentRepository<String> getIdempotentRepository()
public void setIdempotentRepository(IdempotentRepository<String> idempotentRepository)
public boolean isRemoveOnRollback()
public void setRemoveOnRollback(boolean removeOnRollback)
public boolean isRemoveOnCommit()
public void setRemoveOnCommit(boolean removeOnCommit)
protected String asKey(GenericFile<File> file)
protected void doStart() throws Exception
ServiceSupportServiceSupport.doStop() for more details.doStart in class ServiceSupportExceptionServiceSupport.doStop()protected void doStop() throws Exception
ServiceSupportServiceSupport.doStop() method when
the service is being stopped. This method will also be invoked
if the service is still in uninitialized state (eg has not
been started). The method is always called to allow the service
to do custom logic when the service is being stopped, such as when
CamelContext is shutting down.doStop in class ServiceSupportExceptionServiceSupport.doStart()Apache Camel