Author: hshreedharan
Date: Wed Jul 18 22:24:11 2012
New Revision: 1363157

URL: http://svn.apache.org/viewvc?rev=1363157&view=rev
Log:
FLUME-1380. File channel log can record the op code and not the operation in 
some cases.

(Arvind Prabhakar via Hari Shreedharan)

Modified:
    
flume/trunk/flume-ng-channels/flume-file-channel/src/main/java/org/apache/flume/channel/file/LogFile.java

Modified: 
flume/trunk/flume-ng-channels/flume-file-channel/src/main/java/org/apache/flume/channel/file/LogFile.java
URL: 
http://svn.apache.org/viewvc/flume/trunk/flume-ng-channels/flume-file-channel/src/main/java/org/apache/flume/channel/file/LogFile.java?rev=1363157&r1=1363156&r2=1363157&view=diff
==============================================================================
--- 
flume/trunk/flume-ng-channels/flume-file-channel/src/main/java/org/apache/flume/channel/file/LogFile.java
 (original)
+++ 
flume/trunk/flume-ng-channels/flume-file-channel/src/main/java/org/apache/flume/channel/file/LogFile.java
 Wed Jul 18 22:24:11 2012
@@ -195,10 +195,14 @@ class LogFile {
       Preconditions.checkArgument(expectedLength < (long) Integer.MAX_VALUE);
       int offset = (int)length;
       Preconditions.checkState(offset > 0);
-      preallocate(1 + buffer.capacity());
-      writeFileHandle.writeByte(OP_RECORD);
-      int wrote = writeFileChannel.write(buffer);
-      Preconditions.checkState(wrote == buffer.limit());
+      int recordLength = 1 + buffer.capacity();
+      preallocate(recordLength);
+      ByteBuffer toWrite = ByteBuffer.allocate(recordLength);
+      toWrite.put(OP_RECORD);
+      toWrite.put(buffer);
+      toWrite.position(0);
+      int wrote = writeFileChannel.write(toWrite);
+      Preconditions.checkState(wrote == toWrite.limit());
       return Pair.of(fileID, offset);
     }
     private void preallocate(int size) throws IOException {


Reply via email to