public class FileIdempotentChangedRepositoryReadLockStrategy extends org.apache.camel.support.service.ServiceSupport implements GenericFileExclusiveReadLockStrategy<File>, org.apache.camel.CamelContextAware
IdempotentRepository
and
changed
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.Constructor and Description |
---|
FileIdempotentChangedRepositoryReadLockStrategy() |
Modifier and Type | Method and Description |
---|---|
boolean |
acquireExclusiveReadLock(GenericFileOperations<File> operations,
GenericFile<File> file,
org.apache.camel.Exchange exchange)
Acquires exclusive read lock to the file.
|
protected String |
asKey(GenericFile<File> file) |
protected void |
doStart() |
protected void |
doStop() |
org.apache.camel.CamelContext |
getCamelContext() |
org.apache.camel.spi.IdempotentRepository |
getIdempotentRepository()
The idempotent repository to use as the store for the read locks.
|
int |
getReadLockIdempotentReleaseAsyncPoolSize() |
ScheduledExecutorService |
getReadLockIdempotentReleaseExecutorService() |
boolean |
isReadLockIdempotentReleaseAsync() |
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,
org.apache.camel.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,
org.apache.camel.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,
org.apache.camel.Exchange exchange)
Releases the exclusive read lock granted by the
acquireExclusiveReadLock method due a rollback operation
(Exchange processing failed)
|
void |
setCamelContext(org.apache.camel.CamelContext 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(org.apache.camel.spi.IdempotentRepository 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 |
setMinAge(long minAge) |
void |
setMinLength(long minLength) |
void |
setReadLockIdempotentReleaseAsync(boolean readLockIdempotentReleaseAsync)
Whether the delayed release task should be synchronous or asynchronous.
|
void |
setReadLockIdempotentReleaseAsyncPoolSize(int readLockIdempotentReleaseAsyncPoolSize)
The number of threads in the scheduled thread pool when using
asynchronous release tasks.
|
void |
setReadLockIdempotentReleaseDelay(int readLockIdempotentReleaseDelay)
Whether to delay the release task for a period of millis.
|
void |
setReadLockIdempotentReleaseExecutorService(ScheduledExecutorService readLockIdempotentReleaseExecutorService)
To use a custom and shared thread pool for asynchronous release tasks.
|
void |
setReadLockLoggingLevel(org.apache.camel.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.
|
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, suspend
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public FileIdempotentChangedRepositoryReadLockStrategy()
public void prepareOnStartup(GenericFileOperations<File> operations, GenericFileEndpoint<File> endpoint) throws Exception
GenericFileExclusiveReadLockStrategy
prepareOnStartup
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, org.apache.camel.Exchange exchange) throws Exception
GenericFileExclusiveReadLockStrategy
acquireExclusiveReadLock
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, org.apache.camel.Exchange exchange) throws Exception
GenericFileExclusiveReadLockStrategy
releaseExclusiveReadLockOnAbort
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, org.apache.camel.Exchange exchange) throws Exception
GenericFileExclusiveReadLockStrategy
releaseExclusiveReadLockOnRollback
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, org.apache.camel.Exchange exchange) throws Exception
GenericFileExclusiveReadLockStrategy
releaseExclusiveReadLockOnCommit
in interface GenericFileExclusiveReadLockStrategy<File>
operations
- generic file operationsfile
- the fileexchange
- the exchangeException
- can be thrown in case of errorspublic void setTimeout(long timeout)
GenericFileExclusiveReadLockStrategy
setTimeout
in interface GenericFileExclusiveReadLockStrategy<File>
timeout
- period in millispublic void setCheckInterval(long checkInterval)
GenericFileExclusiveReadLockStrategy
setCheckInterval
in interface GenericFileExclusiveReadLockStrategy<File>
checkInterval
- interval in millispublic void setReadLockLoggingLevel(org.apache.camel.LoggingLevel readLockLoggingLevel)
GenericFileExclusiveReadLockStrategy
setReadLockLoggingLevel
in interface GenericFileExclusiveReadLockStrategy<File>
readLockLoggingLevel
- LoggingLevelpublic void setMarkerFiler(boolean markerFile)
GenericFileExclusiveReadLockStrategy
setMarkerFiler
in interface GenericFileExclusiveReadLockStrategy<File>
markerFile
- true to use marker files.public void setDeleteOrphanLockFiles(boolean deleteOrphanLockFiles)
GenericFileExclusiveReadLockStrategy
setDeleteOrphanLockFiles
in interface GenericFileExclusiveReadLockStrategy<File>
deleteOrphanLockFiles
- true to delete files,
false to skip this checkpublic void setMinLength(long minLength)
public void setMinAge(long minAge)
public org.apache.camel.CamelContext getCamelContext()
getCamelContext
in interface org.apache.camel.CamelContextAware
public void setCamelContext(org.apache.camel.CamelContext camelContext)
setCamelContext
in interface org.apache.camel.CamelContextAware
public org.apache.camel.spi.IdempotentRepository getIdempotentRepository()
public void setIdempotentRepository(org.apache.camel.spi.IdempotentRepository idempotentRepository)
public boolean isRemoveOnRollback()
public void setRemoveOnRollback(boolean removeOnRollback)
public boolean isRemoveOnCommit()
public void setRemoveOnCommit(boolean removeOnCommit)
public void setReadLockIdempotentReleaseDelay(int readLockIdempotentReleaseDelay)
public boolean isReadLockIdempotentReleaseAsync()
public void setReadLockIdempotentReleaseAsync(boolean readLockIdempotentReleaseAsync)
public int getReadLockIdempotentReleaseAsyncPoolSize()
public void setReadLockIdempotentReleaseAsyncPoolSize(int readLockIdempotentReleaseAsyncPoolSize)
public ScheduledExecutorService getReadLockIdempotentReleaseExecutorService()
public void setReadLockIdempotentReleaseExecutorService(ScheduledExecutorService readLockIdempotentReleaseExecutorService)
protected String asKey(GenericFile<File> file)
protected void doStart() throws Exception
doStart
in class org.apache.camel.support.service.BaseService
Exception
Apache Camel