Search in sources :

Example 26 with TabletServerStatus

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;
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloServerContext(org.apache.accumulo.server.AccumuloServerContext) ServerConfigurationFactory(org.apache.accumulo.server.conf.ServerConfigurationFactory) TabletClientService(org.apache.accumulo.core.tabletserver.thrift.TabletClientService) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus)

Example 27 with TabletServerStatus

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);
}
Also used : Master(org.apache.accumulo.master.Master) TServerConnection(org.apache.accumulo.server.master.LiveTServerSet.TServerConnection) TableInfo(org.apache.accumulo.core.master.thrift.TableInfo) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) ShutdownTServer(org.apache.accumulo.master.tserverOps.ShutdownTServer) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus) Test(org.junit.Test)

Example 28 with TabletServerStatus

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;
}
Also used : TServerConnection(org.apache.accumulo.server.master.LiveTServerSet.TServerConnection) TTransportException(org.apache.thrift.transport.TTransportException) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus) TTransportException(org.apache.thrift.transport.TTransportException)

Example 29 with TabletServerStatus

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;
}
Also used : BulkImportStatus(org.apache.accumulo.core.master.thrift.BulkImportStatus) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus) GET(javax.ws.rs.GET)

Example 30 with TabletServerStatus

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;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TKeyExtent(org.apache.accumulo.core.data.thrift.TKeyExtent) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) Compacting(org.apache.accumulo.core.master.thrift.Compacting) MapCounter(org.apache.accumulo.core.util.MapCounter) Tablet(org.apache.accumulo.tserver.tablet.Tablet) TableInfo(org.apache.accumulo.core.master.thrift.TableInfo) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus)

Aggregations

TabletServerStatus (org.apache.accumulo.core.master.thrift.TabletServerStatus)36 TableInfo (org.apache.accumulo.core.master.thrift.TableInfo)16 ArrayList (java.util.ArrayList)14 TServerInstance (org.apache.accumulo.server.master.state.TServerInstance)14 HashMap (java.util.HashMap)11 Test (org.junit.Test)11 MasterMonitorInfo (org.apache.accumulo.core.master.thrift.MasterMonitorInfo)10 KeyExtent (org.apache.accumulo.core.data.impl.KeyExtent)9 GET (javax.ws.rs.GET)8 TreeMap (java.util.TreeMap)6 SortedMap (java.util.SortedMap)5 ClientContext (org.apache.accumulo.core.client.impl.ClientContext)5 ThriftNotActiveServiceException (org.apache.accumulo.core.client.impl.thrift.ThriftNotActiveServiceException)5 MasterClientService (org.apache.accumulo.core.master.thrift.MasterClientService)5 AccumuloServerContext (org.apache.accumulo.server.AccumuloServerContext)5 WebApplicationException (javax.ws.rs.WebApplicationException)4 Connector (org.apache.accumulo.core.client.Connector)4 Credentials (org.apache.accumulo.core.client.impl.Credentials)4 Table (org.apache.accumulo.core.client.impl.Table)4 TabletStats (org.apache.accumulo.core.tabletserver.thrift.TabletStats)4