use of org.apache.accumulo.core.master.thrift.TabletServerStatus in project accumulo by apache.
the class TotalQueuedIT method getSyncs.
private long getSyncs() throws Exception {
Connector c = getConnector();
ServerConfigurationFactory confFactory = new ServerConfigurationFactory(c.getInstance());
AccumuloServerContext context = new AccumuloServerContext(c.getInstance(), confFactory);
for (String address : c.instanceOperations().getTabletServers()) {
TabletClientService.Client client = ThriftUtil.getTServerClient(HostAndPort.fromString(address), context);
TabletServerStatus status = client.getTabletServerStatus(null, context.rpcCreds());
return status.syncs;
}
return 0;
}
use of org.apache.accumulo.core.master.thrift.TabletServerStatus in project accumulo by apache.
the class ShutdownTServerTest method testSingleShutdown.
@Test
public void testSingleShutdown() throws Exception {
final TServerInstance tserver = EasyMock.createMock(TServerInstance.class);
final boolean force = false;
final ShutdownTServer op = new ShutdownTServer(tserver, force);
final Master master = EasyMock.createMock(Master.class);
final long tid = 1l;
final TServerConnection tserverCnxn = EasyMock.createMock(TServerConnection.class);
final TabletServerStatus status = new TabletServerStatus();
status.tableMap = new HashMap<>();
// Put in a table info record, don't care what
status.tableMap.put("a_table", new TableInfo());
master.shutdownTServer(tserver);
EasyMock.expectLastCall().once();
EasyMock.expect(master.onlineTabletServers()).andReturn(Collections.singleton(tserver));
EasyMock.expect(master.getConnection(tserver)).andReturn(tserverCnxn);
EasyMock.expect(tserverCnxn.getTableMap(false)).andReturn(status);
EasyMock.replay(tserver, tserverCnxn, master);
// FATE op is not ready
long wait = op.isReady(tid, master);
assertTrue("Expected wait to be greater than 0", wait > 0);
EasyMock.verify(tserver, tserverCnxn, master);
// Reset the mocks
EasyMock.reset(tserver, tserverCnxn, master);
// The same as above, but should not expect call shutdownTServer on master again
EasyMock.expect(master.onlineTabletServers()).andReturn(Collections.singleton(tserver));
EasyMock.expect(master.getConnection(tserver)).andReturn(tserverCnxn);
EasyMock.expect(tserverCnxn.getTableMap(false)).andReturn(status);
EasyMock.replay(tserver, tserverCnxn, master);
// FATE op is not ready
wait = op.isReady(tid, master);
assertTrue("Expected wait to be greater than 0", wait > 0);
EasyMock.verify(tserver, tserverCnxn, master);
}
use of org.apache.accumulo.core.master.thrift.TabletServerStatus in project accumulo by apache.
the class ShutdownTServer method isReady.
@Override
public long isReady(long tid, Master master) throws Exception {
// suppress assignment of tablets to the server
if (force) {
return 0;
}
// only send this request once
if (!requestedShutdown) {
master.shutdownTServer(server);
requestedShutdown = true;
}
if (master.onlineTabletServers().contains(server)) {
TServerConnection connection = master.getConnection(server);
if (connection != null) {
try {
TabletServerStatus status = connection.getTableMap(false);
if (status.tableMap != null && status.tableMap.isEmpty()) {
log.info("tablet server hosts no tablets {}", server);
connection.halt(master.getMasterLock());
log.info("tablet server asked to halt {}", server);
return 0;
}
} catch (TTransportException ex) {
// expected
} catch (Exception ex) {
log.error("Error talking to tablet server {}: ", server, ex);
}
// tserver to ack the request and stop itself.
return 1000;
}
}
return 0;
}
use of org.apache.accumulo.core.master.thrift.TabletServerStatus in project accumulo by apache.
the class BulkImportResource method getTables.
/**
* Generates bulk import and tserver bulk imports with the information from the Monitor
*
* @return JSON object with BulkImport information
*/
@GET
public BulkImport getTables() {
BulkImport bulkImport = new BulkImport();
// Generating Bulk Import and adding it to the return object
for (BulkImportStatus bulk : Monitor.getMmi().bulkImports) {
bulkImport.addBulkImport(new BulkImportInformation(bulk.filename, bulk.startTime, bulk.state));
}
// Generating TServer Bulk Import and adding it to the return object
for (TabletServerStatus tserverInfo : Monitor.getMmi().getTServerInfo()) {
int size = 0;
long oldest = 0L;
List<BulkImportStatus> stats = tserverInfo.bulkImports;
if (stats != null) {
size = stats.size();
oldest = Long.MAX_VALUE;
for (BulkImportStatus bulk : stats) {
oldest = Math.min(oldest, bulk.startTime);
}
if (oldest == Long.MAX_VALUE) {
oldest = 0L;
}
}
bulkImport.addTabletServerBulkImport(new TabletServerBulkImportInformation(tserverInfo, size, oldest));
}
return bulkImport;
}
use of org.apache.accumulo.core.master.thrift.TabletServerStatus in project accumulo by apache.
the class TabletServer method getStats.
public TabletServerStatus getStats(Map<Table.ID, MapCounter<ScanRunState>> scanCounts) {
long start = System.currentTimeMillis();
TabletServerStatus result = new TabletServerStatus();
Map<KeyExtent, Tablet> onlineTabletsCopy;
synchronized (this.onlineTablets) {
onlineTabletsCopy = new HashMap<>(this.onlineTablets);
}
Map<String, TableInfo> tables = new HashMap<>();
for (Entry<KeyExtent, Tablet> entry : onlineTabletsCopy.entrySet()) {
String tableId = entry.getKey().getTableId().canonicalID();
TableInfo table = tables.get(tableId);
if (table == null) {
table = new TableInfo();
table.minors = new Compacting();
table.majors = new Compacting();
tables.put(tableId, table);
}
Tablet tablet = entry.getValue();
long recs = tablet.getNumEntries();
table.tablets++;
table.onlineTablets++;
table.recs += recs;
table.queryRate += tablet.queryRate();
table.queryByteRate += tablet.queryByteRate();
table.ingestRate += tablet.ingestRate();
table.ingestByteRate += tablet.ingestByteRate();
table.scanRate += tablet.scanRate();
long recsInMemory = tablet.getNumEntriesInMemory();
table.recsInMemory += recsInMemory;
if (tablet.isMinorCompactionRunning())
table.minors.running++;
if (tablet.isMinorCompactionQueued())
table.minors.queued++;
if (tablet.isMajorCompactionRunning())
table.majors.running++;
if (tablet.isMajorCompactionQueued())
table.majors.queued++;
}
for (Entry<Table.ID, MapCounter<ScanRunState>> entry : scanCounts.entrySet()) {
TableInfo table = tables.get(entry.getKey().canonicalID());
if (table == null) {
table = new TableInfo();
tables.put(entry.getKey().canonicalID(), table);
}
if (table.scans == null)
table.scans = new Compacting();
table.scans.queued += entry.getValue().get(ScanRunState.QUEUED);
table.scans.running += entry.getValue().get(ScanRunState.RUNNING);
}
ArrayList<KeyExtent> offlineTabletsCopy = new ArrayList<>();
synchronized (this.unopenedTablets) {
synchronized (this.openingTablets) {
offlineTabletsCopy.addAll(this.unopenedTablets);
offlineTabletsCopy.addAll(this.openingTablets);
}
}
for (KeyExtent extent : offlineTabletsCopy) {
String tableId = extent.getTableId().canonicalID();
TableInfo table = tables.get(tableId);
if (table == null) {
table = new TableInfo();
tables.put(tableId, table);
}
table.tablets++;
}
result.lastContact = RelativeTime.currentTimeMillis();
result.tableMap = tables;
result.osLoad = ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage();
result.name = getClientAddressString();
result.holdTime = resourceManager.holdTime();
result.lookups = seekCount.get();
result.indexCacheHits = resourceManager.getIndexCache().getStats().hitCount();
result.indexCacheRequest = resourceManager.getIndexCache().getStats().requestCount();
result.dataCacheHits = resourceManager.getDataCache().getStats().hitCount();
result.dataCacheRequest = resourceManager.getDataCache().getStats().requestCount();
result.logSorts = logSorter.getLogSorts();
result.flushs = flushCounter.get();
result.syncs = syncCounter.get();
result.bulkImports = new ArrayList<>();
result.bulkImports.addAll(clientHandler.getBulkLoadStatus());
result.bulkImports.addAll(bulkImportStatus.getBulkLoadStatus());
result.version = getVersion();
result.responseTime = System.currentTimeMillis() - start;
return result;
}
Aggregations