HBASE-2359 WALEdit doesn't implement HeapSize

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@928351 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2010-03-28 06:19:15 +00:00
parent 961b0938cb
commit 5e4aa0830f
5 changed files with 11 additions and 28 deletions

View File

@ -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

View File

@ -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;

View File

@ -37,7 +37,7 @@ import java.io.*;
* <p>Some Transactional edits (START, COMMIT, ABORT) will not have an
* associated row.
*/
public class HLogKey implements WritableComparable<HLogKey>, HeapSize {
public class HLogKey implements WritableComparable<HLogKey> {
private byte [] regionName;
private byte [] tablename;
private long logSeqNum;
@ -204,7 +204,4 @@ public class HLogKey implements WritableComparable<HLogKey>, HeapSize {
}
}
public long heapSize() {
return this.regionName.length + this.tablename.length + HEAP_TAX;
}
}

View File

@ -90,4 +90,8 @@ public class SequenceFileLogWriter implements HLog.Writer {
this.writer.syncFs();
}
@Override
public long getLength() throws IOException {
return this.writer.getLength();
}
}

View File

@ -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();