Search in sources :

Example 11 with WalStateManager

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);
}
Also used : VolumeManager(org.apache.accumulo.server.fs.VolumeManager) Connector(org.apache.accumulo.core.client.Connector) Scanner(org.apache.accumulo.core.client.Scanner) AccumuloServerContext(org.apache.accumulo.server.AccumuloServerContext) WalStateManager(org.apache.accumulo.server.log.WalStateManager) GcCycleStats(org.apache.accumulo.core.gc.thrift.GcCycleStats) GCStatus(org.apache.accumulo.core.gc.thrift.GCStatus) LiveTServerSet(org.apache.accumulo.server.master.LiveTServerSet) Test(org.junit.Test)

Example 12 with WalStateManager

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);
}
Also used : VolumeManager(org.apache.accumulo.server.fs.VolumeManager) AccumuloServerContext(org.apache.accumulo.server.AccumuloServerContext) WalStateManager(org.apache.accumulo.server.log.WalStateManager) GcCycleStats(org.apache.accumulo.core.gc.thrift.GcCycleStats) GCStatus(org.apache.accumulo.core.gc.thrift.GCStatus) Map(java.util.Map) LiveTServerSet(org.apache.accumulo.server.master.LiveTServerSet) Test(org.junit.Test)

Example 13 with WalStateManager

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);
}
Also used : Path(org.apache.hadoop.fs.Path) Scanner(org.apache.accumulo.core.client.Scanner) TreeSet(java.util.TreeSet) WalStateManager(org.apache.accumulo.server.log.WalStateManager) Value(org.apache.accumulo.core.data.Value) Key(org.apache.accumulo.core.data.Key) LogEntry(org.apache.accumulo.core.tabletserver.log.LogEntry)

Example 14 with WalStateManager

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

WalStateManager (org.apache.accumulo.server.log.WalStateManager)14 Scanner (org.apache.accumulo.core.client.Scanner)7 Path (org.apache.hadoop.fs.Path)7 Connector (org.apache.accumulo.core.client.Connector)6 WalState (org.apache.accumulo.server.log.WalStateManager.WalState)6 Test (org.junit.Test)6 Instance (org.apache.accumulo.core.client.Instance)5 GCStatus (org.apache.accumulo.core.gc.thrift.GCStatus)5 GcCycleStats (org.apache.accumulo.core.gc.thrift.GcCycleStats)5 AccumuloServerContext (org.apache.accumulo.server.AccumuloServerContext)5 VolumeManager (org.apache.accumulo.server.fs.VolumeManager)5 LiveTServerSet (org.apache.accumulo.server.master.LiveTServerSet)5 ZooReaderWriter (org.apache.accumulo.server.zookeeper.ZooReaderWriter)5 Key (org.apache.accumulo.core.data.Key)4 Value (org.apache.accumulo.core.data.Value)4 TServerInstance (org.apache.accumulo.server.master.state.TServerInstance)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 List (java.util.List)3 ZooKeeperInstance (org.apache.accumulo.core.client.ZooKeeperInstance)3