flume-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpe...@apache.org
Subject git commit: FLUME-1939. FlumeEventQueue must check if file is open before setting the length of the file
Date Thu, 14 Mar 2013 01:16:28 GMT
Updated Branches:
  refs/heads/flume-1.4 6495c3230 -> 97855decb


FLUME-1939. FlumeEventQueue must check if file is open before setting the length of the file

(Hari Shreedharan via Mike Percy)


Project: http://git-wip-us.apache.org/repos/asf/flume/repo
Commit: http://git-wip-us.apache.org/repos/asf/flume/commit/97855dec
Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/97855dec
Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/97855dec

Branch: refs/heads/flume-1.4
Commit: 97855decb7143aa612e79660260f434ef440bb50
Parents: 6495c32
Author: Mike Percy <mpercy@apache.org>
Authored: Wed Mar 13 18:15:00 2013 -0700
Committer: Mike Percy <mpercy@apache.org>
Committed: Wed Mar 13 18:15:57 2013 -0700

----------------------------------------------------------------------
 .../apache/flume/channel/file/FlumeEventQueue.java |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flume/blob/97855dec/flume-ng-channels/flume-file-channel/src/main/java/org/apache/flume/channel/file/FlumeEventQueue.java
----------------------------------------------------------------------
diff --git a/flume-ng-channels/flume-file-channel/src/main/java/org/apache/flume/channel/file/FlumeEventQueue.java
b/flume-ng-channels/flume-file-channel/src/main/java/org/apache/flume/channel/file/FlumeEventQueue.java
index 0f9456b..72d9425 100644
--- a/flume-ng-channels/flume-file-channel/src/main/java/org/apache/flume/channel/file/FlumeEventQueue.java
+++ b/flume-ng-channels/flume-file-channel/src/main/java/org/apache/flume/channel/file/FlumeEventQueue.java
@@ -336,7 +336,9 @@ final class FlumeEventQueue {
    */
   class InflightEventWrapper {
     private SetMultimap<Long, Long> inflightEvents = HashMultimap.create();
-    private RandomAccessFile file;
+    // Both these are volatile for safe publication, they are never accessed by
+    // more than 1 thread at a time.
+    private volatile RandomAccessFile file;
     private volatile java.nio.channels.FileChannel fileChannel;
     private final MessageDigest digest;
     private volatile Future<?> future;
@@ -402,13 +404,13 @@ final class FlumeEventQueue {
         }
       }
       Collection<Long> values = inflightEvents.values();
-      if(values.isEmpty()){
-        file.setLength(0L);
-      }
       if(!fileChannel.isOpen()){
         file = new RandomAccessFile(inflightEventsFile, "rw");
         fileChannel = file.getChannel();
       }
+      if(values.isEmpty()){
+        file.setLength(0L);
+      }
       //What is written out?
       //Checksum - 16 bytes
       //and then each key-value pair from the map:


Mime
View raw message