Search in sources :

Example 1 with GCStatus

use of org.apache.accumulo.core.gc.thrift.GCStatus in project accumulo by apache.

the class GarbageCollectWriteAheadLogsTest method deleteUnreferenceLogOnDeadServer.

@Test
public void deleteUnreferenceLogOnDeadServer() 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.expect(fs.deleteRecursively(path)).andReturn(true).once();
    marker.removeWalMarker(server2, id);
    EasyMock.expectLastCall().once();
    marker.forget(server2);
    EasyMock.expectLastCall().once();
    EasyMock.replay(context, fs, marker, tserverSet, conn, rscanner, mscanner);
    GarbageCollectWriteAheadLogs gc = new GarbageCollectWriteAheadLogs(context, fs, false, tserverSet, marker, tabletOnServer1List);
    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 2 with GCStatus

use of org.apache.accumulo.core.gc.thrift.GCStatus in project accumulo by apache.

the class GarbageCollectWriteAheadLogsTest method testRemoveUnusedLog.

@Test
public void testRemoveUnusedLog() 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.UNREFERENCED, path));
    EasyMock.expect(fs.deleteRecursively(path)).andReturn(true).once();
    marker.removeWalMarker(server1, id);
    EasyMock.expectLastCall().once();
    EasyMock.replay(context, fs, marker, tserverSet);
    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, fs, marker, tserverSet);
}
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 3 with GCStatus

use of org.apache.accumulo.core.gc.thrift.GCStatus in project accumulo by apache.

the class Monitor method fetchGcStatus.

private static GCStatus fetchGcStatus() {
    GCStatus result = null;
    HostAndPort address = null;
    try {
        // Read the gc location from its lock
        ZooReaderWriter zk = ZooReaderWriter.getInstance();
        String path = ZooUtil.getRoot(instance) + Constants.ZGC_LOCK;
        List<String> locks = zk.getChildren(path, null);
        if (locks != null && locks.size() > 0) {
            Collections.sort(locks);
            address = new ServerServices(new String(zk.getData(path + "/" + locks.get(0), null), UTF_8)).getAddress(Service.GC_CLIENT);
            GCMonitorService.Client client = ThriftUtil.getClient(new GCMonitorService.Client.Factory(), address, new AccumuloServerContext(instance, config));
            try {
                result = client.getStatus(Tracer.traceInfo(), getContext().rpcCreds());
            } finally {
                ThriftUtil.returnClient(client);
            }
        }
    } catch (Exception ex) {
        log.warn("Unable to contact the garbage collector at " + address, ex);
    }
    return result;
}
Also used : HostAndPort(org.apache.accumulo.core.util.HostAndPort) ServerServices(org.apache.accumulo.core.util.ServerServices) AccumuloServerContext(org.apache.accumulo.server.AccumuloServerContext) ZooReaderWriter(org.apache.accumulo.server.zookeeper.ZooReaderWriter) GCStatus(org.apache.accumulo.core.gc.thrift.GCStatus) GCMonitorService(org.apache.accumulo.core.gc.thrift.GCMonitorService) MasterClient(org.apache.accumulo.core.client.impl.MasterClient) Client(org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Client) KeeperException(org.apache.zookeeper.KeeperException) UnknownHostException(java.net.UnknownHostException)

Example 4 with GCStatus

use of org.apache.accumulo.core.gc.thrift.GCStatus in project accumulo by apache.

the class MasterResource method getTables.

/**
 * Generates a master information JSON object
 *
 * @return master JSON object
 */
@GET
public static MasterInformation getTables() {
    MasterInformation masterInformation;
    MasterMonitorInfo mmi = Monitor.getMmi();
    if (mmi != null) {
        GCStatus gcStatusObj = Monitor.getGcStatus();
        String gcStatus = "Waiting";
        String label = "";
        if (gcStatusObj != null) {
            long start = 0;
            if (gcStatusObj.current.started != 0 || gcStatusObj.currentLog.started != 0) {
                start = Math.max(gcStatusObj.current.started, gcStatusObj.currentLog.started);
                label = "Running";
            } else if (gcStatusObj.lastLog.finished != 0) {
                start = gcStatusObj.lastLog.finished;
            }
            if (start != 0) {
                gcStatus = String.valueOf(start);
            }
        } else {
            gcStatus = "Down";
        }
        List<String> tservers = new ArrayList<>();
        for (TabletServerStatus up : mmi.tServerInfo) {
            tservers.add(up.name);
        }
        for (DeadServer down : mmi.deadTabletServers) {
            tservers.add(down.server);
        }
        List<String> masters = Monitor.getContext().getInstance().getMasterLocations();
        String master = masters.size() == 0 ? "Down" : AddressUtil.parseAddress(masters.get(0), false).getHost();
        Integer onlineTabletServers = mmi.tServerInfo.size();
        Integer totalTabletServers = tservers.size();
        Integer tablets = Monitor.getTotalTabletCount();
        Integer unassignedTablets = mmi.unassignedTablets;
        long entries = Monitor.getTotalEntries();
        double ingest = Monitor.getTotalIngestRate();
        double entriesRead = Monitor.getTotalScanRate();
        double entriesReturned = Monitor.getTotalQueryRate();
        long holdTime = Monitor.getTotalHoldTime();
        double osLoad = ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage();
        int tables = Monitor.getTotalTables();
        int deadTabletServers = mmi.deadTabletServers.size();
        long lookups = Monitor.getTotalLookups();
        long uptime = System.currentTimeMillis() - Monitor.getStartTime();
        masterInformation = new MasterInformation(master, onlineTabletServers, totalTabletServers, gcStatus, tablets, unassignedTablets, entries, ingest, entriesRead, entriesReturned, holdTime, osLoad, tables, deadTabletServers, lookups, uptime, label, getGoalState(), getState(), getNumBadTservers(), getServersShuttingDown(), getDeadTservers(), getDeadLoggers());
    } else {
        masterInformation = new MasterInformation();
    }
    return masterInformation;
}
Also used : MasterMonitorInfo(org.apache.accumulo.core.master.thrift.MasterMonitorInfo) ArrayList(java.util.ArrayList) GCStatus(org.apache.accumulo.core.gc.thrift.GCStatus) DeadServer(org.apache.accumulo.core.master.thrift.DeadServer) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus) GET(javax.ws.rs.GET)

Example 5 with GCStatus

use of org.apache.accumulo.core.gc.thrift.GCStatus in project accumulo by apache.

the class GarbageCollectWriteAheadLogsTest method replicationDelaysFileCollection.

@Test
public void replicationDelaysFileCollection() 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);
    String row = MetadataSchema.ReplicationSection.getRowPrefix() + path.toString();
    String colf = MetadataSchema.ReplicationSection.COLF.toString();
    String colq = "1";
    Map<Key, Value> replicationWork = Collections.singletonMap(new Key(row, colf, colq), new Value(new byte[0]));
    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.UNREFERENCED, 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(replicationWork.entrySet().iterator());
    EasyMock.replay(context, fs, marker, tserverSet, conn, rscanner, mscanner);
    GarbageCollectWriteAheadLogs gc = new GarbageCollectWriteAheadLogs(context, fs, false, tserverSet, marker, tabletOnServer1List);
    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) GcCycleStats(org.apache.accumulo.core.gc.thrift.GcCycleStats) GCStatus(org.apache.accumulo.core.gc.thrift.GCStatus) LiveTServerSet(org.apache.accumulo.server.master.LiveTServerSet) WalStateManager(org.apache.accumulo.server.log.WalStateManager) Value(org.apache.accumulo.core.data.Value) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Aggregations

GCStatus (org.apache.accumulo.core.gc.thrift.GCStatus)7 AccumuloServerContext (org.apache.accumulo.server.AccumuloServerContext)6 GcCycleStats (org.apache.accumulo.core.gc.thrift.GcCycleStats)5 VolumeManager (org.apache.accumulo.server.fs.VolumeManager)5 WalStateManager (org.apache.accumulo.server.log.WalStateManager)5 LiveTServerSet (org.apache.accumulo.server.master.LiveTServerSet)5 Test (org.junit.Test)5 Connector (org.apache.accumulo.core.client.Connector)3 Scanner (org.apache.accumulo.core.client.Scanner)3 Map (java.util.Map)2 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1 GET (javax.ws.rs.GET)1 MasterClient (org.apache.accumulo.core.client.impl.MasterClient)1 Key (org.apache.accumulo.core.data.Key)1 Value (org.apache.accumulo.core.data.Value)1 GCMonitorService (org.apache.accumulo.core.gc.thrift.GCMonitorService)1 DeadServer (org.apache.accumulo.core.master.thrift.DeadServer)1 MasterMonitorInfo (org.apache.accumulo.core.master.thrift.MasterMonitorInfo)1 TabletServerStatus (org.apache.accumulo.core.master.thrift.TabletServerStatus)1