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();
}
}
};
}
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);
}
}
Aggregations