Search in sources :

Example 16 with TableInfo

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

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

Example 18 with TableInfo

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

use of org.apache.accumulo.core.master.thrift.TableInfo 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) {
    Instance instance = Monitor.getContext().getInstance();
    Table.ID tableId = Table.ID.of(tableIdStr);
    TabletServers tabletServers = new TabletServers(Monitor.getMmi().tServerInfo.size());
    if (StringUtils.isBlank(tableIdStr)) {
        return tabletServers;
    }
    TreeSet<String> locs = new TreeSet<>();
    if (RootTable.ID.equals(tableId)) {
        locs.add(instance.getRootTabletLocation());
    } else {
        String systemTableName = MetadataTable.ID.equals(tableId) ? RootTable.NAME : MetadataTable.NAME;
        MetaDataTableScanner scanner = new MetaDataTableScanner(Monitor.getContext(), new Range(KeyExtent.getMetadataEntry(tableId, new Text()), KeyExtent.getMetadataEntry(tableId, null)), systemTableName);
        while (scanner.hasNext()) {
            TabletLocationState state = scanner.next();
            if (state.current != null) {
                try {
                    locs.add(state.current.hostPort());
                } catch (Exception ex) {
                    scanner.close();
                    return tabletServers;
                }
            }
        }
        scanner.close();
    }
    List<TabletServerStatus> tservers = new ArrayList<>();
    if (Monitor.getMmi() != null) {
        for (TabletServerStatus tss : Monitor.getMmi().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 = TableInfoUtil.summarizeTableStats(status);
        if (tableId != null)
            summary = status.tableMap.get(tableId.canonicalID());
        if (summary == null)
            continue;
        TabletServer tabletServerInfo = new TabletServer();
        tabletServerInfo.updateTabletServerInfo(status, summary);
        tabletServers.addTablet(tabletServerInfo);
    }
    return tabletServers;
}
Also used : MetadataTable(org.apache.accumulo.core.metadata.MetadataTable) RootTable(org.apache.accumulo.core.metadata.RootTable) Table(org.apache.accumulo.core.client.impl.Table) Instance(org.apache.accumulo.core.client.Instance) HdfsZooInstance(org.apache.accumulo.server.client.HdfsZooInstance) 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.master.state.MetaDataTableScanner) TabletServer(org.apache.accumulo.monitor.rest.tservers.TabletServer) TabletLocationState(org.apache.accumulo.server.master.state.TabletLocationState) TableInfo(org.apache.accumulo.core.master.thrift.TableInfo) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 20 with TableInfo

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

the class MetadataMaxFilesIT method test.

@Test
public void test() throws Exception {
    Connector c = getConnector();
    SortedSet<Text> splits = new TreeSet<>();
    for (int i = 0; i < 1000; i++) {
        splits.add(new Text(String.format("%03d", i)));
    }
    c.tableOperations().setProperty(MetadataTable.NAME, Property.TABLE_SPLIT_THRESHOLD.getKey(), "10000");
    // propagation time
    sleepUninterruptibly(5, TimeUnit.SECONDS);
    for (int i = 0; i < 5; i++) {
        String tableName = "table" + i;
        log.info("Creating {}", tableName);
        c.tableOperations().create(tableName);
        log.info("adding splits");
        c.tableOperations().addSplits(tableName, splits);
        log.info("flushing");
        c.tableOperations().flush(MetadataTable.NAME, null, null, true);
        c.tableOperations().flush(RootTable.NAME, null, null, true);
    }
    log.info("shutting down");
    assertEquals(0, cluster.exec(Admin.class, "stopAll").waitFor());
    cluster.stop();
    log.info("starting up");
    cluster.start();
    Credentials creds = new Credentials("root", new PasswordToken(ROOT_PASSWORD));
    while (true) {
        MasterMonitorInfo stats = null;
        Client client = null;
        try {
            ClientContext context = new ClientContext(c.getInstance(), creds, getClientConfig());
            client = MasterClient.getConnectionWithRetry(context);
            log.info("Fetching stats");
            stats = client.getMasterStats(Tracer.traceInfo(), context.rpcCreds());
        } catch (ThriftNotActiveServiceException e) {
            // Let it loop, fetching a new location
            sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
            continue;
        } finally {
            if (client != null)
                MasterClient.close(client);
        }
        int tablets = 0;
        for (TabletServerStatus tserver : stats.tServerInfo) {
            for (Entry<String, TableInfo> entry : tserver.tableMap.entrySet()) {
                if (entry.getKey().startsWith("!") || entry.getKey().startsWith("+"))
                    continue;
                tablets += entry.getValue().onlineTablets;
            }
        }
        log.info("Online tablets " + tablets);
        if (tablets == 5005)
            break;
        sleepUninterruptibly(1, TimeUnit.SECONDS);
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) MasterMonitorInfo(org.apache.accumulo.core.master.thrift.MasterMonitorInfo) ThriftNotActiveServiceException(org.apache.accumulo.core.client.impl.thrift.ThriftNotActiveServiceException) ClientContext(org.apache.accumulo.core.client.impl.ClientContext) Text(org.apache.hadoop.io.Text) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) TreeSet(java.util.TreeSet) TableInfo(org.apache.accumulo.core.master.thrift.TableInfo) Client(org.apache.accumulo.core.master.thrift.MasterClientService.Client) MasterClient(org.apache.accumulo.core.client.impl.MasterClient) Credentials(org.apache.accumulo.core.client.impl.Credentials) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus) Test(org.junit.Test)

Aggregations

TableInfo (org.apache.accumulo.core.master.thrift.TableInfo)21 TabletServerStatus (org.apache.accumulo.core.master.thrift.TabletServerStatus)16 ArrayList (java.util.ArrayList)7 MasterMonitorInfo (org.apache.accumulo.core.master.thrift.MasterMonitorInfo)7 ThriftNotActiveServiceException (org.apache.accumulo.core.client.impl.thrift.ThriftNotActiveServiceException)6 MasterClientService (org.apache.accumulo.core.master.thrift.MasterClientService)6 TServerInstance (org.apache.accumulo.server.master.state.TServerInstance)6 ClientContext (org.apache.accumulo.core.client.impl.ClientContext)5 Credentials (org.apache.accumulo.core.client.impl.Credentials)5 Table (org.apache.accumulo.core.client.impl.Table)5 Test (org.junit.Test)5 HashMap (java.util.HashMap)4 KeyExtent (org.apache.accumulo.core.data.impl.KeyExtent)4 Map (java.util.Map)3 SortedMap (java.util.SortedMap)3 TreeMap (java.util.TreeMap)3 BatchWriterOpts (org.apache.accumulo.core.cli.BatchWriterOpts)3 Connector (org.apache.accumulo.core.client.Connector)3 Instance (org.apache.accumulo.core.client.Instance)3 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)3