use of org.apache.accumulo.server.log.WalStateManager in project accumulo by apache.
the class GarbageCollectWriteAheadLogsTest method ignoreReferenceLogOnDeadServer.
@Test
public void ignoreReferenceLogOnDeadServer() throws Exception {
AccumuloServerContext context = EasyMock.createMock(AccumuloServerContext.class);
VolumeManager fs = EasyMock.createMock(VolumeManager.class);
WalStateManager marker = EasyMock.createMock(WalStateManager.class);
LiveTServerSet tserverSet = EasyMock.createMock(LiveTServerSet.class);
Connector conn = EasyMock.createMock(Connector.class);
Scanner mscanner = EasyMock.createMock(Scanner.class);
Scanner rscanner = EasyMock.createMock(Scanner.class);
GCStatus status = new GCStatus(null, null, null, new GcCycleStats());
EasyMock.expect(tserverSet.getCurrentServers()).andReturn(Collections.singleton(server1));
EasyMock.expect(marker.getAllMarkers()).andReturn(markers2).once();
EasyMock.expect(marker.state(server2, id)).andReturn(new Pair<>(WalState.OPEN, path));
EasyMock.expect(context.getConnector()).andReturn(conn);
EasyMock.expect(conn.createScanner(ReplicationTable.NAME, Authorizations.EMPTY)).andReturn(rscanner);
rscanner.fetchColumnFamily(ReplicationSchema.StatusSection.NAME);
EasyMock.expectLastCall().once();
EasyMock.expect(rscanner.iterator()).andReturn(emptyKV);
EasyMock.expect(conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY)).andReturn(mscanner);
mscanner.fetchColumnFamily(MetadataSchema.ReplicationSection.COLF);
EasyMock.expectLastCall().once();
mscanner.setRange(MetadataSchema.ReplicationSection.getRange());
EasyMock.expectLastCall().once();
EasyMock.expect(mscanner.iterator()).andReturn(emptyKV);
EasyMock.replay(context, fs, marker, tserverSet, conn, rscanner, mscanner);
GarbageCollectWriteAheadLogs gc = new GarbageCollectWriteAheadLogs(context, fs, false, tserverSet, marker, tabletOnServer2List);
gc.collect(status);
EasyMock.verify(context, fs, marker, tserverSet, conn, rscanner, mscanner);
}
use of org.apache.accumulo.server.log.WalStateManager in project accumulo by apache.
the class GarbageCollectWriteAheadLogsTest method testKeepClosedLog.
@Test
public void testKeepClosedLog() throws Exception {
AccumuloServerContext context = EasyMock.createMock(AccumuloServerContext.class);
VolumeManager fs = EasyMock.createMock(VolumeManager.class);
WalStateManager marker = EasyMock.createMock(WalStateManager.class);
LiveTServerSet tserverSet = EasyMock.createMock(LiveTServerSet.class);
GCStatus status = new GCStatus(null, null, null, new GcCycleStats());
EasyMock.expect(tserverSet.getCurrentServers()).andReturn(Collections.singleton(server1));
EasyMock.expect(marker.getAllMarkers()).andReturn(markers).once();
EasyMock.expect(marker.state(server1, id)).andReturn(new Pair<>(WalState.CLOSED, path));
EasyMock.replay(context, marker, tserverSet, fs);
GarbageCollectWriteAheadLogs gc = new GarbageCollectWriteAheadLogs(context, fs, false, tserverSet, marker, tabletOnServer1List) {
@Override
protected int removeReplicationEntries(Map<UUID, TServerInstance> candidates) throws IOException, KeeperException, InterruptedException {
return 0;
}
};
gc.collect(status);
EasyMock.verify(context, marker, tserverSet, fs);
}
use of org.apache.accumulo.server.log.WalStateManager in project accumulo by apache.
the class ListVolumesUsed method listTable.
private static void listTable(String name, Connector conn) throws Exception {
System.out.println("Listing volumes referenced in " + name + " tablets section");
Scanner scanner = conn.createScanner(name, Authorizations.EMPTY);
scanner.setRange(MetadataSchema.TabletsSection.getRange());
scanner.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
scanner.fetchColumnFamily(MetadataSchema.TabletsSection.LogColumnFamily.NAME);
MetadataSchema.TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.fetch(scanner);
TreeSet<String> volumes = new TreeSet<>();
for (Entry<Key, Value> entry : scanner) {
if (entry.getKey().getColumnFamily().equals(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME)) {
volumes.add(getTableURI(entry.getKey().getColumnQualifier().toString()));
} else if (entry.getKey().getColumnFamily().equals(MetadataSchema.TabletsSection.LogColumnFamily.NAME)) {
LogEntry le = LogEntry.fromKeyValue(entry.getKey(), entry.getValue());
getLogURIs(volumes, le);
} else if (MetadataSchema.TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.hasColumns(entry.getKey())) {
volumes.add(getTableURI(entry.getValue().toString()));
}
}
for (String volume : volumes) System.out.println("\tVolume : " + volume);
volumes.clear();
scanner.clearColumns();
scanner.setRange(MetadataSchema.DeletesSection.getRange());
for (Entry<Key, Value> entry : scanner) {
String delPath = entry.getKey().getRow().toString().substring(MetadataSchema.DeletesSection.getRowPrefix().length());
volumes.add(getTableURI(delPath));
}
System.out.println("Listing volumes referenced in " + name + " deletes section (volume replacement occurrs at deletion time)");
for (String volume : volumes) System.out.println("\tVolume : " + volume);
volumes.clear();
WalStateManager wals = new WalStateManager(conn.getInstance(), ZooReaderWriter.getInstance());
for (Path path : wals.getAllState().keySet()) {
volumes.add(getLogURI(path.toString()));
}
System.out.println("Listing volumes referenced in " + name + " current logs");
for (String volume : volumes) System.out.println("\tVolume : " + volume);
}
use of org.apache.accumulo.server.log.WalStateManager 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