Search in sources :

Example 76 with TServerInstance

use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.

the class TabletServer method markUnusedWALs.

private void markUnusedWALs() {
    List<DfsLogger> closedCopy;
    synchronized (closedLogs) {
        closedCopy = copyClosedLogs(closedLogs);
    }
    ReferencedRemover refRemover = candidates -> {
        for (Tablet tablet : getOnlineTablets().values()) {
            tablet.removeInUseLogs(candidates);
            if (candidates.isEmpty()) {
                break;
            }
        }
    };
    Set<DfsLogger> eligible = findOldestUnreferencedWals(closedCopy, refRemover);
    try {
        TServerInstance session = this.getTabletSession();
        for (DfsLogger candidate : eligible) {
            log.info("Marking " + candidate.getPath() + " as unreferenced");
            walMarker.walUnreferenced(session, candidate.getPath());
        }
        synchronized (closedLogs) {
            closedLogs.removeAll(eligible);
        }
    } catch (WalMarkerException ex) {
        log.info(ex.toString(), ex);
    }
}
Also used : VolumeChooserEnvironmentImpl(org.apache.accumulo.server.fs.VolumeChooserEnvironmentImpl) Arrays(java.util.Arrays) TableInfo(org.apache.accumulo.core.master.thrift.TableInfo) Text(org.apache.hadoop.io.Text) Iface(org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Iface) TServer(org.apache.thrift.server.TServer) GarbageCollectionLogger(org.apache.accumulo.server.GarbageCollectionLogger) TServerInstance(org.apache.accumulo.core.metadata.TServerInstance) SecureRandom(java.security.SecureRandom) TabletLevel(org.apache.accumulo.server.TabletLevel) Map(java.util.Map) RootTable(org.apache.accumulo.core.metadata.RootTable) ServerBulkImportStatus(org.apache.accumulo.server.util.ServerBulkImportStatus) ThriftServerType(org.apache.accumulo.server.rpc.ThriftServerType) DfsLogger(org.apache.accumulo.tserver.log.DfsLogger) ServerAddress(org.apache.accumulo.server.rpc.ServerAddress) BulkImportState(org.apache.accumulo.core.master.thrift.BulkImportState) SortedLogState(org.apache.accumulo.server.log.SortedLogState) EnumSet(java.util.EnumSet) Property(org.apache.accumulo.core.conf.Property) InstanceId(org.apache.accumulo.core.data.InstanceId) TServiceClient(org.apache.thrift.TServiceClient) VolumeManager(org.apache.accumulo.server.fs.VolumeManager) Compactable(org.apache.accumulo.tserver.compactions.Compactable) Set(java.util.Set) RelativeTime(org.apache.accumulo.server.util.time.RelativeTime) ServerServices(org.apache.accumulo.core.util.ServerServices) NodeExistsPolicy(org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy) AuthenticationTokenSecretManager(org.apache.accumulo.server.security.delegation.AuthenticationTokenSecretManager) ServiceLock(org.apache.accumulo.fate.zookeeper.ServiceLock) AuditedSecurityOperation(org.apache.accumulo.server.security.AuditedSecurityOperation) UtilWaitThread.sleepUninterruptibly(org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly) TProcessor(org.apache.thrift.TProcessor) LogSorter(org.apache.accumulo.tserver.log.LogSorter) HostAndPort(org.apache.accumulo.core.util.HostAndPort) SecurityOperation(org.apache.accumulo.server.security.SecurityOperation) Threads(org.apache.accumulo.core.util.threads.Threads) AbstractServer(org.apache.accumulo.server.AbstractServer) DurabilityImpl(org.apache.accumulo.core.clientImpl.DurabilityImpl) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) MetricsUtil(org.apache.accumulo.core.metrics.MetricsUtil) DistributedWorkQueue(org.apache.accumulo.server.zookeeper.DistributedWorkQueue) WalMarkerException(org.apache.accumulo.server.log.WalStateManager.WalMarkerException) SessionManager(org.apache.accumulo.tserver.session.SessionManager) CommitSession(org.apache.accumulo.tserver.tablet.CommitSession) ManagementFactory(java.lang.management.ManagementFactory) Service(org.apache.accumulo.core.util.ServerServices.Service) FILES(org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.FILES) LinkedHashSet(java.util.LinkedHashSet) BlockingDeque(java.util.concurrent.BlockingDeque) ServerContext(org.apache.accumulo.server.ServerContext) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) TException(org.apache.thrift.TException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) AtomicLong(java.util.concurrent.atomic.AtomicLong) TreeMap(java.util.TreeMap) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) LockWatcher(org.apache.accumulo.fate.zookeeper.ServiceLock.LockWatcher) FileSystemMonitor(org.apache.accumulo.server.util.FileSystemMonitor) TableId(org.apache.accumulo.core.data.TableId) RetryFactory(org.apache.accumulo.fate.util.Retry.RetryFactory) ServerOpts(org.apache.accumulo.server.ServerOpts) ThriftUtil(org.apache.accumulo.core.rpc.ThriftUtil) LockLossReason(org.apache.accumulo.fate.zookeeper.ServiceLock.LockLossReason) TabletData(org.apache.accumulo.tserver.tablet.TabletData) SortedSet(java.util.SortedSet) ZooCache(org.apache.accumulo.fate.zookeeper.ZooCache) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus) TabletsMetadata(org.apache.accumulo.core.metadata.schema.TabletsMetadata) TCredentialsUpdatingWrapper(org.apache.accumulo.server.rpc.TCredentialsUpdatingWrapper) LoggerFactory(org.slf4j.LoggerFactory) LRUMap(org.apache.commons.collections4.map.LRUMap) MetadataTable(org.apache.accumulo.core.metadata.MetadataTable) ManagerMessage(org.apache.accumulo.tserver.managermessage.ManagerMessage) RecoveryPath(org.apache.accumulo.server.manager.recovery.RecoveryPath) TServerUtils(org.apache.accumulo.server.rpc.TServerUtils) ComparablePair(org.apache.accumulo.core.util.ComparablePair) TabletServerLogger(org.apache.accumulo.tserver.log.TabletServerLogger) ScanRunState(org.apache.accumulo.tserver.scan.ScanRunState) ReplicationServicer(org.apache.accumulo.core.replication.thrift.ReplicationServicer) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Path(org.apache.hadoop.fs.Path) TabletServerUpdateMetrics(org.apache.accumulo.tserver.metrics.TabletServerUpdateMetrics) TabletServerScanMetrics(org.apache.accumulo.tserver.metrics.TabletServerScanMetrics) PREV_ROW(org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.PREV_ROW) SecurityUtil(org.apache.accumulo.server.security.SecurityUtil) Operation(org.apache.accumulo.tserver.TabletStatsKeeper.Operation) Collection(java.util.Collection) TabletServerMetrics(org.apache.accumulo.tserver.metrics.TabletServerMetrics) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Durability(org.apache.accumulo.core.client.Durability) Processor(org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Processor) ThreadPools(org.apache.accumulo.core.util.threads.ThreadPools) UUID(java.util.UUID) Session(org.apache.accumulo.tserver.session.Session) WalStateManager(org.apache.accumulo.server.log.WalStateManager) SplitReportMessage(org.apache.accumulo.tserver.managermessage.SplitReportMessage) MapCounter(org.apache.accumulo.core.util.MapCounter) List(java.util.List) TableConfiguration(org.apache.accumulo.server.conf.TableConfiguration) Pair(org.apache.accumulo.core.util.Pair) Entry(java.util.Map.Entry) TraceUtil(org.apache.accumulo.core.trace.TraceUtil) SortedMap(java.util.SortedMap) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) UtilWaitThread(org.apache.accumulo.fate.util.UtilWaitThread) HashMap(java.util.HashMap) Iterators(com.google.common.collect.Iterators) HashSet(java.util.HashSet) TabletLocator(org.apache.accumulo.core.clientImpl.TabletLocator) TabletResourceManager(org.apache.accumulo.tserver.TabletServerResourceManager.TabletResourceManager) TabletServerMinCMetrics(org.apache.accumulo.tserver.metrics.TabletServerMinCMetrics) ZooAuthenticationKeyWatcher(org.apache.accumulo.server.security.delegation.ZooAuthenticationKeyWatcher) Halt(org.apache.accumulo.core.util.Halt) ManagerClientService(org.apache.accumulo.core.manager.thrift.ManagerClientService) ZooReaderWriter(org.apache.accumulo.fate.zookeeper.ZooReaderWriter) CompactionManager(org.apache.accumulo.tserver.compactions.CompactionManager) LogEntry(org.apache.accumulo.core.tabletserver.log.LogEntry) Retry(org.apache.accumulo.fate.util.Retry) CompactionWatcher(org.apache.accumulo.server.compaction.CompactionWatcher) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) ReentrantLock(java.util.concurrent.locks.ReentrantLock) KeeperException(org.apache.zookeeper.KeeperException) UTF_8(java.nio.charset.StandardCharsets.UTF_8) VolumeChooserEnvironment(org.apache.accumulo.core.spi.fs.VolumeChooserEnvironment) CompactionExecutorsMetrics(org.apache.accumulo.tserver.metrics.CompactionExecutorsMetrics) Compacting(org.apache.accumulo.core.master.thrift.Compacting) BulkImportCacheCleaner(org.apache.accumulo.tserver.tablet.BulkImportCacheCleaner) Constants(org.apache.accumulo.core.Constants) TimeUnit(java.util.concurrent.TimeUnit) ECOMP(org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.ECOMP) MutationReceiver(org.apache.accumulo.tserver.log.MutationReceiver) Tablet(org.apache.accumulo.tserver.tablet.Tablet) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) LOGS(org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.LOGS) Tablet(org.apache.accumulo.tserver.tablet.Tablet) TServerInstance(org.apache.accumulo.core.metadata.TServerInstance) DfsLogger(org.apache.accumulo.tserver.log.DfsLogger) WalMarkerException(org.apache.accumulo.server.log.WalStateManager.WalMarkerException)

Example 77 with TServerInstance

use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.

the class Upgrader9to10 method upgradeRootTabletMetadata.

/**
 * Improvements to the metadata and root tables were made in this version. See pull request
 * <a href="https://github.com/apache/accumulo/pull/1174">#1174</a> for more details.
 */
private void upgradeRootTabletMetadata(ServerContext context) {
    String rootMetaSer = getFromZK(context, ZROOT_TABLET);
    if (rootMetaSer == null || rootMetaSer.isEmpty()) {
        String dir = getFromZK(context, ZROOT_TABLET_PATH);
        List<LogEntry> logs = getRootLogEntries(context);
        TServerInstance last = getLocation(context, ZROOT_TABLET_LAST_LOCATION);
        TServerInstance future = getLocation(context, ZROOT_TABLET_FUTURE_LOCATION);
        TServerInstance current = getLocation(context, ZROOT_TABLET_LOCATION);
        UpgradeMutator tabletMutator = new UpgradeMutator(context);
        tabletMutator.putPrevEndRow(RootTable.EXTENT.prevEndRow());
        tabletMutator.putDirName(upgradeDirColumn(dir));
        if (last != null)
            tabletMutator.putLocation(last, LocationType.LAST);
        if (future != null)
            tabletMutator.putLocation(future, LocationType.FUTURE);
        if (current != null)
            tabletMutator.putLocation(current, LocationType.CURRENT);
        logs.forEach(tabletMutator::putWal);
        Map<String, DataFileValue> files = cleanupRootTabletFiles(context.getVolumeManager(), dir);
        files.forEach((path, dfv) -> tabletMutator.putFile(new TabletFile(new Path(path)), dfv));
        tabletMutator.putTime(computeRootTabletTime(context, files.keySet()));
        tabletMutator.mutate();
    }
    try {
        context.getZooReaderWriter().putPersistentData(context.getZooKeeperRoot() + ZROOT_TABLET_GC_CANDIDATES, new RootGcCandidates().toJson().getBytes(UTF_8), NodeExistsPolicy.SKIP);
    } catch (KeeperException | InterruptedException e) {
        throw new RuntimeException(e);
    }
    // this operation must be idempotent, so deleting after updating is very important
    delete(context, ZROOT_TABLET_CURRENT_LOGS);
    delete(context, ZROOT_TABLET_FUTURE_LOCATION);
    delete(context, ZROOT_TABLET_LAST_LOCATION);
    delete(context, ZROOT_TABLET_LOCATION);
    delete(context, ZROOT_TABLET_WALOGS);
    delete(context, ZROOT_TABLET_PATH);
}
Also used : Path(org.apache.hadoop.fs.Path) RootGcCandidates(org.apache.accumulo.server.metadata.RootGcCandidates) DataFileValue(org.apache.accumulo.core.metadata.schema.DataFileValue) TServerInstance(org.apache.accumulo.core.metadata.TServerInstance) TabletFile(org.apache.accumulo.core.metadata.TabletFile) LogEntry(org.apache.accumulo.core.tabletserver.log.LogEntry) KeeperException(org.apache.zookeeper.KeeperException)

Example 78 with TServerInstance

use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.

the class ManagerReplicationCoordinatorTest method randomServerFromMany.

@Test
public void randomServerFromMany() {
    Manager manager = EasyMock.createMock(Manager.class);
    ZooReader reader = EasyMock.createMock(ZooReader.class);
    ServerContext context = EasyMock.createMock(ServerContext.class);
    EasyMock.expect(context.getConfiguration()).andReturn(config).anyTimes();
    EasyMock.expect(context.getInstanceID()).andReturn(InstanceId.of("1234")).anyTimes();
    EasyMock.expect(context.getZooReaderWriter()).andReturn(null).anyTimes();
    EasyMock.expect(manager.getInstanceID()).andReturn(InstanceId.of("1234")).anyTimes();
    EasyMock.expect(manager.getContext()).andReturn(context).anyTimes();
    EasyMock.replay(manager, context, reader);
    ManagerReplicationCoordinator coordinator = new ManagerReplicationCoordinator(manager, reader);
    EasyMock.verify(manager, reader);
    TreeSet<TServerInstance> instances = new TreeSet<>();
    TServerInstance inst1 = new TServerInstance(HostAndPort.fromParts("host1", 1234), "session");
    instances.add(inst1);
    TServerInstance inst2 = new TServerInstance(HostAndPort.fromParts("host2", 1234), "session");
    instances.add(inst2);
    assertEquals(inst1, coordinator.getRandomTServer(instances, 0));
    assertEquals(inst2, coordinator.getRandomTServer(instances, 1));
}
Also used : ZooReader(org.apache.accumulo.fate.zookeeper.ZooReader) ServerContext(org.apache.accumulo.server.ServerContext) TreeSet(java.util.TreeSet) Manager(org.apache.accumulo.manager.Manager) TServerInstance(org.apache.accumulo.core.metadata.TServerInstance) Test(org.junit.Test)

Example 79 with TServerInstance

use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.

the class UnusedWALIT method getWALCount.

private int getWALCount(ServerContext context) throws Exception {
    WalStateManager wals = new WalStateManager(context);
    int result = 0;
    for (Entry<TServerInstance, List<UUID>> entry : wals.getAllMarkers().entrySet()) {
        result += entry.getValue().size();
    }
    return result;
}
Also used : WalStateManager(org.apache.accumulo.server.log.WalStateManager) List(java.util.List) TServerInstance(org.apache.accumulo.core.metadata.TServerInstance)

Example 80 with TServerInstance

use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.

the class SplitRecoveryIT method splitPartiallyAndRecover.

private void splitPartiallyAndRecover(ServerContext context, KeyExtent extent, KeyExtent high, KeyExtent low, double splitRatio, SortedMap<StoredTabletFile, DataFileValue> mapFiles, Text midRow, String location, int steps, ServiceLock zl) throws Exception {
    SortedMap<StoredTabletFile, DataFileValue> lowDatafileSizes = new TreeMap<>();
    SortedMap<StoredTabletFile, DataFileValue> highDatafileSizes = new TreeMap<>();
    List<StoredTabletFile> highDatafilesToRemove = new ArrayList<>();
    MetadataTableUtil.splitDatafiles(midRow, splitRatio, new HashMap<>(), mapFiles, lowDatafileSizes, highDatafileSizes, highDatafilesToRemove);
    MetadataTableUtil.splitTablet(high, extent.prevEndRow(), splitRatio, context, zl, Set.of());
    TServerInstance instance = new TServerInstance(location, zl.getSessionId());
    Assignment assignment = new Assignment(high, instance);
    TabletMutator tabletMutator = context.getAmple().mutateTablet(extent);
    tabletMutator.putLocation(assignment.server, LocationType.FUTURE);
    tabletMutator.mutate();
    if (steps >= 1) {
        Map<Long, List<TabletFile>> bulkFiles = getBulkFilesLoaded(context, high);
        ManagerMetadataUtil.addNewTablet(context, low, "lowDir", instance, lowDatafileSizes, bulkFiles, new MetadataTime(0, TimeType.LOGICAL), -1L, -1L, zl);
    }
    if (steps >= 2) {
        MetadataTableUtil.finishSplit(high, highDatafileSizes, highDatafilesToRemove, context, zl);
    }
    TabletMetadata meta = context.getAmple().readTablet(high);
    KeyExtent fixedExtent = ManagerMetadataUtil.fixSplit(context, meta, zl);
    if (steps < 2)
        assertEquals(splitRatio, meta.getSplitRatio(), 0.0);
    if (steps >= 1) {
        assertEquals(high, fixedExtent);
        ensureTabletHasNoUnexpectedMetadataEntries(context, low, lowDatafileSizes);
        ensureTabletHasNoUnexpectedMetadataEntries(context, high, highDatafileSizes);
        Map<Long, ? extends Collection<TabletFile>> lowBulkFiles = getBulkFilesLoaded(context, low);
        Map<Long, ? extends Collection<TabletFile>> highBulkFiles = getBulkFilesLoaded(context, high);
        if (!lowBulkFiles.equals(highBulkFiles)) {
            throw new Exception(" " + lowBulkFiles + " != " + highBulkFiles + " " + low + " " + high);
        }
        if (lowBulkFiles.isEmpty()) {
            throw new Exception(" no bulk files " + low);
        }
    } else {
        assertEquals(extent, fixedExtent);
        ensureTabletHasNoUnexpectedMetadataEntries(context, extent, mapFiles);
    }
}
Also used : DataFileValue(org.apache.accumulo.core.metadata.schema.DataFileValue) ArrayList(java.util.ArrayList) TabletMutator(org.apache.accumulo.core.metadata.schema.Ample.TabletMutator) TreeMap(java.util.TreeMap) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) TServerInstance(org.apache.accumulo.core.metadata.TServerInstance) Assignment(org.apache.accumulo.server.manager.state.Assignment) TabletMetadata(org.apache.accumulo.core.metadata.schema.TabletMetadata) StoredTabletFile(org.apache.accumulo.core.metadata.StoredTabletFile) List(java.util.List) ArrayList(java.util.ArrayList) StoredTabletFile(org.apache.accumulo.core.metadata.StoredTabletFile) TabletFile(org.apache.accumulo.core.metadata.TabletFile) MetadataTime(org.apache.accumulo.core.metadata.schema.MetadataTime)

Aggregations

TServerInstance (org.apache.accumulo.core.metadata.TServerInstance)89 KeyExtent (org.apache.accumulo.core.dataImpl.KeyExtent)32 ArrayList (java.util.ArrayList)31 Test (org.junit.Test)30 HashMap (java.util.HashMap)21 ServerContext (org.apache.accumulo.server.ServerContext)18 TabletLocationState (org.apache.accumulo.core.metadata.TabletLocationState)17 HostAndPort (org.apache.accumulo.core.util.HostAndPort)14 HashSet (java.util.HashSet)13 TabletServerStatus (org.apache.accumulo.core.master.thrift.TabletServerStatus)13 TableId (org.apache.accumulo.core.data.TableId)12 AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)11 List (java.util.List)10 LiveTServerSet (org.apache.accumulo.server.manager.LiveTServerSet)10 TException (org.apache.thrift.TException)10 TreeMap (java.util.TreeMap)9 UUID (java.util.UUID)9 TreeSet (java.util.TreeSet)8 Key (org.apache.accumulo.core.data.Key)8 Value (org.apache.accumulo.core.data.Value)8