Search in sources :

Example 1 with RecoveryStatus

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

the class LogSorter method getLogSorts.

public List<RecoveryStatus> getLogSorts() {
    List<RecoveryStatus> result = new ArrayList<>();
    synchronized (currentWork) {
        for (Entry<String, LogProcessor> entries : currentWork.entrySet()) {
            RecoveryStatus status = new RecoveryStatus();
            status.name = entries.getKey();
            try {
                double progress = entries.getValue().getBytesCopied() / walBlockSize;
                // to be sure progress does not exceed 100%
                status.progress = Math.min(progress, 99.9);
            } catch (IOException ex) {
                log.warn("Error getting bytes read");
            }
            status.runtime = (int) entries.getValue().getSortTime();
            result.add(status);
        }
        return result;
    }
}
Also used : ArrayList(java.util.ArrayList) RecoveryStatus(org.apache.accumulo.core.master.thrift.RecoveryStatus) IOException(java.io.IOException)

Example 2 with RecoveryStatus

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

use of org.apache.accumulo.core.master.thrift.RecoveryStatus 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)

Example 4 with RecoveryStatus

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

the class TabletServerInformationTest method testFromThrift.

@Test
public void testFromThrift() {
    TabletServerStatus ts = new TabletServerStatus();
    ts.setBulkImports(Collections.singletonList(new BulkImportStatus()));
    ts.setDataCacheHits(11);
    ts.setDataCacheRequest(22);
    ts.setFlushs(33);
    ts.setHoldTime(44);
    ts.setIndexCacheHits(55);
    ts.setIndexCacheRequest(66);
    ts.setLastContact(77);
    RecoveryStatus recoveries = new RecoveryStatus();
    recoveries.setName("testRecovery");
    recoveries.setProgress(0.42);
    recoveries.setRuntime(4);
    ts.setLogSorts(Collections.singletonList(recoveries));
    ts.setLookups(88);
    ts.setName("tServerTestName:1234");
    ts.setOsLoad(1.23);
    ts.setResponseTime(99);
    ts.setSyncs(101);
    TableInfo tableInfo = new TableInfo();
    tableInfo.tablets = 202;
    tableInfo.ingestRate = 2.34;
    tableInfo.queryRate = 3.45;
    tableInfo.ingestByteRate = 4.56;
    tableInfo.queryByteRate = 5.67;
    tableInfo.scans = new Compacting(301, 401);
    tableInfo.recs = 502;
    tableInfo.majors = new Compacting(501, 601);
    tableInfo.minors = new Compacting(701, 801);
    ts.setTableMap(Collections.singletonMap("tableId0", tableInfo));
    ts.setVersion("testVersion");
    TabletServerInformation tsi = new TabletServerInformation(ts);
    assertEquals("tServerTestName:1234", tsi.server);
    assertEquals("tServerTestName:1234", tsi.hostname);
    // can only get within a small distance of time, since it is computed from "now" at time of object creation
    assertTrue(Math.abs((System.currentTimeMillis() - 77) - tsi.lastContact) < 500);
    assertEquals(99, tsi.responseTime);
    assertEquals(1.23, tsi.osload, 0.001);
    assertEquals("testVersion", tsi.version);
    CompactionsTypes compactions = tsi.compactions;
    assertEquals(501, compactions.major.running.intValue());
    assertEquals(601, compactions.major.queued.intValue());
    assertEquals(701, compactions.minor.running.intValue());
    assertEquals(801, compactions.minor.queued.intValue());
    assertEquals(301, compactions.scans.running.intValue());
    assertEquals(401, compactions.scans.queued.intValue());
    assertEquals(202, tsi.tablets);
    assertEquals(2.34, tsi.ingest, 0.001);
    assertEquals(3.45, tsi.query, 0.001);
    assertEquals(4.56, tsi.ingestMB, 0.001);
    assertEquals(5.67, tsi.queryMB, 0.001);
    assertEquals(301, tsi.scans.intValue());
    // can't test here; this comes from MasterMonitorInfo
    assertEquals(0.0, tsi.scansessions, 0.001);
    assertEquals(tsi.scansessions, tsi.scanssessions, 0.001);
    assertEquals(44, tsi.holdtime);
    assertEquals("tServerTestName:1234", tsi.ip);
    assertEquals(502, tsi.entries);
    assertEquals(88, tsi.lookups);
    assertEquals(55, tsi.indexCacheHits);
    assertEquals(66, tsi.indexCacheRequests);
    assertEquals(11, tsi.dataCacheHits);
    assertEquals(22, tsi.dataCacheRequests);
    assertEquals(55 / 66.0, tsi.indexCacheHitRate, 0.001);
    assertEquals(11 / 22.0, tsi.dataCacheHitRate, 0.001);
    RecoveryStatusInformation rec = tsi.logRecoveries.get(0);
    assertEquals("testRecovery", rec.name);
    assertEquals(0.42, rec.progress, 0.001);
    assertEquals(4, rec.runtime.intValue());
}
Also used : BulkImportStatus(org.apache.accumulo.core.master.thrift.BulkImportStatus) Compacting(org.apache.accumulo.core.master.thrift.Compacting) RecoveryStatus(org.apache.accumulo.core.master.thrift.RecoveryStatus) TableInfo(org.apache.accumulo.core.master.thrift.TableInfo) CompactionsTypes(org.apache.accumulo.monitor.rest.tables.CompactionsTypes) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus) RecoveryStatusInformation(org.apache.accumulo.monitor.rest.trace.RecoveryStatusInformation) Test(org.junit.Test)

Example 5 with RecoveryStatus

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

the class TabletServerInformation method updateTabletServerInfo.

/**
 * Generate tserver information from thrift status and table summary
 *
 * @param thriftStatus
 *          Thrift status to obtain information
 * @param summary
 *          Table info summary
 */
public void updateTabletServerInfo(TabletServerStatus thriftStatus, TableInfo summary) {
    long now = System.currentTimeMillis();
    this.server = this.ip = this.hostname = thriftStatus.name;
    this.tablets = summary.tablets;
    this.lastContact = now - thriftStatus.lastContact;
    this.responseTime = thriftStatus.responseTime;
    this.entries = summary.recs;
    this.ingest = cleanNumber(summary.ingestRate);
    this.query = cleanNumber(summary.queryRate);
    this.holdtime = thriftStatus.holdTime;
    this.scansRunning = summary.scans != null ? summary.scans.running : 0;
    this.scansQueued = summary.scans != null ? summary.scans.queued : 0;
    this.scansCombo = scansRunning + "(" + scansQueued + ")";
    this.scans = this.scansRunning;
    this.scansCompacting = new CompactionsList(this.scansRunning, this.scansQueued);
    this.minorRunning = summary.minors != null ? summary.minors.running : 0;
    this.minorQueued = summary.minors != null ? summary.minors.queued : 0;
    this.minorCombo = minorRunning + "(" + minorQueued + ")";
    this.minor = new CompactionsList(this.minorRunning, this.minorQueued);
    this.majorRunning = summary.majors != null ? summary.majors.running : 0;
    this.majorQueued = summary.majors != null ? summary.majors.queued : 0;
    this.majorCombo = majorRunning + "(" + majorQueued + ")";
    this.major = new CompactionsList(this.majorRunning, this.majorQueued);
    this.compactions = new CompactionsTypes(scansCompacting, major, minor);
    this.osload = thriftStatus.osLoad;
    this.version = thriftStatus.version;
    this.lookups = thriftStatus.lookups;
    this.dataCacheHits = thriftStatus.dataCacheHits;
    this.dataCacheRequests = thriftStatus.dataCacheRequest;
    this.indexCacheHits = thriftStatus.indexCacheHits;
    this.indexCacheRequests = thriftStatus.indexCacheRequest;
    this.indexCacheHitRate = this.indexCacheHits / (double) Math.max(this.indexCacheRequests, 1);
    this.dataCacheHitRate = this.dataCacheHits / (double) Math.max(this.dataCacheRequests, 1);
    this.ingestMB = cleanNumber(summary.ingestByteRate);
    this.queryMB = cleanNumber(summary.queryByteRate);
    this.scansessions = Monitor.getLookupRate();
    // For backwards compatibility
    this.scanssessions = this.scansessions;
    this.logRecoveries = new ArrayList<>(thriftStatus.logSorts.size());
    for (RecoveryStatus recovery : thriftStatus.logSorts) {
        logRecoveries.add(new RecoveryStatusInformation(recovery));
    }
}
Also used : CompactionsTypes(org.apache.accumulo.monitor.rest.tables.CompactionsTypes) RecoveryStatus(org.apache.accumulo.core.master.thrift.RecoveryStatus) CompactionsList(org.apache.accumulo.monitor.rest.tables.CompactionsList) RecoveryStatusInformation(org.apache.accumulo.monitor.rest.trace.RecoveryStatusInformation)

Aggregations

RecoveryStatus (org.apache.accumulo.core.master.thrift.RecoveryStatus)5 TabletServerStatus (org.apache.accumulo.core.master.thrift.TabletServerStatus)3 BulkImportStatus (org.apache.accumulo.core.master.thrift.BulkImportStatus)2 MasterMonitorInfo (org.apache.accumulo.core.master.thrift.MasterMonitorInfo)2 TableInfo (org.apache.accumulo.core.master.thrift.TableInfo)2 CompactionsTypes (org.apache.accumulo.monitor.rest.tables.CompactionsTypes)2 RecoveryStatusInformation (org.apache.accumulo.monitor.rest.trace.RecoveryStatusInformation)2 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Instance (org.apache.accumulo.core.client.Instance)1 ThriftNotActiveServiceException (org.apache.accumulo.core.client.impl.thrift.ThriftNotActiveServiceException)1 Compacting (org.apache.accumulo.core.master.thrift.Compacting)1 DeadServer (org.apache.accumulo.core.master.thrift.DeadServer)1 MasterClientService (org.apache.accumulo.core.master.thrift.MasterClientService)1 CompactionsList (org.apache.accumulo.monitor.rest.tables.CompactionsList)1