Search in sources :

Example 6 with ThriftNotActiveServiceException

use of org.apache.accumulo.core.clientImpl.thrift.ThriftNotActiveServiceException in project accumulo by apache.

the class BalanceAfterCommsFailureIT method checkBalance.

private void checkBalance(AccumuloClient c) throws Exception {
    ClientContext context = (ClientContext) c;
    ManagerMonitorInfo stats = null;
    int unassignedTablets = 1;
    for (int i = 0; unassignedTablets > 0 && i < 10; i++) {
        ManagerClientService.Iface client = null;
        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
                log.debug("Contacted a Manager which is no longer active, retrying");
                sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
            } finally {
                if (client != null)
                    ManagerClient.close(client, context);
            }
        }
        unassignedTablets = stats.getUnassignedTablets();
        if (unassignedTablets > 0) {
            log.info("Found {} unassigned tablets, sleeping 3 seconds for tablet assignment", unassignedTablets);
            Thread.sleep(3000);
        }
    }
    assertEquals("Unassigned tablets were not assigned within 30 seconds", 0, unassignedTablets);
    List<Integer> counts = new ArrayList<>();
    for (TabletServerStatus server : stats.tServerInfo) {
        int count = 0;
        for (TableInfo table : server.tableMap.values()) {
            count += table.onlineTablets;
        }
        counts.add(count);
    }
    assertTrue("Expected to have at least two TabletServers", counts.size() > 1);
    for (int i = 1; i < counts.size(); i++) {
        int diff = Math.abs(counts.get(0) - counts.get(i));
        assertTrue("Expected difference in tablets to be less than or equal to " + counts.size() + " but was " + diff + ". Counts " + counts, diff <= counts.size());
    }
}
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) ArrayList(java.util.ArrayList) TableInfo(org.apache.accumulo.core.master.thrift.TableInfo) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus)

Example 7 with ThriftNotActiveServiceException

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

Example 8 with ThriftNotActiveServiceException

use of org.apache.accumulo.core.clientImpl.thrift.ThriftNotActiveServiceException in project accumulo by apache.

the class SimpleBalancerFairnessIT method simpleBalancerFairness.

@Test
public void simpleBalancerFairness() throws Exception {
    try (AccumuloClient c = Accumulo.newClient().from(getClientProperties()).build()) {
        c.tableOperations().create("test_ingest");
        c.tableOperations().setProperty("test_ingest", Property.TABLE_SPLIT_THRESHOLD.getKey(), "1K");
        c.tableOperations().create("unused");
        TreeSet<Text> splits = TestIngest.getSplitPoints(0, 10000000, NUM_SPLITS);
        log.info("Creating {} splits", splits.size());
        c.tableOperations().addSplits("unused", splits);
        List<String> tservers = c.instanceOperations().getTabletServers();
        TestIngest.IngestParams params = new TestIngest.IngestParams(getClientProperties());
        params.rows = 5000;
        TestIngest.ingest(c, params);
        c.tableOperations().flush("test_ingest", null, null, false);
        sleepUninterruptibly(45, TimeUnit.SECONDS);
        Credentials creds = new Credentials("root", new PasswordToken(ROOT_PASSWORD));
        ManagerMonitorInfo stats = null;
        int unassignedTablets = 1;
        for (int i = 0; unassignedTablets > 0 && i < 20; i++) {
            ManagerClientService.Iface client = null;
            while (true) {
                try {
                    client = ManagerClient.getConnectionWithRetry((ClientContext) c);
                    stats = client.getManagerStats(TraceUtil.traceInfo(), creds.toThrift(c.instanceOperations().getInstanceId()));
                    break;
                } catch (ThriftNotActiveServiceException e) {
                    // Let it loop, fetching a new location
                    sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
                } finally {
                    if (client != null)
                        ManagerClient.close(client, (ClientContext) c);
                }
            }
            unassignedTablets = stats.getUnassignedTablets();
            if (unassignedTablets > 0) {
                log.info("Found {} unassigned tablets, sleeping 3 seconds for tablet assignment", unassignedTablets);
                Thread.sleep(3000);
            }
        }
        assertEquals("Unassigned tablets were not assigned within 60 seconds", 0, unassignedTablets);
        // Compute online tablets per tserver
        List<Integer> counts = new ArrayList<>();
        for (TabletServerStatus server : stats.tServerInfo) {
            int count = 0;
            for (TableInfo table : server.tableMap.values()) {
                count += table.onlineTablets;
            }
            counts.add(count);
        }
        assertTrue("Expected to have at least two TabletServers", counts.size() > 1);
        for (int i = 1; i < counts.size(); i++) {
            int diff = Math.abs(counts.get(0) - counts.get(i));
            assertTrue("Expected difference in tablets to be less than or equal to " + counts.size() + " but was " + diff + ". Counts " + counts, diff <= tservers.size());
        }
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) ManagerClientService(org.apache.accumulo.core.manager.thrift.ManagerClientService) ThriftNotActiveServiceException(org.apache.accumulo.core.clientImpl.thrift.ThriftNotActiveServiceException) ClientContext(org.apache.accumulo.core.clientImpl.ClientContext) ArrayList(java.util.ArrayList) Text(org.apache.hadoop.io.Text) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) TestIngest(org.apache.accumulo.test.TestIngest) ManagerMonitorInfo(org.apache.accumulo.core.manager.thrift.ManagerMonitorInfo) TableInfo(org.apache.accumulo.core.master.thrift.TableInfo) Credentials(org.apache.accumulo.core.clientImpl.Credentials) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus) Test(org.junit.Test)

Example 9 with ThriftNotActiveServiceException

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

Aggregations

ThriftNotActiveServiceException (org.apache.accumulo.core.clientImpl.thrift.ThriftNotActiveServiceException)9 ManagerClientService (org.apache.accumulo.core.manager.thrift.ManagerClientService)7 ClientContext (org.apache.accumulo.core.clientImpl.ClientContext)6 ManagerMonitorInfo (org.apache.accumulo.core.manager.thrift.ManagerMonitorInfo)6 TableInfo (org.apache.accumulo.core.master.thrift.TableInfo)5 TabletServerStatus (org.apache.accumulo.core.master.thrift.TabletServerStatus)4 AccumuloClient (org.apache.accumulo.core.client.AccumuloClient)3 AccumuloException (org.apache.accumulo.core.client.AccumuloException)3 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)3 ThriftSecurityException (org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 NamespaceNotFoundException (org.apache.accumulo.core.client.NamespaceNotFoundException)2 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)2 Credentials (org.apache.accumulo.core.clientImpl.Credentials)2 ManagerClient (org.apache.accumulo.core.clientImpl.ManagerClient)2 ThriftTableOperationException (org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException)2 Client (org.apache.accumulo.core.manager.thrift.ManagerClientService.Client)2 Text (org.apache.hadoop.io.Text)2 TException (org.apache.thrift.TException)2