diff --git a/CHANGES.txt b/CHANGES.txt index b0b2880bda2..cacdd2b8abf 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -458,6 +458,8 @@ Release 0.21.0 - Unreleased HBASE-2364 Ignore Deprecations during build (Paul Smith via Stack) HBASE-2338 log recovery: deleted items may be resurrected (Aravind Menon via Stack) + HBASE-2359 WALEdit doesn't implement HeapSize + (Kannan Muthukkaruppan via Stack) NEW FEATURES HBASE-1961 HBase EC2 scripts diff --git a/core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java b/core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java index d2b01fe2e1f..b363a6aeb81 100644 --- a/core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java +++ b/core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java @@ -137,15 +137,11 @@ public class HLog implements HConstants, Syncable { } public interface Writer { - void init(FileSystem fs, Path path, Configuration c) throws IOException; - void close() throws IOException; - void sync() throws IOException; - void append(Entry entry) throws IOException; - + long getLength() throws IOException; } // used to indirectly tell syncFs to force the sync @@ -176,9 +172,6 @@ public class HLog implements HConstants, Syncable { private final AtomicInteger numEntries = new AtomicInteger(0); - // Size of edits written so far. Used figuring when to rotate logs. - private final AtomicLong editsSize = new AtomicLong(0); - // If > than this size, roll the log. private final long logrollsize; @@ -365,7 +358,7 @@ public class HLog implements HConstants, Syncable { LOG.info((oldFile != null? "Roll " + FSUtils.getPath(oldFile) + ", entries=" + this.numEntries.get() + - ", calcsize=" + this.editsSize.get() + ", filesize=" + + ", filesize=" + this.fs.getFileStatus(oldFile).getLen() + ". ": "") + "New hlog " + FSUtils.getPath(newPath)); // Can we delete any of the old log files? @@ -384,7 +377,6 @@ public class HLog implements HConstants, Syncable { } } this.numEntries.set(0); - this.editsSize.set(0); } } finally { this.cacheFlushLock.unlock(); @@ -682,7 +674,7 @@ public class HLog implements HConstants, Syncable { // sync txn to file system this.sync(isMetaRegion); - if (this.editsSize.get() > this.logrollsize) { + if (this.writer.getLength() > this.logrollsize) { if (listener != null) { listener.logRollRequested(); } @@ -737,7 +729,7 @@ public class HLog implements HConstants, Syncable { } // sync txn to file system this.sync(info.isMetaRegion()); - if (this.editsSize.get() > this.logrollsize) { + if (this.writer.getLength() > this.logrollsize) { requestLogRoll(); } } @@ -883,7 +875,6 @@ public class HLog implements HConstants, Syncable { return; } try { - this.editsSize.addAndGet(logKey.heapSize() + logEdit.heapSize()); long now = System.currentTimeMillis(); this.writer.append(new HLog.Entry(logKey, logEdit)); long took = System.currentTimeMillis() - now; diff --git a/core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogKey.java b/core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogKey.java index eb3ae377ff2..4e97470964c 100644 --- a/core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogKey.java +++ b/core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogKey.java @@ -37,7 +37,7 @@ import java.io.*; *

Some Transactional edits (START, COMMIT, ABORT) will not have an * associated row. */ -public class HLogKey implements WritableComparable, HeapSize { +public class HLogKey implements WritableComparable { private byte [] regionName; private byte [] tablename; private long logSeqNum; @@ -204,7 +204,4 @@ public class HLogKey implements WritableComparable, HeapSize { } } - public long heapSize() { - return this.regionName.length + this.tablename.length + HEAP_TAX; - } } diff --git a/core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/SequenceFileLogWriter.java b/core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/SequenceFileLogWriter.java index 5fcf70ba858..9aa7d5e347a 100644 --- a/core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/SequenceFileLogWriter.java +++ b/core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/SequenceFileLogWriter.java @@ -90,4 +90,8 @@ public class SequenceFileLogWriter implements HLog.Writer { this.writer.syncFs(); } + @Override + public long getLength() throws IOException { + return this.writer.getLength(); + } } diff --git a/core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEdit.java b/core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEdit.java index 8d2facd1c8a..317bb0e23d3 100644 --- a/core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEdit.java +++ b/core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEdit.java @@ -121,17 +121,6 @@ public class WALEdit implements Writable { } } - public long heapSize() { - long size = ClassSize.align(ClassSize.OBJECT + - ClassSize.REFERENCE + - ClassSize.ARRAYLIST); - for (KeyValue kv : kvs) { - size += kv.heapSize(); - } - - return size; - } - public String toString() { StringBuilder sb = new StringBuilder();