Search in sources :

Example 1 with ExternalCompactionJob

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);
    }
}
Also used : DataFileValue(org.apache.accumulo.core.metadata.schema.DataFileValue) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ExternalCompactionJob(org.apache.accumulo.tserver.compactions.ExternalCompactionJob) UncheckedIOException(java.io.UncheckedIOException) CompactionCanceledException(org.apache.accumulo.server.compaction.FileCompactor.CompactionCanceledException) IOException(java.io.IOException) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException) ExternalCompactionMetadata(org.apache.accumulo.core.metadata.schema.ExternalCompactionMetadata) StoredTabletFile(org.apache.accumulo.core.metadata.StoredTabletFile) TabletFile(org.apache.accumulo.core.metadata.TabletFile) StoredTabletFile(org.apache.accumulo.core.metadata.StoredTabletFile)

Aggregations

IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)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 ExternalCompactionMetadata (org.apache.accumulo.core.metadata.schema.ExternalCompactionMetadata)1 CompactionCanceledException (org.apache.accumulo.server.compaction.FileCompactor.CompactionCanceledException)1 ExternalCompactionJob (org.apache.accumulo.tserver.compactions.ExternalCompactionJob)1 NoNodeException (org.apache.zookeeper.KeeperException.NoNodeException)1