camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1463896 - in /camel/trunk/camel-core/src/main/java/org/apache/camel: ./ component/file/strategy/
Date Wed, 03 Apr 2013 09:43:47 GMT
Author: davsclaus
Date: Wed Apr  3 09:43:46 2013
New Revision: 1463896

URL: http://svn.apache.org/r1463896
Log:
CAMEL-6235: File consumer - preMove should happen after the file lock has been acquired

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameProcessStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/MarkerFileExclusiveReadLockStrategy.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java?rev=1463896&r1=1463895&r2=1463896&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java Wed Apr  3 09:43:46
2013
@@ -124,6 +124,7 @@ public interface Exchange {
     String FILE_LENGTH          = "CamelFileLength";
     String FILTER_MATCHED       = "CamelFilterMatched";
     String FILE_LOCK_FILE_ACQUIRED   = "CamelFileLockFileAcquired"; 
+    String FILE_LOCK_FILE_NAME  = "CamelFileLockFileName";
 
     String GROUPED_EXCHANGE = "CamelGroupedExchange";
     

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategy.java?rev=1463896&r1=1463895&r2=1463896&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategy.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileDeleteProcessStrategy.java
Wed Apr  3 09:43:46 2013
@@ -30,21 +30,20 @@ public class GenericFileDeleteProcessStr
     @Override
     public boolean begin(GenericFileOperations<T> operations, GenericFileEndpoint<T>
endpoint, Exchange exchange, GenericFile<T> file) throws Exception {
 
-        // We need to invoke super, but to the file that we are going to use for processing,
so we do super after renaming.
-        GenericFile<T> to = file;
+        // must invoke super
+        boolean result = super.begin(operations, endpoint, exchange, file);
+        if (!result) {
+            return false;
+        }
 
+        // okay we got the file then execute the begin renamer
         if (beginRenamer != null) {
             GenericFile<T> newName = beginRenamer.renameFile(exchange, file);
-            to = renameFile(operations, file, newName);
+            GenericFile<T> to = renameFile(operations, file, newName);
             if (to != null) {
                 to.bindToExchange(exchange);
             }
         }
-        // must invoke super
-        boolean result = super.begin(operations, endpoint, exchange, to);
-        if (!result) {
-            return false;
-        }
 
         return true;
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameProcessStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameProcessStrategy.java?rev=1463896&r1=1463895&r2=1463896&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameProcessStrategy.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/GenericFileRenameProcessStrategy.java
Wed Apr  3 09:43:46 2013
@@ -32,21 +32,20 @@ public class GenericFileRenameProcessStr
     @Override
     public boolean begin(GenericFileOperations<T> operations, GenericFileEndpoint<T>
endpoint, Exchange exchange, GenericFile<T> file) throws Exception {
 
-        // We need to invoke super, but to the file that we are going to use for processing,
so we do super after renaming.
-        GenericFile<T> to = file;
+        // must invoke super
+        boolean result = super.begin(operations, endpoint, exchange, file);
+        if (!result) {
+            return false;
+        }
 
+        // okay we got the file then execute the begin renamer
         if (beginRenamer != null) {
             GenericFile<T> newName = beginRenamer.renameFile(exchange, file);
-            to = renameFile(operations, file, newName);
+            GenericFile<T> to = renameFile(operations, file, newName);
             if (to != null) {
                 to.bindToExchange(exchange);
             }
         }
-        // must invoke super
-        boolean result = super.begin(operations, endpoint, exchange, to);
-        if (!result) {
-            return false;
-        }
 
         return true;
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/MarkerFileExclusiveReadLockStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/MarkerFileExclusiveReadLockStrategy.java?rev=1463896&r1=1463895&r2=1463896&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/MarkerFileExclusiveReadLockStrategy.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/strategy/MarkerFileExclusiveReadLockStrategy.java
Wed Apr  3 09:43:46 2013
@@ -59,13 +59,14 @@ public class MarkerFileExclusiveReadLock
         // create a plain file as marker filer for locking (do not use FileLock)
         boolean acquired = FileUtil.createNewFile(new File(lockFileName));
         exchange.setProperty(Exchange.FILE_LOCK_FILE_ACQUIRED, acquired);
+        exchange.setProperty(Exchange.FILE_LOCK_FILE_NAME, lockFileName);
 
         return acquired;
     }
 
     public void releaseExclusiveReadLock(GenericFileOperations<File> operations,
                                          GenericFile<File> file, Exchange exchange)
throws Exception {
-        String lockFileName = getLockFileName(file);
+        String lockFileName = exchange.getProperty(Exchange.FILE_LOCK_FILE_NAME, getLockFileName(file),
String.class);
         File lock = new File(lockFileName);
         // only release the file if camel get the lock before
         if (exchange.getProperty(Exchange.FILE_LOCK_FILE_ACQUIRED, false, Boolean.class))
{



Mime
View raw message