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