Search in sources :

Example 11 with ManagerMonitorInfo

use of org.apache.accumulo.core.manager.thrift.ManagerMonitorInfo in project accumulo by apache.

the class GetManagerStats method main.

public static void main(String[] args) throws Exception {
    ManagerClientService.Iface client = null;
    ManagerMonitorInfo stats = null;
    var context = new ServerContext(SiteConfiguration.auto());
    while (true) {
        try {
            client = ManagerClient.getConnectionWithRetry(context);
            stats = client.getManagerStats(TraceUtil.traceInfo(), context.rpcCreds());
            break;
        } catch (ThriftNotActiveServiceException e) {
            // Let it loop, fetching a new location
            sleepUninterruptibly(100, MILLISECONDS);
        } finally {
            if (client != null) {
                ManagerClient.close(client, context);
            }
        }
    }
    out(0, "State: " + stats.state.name());
    out(0, "Goal State: " + stats.goalState.name());
    if (stats.serversShuttingDown != null && !stats.serversShuttingDown.isEmpty()) {
        out(0, "Servers to shutdown");
        for (String server : stats.serversShuttingDown) {
            out(1, "%s", server);
        }
    }
    out(0, "Unassigned tablets: %d", stats.unassignedTablets);
    if (stats.badTServers != null && !stats.badTServers.isEmpty()) {
        out(0, "Bad servers");
        for (Entry<String, Byte> entry : stats.badTServers.entrySet()) {
            out(1, "%s: %d", entry.getKey(), (int) entry.getValue());
        }
    }
    out(0, "Dead tablet servers count: %s", stats.deadTabletServers.size());
    for (DeadServer dead : stats.deadTabletServers) {
        out(1, "Dead tablet server: %s", dead.server);
        out(2, "Last report: %s", new SimpleDateFormat().format(new Date(dead.lastStatus)));
        out(2, "Cause: %s", dead.status);
    }
    out(0, "Bulk imports: %s", stats.bulkImports.size());
    for (BulkImportStatus bulk : stats.bulkImports) {
        out(1, "Import directory: %s", bulk.filename);
        out(2, "Bulk state %s", bulk.state);
        out(2, "Bulk start %s", bulk.startTime);
    }
    if (stats.tableMap != null && !stats.tableMap.isEmpty()) {
        out(0, "Tables");
        for (Entry<String, TableInfo> entry : stats.tableMap.entrySet()) {
            TableInfo v = entry.getValue();
            out(1, "%s", entry.getKey());
            out(2, "Records: %d", v.recs);
            out(2, "Records in Memory: %d", v.recsInMemory);
            out(2, "Tablets: %d", v.tablets);
            out(2, "Online Tablets: %d", v.onlineTablets);
            out(2, "Ingest Rate: %.2f", v.ingestRate);
            out(2, "Query Rate: %.2f", v.queryRate);
        }
    }
    if (stats.tServerInfo != null && !stats.tServerInfo.isEmpty()) {
        out(0, "Tablet Servers");
        long now = System.currentTimeMillis();
        for (TabletServerStatus server : stats.tServerInfo) {
            TableInfo summary = TableInfoUtil.summarizeTableStats(server);
            out(1, "Name: %s", server.name);
            out(2, "Ingest: %.2f", summary.ingestRate);
            out(2, "Last Contact: %s", server.lastContact);
            out(2, "OS Load Average: %.2f", server.osLoad);
            out(2, "Queries: %.2f", summary.queryRate);
            out(2, "Time Difference: %.1f", ((now - server.lastContact) / 1000.));
            out(2, "Total Records: %d", summary.recs);
            out(2, "Lookups: %d", server.lookups);
            if (server.holdTime > 0) {
                out(2, "Hold Time: %d", server.holdTime);
            }
            if (server.tableMap != null && !server.tableMap.isEmpty()) {
                out(2, "Tables");
                for (Entry<String, TableInfo> status : server.tableMap.entrySet()) {
                    TableInfo info = status.getValue();
                    out(3, "Table: %s", status.getKey());
                    out(4, "Tablets: %d", info.onlineTablets);
                    out(4, "Records: %d", info.recs);
                    out(4, "Records in Memory: %d", info.recsInMemory);
                    out(4, "Ingest: %.2f", info.ingestRate);
                    out(4, "Queries: %.2f", info.queryRate);
                    out(4, "Major Compacting: %d", info.majors == null ? 0 : info.majors.running);
                    out(4, "Queued for Major Compaction: %d", info.majors == null ? 0 : info.majors.queued);
                    out(4, "Minor Compacting: %d", info.minors == null ? 0 : info.minors.running);
                    out(4, "Queued for Minor Compaction: %d", info.minors == null ? 0 : info.minors.queued);
                }
            }
            out(2, "Recoveries: %d", server.logSorts.size());
            for (RecoveryStatus sort : server.logSorts) {
                out(3, "File: %s", sort.name);
                out(3, "Progress: %.2f%%", sort.progress * 100);
                out(3, "Time running: %s", sort.runtime / 1000.);
            }
            out(3, "Bulk imports: %s", stats.bulkImports.size());
            for (BulkImportStatus bulk : stats.bulkImports) {
                out(4, "Import file: %s", bulk.filename);
                out(5, "Bulk state %s", bulk.state);
                out(5, "Bulk start %s", bulk.startTime);
            }
        }
    }
}
Also used : ManagerClientService(org.apache.accumulo.core.manager.thrift.ManagerClientService) ThriftNotActiveServiceException(org.apache.accumulo.core.clientImpl.thrift.ThriftNotActiveServiceException) DeadServer(org.apache.accumulo.core.manager.thrift.DeadServer) Date(java.util.Date) BulkImportStatus(org.apache.accumulo.core.master.thrift.BulkImportStatus) ServerContext(org.apache.accumulo.server.ServerContext) ManagerMonitorInfo(org.apache.accumulo.core.manager.thrift.ManagerMonitorInfo) TableInfo(org.apache.accumulo.core.master.thrift.TableInfo) RecoveryStatus(org.apache.accumulo.core.master.thrift.RecoveryStatus) SimpleDateFormat(java.text.SimpleDateFormat) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus)

Example 12 with ManagerMonitorInfo

use of org.apache.accumulo.core.manager.thrift.ManagerMonitorInfo in project accumulo by apache.

the class ListBulkCommand method execute.

@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
    List<String> tservers;
    ManagerMonitorInfo stats;
    ManagerClientService.Iface client = null;
    ClientContext context = shellState.getContext();
    while (true) {
        try {
            client = ManagerClient.getConnectionWithRetry(context);
            stats = client.getManagerStats(TraceUtil.traceInfo(), context.rpcCreds());
            break;
        } catch (ThriftNotActiveServiceException e) {
            // Let it loop, fetching a new location
            sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
        } finally {
            if (client != null)
                ManagerClient.close(client, context);
        }
    }
    final boolean paginate = !cl.hasOption(disablePaginationOpt.getOpt());
    if (cl.hasOption(tserverOption.getOpt())) {
        tservers = new ArrayList<>();
        tservers.add(cl.getOptionValue(tserverOption.getOpt()));
    } else {
        tservers = Collections.emptyList();
    }
    shellState.printLines(new BulkImportListIterator(tservers, stats), paginate);
    return 0;
}
Also used : ManagerClientService(org.apache.accumulo.core.manager.thrift.ManagerClientService) ThriftNotActiveServiceException(org.apache.accumulo.core.clientImpl.thrift.ThriftNotActiveServiceException) ClientContext(org.apache.accumulo.core.clientImpl.ClientContext) ManagerMonitorInfo(org.apache.accumulo.core.manager.thrift.ManagerMonitorInfo)

Example 13 with ManagerMonitorInfo

use of org.apache.accumulo.core.manager.thrift.ManagerMonitorInfo in project accumulo by apache.

the class TabletServerResource method getTserverDetails.

/**
 * Generates details for the selected tserver
 *
 * @param tserverAddress
 *          TServer name
 * @return TServer details
 */
@Path("{address}")
@GET
public TabletServerSummary getTserverDetails(@PathParam("address") @NotNull @Pattern(regexp = HOSTNAME_PORT_REGEX) String tserverAddress) throws Exception {
    ManagerMonitorInfo mmi = monitor.getMmi();
    if (mmi == null)
        return new TabletServerSummary();
    boolean tserverExists = false;
    for (TabletServerStatus ts : mmi.getTServerInfo()) {
        if (tserverAddress.equals(ts.getName())) {
            tserverExists = true;
            break;
        }
    }
    if (!tserverExists) {
        return null;
    }
    double splitStdDev = 0;
    double minorStdDev = 0;
    double minorQueueStdDev = 0;
    double majorStdDev = 0;
    double majorQueueStdDev = 0;
    double currentMinorAvg = 0;
    double currentMajorAvg = 0;
    double currentMinorStdDev = 0;
    double currentMajorStdDev = 0;
    total = new TabletStats(null, new ActionStats(), new ActionStats(), new ActionStats(), 0, 0, 0, 0);
    HostAndPort address = HostAndPort.fromString(tserverAddress);
    historical = new TabletStats(null, new ActionStats(), new ActionStats(), new ActionStats(), 0, 0, 0, 0);
    List<TabletStats> tsStats = new ArrayList<>();
    try {
        ClientContext context = monitor.getContext();
        TabletClientService.Client client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, context);
        try {
            for (String tableId : mmi.tableMap.keySet()) {
                tsStats.addAll(client.getTabletStats(TraceUtil.traceInfo(), context.rpcCreds(), tableId));
            }
            historical = client.getHistoricalStats(TraceUtil.traceInfo(), context.rpcCreds());
        } finally {
            ThriftUtil.returnClient(client, context);
        }
    } catch (Exception e) {
        return null;
    }
    List<CurrentOperations> currentOps = doCurrentOperations(tsStats);
    if (total.minors.num != 0) {
        currentMinorAvg = (long) (total.minors.elapsed / total.minors.num);
    }
    if (total.minors.elapsed != 0 && total.minors.num != 0) {
        currentMinorStdDev = stddev(total.minors.elapsed, total.minors.num, total.minors.sumDev);
    }
    if (total.majors.num != 0) {
        currentMajorAvg = total.majors.elapsed / total.majors.num;
    }
    if (total.majors.elapsed != 0 && total.majors.num != 0 && total.majors.elapsed > total.majors.num) {
        currentMajorStdDev = stddev(total.majors.elapsed, total.majors.num, total.majors.sumDev);
    }
    ActionStatsUpdator.update(total.minors, historical.minors);
    ActionStatsUpdator.update(total.majors, historical.majors);
    minorStdDev = stddev(total.minors.elapsed, total.minors.num, total.minors.sumDev);
    minorQueueStdDev = stddev(total.minors.queueTime, total.minors.num, total.minors.queueSumDev);
    majorStdDev = stddev(total.majors.elapsed, total.majors.num, total.majors.sumDev);
    majorQueueStdDev = stddev(total.majors.queueTime, total.majors.num, total.majors.queueSumDev);
    splitStdDev = stddev(historical.splits.elapsed, historical.splits.num, historical.splits.sumDev);
    TabletServerDetailInformation details = doDetails(tsStats.size());
    List<AllTimeTabletResults> allTime = doAllTimeResults(majorQueueStdDev, minorQueueStdDev, splitStdDev, majorStdDev, minorStdDev);
    CurrentTabletResults currentRes = doCurrentTabletResults(currentMinorAvg, currentMinorStdDev, currentMajorAvg, currentMajorStdDev);
    return new TabletServerSummary(details, allTime, currentRes, currentOps);
}
Also used : TabletStats(org.apache.accumulo.core.tabletserver.thrift.TabletStats) ClientContext(org.apache.accumulo.core.clientImpl.ClientContext) ArrayList(java.util.ArrayList) ActionStats(org.apache.accumulo.core.tabletserver.thrift.ActionStats) HostAndPort(org.apache.accumulo.core.util.HostAndPort) ManagerMonitorInfo(org.apache.accumulo.core.manager.thrift.ManagerMonitorInfo) TabletClientService(org.apache.accumulo.core.tabletserver.thrift.TabletClientService) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus) Path(jakarta.ws.rs.Path) GET(jakarta.ws.rs.GET)

Example 14 with ManagerMonitorInfo

use of org.apache.accumulo.core.manager.thrift.ManagerMonitorInfo in project accumulo by apache.

the class TabletServerResource method getTserverSummary.

/**
 * Generates tserver summary
 *
 * @return tserver summary
 */
@GET
public TabletServers getTserverSummary() {
    ManagerMonitorInfo mmi = monitor.getMmi();
    if (mmi == null) {
        return new TabletServers();
    }
    TabletServers tserverInfo = new TabletServers(mmi.tServerInfo.size());
    for (TabletServerStatus status : mmi.tServerInfo) {
        tserverInfo.addTablet(new TabletServer(monitor, status));
    }
    tserverInfo.addBadTabletServer(ManagerResource.getTables(monitor));
    return tserverInfo;
}
Also used : ManagerMonitorInfo(org.apache.accumulo.core.manager.thrift.ManagerMonitorInfo) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus) GET(jakarta.ws.rs.GET)

Example 15 with ManagerMonitorInfo

use of org.apache.accumulo.core.manager.thrift.ManagerMonitorInfo in project accumulo by apache.

the class TablesResource method getParticipatingTabletServers.

/**
 * Generates a list of participating tservers for a table
 *
 * @param tableIdStr
 *          Table ID to find participating tservers
 * @return List of participating tservers
 */
@Path("{tableId}")
@GET
public TabletServers getParticipatingTabletServers(@PathParam("tableId") @NotNull @Pattern(regexp = ALPHA_NUM_REGEX_TABLE_ID) String tableIdStr) {
    String rootTabletLocation = monitor.getContext().getRootTabletLocation();
    TableId tableId = TableId.of(tableIdStr);
    ManagerMonitorInfo mmi = monitor.getMmi();
    // fail fast if unable to get monitor info
    if (mmi == null) {
        return new TabletServers();
    }
    TabletServers tabletServers = new TabletServers(mmi.tServerInfo.size());
    if (tableIdStr.isBlank()) {
        return tabletServers;
    }
    TreeSet<String> locs = new TreeSet<>();
    if (RootTable.ID.equals(tableId)) {
        locs.add(rootTabletLocation);
    } else {
        String systemTableName = MetadataTable.ID.equals(tableId) ? RootTable.NAME : MetadataTable.NAME;
        MetaDataTableScanner scanner = new MetaDataTableScanner(monitor.getContext(), new Range(TabletsSection.encodeRow(tableId, new Text()), TabletsSection.encodeRow(tableId, null)), systemTableName);
        while (scanner.hasNext()) {
            TabletLocationState state = scanner.next();
            if (state.current != null) {
                try {
                    locs.add(state.current.getHostPort());
                } catch (Exception ex) {
                    scanner.close();
                    return tabletServers;
                }
            }
        }
        scanner.close();
    }
    List<TabletServerStatus> tservers = new ArrayList<>();
    for (TabletServerStatus tss : mmi.tServerInfo) {
        try {
            if (tss.name != null && locs.contains(tss.name)) {
                tservers.add(tss);
            }
        } catch (Exception ex) {
            return tabletServers;
        }
    }
    // Adds tservers to the list
    for (TabletServerStatus status : tservers) {
        if (status == null) {
            status = NO_STATUS;
        }
        TableInfo summary = status.tableMap.get(tableId.canonical());
        if (summary == null) {
            continue;
        }
        TabletServer tabletServerInfo = new TabletServer();
        tabletServerInfo.server.updateTabletServerInfo(monitor, status, summary);
        tabletServers.addTablet(tabletServerInfo);
    }
    return tabletServers;
}
Also used : TableId(org.apache.accumulo.core.data.TableId) ArrayList(java.util.ArrayList) Text(org.apache.hadoop.io.Text) Range(org.apache.accumulo.core.data.Range) TabletServers(org.apache.accumulo.monitor.rest.tservers.TabletServers) TreeSet(java.util.TreeSet) MetaDataTableScanner(org.apache.accumulo.server.manager.state.MetaDataTableScanner) TabletServer(org.apache.accumulo.monitor.rest.tservers.TabletServer) ManagerMonitorInfo(org.apache.accumulo.core.manager.thrift.ManagerMonitorInfo) TabletLocationState(org.apache.accumulo.core.metadata.TabletLocationState) TableInfo(org.apache.accumulo.core.master.thrift.TableInfo) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus) Path(jakarta.ws.rs.Path) GET(jakarta.ws.rs.GET)

Aggregations

ManagerMonitorInfo (org.apache.accumulo.core.manager.thrift.ManagerMonitorInfo)26 TabletServerStatus (org.apache.accumulo.core.master.thrift.TabletServerStatus)14 GET (jakarta.ws.rs.GET)8 ArrayList (java.util.ArrayList)8 TableInfo (org.apache.accumulo.core.master.thrift.TableInfo)8 Test (org.junit.Test)7 AccumuloClient (org.apache.accumulo.core.client.AccumuloClient)6 ClientContext (org.apache.accumulo.core.clientImpl.ClientContext)6 ThriftNotActiveServiceException (org.apache.accumulo.core.clientImpl.thrift.ThriftNotActiveServiceException)6 ManagerClientService (org.apache.accumulo.core.manager.thrift.ManagerClientService)5 Text (org.apache.hadoop.io.Text)5 TreeSet (java.util.TreeSet)4 DeadServer (org.apache.accumulo.core.manager.thrift.DeadServer)4 Path (jakarta.ws.rs.Path)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 TableId (org.apache.accumulo.core.data.TableId)3 HostAndPort (org.apache.accumulo.core.util.HostAndPort)3 SortedMap (java.util.SortedMap)2 TreeMap (java.util.TreeMap)2