Search in sources :

Example 1 with CompactionCanceledException

use of org.apache.accumulo.tserver.tablet.Compactor.CompactionCanceledException 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;
}
Also used : ProbabilitySampler(org.apache.accumulo.core.trace.ProbabilitySampler) TabletStatusMessage(org.apache.accumulo.tserver.mastermessage.TabletStatusMessage) CompactionCanceledException(org.apache.accumulo.tserver.tablet.Compactor.CompactionCanceledException) IOException(java.io.IOException) Span(org.apache.accumulo.core.trace.Span)

Aggregations

IOException (java.io.IOException)1 ProbabilitySampler (org.apache.accumulo.core.trace.ProbabilitySampler)1 Span (org.apache.accumulo.core.trace.Span)1 TabletStatusMessage (org.apache.accumulo.tserver.mastermessage.TabletStatusMessage)1 CompactionCanceledException (org.apache.accumulo.tserver.tablet.Compactor.CompactionCanceledException)1