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;
}
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;
}
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;
}
Aggregations