Class FileChangedExclusiveReadLockStrategy
- java.lang.Object
-
- org.apache.camel.component.file.strategy.MarkerFileExclusiveReadLockStrategy
-
- org.apache.camel.component.file.strategy.FileChangedExclusiveReadLockStrategy
-
- All Implemented Interfaces:
GenericFileExclusiveReadLockStrategy<File>
public class FileChangedExclusiveReadLockStrategy extends MarkerFileExclusiveReadLockStrategy
Acquires exclusive read lock to the given file by checking whether the file is being changed by scanning the file at different intervals (to detect changes). Setting the optionMarkerFileExclusiveReadLockStrategy.setMarkerFiler(boolean)to false allows to turn off using marker files.
-
-
Constructor Summary
Constructors Constructor Description FileChangedExclusiveReadLockStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanacquireExclusiveReadLock(GenericFileOperations<File> operations, GenericFile<File> file, org.apache.camel.Exchange exchange)Acquires exclusive read lock to the file.longgetCheckInterval()longgetMinAge()longgetMinLength()longgetTimeout()voidsetCheckInterval(long checkInterval)Sets the check interval period.voidsetMinAge(long minAge)voidsetMinLength(long minLength)voidsetReadLockLoggingLevel(org.apache.camel.LoggingLevel readLockLoggingLevel)Sets logging level used when a read lock could not be acquired.voidsetTimeout(long timeout)Sets an optional timeout period.-
Methods inherited from class org.apache.camel.component.file.strategy.MarkerFileExclusiveReadLockStrategy
doReleaseExclusiveReadLock, prepareOnStartup, releaseExclusiveReadLockOnAbort, releaseExclusiveReadLockOnCommit, releaseExclusiveReadLockOnRollback, setDeleteOrphanLockFiles, setMarkerFiler
-
-
-
-
Method Detail
-
acquireExclusiveReadLock
public boolean acquireExclusiveReadLock(GenericFileOperations<File> operations, GenericFile<File> file, org.apache.camel.Exchange exchange) throws Exception
Description copied from interface:GenericFileExclusiveReadLockStrategyAcquires exclusive read lock to the file.- Specified by:
acquireExclusiveReadLockin interfaceGenericFileExclusiveReadLockStrategy<File>- Overrides:
acquireExclusiveReadLockin classMarkerFileExclusiveReadLockStrategy- 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
-
getTimeout
public long getTimeout()
-
setTimeout
public void setTimeout(long timeout)
Description copied from interface:GenericFileExclusiveReadLockStrategySets an optional timeout period. If the readlock could not be granted within the time period then the wait is stopped and the acquireExclusiveReadLock method returns false.- Specified by:
setTimeoutin interfaceGenericFileExclusiveReadLockStrategy<File>- Overrides:
setTimeoutin classMarkerFileExclusiveReadLockStrategy- Parameters:
timeout- period in millis
-
getCheckInterval
public long getCheckInterval()
-
setCheckInterval
public void setCheckInterval(long checkInterval)
Description copied from interface:GenericFileExclusiveReadLockStrategySets the check interval period. The check interval is used for sleeping between attempts to acquire read lock. Setting a high value allows to cater for slow writes in case the producer of the file is slow. The default period is 1000 millis.- Specified by:
setCheckIntervalin interfaceGenericFileExclusiveReadLockStrategy<File>- Overrides:
setCheckIntervalin classMarkerFileExclusiveReadLockStrategy- Parameters:
checkInterval- interval in millis
-
setReadLockLoggingLevel
public void setReadLockLoggingLevel(org.apache.camel.LoggingLevel readLockLoggingLevel)
Description copied from interface:GenericFileExclusiveReadLockStrategySets logging level used when a read lock could not be acquired. Logging level used when a read lock could not be acquired. The default logging level is WARN- Specified by:
setReadLockLoggingLevelin interfaceGenericFileExclusiveReadLockStrategy<File>- Overrides:
setReadLockLoggingLevelin classMarkerFileExclusiveReadLockStrategy- Parameters:
readLockLoggingLevel- LoggingLevel
-
getMinLength
public long getMinLength()
-
setMinLength
public void setMinLength(long minLength)
-
getMinAge
public long getMinAge()
-
setMinAge
public void setMinAge(long minAge)
-
-