use of org.apache.accumulo.tserver.mastermessage.TabletStatusMessage in project accumulo by apache.
the class Tablet method majorCompact.
// END PRIVATE METHODS RELATED TO MAJOR COMPACTION
/**
* Performs a major compaction on the tablet. If needsSplit() returns true, the tablet is split and a reference to the new tablet is returned.
*/
CompactionStats majorCompact(MajorCompactionReason reason, long queued) {
CompactionStats majCStats = null;
boolean success = false;
long start = System.currentTimeMillis();
timer.incrementStatusMajor();
synchronized (this) {
// check that compaction is still needed - defer to splitting
majorCompactionQueued.remove(reason);
if (isClosing() || isClosed() || !needsMajorCompaction(reason) || isMajorCompactionRunning() || needsSplit()) {
return null;
}
majorCompactionState = CompactionState.WAITING_TO_START;
}
Span span = null;
try {
double tracePercent = tabletServer.getConfiguration().getFraction(Property.TSERV_MAJC_TRACE_PERCENT);
ProbabilitySampler sampler = new ProbabilitySampler(tracePercent);
span = Trace.on("majorCompaction", sampler);
majCStats = _majorCompact(reason);
if (reason == MajorCompactionReason.CHOP) {
MetadataTableUtil.chopped(getTabletServer(), getExtent(), this.getTabletServer().getLock());
getTabletServer().enqueueMasterMessage(new TabletStatusMessage(TabletLoadState.CHOPPED, extent));
}
success = true;
} catch (CompactionCanceledException cce) {
log.debug("Major compaction canceled, extent = {}", getExtent());
} catch (IOException ioe) {
log.error("MajC Failed, extent = " + getExtent(), ioe);
} catch (RuntimeException e) {
log.error("MajC Unexpected exception, extent = " + getExtent(), e);
} finally {
// when an exception is thrown
synchronized (this) {
majorCompactionState = null;
this.notifyAll();
}
if (span != null) {
span.data("extent", "" + getExtent());
if (majCStats != null) {
span.data("read", "" + majCStats.getEntriesRead());
span.data("written", "" + majCStats.getEntriesWritten());
}
span.stop();
}
}
long count = 0;
if (majCStats != null)
count = majCStats.getEntriesRead();
timer.updateTime(Operation.MAJOR, queued, start, count, !success);
return majCStats;
}
Aggregations