org.apache.camel.component.file.strategy
Class FileChangedExclusiveReadLockStrategy

java.lang.Object
  extended by org.apache.camel.component.file.strategy.MarkerFileExclusiveReadLockStrategy
      extended by 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).


Constructor Summary
FileChangedExclusiveReadLockStrategy()
           
 
Method Summary
 boolean acquireExclusiveReadLock(GenericFileOperations<File> operations, GenericFile<File> file, Exchange exchange)
          Acquires exclusive read lock to the file.
 long getCheckInterval()
           
 long getMinLength()
           
 long getTimeout()
           
 void setCheckInterval(long checkInterval)
          Sets the check interval period.
 void setMinLength(long minLength)
           
 void setReadLockLoggingLevel(LoggingLevel readLockLoggingLevel)
          Sets logging level used when a read lock could not be acquired.
 void setTimeout(long timeout)
          Sets an optional timeout period.
 
Methods inherited from class org.apache.camel.component.file.strategy.MarkerFileExclusiveReadLockStrategy
prepareOnStartup, releaseExclusiveReadLock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileChangedExclusiveReadLockStrategy

public FileChangedExclusiveReadLockStrategy()
Method Detail

acquireExclusiveReadLock

public boolean acquireExclusiveReadLock(GenericFileOperations<File> operations,
                                        GenericFile<File> file,
                                        Exchange exchange)
                                 throws Exception
Description copied from interface: GenericFileExclusiveReadLockStrategy
Acquires exclusive read lock to the file.

Specified by:
acquireExclusiveReadLock in interface GenericFileExclusiveReadLockStrategy<File>
Overrides:
acquireExclusiveReadLock in class MarkerFileExclusiveReadLockStrategy
Parameters:
operations - generic file operations
file - the file
exchange - 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: GenericFileExclusiveReadLockStrategy
Sets 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:
setTimeout in interface GenericFileExclusiveReadLockStrategy<File>
Overrides:
setTimeout in class MarkerFileExclusiveReadLockStrategy
Parameters:
timeout - period in millis

getCheckInterval

public long getCheckInterval()

setCheckInterval

public void setCheckInterval(long checkInterval)
Description copied from interface: GenericFileExclusiveReadLockStrategy
Sets 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:
setCheckInterval in interface GenericFileExclusiveReadLockStrategy<File>
Overrides:
setCheckInterval in class MarkerFileExclusiveReadLockStrategy
Parameters:
checkInterval - interval in millis

setReadLockLoggingLevel

public void setReadLockLoggingLevel(LoggingLevel readLockLoggingLevel)
Description copied from interface: GenericFileExclusiveReadLockStrategy
Sets 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:
setReadLockLoggingLevel in interface GenericFileExclusiveReadLockStrategy<File>
Overrides:
setReadLockLoggingLevel in class MarkerFileExclusiveReadLockStrategy
Parameters:
readLockLoggingLevel - LoggingLevel

getMinLength

public long getMinLength()

setMinLength

public void setMinLength(long minLength)


Apache Camel