use of org.apache.accumulo.tserver.compactions.ExternalCompactionJob in project accumulo by apache.
the class CompactableImpl method reserveExternalCompaction.
@Override
public ExternalCompactionJob reserveExternalCompaction(CompactionServiceId service, CompactionJob job, String compactorId, ExternalCompactionId externalCompactionId) {
Preconditions.checkState(!tablet.getExtent().isMeta());
Optional<CompactionInfo> ocInfo = reserveFilesForCompaction(service, job);
if (ocInfo.isEmpty())
return null;
var cInfo = ocInfo.get();
try {
Map<String, String> overrides = CompactableUtils.getOverrides(job.getKind(), tablet, cInfo.localHelper, job.getFiles());
TabletFile compactTmpName = tablet.getNextMapFilenameForMajc(cInfo.propagateDeletes);
ExternalCompactionInfo ecInfo = new ExternalCompactionInfo();
ecInfo.meta = new ExternalCompactionMetadata(cInfo.jobFiles, Sets.difference(cInfo.selectedFiles, cInfo.jobFiles), compactTmpName, compactorId, job.getKind(), job.getPriority(), job.getExecutor(), cInfo.propagateDeletes, cInfo.initiallySelectedAll, cInfo.checkCompactionId);
tablet.getContext().getAmple().mutateTablet(getExtent()).putExternalCompaction(externalCompactionId, ecInfo.meta).mutate();
ecInfo.job = job;
externalCompactions.put(externalCompactionId, ecInfo);
SortedMap<StoredTabletFile, DataFileValue> allFiles = tablet.getDatafiles();
HashMap<StoredTabletFile, DataFileValue> compactFiles = new HashMap<>();
cInfo.jobFiles.forEach(file -> compactFiles.put(file, allFiles.get(file)));
TabletLogger.compacting(getExtent(), job, cInfo.localCompactionCfg);
return new ExternalCompactionJob(compactFiles, cInfo.propagateDeletes, compactTmpName, getExtent(), externalCompactionId, job.getKind(), cInfo.iters, cInfo.checkCompactionId, overrides);
} catch (Exception e) {
externalCompactions.remove(externalCompactionId);
completeCompaction(job, cInfo.jobFiles, null);
throw new RuntimeException(e);
}
}
Aggregations