Search in sources :

Example 1 with CompactionCanceledException

use of org.apache.accumulo.server.compaction.FileCompactor.CompactionCanceledException in project accumulo by apache.

the class ExternalDoNothingCompactor method createCompactionJob.

@Override
protected Runnable createCompactionJob(TExternalCompactionJob job, LongAdder totalInputEntries, LongAdder totalInputBytes, CountDownLatch started, CountDownLatch stopped, AtomicReference<Throwable> err) {
    // Set this to true so that only 1 external compaction is run
    this.shutdown = true;
    return new Runnable() {

        @Override
        public void run() {
            try {
                LOG.info("Starting up compaction runnable for job: {}", job);
                TCompactionStatusUpdate update = new TCompactionStatusUpdate();
                update.setState(TCompactionState.STARTED);
                update.setMessage("Compaction started");
                updateCompactionState(job, update);
                LOG.info("Starting compactor");
                started.countDown();
                while (!JOB_HOLDER.isCancelled()) {
                    LOG.info("Sleeping while job is not cancelled");
                    UtilWaitThread.sleep(1000);
                }
                // Compactor throws this exception when cancelled
                throw new CompactionCanceledException();
            } catch (Exception e) {
                LOG.error("Compaction failed", e);
                err.set(e);
            } finally {
                stopped.countDown();
            }
        }
    };
}
Also used : TCompactionStatusUpdate(org.apache.accumulo.core.compaction.thrift.TCompactionStatusUpdate) CompactionCanceledException(org.apache.accumulo.server.compaction.FileCompactor.CompactionCanceledException) CompactionCanceledException(org.apache.accumulo.server.compaction.FileCompactor.CompactionCanceledException)

Example 2 with CompactionCanceledException

use of org.apache.accumulo.server.compaction.FileCompactor.CompactionCanceledException in project accumulo by apache.

the class CompactableImpl method compact.

@Override
public void compact(CompactionServiceId service, CompactionJob job, RateLimiter readLimiter, RateLimiter writeLimiter, long queuedTime) {
    Optional<CompactionInfo> ocInfo = reserveFilesForCompaction(service, job);
    if (ocInfo.isEmpty())
        return;
    var cInfo = ocInfo.get();
    StoredTabletFile newFile = null;
    long startTime = System.currentTimeMillis();
    CompactionKind kind = job.getKind();
    CompactionStats stats = new CompactionStats();
    try {
        TabletLogger.compacting(getExtent(), job, cInfo.localCompactionCfg);
        tablet.incrementStatusMajor();
        var check = new CompactionCheck(service, kind, cInfo.checkCompactionId);
        TabletFile tmpFileName = tablet.getNextMapFilenameForMajc(cInfo.propagateDeletes);
        var compactEnv = new MajCEnv(kind, check, readLimiter, writeLimiter, cInfo.propagateDeletes);
        SortedMap<StoredTabletFile, DataFileValue> allFiles = tablet.getDatafiles();
        HashMap<StoredTabletFile, DataFileValue> compactFiles = new HashMap<>();
        cInfo.jobFiles.forEach(file -> compactFiles.put(file, allFiles.get(file)));
        stats = CompactableUtils.compact(tablet, job, cInfo, compactEnv, compactFiles, tmpFileName);
        newFile = CompactableUtils.bringOnline(tablet.getDatafileManager(), cInfo, stats, compactFiles, allFiles, kind, tmpFileName);
        TabletLogger.compacted(getExtent(), job, newFile);
    } catch (CompactionCanceledException cce) {
        log.debug("Compaction canceled {} ", getExtent());
    } catch (Exception e) {
        newFile = null;
        throw new RuntimeException(e);
    } finally {
        completeCompaction(job, cInfo.jobFiles, newFile);
        tablet.updateTimer(MAJOR, queuedTime, startTime, stats.getEntriesRead(), newFile == null);
    }
}
Also used : DataFileValue(org.apache.accumulo.core.metadata.schema.DataFileValue) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) CompactionStats(org.apache.accumulo.server.compaction.CompactionStats) UncheckedIOException(java.io.UncheckedIOException) CompactionCanceledException(org.apache.accumulo.server.compaction.FileCompactor.CompactionCanceledException) IOException(java.io.IOException) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException) CompactionKind(org.apache.accumulo.core.spi.compaction.CompactionKind) StoredTabletFile(org.apache.accumulo.core.metadata.StoredTabletFile) StoredTabletFile(org.apache.accumulo.core.metadata.StoredTabletFile) TabletFile(org.apache.accumulo.core.metadata.TabletFile) CompactionCanceledException(org.apache.accumulo.server.compaction.FileCompactor.CompactionCanceledException)

Aggregations

CompactionCanceledException (org.apache.accumulo.server.compaction.FileCompactor.CompactionCanceledException)2 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 TCompactionStatusUpdate (org.apache.accumulo.core.compaction.thrift.TCompactionStatusUpdate)1 StoredTabletFile (org.apache.accumulo.core.metadata.StoredTabletFile)1 TabletFile (org.apache.accumulo.core.metadata.TabletFile)1 DataFileValue (org.apache.accumulo.core.metadata.schema.DataFileValue)1 CompactionKind (org.apache.accumulo.core.spi.compaction.CompactionKind)1 CompactionStats (org.apache.accumulo.server.compaction.CompactionStats)1 NoNodeException (org.apache.zookeeper.KeeperException.NoNodeException)1