Search in sources :

Example 6 with WalState

use of org.apache.accumulo.server.log.WalStateManager.WalState in project accumulo by apache.

the class GarbageCollectorCommunicatesWithTServersIT method getWalsForTable.

/**
 * Fetch all of the WALs referenced by tablets in the metadata table for this table
 */
private Set<String> getWalsForTable(String tableName) throws Exception {
    final Connector conn = getConnector();
    final String tableId = conn.tableOperations().tableIdMap().get(tableName);
    Assert.assertNotNull("Could not determine table ID for " + tableName, tableId);
    Instance i = conn.getInstance();
    ZooReaderWriter zk = new ZooReaderWriter(i.getZooKeepers(), i.getZooKeepersSessionTimeOut(), "");
    WalStateManager wals = new WalStateManager(conn.getInstance(), zk);
    Set<String> result = new HashSet<>();
    for (Entry<Path, WalState> entry : wals.getAllState().entrySet()) {
        log.debug("Reading WALs: {}={}", entry.getKey(), entry.getValue());
        result.add(entry.getKey().toString());
    }
    return result;
}
Also used : Path(org.apache.hadoop.fs.Path) Connector(org.apache.accumulo.core.client.Connector) Instance(org.apache.accumulo.core.client.Instance) WalStateManager(org.apache.accumulo.server.log.WalStateManager) ZooReaderWriter(org.apache.accumulo.server.zookeeper.ZooReaderWriter) WalState(org.apache.accumulo.server.log.WalStateManager.WalState) HashSet(java.util.HashSet)

Example 7 with WalState

use of org.apache.accumulo.server.log.WalStateManager.WalState in project accumulo by apache.

the class GarbageCollectWriteAheadLogs method removeEntriesInUse.

private Map<UUID, TServerInstance> removeEntriesInUse(Map<TServerInstance, Set<UUID>> candidates, Set<TServerInstance> liveServers, Map<UUID, Pair<WalState, Path>> logsState) throws IOException, KeeperException, InterruptedException {
    Map<UUID, TServerInstance> result = new HashMap<>();
    for (Entry<TServerInstance, Set<UUID>> entry : candidates.entrySet()) {
        for (UUID id : entry.getValue()) {
            result.put(id, entry.getKey());
        }
    }
    // remove any entries if there's a log reference (recovery hasn't finished)
    Iterator<TabletLocationState> states = store.iterator();
    while (states.hasNext()) {
        TabletLocationState state = states.next();
        // Easiest to just ignore all the WALs for the dead server.
        if (state.getState(liveServers) == TabletState.ASSIGNED_TO_DEAD_SERVER) {
            Set<UUID> idsToIgnore = candidates.remove(state.current);
            if (idsToIgnore != null) {
                for (UUID id : idsToIgnore) {
                    result.remove(id);
                }
            }
        }
        // that made the WALs.
        for (Collection<String> wals : state.walogs) {
            for (String wal : wals) {
                UUID walUUID = path2uuid(new Path(wal));
                TServerInstance dead = result.get(walUUID);
                // There's a reference to a log file, so skip that server's logs
                Set<UUID> idsToIgnore = candidates.remove(dead);
                if (idsToIgnore != null) {
                    for (UUID id : idsToIgnore) {
                        result.remove(id);
                    }
                }
            }
        }
    }
    // Remove OPEN and CLOSED logs for live servers: they are still in use
    for (TServerInstance liveServer : liveServers) {
        Set<UUID> idsForServer = candidates.get(liveServer);
        // Server may not have any logs yet
        if (idsForServer != null) {
            for (UUID id : idsForServer) {
                Pair<WalState, Path> stateFile = logsState.get(id);
                if (stateFile.getFirst() != WalState.UNREFERENCED) {
                    result.remove(id);
                }
            }
        }
    }
    return result;
}
Also used : Path(org.apache.hadoop.fs.Path) LiveTServerSet(org.apache.accumulo.server.master.LiveTServerSet) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) TabletLocationState(org.apache.accumulo.server.master.state.TabletLocationState) WalState(org.apache.accumulo.server.log.WalStateManager.WalState) UUID(java.util.UUID)

Example 8 with WalState

use of org.apache.accumulo.server.log.WalStateManager.WalState in project accumulo by apache.

the class WALSunnyDayIT method _getWals.

private Map<String, Boolean> _getWals(Connector c) throws Exception {
    Map<String, Boolean> result = new HashMap<>();
    Instance i = c.getInstance();
    ZooReaderWriter zk = new ZooReaderWriter(i.getZooKeepers(), i.getZooKeepersSessionTimeOut(), "");
    WalStateManager wals = new WalStateManager(c.getInstance(), zk);
    for (Entry<Path, WalState> entry : wals.getAllState().entrySet()) {
        // WALs are in use if they are not unreferenced
        result.put(entry.getKey().toString(), entry.getValue() != WalState.UNREFERENCED);
    }
    return result;
}
Also used : Path(org.apache.hadoop.fs.Path) HashMap(java.util.HashMap) Instance(org.apache.accumulo.core.client.Instance) WalStateManager(org.apache.accumulo.server.log.WalStateManager) ZooReaderWriter(org.apache.accumulo.server.zookeeper.ZooReaderWriter) WalState(org.apache.accumulo.server.log.WalStateManager.WalState)

Aggregations

WalState (org.apache.accumulo.server.log.WalStateManager.WalState)8 Path (org.apache.hadoop.fs.Path)8 WalStateManager (org.apache.accumulo.server.log.WalStateManager)6 Instance (org.apache.accumulo.core.client.Instance)5 ZooReaderWriter (org.apache.accumulo.server.zookeeper.ZooReaderWriter)5 HashSet (java.util.HashSet)4 Connector (org.apache.accumulo.core.client.Connector)3 Scanner (org.apache.accumulo.core.client.Scanner)3 ZooKeeperInstance (org.apache.accumulo.core.client.ZooKeeperInstance)3 TServerInstance (org.apache.accumulo.server.master.state.TServerInstance)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 UUID (java.util.UUID)2 Key (org.apache.accumulo.core.data.Key)2 Value (org.apache.accumulo.core.data.Value)2 WalMarkerException (org.apache.accumulo.server.log.WalStateManager.WalMarkerException)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1