Updated Branches: refs/heads/flume-1.4 61c5b0726 -> b64c8d040
FLUME-1918. File Channel cannot handle capacity of more than 500 Million events. (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/b64c8d04 Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/b64c8d04 Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/b64c8d04 Branch: refs/heads/flume-1.4 Commit: b64c8d04089934384e968fb2341fae25c2d12191 Parents: 61c5b07 Author: Mike Percy <[email protected]> Authored: Thu Feb 14 18:55:21 2013 -0800 Committer: Mike Percy <[email protected]> Committed: Thu Feb 14 18:57:52 2013 -0800 ---------------------------------------------------------------------- .../channel/file/EventQueueBackingStoreFile.java | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flume/blob/b64c8d04/flume-ng-channels/flume-file-channel/src/main/java/org/apache/flume/channel/file/EventQueueBackingStoreFile.java ---------------------------------------------------------------------- diff --git a/flume-ng-channels/flume-file-channel/src/main/java/org/apache/flume/channel/file/EventQueueBackingStoreFile.java b/flume-ng-channels/flume-file-channel/src/main/java/org/apache/flume/channel/file/EventQueueBackingStoreFile.java index 7f35301..4115505 100644 --- a/flume-ng-channels/flume-file-channel/src/main/java/org/apache/flume/channel/file/EventQueueBackingStoreFile.java +++ b/flume-ng-channels/flume-file-channel/src/main/java/org/apache/flume/channel/file/EventQueueBackingStoreFile.java @@ -62,7 +62,7 @@ abstract class EventQueueBackingStoreFile extends EventQueueBackingStore { super(capacity, name); this.checkpointFile = checkpointFile; checkpointFileHandle = new RandomAccessFile(checkpointFile, "rw"); - int totalBytes = (capacity + HEADER_SIZE) * Serialization.SIZE_OF_LONG; + long totalBytes = (capacity + HEADER_SIZE) * Serialization.SIZE_OF_LONG; if(checkpointFileHandle.length() == 0) { allocate(checkpointFile, totalBytes); checkpointFileHandle.seek(INDEX_VERSION * Serialization.SIZE_OF_LONG); @@ -210,6 +210,10 @@ abstract class EventQueueBackingStoreFile extends EventQueueBackingStore { boolean success = false; try { if (totalBytes <= MAX_ALLOC_BUFFER_SIZE) { + /* + * totalBytes <= MAX_ALLOC_BUFFER_SIZE, so this can be cast to int + * without a problem. + */ checkpointFile.write(new byte[(int)totalBytes]); } else { byte[] initBuffer = new byte[MAX_ALLOC_BUFFER_SIZE]; @@ -218,6 +222,10 @@ abstract class EventQueueBackingStoreFile extends EventQueueBackingStore { checkpointFile.write(initBuffer); remainingBytes -= MAX_ALLOC_BUFFER_SIZE; } + /* + * At this point, remainingBytes is < MAX_ALLOC_BUFFER_SIZE, + * so casting to int is fine. + */ if (remainingBytes > 0) { checkpointFile.write(initBuffer, 0, (int)remainingBytes); }
