Search in sources :

Example 6 with MasterMonitorInfo

use of org.apache.accumulo.core.master.thrift.MasterMonitorInfo in project accumulo by apache.

the class XMLResource method getInformation.

/**
 * Generates summary of the Monitor
 *
 * @return SummaryInformation object
 */
public SummaryInformation getInformation() {
    MasterMonitorInfo mmi = Monitor.getMmi();
    if (null == mmi) {
        throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
    }
    // Add Monitor information
    SummaryInformation xml = new SummaryInformation(mmi.tServerInfo.size(), MasterResource.getTables(), TablesResource.getTables());
    // Add tserver information
    for (TabletServerStatus status : mmi.tServerInfo) {
        xml.addTabletServer(new TabletServer(status));
    }
    return xml;
}
Also used : MasterMonitorInfo(org.apache.accumulo.core.master.thrift.MasterMonitorInfo) WebApplicationException(javax.ws.rs.WebApplicationException) TabletServer(org.apache.accumulo.monitor.rest.tservers.TabletServer) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus)

Example 7 with MasterMonitorInfo

use of org.apache.accumulo.core.master.thrift.MasterMonitorInfo in project accumulo by apache.

the class TabletServerResource method getTserverRecovery.

/**
 * Generates a recovery tserver list
 *
 * @return Recovery tserver list
 */
@Path("recovery")
@GET
public TabletServersRecovery getTserverRecovery() {
    TabletServersRecovery recoveryList = new TabletServersRecovery();
    MasterMonitorInfo mmi = Monitor.getMmi();
    if (null == mmi) {
        throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
    }
    for (TabletServerStatus server : mmi.tServerInfo) {
        if (server.logSorts != null) {
            for (RecoveryStatus recovery : server.logSorts) {
                String serv = AddressUtil.parseAddress(server.name, false).getHost();
                String log = recovery.name;
                int time = recovery.runtime;
                double progress = recovery.progress;
                recoveryList.addRecovery(new TabletServerRecoveryInformation(serv, log, time, progress));
            }
        }
    }
    return recoveryList;
}
Also used : MasterMonitorInfo(org.apache.accumulo.core.master.thrift.MasterMonitorInfo) WebApplicationException(javax.ws.rs.WebApplicationException) RecoveryStatus(org.apache.accumulo.core.master.thrift.RecoveryStatus) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 8 with MasterMonitorInfo

use of org.apache.accumulo.core.master.thrift.MasterMonitorInfo 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 9 with MasterMonitorInfo

use of org.apache.accumulo.core.master.thrift.MasterMonitorInfo in project accumulo by apache.

the class DetectDeadTabletServersIT method test.

@Test
public void test() throws Exception {
    Connector c = getConnector();
    log.info("verifying that everything is up");
    Iterators.size(c.createScanner(MetadataTable.NAME, Authorizations.EMPTY).iterator());
    MasterMonitorInfo stats = getStats(c);
    assertEquals(2, stats.tServerInfo.size());
    assertEquals(0, stats.badTServers.size());
    assertEquals(0, stats.deadTabletServers.size());
    log.info("Killing a tablet server");
    getCluster().killProcess(TABLET_SERVER, getCluster().getProcesses().get(TABLET_SERVER).iterator().next());
    while (true) {
        stats = getStats(c);
        if (2 != stats.tServerInfo.size()) {
            break;
        }
        UtilWaitThread.sleep(500);
    }
    assertEquals(1, stats.tServerInfo.size());
    assertEquals(1, stats.badTServers.size() + stats.deadTabletServers.size());
    while (true) {
        stats = getStats(c);
        if (0 != stats.deadTabletServers.size()) {
            break;
        }
        UtilWaitThread.sleep(500);
    }
    assertEquals(1, stats.tServerInfo.size());
    assertEquals(0, stats.badTServers.size());
    assertEquals(1, stats.deadTabletServers.size());
}
Also used : Connector(org.apache.accumulo.core.client.Connector) MasterMonitorInfo(org.apache.accumulo.core.master.thrift.MasterMonitorInfo) Test(org.junit.Test)

Example 10 with MasterMonitorInfo

use of org.apache.accumulo.core.master.thrift.MasterMonitorInfo in project accumulo by apache.

the class GetMasterStats method main.

public static void main(String[] args) throws Exception {
    MasterClientService.Iface client = null;
    MasterMonitorInfo stats = null;
    Instance instance = HdfsZooInstance.getInstance();
    AccumuloServerContext context = new AccumuloServerContext(instance, new ServerConfigurationFactory(instance));
    while (true) {
        try {
            client = MasterClient.getConnectionWithRetry(context);
            stats = client.getMasterStats(Tracer.traceInfo(), context.rpcCreds());
            break;
        } catch (ThriftNotActiveServiceException e) {
            // Let it loop, fetching a new location
            sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
        } finally {
            if (client != null)
                MasterClient.close(client);
        }
    }
    out(0, "State: " + stats.state.name());
    out(0, "Goal State: " + stats.goalState.name());
    if (stats.serversShuttingDown != null && stats.serversShuttingDown.size() > 0) {
        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.size() > 0) {
        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.size() > 0) {
        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.size() > 0) {
        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.size() > 0) {
                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 : MasterMonitorInfo(org.apache.accumulo.core.master.thrift.MasterMonitorInfo) AccumuloServerContext(org.apache.accumulo.server.AccumuloServerContext) ThriftNotActiveServiceException(org.apache.accumulo.core.client.impl.thrift.ThriftNotActiveServiceException) Instance(org.apache.accumulo.core.client.Instance) HdfsZooInstance(org.apache.accumulo.server.client.HdfsZooInstance) ServerConfigurationFactory(org.apache.accumulo.server.conf.ServerConfigurationFactory) DeadServer(org.apache.accumulo.core.master.thrift.DeadServer) Date(java.util.Date) BulkImportStatus(org.apache.accumulo.core.master.thrift.BulkImportStatus) MasterClientService(org.apache.accumulo.core.master.thrift.MasterClientService) 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)

Aggregations

MasterMonitorInfo (org.apache.accumulo.core.master.thrift.MasterMonitorInfo)19 TabletServerStatus (org.apache.accumulo.core.master.thrift.TabletServerStatus)10 Test (org.junit.Test)8 ThriftNotActiveServiceException (org.apache.accumulo.core.client.impl.thrift.ThriftNotActiveServiceException)7 TableInfo (org.apache.accumulo.core.master.thrift.TableInfo)7 Connector (org.apache.accumulo.core.client.Connector)6 MasterClientService (org.apache.accumulo.core.master.thrift.MasterClientService)6 ArrayList (java.util.ArrayList)5 ClientContext (org.apache.accumulo.core.client.impl.ClientContext)5 Credentials (org.apache.accumulo.core.client.impl.Credentials)5 DeadServer (org.apache.accumulo.core.master.thrift.DeadServer)4 TreeSet (java.util.TreeSet)3 GET (javax.ws.rs.GET)3 WebApplicationException (javax.ws.rs.WebApplicationException)3 BatchWriterOpts (org.apache.accumulo.core.cli.BatchWriterOpts)3 Instance (org.apache.accumulo.core.client.Instance)3 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)3 Text (org.apache.hadoop.io.Text)3 Callable (java.util.concurrent.Callable)2 ExecutorService (java.util.concurrent.ExecutorService)2