Search in sources :

Example 1 with Client

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

the class DetectDeadTabletServersIT method getStats.

private ManagerMonitorInfo getStats(AccumuloClient c) throws Exception {
    ClientContext context = (ClientContext) c;
    Client client = null;
    while (true) {
        try {
            client = ManagerClient.getConnectionWithRetry(context);
            log.info("Fetching manager stats");
            return client.getManagerStats(TraceUtil.traceInfo(), context.rpcCreds());
        } catch (ThriftNotActiveServiceException e) {
            // Let it loop, fetching a new location
            sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
        } finally {
            if (client != null) {
                ManagerClient.close(client, context);
            }
        }
    }
}
Also used : ThriftNotActiveServiceException(org.apache.accumulo.core.clientImpl.thrift.ThriftNotActiveServiceException) ClientContext(org.apache.accumulo.core.clientImpl.ClientContext) AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) ManagerClient(org.apache.accumulo.core.clientImpl.ManagerClient) Client(org.apache.accumulo.core.manager.thrift.ManagerClientService.Client)

Example 2 with Client

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

the class MetadataMaxFilesIT method test.

@Test
public void test() throws Exception {
    try (AccumuloClient c = Accumulo.newClient().from(getClientProperties()).build()) {
        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 < 2; i++) {
            String tableName = "table" + i;
            log.info("Creating {} with splits", tableName);
            NewTableConfiguration ntc = new NewTableConfiguration().withSplits(splits);
            c.tableOperations().create(tableName, ntc);
            log.info("flushing");
            c.tableOperations().flush(MetadataTable.NAME, null, null, true);
            c.tableOperations().flush(RootTable.NAME, null, null, true);
        }
        while (true) {
            ManagerMonitorInfo stats;
            Client client = null;
            try {
                ClientContext context = (ClientContext) c;
                client = ManagerClient.getConnectionWithRetry(context);
                log.info("Fetching stats");
                stats = client.getManagerStats(TraceUtil.traceInfo(), context.rpcCreds());
            } catch (ThriftNotActiveServiceException e) {
                // Let it loop, fetching a new location
                sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
                continue;
            } finally {
                if (client != null)
                    ManagerClient.close(client, (ClientContext) c);
            }
            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 == 2002)
                break;
            sleepUninterruptibly(1, TimeUnit.SECONDS);
        }
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) ThriftNotActiveServiceException(org.apache.accumulo.core.clientImpl.thrift.ThriftNotActiveServiceException) ClientContext(org.apache.accumulo.core.clientImpl.ClientContext) Text(org.apache.hadoop.io.Text) TreeSet(java.util.TreeSet) NewTableConfiguration(org.apache.accumulo.core.client.admin.NewTableConfiguration) ManagerMonitorInfo(org.apache.accumulo.core.manager.thrift.ManagerMonitorInfo) TableInfo(org.apache.accumulo.core.master.thrift.TableInfo) AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) ManagerClient(org.apache.accumulo.core.clientImpl.ManagerClient) Client(org.apache.accumulo.core.manager.thrift.ManagerClientService.Client) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus) Test(org.junit.Test)

Aggregations

AccumuloClient (org.apache.accumulo.core.client.AccumuloClient)2 ClientContext (org.apache.accumulo.core.clientImpl.ClientContext)2 ManagerClient (org.apache.accumulo.core.clientImpl.ManagerClient)2 ThriftNotActiveServiceException (org.apache.accumulo.core.clientImpl.thrift.ThriftNotActiveServiceException)2 Client (org.apache.accumulo.core.manager.thrift.ManagerClientService.Client)2 TreeSet (java.util.TreeSet)1 NewTableConfiguration (org.apache.accumulo.core.client.admin.NewTableConfiguration)1 ManagerMonitorInfo (org.apache.accumulo.core.manager.thrift.ManagerMonitorInfo)1 TableInfo (org.apache.accumulo.core.master.thrift.TableInfo)1 TabletServerStatus (org.apache.accumulo.core.master.thrift.TabletServerStatus)1 Text (org.apache.hadoop.io.Text)1 Test (org.junit.Test)1