Search in sources :

Example 1 with Operation

use of org.apache.accumulo.tserver.TabletStatsKeeper.Operation in project accumulo by apache.

the class Tablet method importMapFiles.

public void importMapFiles(long tid, Map<TabletFile, MapFileInfo> fileMap, boolean setTime) throws IOException {
    Map<TabletFile, DataFileValue> entries = new HashMap<>(fileMap.size());
    List<String> files = new ArrayList<>();
    for (Entry<TabletFile, MapFileInfo> entry : fileMap.entrySet()) {
        entries.put(entry.getKey(), new DataFileValue(entry.getValue().estimatedSize, 0L));
        files.add(entry.getKey().getPathStr());
    }
    // Clients timeout and will think that this operation failed.
    // Don't do it if we spent too long waiting for the lock
    long now = System.currentTimeMillis();
    synchronized (this) {
        if (isClosed()) {
            throw new IOException("tablet " + extent + " is closed");
        }
        // TODO check seems unneeded now - ACCUMULO-1291
        long lockWait = System.currentTimeMillis() - now;
        if (lockWait > getTabletServer().getConfiguration().getTimeInMillis(Property.GENERAL_RPC_TIMEOUT)) {
            throw new IOException("Timeout waiting " + (lockWait / 1000.) + " seconds to get tablet lock for " + extent);
        }
        List<TabletFile> alreadyImported = bulkImported.get(tid);
        if (alreadyImported != null) {
            for (TabletFile entry : alreadyImported) {
                if (fileMap.remove(entry) != null) {
                    log.trace("Ignoring import of bulk file already imported: {}", entry);
                }
            }
        }
        fileMap.keySet().removeIf(file -> {
            if (bulkImporting.contains(file)) {
                log.info("Ignoring import of bulk file currently importing: " + file);
                return true;
            }
            return false;
        });
        if (fileMap.isEmpty()) {
            return;
        }
        incrementWritesInProgress();
        // prevent other threads from processing this file while its added to the metadata table.
        bulkImporting.addAll(fileMap.keySet());
    }
    try {
        tabletServer.updateBulkImportState(files, BulkImportState.LOADING);
        var storedTabletFile = getDatafileManager().importMapFiles(tid, entries, setTime);
        lastMapFileImportTime = System.currentTimeMillis();
        if (needsSplit()) {
            getTabletServer().executeSplit(this);
        } else {
            compactable.filesAdded(false, storedTabletFile);
        }
    } finally {
        synchronized (this) {
            decrementWritesInProgress();
            if (!bulkImporting.removeAll(fileMap.keySet())) {
                throw new AssertionError("Likely bug in code, always expect to remove something.  Please open an Accumulo issue.");
            }
            try {
                bulkImported.computeIfAbsent(tid, k -> new ArrayList<>()).addAll(fileMap.keySet());
            } catch (Exception ex) {
                log.info(ex.toString(), ex);
            }
            tabletServer.removeBulkImportState(files);
        }
    }
}
Also used : ByteSequence(org.apache.accumulo.core.data.ByteSequence) VolumeChooserEnvironmentImpl(org.apache.accumulo.server.fs.VolumeChooserEnvironmentImpl) TooManyFilesException(org.apache.accumulo.server.fs.TooManyFilesException) Text(org.apache.hadoop.io.Text) MetadataTableUtil(org.apache.accumulo.server.util.MetadataTableUtil) FileStatus(org.apache.hadoop.fs.FileStatus) TServerInstance(org.apache.accumulo.core.metadata.TServerInstance) ExternalCompactionId(org.apache.accumulo.core.metadata.schema.ExternalCompactionId) Map(java.util.Map) MapFileInfo(org.apache.accumulo.core.dataImpl.thrift.MapFileInfo) MetadataTime(org.apache.accumulo.core.metadata.schema.MetadataTime) DfsLogger(org.apache.accumulo.tserver.log.DfsLogger) BulkImportState(org.apache.accumulo.core.master.thrift.BulkImportState) Property(org.apache.accumulo.core.conf.Property) TabletServer(org.apache.accumulo.tserver.TabletServer) TableState(org.apache.accumulo.core.manager.state.tables.TableState) Compactable(org.apache.accumulo.tserver.compactions.Compactable) DecoderException(org.apache.commons.codec.DecoderException) TabletStats(org.apache.accumulo.core.tabletserver.thrift.TabletStats) Deriver(org.apache.accumulo.core.conf.AccumuloConfiguration.Deriver) Set(java.util.Set) Stream(java.util.stream.Stream) Violations(org.apache.accumulo.core.constraints.Violations) UtilWaitThread.sleepUninterruptibly(org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly) TabletFiles(org.apache.accumulo.server.fs.VolumeUtil.TabletFiles) ProblemType(org.apache.accumulo.server.problems.ProblemType) ProblemReports(org.apache.accumulo.server.problems.ProblemReports) ReplicationTableUtil(org.apache.accumulo.server.util.ReplicationTableUtil) DurabilityImpl(org.apache.accumulo.core.clientImpl.DurabilityImpl) SortedKeyValueIterator(org.apache.accumulo.core.iterators.SortedKeyValueIterator) ArrayList(java.util.ArrayList) TabletMetadata(org.apache.accumulo.core.metadata.schema.TabletMetadata) ColumnUpdate(org.apache.accumulo.core.data.ColumnUpdate) StoredTabletFile(org.apache.accumulo.core.metadata.StoredTabletFile) Key(org.apache.accumulo.core.data.Key) TabletFile(org.apache.accumulo.core.metadata.TabletFile) ServerContext(org.apache.accumulo.server.ServerContext) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) IOException(java.io.IOException) TabletTime(org.apache.accumulo.server.tablets.TabletTime) Range(org.apache.accumulo.core.data.Range) AtomicLong(java.util.concurrent.atomic.AtomicLong) TreeMap(java.util.TreeMap) ColumnVisibility(org.apache.accumulo.core.security.ColumnVisibility) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException) ExternalCompactionMetadata(org.apache.accumulo.core.metadata.schema.ExternalCompactionMetadata) Preconditions(com.google.common.base.Preconditions) YieldCallback(org.apache.accumulo.core.iterators.YieldCallback) UserCompactionUtils(org.apache.accumulo.core.clientImpl.UserCompactionUtils) FileUtil(org.apache.accumulo.server.util.FileUtil) LoggerFactory(org.slf4j.LoggerFactory) Status(org.apache.accumulo.server.replication.proto.Replication.Status) MetadataTable(org.apache.accumulo.core.metadata.MetadataTable) TabletLogger(org.apache.accumulo.core.logging.TabletLogger) Mutation(org.apache.accumulo.core.data.Mutation) VolumeUtil(org.apache.accumulo.server.fs.VolumeUtil) ScanParameters(org.apache.accumulo.tserver.scan.ScanParameters) LocalityGroupUtil(org.apache.accumulo.core.util.LocalityGroupUtil) FileOperations(org.apache.accumulo.core.file.FileOperations) ByteArrayInputStream(java.io.ByteArrayInputStream) Path(org.apache.hadoop.fs.Path) Value(org.apache.accumulo.core.data.Value) ConstraintChecker(org.apache.accumulo.tserver.constraints.ConstraintChecker) ProblemReport(org.apache.accumulo.server.problems.ProblemReport) ConditionChecker(org.apache.accumulo.tserver.ConditionCheckerContext.ConditionChecker) InMemoryMap(org.apache.accumulo.tserver.InMemoryMap) Span(io.opentelemetry.api.trace.Span) Operation(org.apache.accumulo.tserver.TabletStatsKeeper.Operation) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Durability(org.apache.accumulo.core.client.Durability) Collectors(java.util.stream.Collectors) SourceSwitchingIterator(org.apache.accumulo.core.iteratorsImpl.system.SourceSwitchingIterator) FileNotFoundException(java.io.FileNotFoundException) TabletStatsKeeper(org.apache.accumulo.tserver.TabletStatsKeeper) List(java.util.List) TableConfiguration(org.apache.accumulo.server.conf.TableConfiguration) Pair(org.apache.accumulo.core.util.Pair) ManagerMetadataUtil(org.apache.accumulo.server.util.ManagerMetadataUtil) Entry(java.util.Map.Entry) Optional(java.util.Optional) TraceUtil(org.apache.accumulo.core.trace.TraceUtil) SortedMap(java.util.SortedMap) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) DataInputStream(java.io.DataInputStream) IterationInterruptedException(org.apache.accumulo.core.iteratorsImpl.system.IterationInterruptedException) DataFileValue(org.apache.accumulo.core.metadata.schema.DataFileValue) ProtobufUtil(org.apache.accumulo.core.protobuf.ProtobufUtil) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) CompactionConfig(org.apache.accumulo.core.client.admin.CompactionConfig) Hex(org.apache.commons.codec.binary.Hex) MinorCompactionReason(org.apache.accumulo.tserver.MinorCompactionReason) HashSet(java.util.HashSet) Volume(org.apache.accumulo.core.volume.Volume) TabletResourceManager(org.apache.accumulo.tserver.TabletServerResourceManager.TabletResourceManager) TabletServerMinCMetrics(org.apache.accumulo.tserver.metrics.TabletServerMinCMetrics) Objects.requireNonNull(java.util.Objects.requireNonNull) UniqueNameAllocator(org.apache.accumulo.server.tablets.UniqueNameAllocator) CompactionStats(org.apache.accumulo.server.compaction.CompactionStats) ServerColumnFamily(org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.ServerColumnFamily) LogEntry(org.apache.accumulo.core.tabletserver.log.LogEntry) Logger(org.slf4j.Logger) ReentrantLock(java.util.concurrent.locks.ReentrantLock) KeeperException(org.apache.zookeeper.KeeperException) Scope(io.opentelemetry.context.Scope) UTF_8(java.nio.charset.StandardCharsets.UTF_8) ScanDispatch(org.apache.accumulo.core.spi.scan.ScanDispatch) VolumeChooserEnvironment(org.apache.accumulo.core.spi.fs.VolumeChooserEnvironment) Constants(org.apache.accumulo.core.Constants) Authorizations(org.apache.accumulo.core.security.Authorizations) TimeUnit(java.util.concurrent.TimeUnit) TservConstraintEnv(org.apache.accumulo.tserver.TservConstraintEnv) Collectors.toList(java.util.stream.Collectors.toList) ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet) ShutdownUtil(org.apache.accumulo.core.util.ShutdownUtil) Collections(java.util.Collections) ColumnType(org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType) DataFileValue(org.apache.accumulo.core.metadata.schema.DataFileValue) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MapFileInfo(org.apache.accumulo.core.dataImpl.thrift.MapFileInfo) IOException(java.io.IOException) TooManyFilesException(org.apache.accumulo.server.fs.TooManyFilesException) DecoderException(org.apache.commons.codec.DecoderException) IOException(java.io.IOException) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException) FileNotFoundException(java.io.FileNotFoundException) IterationInterruptedException(org.apache.accumulo.core.iteratorsImpl.system.IterationInterruptedException) KeeperException(org.apache.zookeeper.KeeperException) StoredTabletFile(org.apache.accumulo.core.metadata.StoredTabletFile) TabletFile(org.apache.accumulo.core.metadata.TabletFile)

Aggregations

Preconditions (com.google.common.base.Preconditions)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 Span (io.opentelemetry.api.trace.Span)1 Scope (io.opentelemetry.context.Scope)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 Optional (java.util.Optional)1 Set (java.util.Set)1