CAMEL-8727: File consumer - Add read lock that is based on idempotent repository
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/855a925f Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/855a925f Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/855a925f Branch: refs/heads/master Commit: 855a925f48116f8a23c78b28efe89b693bc54a44 Parents: 5d5c5a4 Author: Claus Ibsen <davscl...@apache.org> Authored: Sun May 3 07:56:53 2015 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Sun May 3 10:52:35 2015 +0200 ---------------------------------------------------------------------- .../file/strategy/GenericFileDeleteProcessStrategy.java | 6 +++--- .../FileConsumerBridgeRouteExceptionHandlerTest.java | 12 +++++++++++- .../file/FileConsumerCustomExceptionHandlerTest.java | 12 +++++++++++- .../strategy/FtpChangedExclusiveReadLockStrategy.java | 12 +++++++++++- .../strategy/SftpChangedExclusiveReadLockStrategy.java | 12 +++++++++++- 5 files changed, 47 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/855a925f/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategy.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategy.java b/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategy.java index 524363f..9cafde6 100644 --- a/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategy.java +++ b/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategy.java @@ -55,7 +55,7 @@ public class GenericFileDeleteProcessStrategy<T> extends GenericFileProcessStrat boolean releaseEager = exclusiveReadLockStrategy instanceof FileLockExclusiveReadLockStrategy; if (releaseEager) { - exclusiveReadLockStrategy.releaseExclusiveReadLock(operations, file, exchange); + exclusiveReadLockStrategy.releaseExclusiveReadLockOnCommit(operations, file, exchange); } try { @@ -91,7 +91,7 @@ public class GenericFileDeleteProcessStrategy<T> extends GenericFileProcessStrat } finally { // must release lock last if (!releaseEager && exclusiveReadLockStrategy != null) { - exclusiveReadLockStrategy.releaseExclusiveReadLock(operations, file, exchange); + exclusiveReadLockStrategy.releaseExclusiveReadLockOnCommit(operations, file, exchange); } } } @@ -117,7 +117,7 @@ public class GenericFileDeleteProcessStrategy<T> extends GenericFileProcessStrat } finally { // must release lock last if (exclusiveReadLockStrategy != null) { - exclusiveReadLockStrategy.releaseExclusiveReadLock(operations, file, exchange); + exclusiveReadLockStrategy.releaseExclusiveReadLockOnRollback(operations, file, exchange); } } } http://git-wip-us.apache.org/repos/asf/camel/blob/855a925f/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBridgeRouteExceptionHandlerTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBridgeRouteExceptionHandlerTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBridgeRouteExceptionHandlerTest.java index 8321de5..989af6a 100644 --- a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBridgeRouteExceptionHandlerTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerBridgeRouteExceptionHandlerTest.java @@ -97,7 +97,17 @@ public class FileConsumerBridgeRouteExceptionHandlerTest extends ContextTestSupp } @Override - public void releaseExclusiveReadLock(GenericFileOperations<File> operations, GenericFile<File> file, Exchange exchange) throws Exception { + public void releaseExclusiveReadLockOnAbort(GenericFileOperations<File> operations, GenericFile<File> file, Exchange exchange) throws Exception { + // noop + } + + @Override + public void releaseExclusiveReadLockOnRollback(GenericFileOperations<File> operations, GenericFile<File> file, Exchange exchange) throws Exception { + // noop + } + + @Override + public void releaseExclusiveReadLockOnCommit(GenericFileOperations<File> operations, GenericFile<File> file, Exchange exchange) throws Exception { // noop } http://git-wip-us.apache.org/repos/asf/camel/blob/855a925f/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerCustomExceptionHandlerTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerCustomExceptionHandlerTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerCustomExceptionHandlerTest.java index 6d05550..d33dd8d 100644 --- a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerCustomExceptionHandlerTest.java +++ b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerCustomExceptionHandlerTest.java @@ -154,7 +154,17 @@ public class FileConsumerCustomExceptionHandlerTest extends ContextTestSupport { } @Override - public void releaseExclusiveReadLock(GenericFileOperations<File> operations, GenericFile<File> file, Exchange exchange) throws Exception { + public void releaseExclusiveReadLockOnAbort(GenericFileOperations<File> operations, GenericFile<File> file, Exchange exchange) throws Exception { + // noop + } + + @Override + public void releaseExclusiveReadLockOnRollback(GenericFileOperations<File> operations, GenericFile<File> file, Exchange exchange) throws Exception { + // noop + } + + @Override + public void releaseExclusiveReadLockOnCommit(GenericFileOperations<File> operations, GenericFile<File> file, Exchange exchange) throws Exception { // noop } http://git-wip-us.apache.org/repos/asf/camel/blob/855a925f/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/FtpChangedExclusiveReadLockStrategy.java ---------------------------------------------------------------------- diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/FtpChangedExclusiveReadLockStrategy.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/FtpChangedExclusiveReadLockStrategy.java index 9fd31ab..5301465 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/FtpChangedExclusiveReadLockStrategy.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/FtpChangedExclusiveReadLockStrategy.java @@ -127,7 +127,17 @@ public class FtpChangedExclusiveReadLockStrategy implements GenericFileExclusive } @Override - public void releaseExclusiveReadLock(GenericFileOperations<FTPFile> operations, GenericFile<FTPFile> file, Exchange exchange) throws Exception { + public void releaseExclusiveReadLockOnAbort(GenericFileOperations<FTPFile> operations, GenericFile<FTPFile> file, Exchange exchange) throws Exception { + // noop + } + + @Override + public void releaseExclusiveReadLockOnRollback(GenericFileOperations<FTPFile> operations, GenericFile<FTPFile> file, Exchange exchange) throws Exception { + // noop + } + + @Override + public void releaseExclusiveReadLockOnCommit(GenericFileOperations<FTPFile> operations, GenericFile<FTPFile> file, Exchange exchange) throws Exception { // noop } http://git-wip-us.apache.org/repos/asf/camel/blob/855a925f/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/SftpChangedExclusiveReadLockStrategy.java ---------------------------------------------------------------------- diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/SftpChangedExclusiveReadLockStrategy.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/SftpChangedExclusiveReadLockStrategy.java index de65962..9b9fec1 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/SftpChangedExclusiveReadLockStrategy.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/strategy/SftpChangedExclusiveReadLockStrategy.java @@ -124,7 +124,17 @@ public class SftpChangedExclusiveReadLockStrategy implements GenericFileExclusiv } @Override - public void releaseExclusiveReadLock(GenericFileOperations<ChannelSftp.LsEntry> operations, GenericFile<ChannelSftp.LsEntry> file, Exchange exchange) throws Exception { + public void releaseExclusiveReadLockOnAbort(GenericFileOperations<ChannelSftp.LsEntry> operations, GenericFile<ChannelSftp.LsEntry> file, Exchange exchange) throws Exception { + // noop + } + + @Override + public void releaseExclusiveReadLockOnRollback(GenericFileOperations<ChannelSftp.LsEntry> operations, GenericFile<ChannelSftp.LsEntry> file, Exchange exchange) throws Exception { + // noop + } + + @Override + public void releaseExclusiveReadLockOnCommit(GenericFileOperations<ChannelSftp.LsEntry> operations, GenericFile<ChannelSftp.LsEntry> file, Exchange exchange) throws Exception { // noop }