You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flume.apache.org by mp...@apache.org on 2013/03/14 02:16:12 UTC
git commit: FLUME-1939. FlumeEventQueue must check if file is open
before setting the length of the file
Updated Branches:
refs/heads/trunk 13b8252bd -> 8ea3f0fb3
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/8ea3f0fb
Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/8ea3f0fb
Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/8ea3f0fb
Branch: refs/heads/trunk
Commit: 8ea3f0fb3d211b7bf18e061bfc3b2dc825285f90
Parents: 13b8252
Author: Mike Percy <mp...@apache.org>
Authored: Wed Mar 13 18:15:00 2013 -0700
Committer: Mike Percy <mp...@apache.org>
Committed: Wed Mar 13 18:15:00 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/8ea3f0fb/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: