Search in sources :

Example 1 with TServerInstance

use of org.apache.accumulo.server.master.state.TServerInstance in project accumulo by apache.

the class UnusedWALIT method getWALCount.

private int getWALCount(Instance i, ZooReaderWriter zk) throws Exception {
    WalStateManager wals = new WalStateManager(i, zk);
    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.server.master.state.TServerInstance)

Example 2 with TServerInstance

use of org.apache.accumulo.server.master.state.TServerInstance in project accumulo by apache.

the class ReplicationIT method getLogs.

private Multimap<String, Table.ID> getLogs(Connector conn) throws Exception {
    // Map of server to tableId
    Multimap<TServerInstance, String> serverToTableID = HashMultimap.create();
    try (Scanner scanner = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
        scanner.setRange(MetadataSchema.TabletsSection.getRange());
        scanner.fetchColumnFamily(MetadataSchema.TabletsSection.CurrentLocationColumnFamily.NAME);
        for (Entry<Key, Value> entry : scanner) {
            TServerInstance key = new TServerInstance(entry.getValue(), entry.getKey().getColumnQualifier());
            byte[] tableId = KeyExtent.tableOfMetadataRow(entry.getKey().getRow());
            serverToTableID.put(key, new String(tableId, UTF_8));
        }
        // Map of logs to tableId
        Multimap<String, Table.ID> logs = HashMultimap.create();
        Instance i = conn.getInstance();
        ZooReaderWriter zk = new ZooReaderWriter(i.getZooKeepers(), i.getZooKeepersSessionTimeOut(), "");
        WalStateManager wals = new WalStateManager(conn.getInstance(), zk);
        for (Entry<TServerInstance, List<UUID>> entry : wals.getAllMarkers().entrySet()) {
            for (UUID id : entry.getValue()) {
                Pair<WalState, Path> state = wals.state(entry.getKey(), id);
                for (String tableId : serverToTableID.get(entry.getKey())) {
                    logs.put(state.getSecond().toString(), Table.ID.of(tableId));
                }
            }
        }
        return logs;
    }
}
Also used : Path(org.apache.hadoop.fs.Path) Scanner(org.apache.accumulo.core.client.Scanner) Instance(org.apache.accumulo.core.client.Instance) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) ZooReaderWriter(org.apache.accumulo.server.zookeeper.ZooReaderWriter) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) WalStateManager(org.apache.accumulo.server.log.WalStateManager) Value(org.apache.accumulo.core.data.Value) List(java.util.List) ArrayList(java.util.ArrayList) WalState(org.apache.accumulo.server.log.WalStateManager.WalState) UUID(java.util.UUID) UUID(java.util.UUID) Key(org.apache.accumulo.core.data.Key)

Example 3 with TServerInstance

use of org.apache.accumulo.server.master.state.TServerInstance in project accumulo by apache.

the class Master method update.

@Override
public void update(LiveTServerSet current, Set<TServerInstance> deleted, Set<TServerInstance> added) {
    DeadServerList obit = new DeadServerList(ZooUtil.getRoot(getInstance()) + Constants.ZDEADTSERVERS);
    if (added.size() > 0) {
        log.info("New servers: {}", added);
        for (TServerInstance up : added) obit.delete(up.hostPort());
    }
    for (TServerInstance dead : deleted) {
        String cause = "unexpected failure";
        if (serversToShutdown.contains(dead))
            // maybe an incorrect assumption
            cause = "clean shutdown";
        if (!getMasterGoalState().equals(MasterGoalState.CLEAN_STOP))
            obit.post(dead.hostPort(), cause);
    }
    Set<TServerInstance> unexpected = new HashSet<>(deleted);
    unexpected.removeAll(this.serversToShutdown);
    if (unexpected.size() > 0) {
        if (stillMaster() && !getMasterGoalState().equals(MasterGoalState.CLEAN_STOP)) {
            log.warn("Lost servers {}", unexpected);
        }
    }
    serversToShutdown.removeAll(deleted);
    badServers.keySet().removeAll(deleted);
    // clear out any bad server with the same host/port as a new server
    synchronized (badServers) {
        cleanListByHostAndPort(badServers.keySet(), deleted, added);
    }
    synchronized (serversToShutdown) {
        cleanListByHostAndPort(serversToShutdown, deleted, added);
    }
    synchronized (migrations) {
        Iterator<Entry<KeyExtent, TServerInstance>> iter = migrations.entrySet().iterator();
        while (iter.hasNext()) {
            Entry<KeyExtent, TServerInstance> entry = iter.next();
            if (deleted.contains(entry.getValue())) {
                log.info("Canceling migration of {} to {}", entry.getKey(), entry.getValue());
                iter.remove();
            }
        }
    }
    nextEvent.event("There are now %d tablet servers", current.size());
}
Also used : Entry(java.util.Map.Entry) DeadServerList(org.apache.accumulo.server.master.state.DeadServerList) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) HashSet(java.util.HashSet)

Example 4 with TServerInstance

use of org.apache.accumulo.server.master.state.TServerInstance in project accumulo by apache.

the class Master method getMasterMonitorInfo.

public MasterMonitorInfo getMasterMonitorInfo() {
    final MasterMonitorInfo result = new MasterMonitorInfo();
    result.tServerInfo = new ArrayList<>();
    result.tableMap = new DefaultMap<>(new TableInfo());
    for (Entry<TServerInstance, TabletServerStatus> serverEntry : tserverStatus.entrySet()) {
        final TabletServerStatus status = serverEntry.getValue();
        result.tServerInfo.add(status);
        for (Entry<String, TableInfo> entry : status.tableMap.entrySet()) {
            TableInfoUtil.add(result.tableMap.get(entry.getKey()), entry.getValue());
        }
    }
    result.badTServers = new HashMap<>();
    synchronized (badServers) {
        for (TServerInstance bad : badServers.keySet()) {
            result.badTServers.put(bad.hostPort(), TabletServerState.UNRESPONSIVE.getId());
        }
    }
    result.state = getMasterState();
    result.goalState = getMasterGoalState();
    result.unassignedTablets = displayUnassigned();
    result.serversShuttingDown = new HashSet<>();
    synchronized (serversToShutdown) {
        for (TServerInstance server : serversToShutdown) result.serversShuttingDown.add(server.hostPort());
    }
    DeadServerList obit = new DeadServerList(ZooUtil.getRoot(getInstance()) + Constants.ZDEADTSERVERS);
    result.deadTabletServers = obit.getList();
    result.bulkImports = bulkImportStatus.getBulkLoadStatus();
    return result;
}
Also used : MasterMonitorInfo(org.apache.accumulo.core.master.thrift.MasterMonitorInfo) TableInfo(org.apache.accumulo.core.master.thrift.TableInfo) DeadServerList(org.apache.accumulo.server.master.state.DeadServerList) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus)

Example 5 with TServerInstance

use of org.apache.accumulo.server.master.state.TServerInstance in project accumulo by apache.

the class MasterClientServiceHandler method reportSplitExtent.

@Override
public void reportSplitExtent(TInfo info, TCredentials credentials, String serverName, TabletSplit split) {
    KeyExtent oldTablet = new KeyExtent(split.oldTablet);
    if (master.migrations.remove(oldTablet) != null) {
        Master.log.info("Canceled migration of {}", split.oldTablet);
    }
    for (TServerInstance instance : master.tserverSet.getCurrentServers()) {
        if (serverName.equals(instance.hostPort())) {
            master.nextEvent.event("%s reported split %s, %s", serverName, new KeyExtent(split.newTablets.get(0)), new KeyExtent(split.newTablets.get(1)));
            return;
        }
    }
    Master.log.warn("Got a split from a server we don't recognize: {}", serverName);
}
Also used : TKeyExtent(org.apache.accumulo.core.data.thrift.TKeyExtent) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance)

Aggregations

TServerInstance (org.apache.accumulo.server.master.state.TServerInstance)67 KeyExtent (org.apache.accumulo.core.data.impl.KeyExtent)35 HashMap (java.util.HashMap)22 Test (org.junit.Test)22 ArrayList (java.util.ArrayList)21 TabletServerStatus (org.apache.accumulo.core.master.thrift.TabletServerStatus)14 HashSet (java.util.HashSet)10 Value (org.apache.accumulo.core.data.Value)10 AccumuloServerContext (org.apache.accumulo.server.AccumuloServerContext)10 TServerConnection (org.apache.accumulo.server.master.LiveTServerSet.TServerConnection)9 TabletMigration (org.apache.accumulo.server.master.state.TabletMigration)9 TreeMap (java.util.TreeMap)8 Instance (org.apache.accumulo.core.client.Instance)8 Table (org.apache.accumulo.core.client.impl.Table)8 TKeyExtent (org.apache.accumulo.core.data.thrift.TKeyExtent)8 UUID (java.util.UUID)7 Key (org.apache.accumulo.core.data.Key)7 Text (org.apache.hadoop.io.Text)7 TException (org.apache.thrift.TException)7 List (java.util.List)6