Class FileRenameExclusiveReadLockStrategy
- java.lang.Object
-
- org.apache.camel.component.file.strategy.GenericFileRenameExclusiveReadLockStrategy<File>
-
- org.apache.camel.component.file.strategy.FileRenameExclusiveReadLockStrategy
-
- All Implemented Interfaces:
GenericFileExclusiveReadLockStrategy<File>
public class FileRenameExclusiveReadLockStrategy extends GenericFileRenameExclusiveReadLockStrategy<File>
Acquires exclusive read lock to the given file. Will wait until the lock is granted. After granting the read lock it is released, we just want to make sure that when we start consuming the file its not currently in progress of being written by third party. This implementation is only supported by the File component, that leverages theMarkerFileExclusiveReadLockStrategy
as well, to ensure only acquiring locks on files, which is not already in progress by another process, that have marked this using the marker file. Setting the optionsetMarkerFiler(boolean)
to false allows to turn off using marker files.
-
-
Constructor Summary
Constructors Constructor Description FileRenameExclusiveReadLockStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
acquireExclusiveReadLock(GenericFileOperations<File> operations, GenericFile<File> file, org.apache.camel.Exchange exchange)
Acquires exclusive read lock to the file.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
setMarkerFiler(boolean markerFile)
Sets whether marker file should be used or not.-
Methods inherited from class org.apache.camel.component.file.strategy.GenericFileRenameExclusiveReadLockStrategy
getTimeout, prepareOnStartup, setCheckInterval, setDeleteOrphanLockFiles, setReadLockLoggingLevel, setTimeout
-
-
-
-
Method Detail
-
acquireExclusiveReadLock
public boolean acquireExclusiveReadLock(GenericFileOperations<File> operations, GenericFile<File> file, org.apache.camel.Exchange exchange) throws Exception
Description copied from interface:GenericFileExclusiveReadLockStrategy
Acquires exclusive read lock to the file.- Specified by:
acquireExclusiveReadLock
in interfaceGenericFileExclusiveReadLockStrategy<File>
- Overrides:
acquireExclusiveReadLock
in classGenericFileRenameExclusiveReadLockStrategy<File>
- Parameters:
operations
- generic file operationsfile
- the fileexchange
- the exchange- Returns:
- true if read lock was acquired. If false Camel will skip the file and try it on the next poll
- Throws:
Exception
- can be thrown in case of errors
-
releaseExclusiveReadLockOnAbort
public void releaseExclusiveReadLockOnAbort(GenericFileOperations<File> operations, GenericFile<File> file, org.apache.camel.Exchange exchange) throws Exception
Description copied from interface:GenericFileExclusiveReadLockStrategy
Releases the exclusive read lock granted by the acquireExclusiveReadLock method due an abort operation (acquireExclusiveReadLock returned false).- Specified by:
releaseExclusiveReadLockOnAbort
in interfaceGenericFileExclusiveReadLockStrategy<File>
- Overrides:
releaseExclusiveReadLockOnAbort
in classGenericFileRenameExclusiveReadLockStrategy<File>
- Parameters:
operations
- generic file operationsfile
- the fileexchange
- the exchange- Throws:
Exception
- can be thrown in case of errors
-
releaseExclusiveReadLockOnRollback
public void releaseExclusiveReadLockOnRollback(GenericFileOperations<File> operations, GenericFile<File> file, org.apache.camel.Exchange exchange) throws Exception
Description copied from interface:GenericFileExclusiveReadLockStrategy
Releases the exclusive read lock granted by the acquireExclusiveReadLock method due a rollback operation (Exchange processing failed)- Specified by:
releaseExclusiveReadLockOnRollback
in interfaceGenericFileExclusiveReadLockStrategy<File>
- Overrides:
releaseExclusiveReadLockOnRollback
in classGenericFileRenameExclusiveReadLockStrategy<File>
- Parameters:
operations
- generic file operationsfile
- the fileexchange
- the exchange- Throws:
Exception
- can be thrown in case of errors
-
releaseExclusiveReadLockOnCommit
public void releaseExclusiveReadLockOnCommit(GenericFileOperations<File> operations, GenericFile<File> file, org.apache.camel.Exchange exchange) throws Exception
Description copied from interface:GenericFileExclusiveReadLockStrategy
Releases the exclusive read lock granted by the acquireExclusiveReadLock method due a commit operation (Exchange processing succeeded)- Specified by:
releaseExclusiveReadLockOnCommit
in interfaceGenericFileExclusiveReadLockStrategy<File>
- Overrides:
releaseExclusiveReadLockOnCommit
in classGenericFileRenameExclusiveReadLockStrategy<File>
- Parameters:
operations
- generic file operationsfile
- the fileexchange
- the exchange- Throws:
Exception
- can be thrown in case of errors
-
setMarkerFiler
public void setMarkerFiler(boolean markerFile)
Description copied from interface:GenericFileExclusiveReadLockStrategy
Sets whether marker file should be used or not.- Specified by:
setMarkerFiler
in interfaceGenericFileExclusiveReadLockStrategy<File>
- Overrides:
setMarkerFiler
in classGenericFileRenameExclusiveReadLockStrategy<File>
- Parameters:
markerFile
- true to use marker files.
-
-