camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [11/13] camel git commit: CAMEL-8727: File consumer - Add read lock that is based on idempotent repository
Date Sun, 03 May 2015 09:04:05 GMT
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/ad736cde
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ad736cde
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ad736cde

Branch: refs/heads/master
Commit: ad736cde70f59448406bd6508dcc802c51df1d2f
Parents: f0343c1
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sun May 3 10:19:43 2015 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sun May 3 10:52:37 2015 +0200

----------------------------------------------------------------------
 ...ileIdempotentRepositoryReadLockStrategy.java | 23 ++++++++++++++------
 1 file changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ad736cde/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileIdempotentRepositoryReadLockStrategy.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileIdempotentRepositoryReadLockStrategy.java
b/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileIdempotentRepositoryReadLockStrategy.java
index 28f4865..4088c0c 100644
--- a/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileIdempotentRepositoryReadLockStrategy.java
+++ b/camel-core/src/main/java/org/apache/camel/component/file/strategy/FileIdempotentRepositoryReadLockStrategy.java
@@ -43,7 +43,7 @@ public class FileIdempotentRepositoryReadLockStrategy extends ServiceSupport
imp
     private static final transient Logger LOG = LoggerFactory.getLogger(FileIdempotentRepositoryReadLockStrategy.class);
 
     private GenericFileEndpoint<File> endpoint;
-    private LoggingLevel loggingLevel = LoggingLevel.TRACE;
+    private LoggingLevel readLockLoggingLevel = LoggingLevel.DEBUG;
     private CamelContext camelContext;
     private IdempotentRepository<String> idempotentRepository;
     private boolean removeOnRollback = true;
@@ -60,21 +60,21 @@ public class FileIdempotentRepositoryReadLockStrategy extends ServiceSupport
imp
         // check if we can begin on this file
         String key = asKey(file);
         boolean answer = idempotentRepository.add(key);
-        CamelLogger.log(LOG, loggingLevel, "acquireExclusiveReadLock: " + key + " -> "
+ answer);
+        if (!answer) {
+            CamelLogger.log(LOG, readLockLoggingLevel, "Cannot acquire read lock. Will skip
the file: " + file);
+        }
         return answer;
     }
 
     @Override
     public void releaseExclusiveReadLockOnAbort(GenericFileOperations<File> operations,
GenericFile<File> file, Exchange exchange) throws Exception {
-        String key = asKey(file);
-        CamelLogger.log(LOG, loggingLevel, "releaseExclusiveReadLockOnAbort: " + key);
+        // noop
     }
 
     @Override
     public void releaseExclusiveReadLockOnRollback(GenericFileOperations<File> operations,
GenericFile<File> file, Exchange exchange) throws Exception {
         if (removeOnRollback) {
             String key = asKey(file);
-            CamelLogger.log(LOG, loggingLevel, "releaseExclusiveReadLockOnRollback: " + key);
             idempotentRepository.remove(key);
         }
     }
@@ -82,7 +82,6 @@ public class FileIdempotentRepositoryReadLockStrategy extends ServiceSupport
imp
     @Override
     public void releaseExclusiveReadLockOnCommit(GenericFileOperations<File> operations,
GenericFile<File> file, Exchange exchange) throws Exception {
         String key = asKey(file);
-        CamelLogger.log(LOG, loggingLevel, "releaseExclusiveReadLockOnCommit: " + key);
         if (removeOnCommit) {
             idempotentRepository.remove(key);
         } else {
@@ -99,8 +98,18 @@ public class FileIdempotentRepositoryReadLockStrategy extends ServiceSupport
imp
         // noop
     }
 
+    /**
+     * Sets logging level used when a read lock could not be acquired.
+     * <p/>
+     * Logging level used when a read lock could not be acquired.
+     * <p/>
+     * The default logging level is DEBUG as it may be more common not to be able to acquire
a read lock
+     * when using idempotent repository in a clustered setup, as another node may be processing
the file.
+     *
+     * @param readLockLoggingLevel LoggingLevel
+     */
     public void setReadLockLoggingLevel(LoggingLevel readLockLoggingLevel) {
-        this.loggingLevel = readLockLoggingLevel;
+        this.readLockLoggingLevel = readLockLoggingLevel;
     }
 
     public void setMarkerFiler(boolean markerFile) {


Mime
View raw message