HBASE-8060 Num compacting KVs diverges from num compacted KVs over time
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1496214 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dfe84fb1f9
commit
4e646ebf3d
|
@ -329,4 +329,16 @@ public class HalfStoreFileReader extends StoreFile.Reader {
|
|||
}
|
||||
return this.firstKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntries() {
|
||||
// Estimate the number of entries as half the original file; this may be wildly inaccurate.
|
||||
return super.getEntries() / 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFilterEntries() {
|
||||
// Estimate the number of entries as half the original file; this may be wildly inaccurate.
|
||||
return super.getFilterEntries() / 2;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,4 +51,19 @@ public class CompactionProgress {
|
|||
public float getProgressPct() {
|
||||
return (float)currentCompactedKVs / totalCompactingKVs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels the compaction progress, setting things to 0.
|
||||
*/
|
||||
public void cancel() {
|
||||
this.currentCompactedKVs = this.totalCompactingKVs = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the compaction as complete by setting total to current KV count;
|
||||
* Total KV count is an estimate, so there might be a discrepancy otherwise.
|
||||
*/
|
||||
public void complete() {
|
||||
this.totalCompactingKVs = this.currentCompactedKVs;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -209,7 +209,6 @@ public abstract class Compactor {
|
|||
kv.setMemstoreTS(0);
|
||||
}
|
||||
writer.append(kv);
|
||||
// update progress per key
|
||||
++progress.currentCompactedKVs;
|
||||
|
||||
// check periodically to see if a system stop is requested
|
||||
|
@ -217,12 +216,16 @@ public abstract class Compactor {
|
|||
bytesWritten += kv.getLength();
|
||||
if (bytesWritten > closeCheckInterval) {
|
||||
bytesWritten = 0;
|
||||
if (!store.areWritesEnabled()) return false;
|
||||
if (!store.areWritesEnabled()) {
|
||||
progress.cancel();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
kvs.clear();
|
||||
} while (hasMore);
|
||||
progress.complete();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue