Search in sources :

Example 6 with ThriftNotActiveServiceException

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

the class DynamicThreadPoolsIT method test.

@Test
public void test() throws Exception {
    final String[] tables = getUniqueNames(15);
    String firstTable = tables[0];
    Connector c = getConnector();
    c.instanceOperations().setProperty(Property.TSERV_MAJC_MAXCONCURRENT.getKey(), "5");
    TestIngest.Opts opts = new TestIngest.Opts();
    opts.rows = 500 * 1000;
    opts.createTable = true;
    opts.setTableName(firstTable);
    ClientConfiguration clientConf = cluster.getClientConfig();
    if (clientConf.hasSasl()) {
        opts.updateKerberosCredentials(clientConf);
    } else {
        opts.setPrincipal(getAdminPrincipal());
    }
    TestIngest.ingest(c, opts, new BatchWriterOpts());
    c.tableOperations().flush(firstTable, null, null, true);
    for (int i = 1; i < tables.length; i++) c.tableOperations().clone(firstTable, tables[i], true, null, null);
    // time between checks of the thread pool sizes
    sleepUninterruptibly(11, TimeUnit.SECONDS);
    Credentials creds = new Credentials(getAdminPrincipal(), getAdminToken());
    for (int i = 1; i < tables.length; i++) c.tableOperations().compact(tables[i], null, null, true, false);
    for (int i = 0; i < 30; i++) {
        int count = 0;
        MasterClientService.Iface client = null;
        MasterMonitorInfo stats = null;
        while (true) {
            try {
                client = MasterClient.getConnectionWithRetry(new ClientContext(c.getInstance(), creds, clientConf));
                stats = client.getMasterStats(Tracer.traceInfo(), creds.toThrift(c.getInstance()));
                break;
            } catch (ThriftNotActiveServiceException e) {
                // Let it loop, fetching a new location
                sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
            } finally {
                if (client != null)
                    MasterClient.close(client);
            }
        }
        for (TabletServerStatus server : stats.tServerInfo) {
            for (TableInfo table : server.tableMap.values()) {
                count += table.majors.running;
            }
        }
        System.out.println("count " + count);
        if (count > 3)
            return;
        sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
    }
    fail("Could not observe higher number of threads after changing the config");
}
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) BatchWriterOpts(org.apache.accumulo.core.cli.BatchWriterOpts) ClientContext(org.apache.accumulo.core.client.impl.ClientContext) TestIngest(org.apache.accumulo.test.TestIngest) MasterClientService(org.apache.accumulo.core.master.thrift.MasterClientService) BatchWriterOpts(org.apache.accumulo.core.cli.BatchWriterOpts) TableInfo(org.apache.accumulo.core.master.thrift.TableInfo) ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration) Credentials(org.apache.accumulo.core.client.impl.Credentials) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus) Test(org.junit.Test)

Example 7 with ThriftNotActiveServiceException

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

the class MiniAccumuloClusterImpl method getMasterMonitorInfo.

/**
 * Get programmatic interface to information available in a normal monitor. XXX the returned structure won't contain information about the metadata table
 * until there is data in it. e.g. if you want to see the metadata table you should create a table.
 *
 * @since 1.6.1
 */
public MasterMonitorInfo getMasterMonitorInfo() throws AccumuloException, AccumuloSecurityException {
    MasterClientService.Iface client = null;
    while (true) {
        try {
            Instance instance = new ZooKeeperInstance(getClientConfig());
            ClientContext context = new ClientContext(instance, new Credentials("root", new PasswordToken("unchecked")), getClientConfig());
            client = MasterClient.getConnectionWithRetry(context);
            return client.getMasterStats(Tracer.traceInfo(), context.rpcCreds());
        } catch (ThriftSecurityException exception) {
            throw new AccumuloSecurityException(exception);
        } catch (ThriftNotActiveServiceException e) {
            // Let it loop, fetching a new location
            log.debug("Contacted a Master which is no longer active, retrying");
            sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
        } catch (TException exception) {
            throw new AccumuloException(exception);
        } finally {
            if (client != null) {
                MasterClient.close(client);
            }
        }
    }
}
Also used : TException(org.apache.thrift.TException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) ThriftNotActiveServiceException(org.apache.accumulo.core.client.impl.thrift.ThriftNotActiveServiceException) Instance(org.apache.accumulo.core.client.Instance) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) ClientContext(org.apache.accumulo.core.client.impl.ClientContext) MasterClientService(org.apache.accumulo.core.master.thrift.MasterClientService) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) Credentials(org.apache.accumulo.core.client.impl.Credentials) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance)

Example 8 with ThriftNotActiveServiceException

use of org.apache.accumulo.core.client.impl.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;
    MasterMonitorInfo stats;
    MasterClientService.Iface client = null;
    Instance instance = shellState.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);
        }
    }
    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 : 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) MasterClientService(org.apache.accumulo.core.master.thrift.MasterClientService) ServerConfigurationFactory(org.apache.accumulo.server.conf.ServerConfigurationFactory)

Example 9 with ThriftNotActiveServiceException

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

the class DetectDeadTabletServersIT method getStats.

private MasterMonitorInfo getStats(Connector c) throws Exception {
    Credentials creds = new Credentials("root", new PasswordToken(ROOT_PASSWORD));
    ClientContext context = new ClientContext(c.getInstance(), creds, getClientConfig());
    Client client = null;
    while (true) {
        try {
            client = MasterClient.getConnectionWithRetry(context);
            log.info("Fetching master stats");
            return client.getMasterStats(Tracer.traceInfo(), context.rpcCreds());
        } catch (ThriftNotActiveServiceException e) {
            // Let it loop, fetching a new location
            sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
        } finally {
            if (client != null) {
                MasterClient.close(client);
            }
        }
    }
}
Also used : PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) ThriftNotActiveServiceException(org.apache.accumulo.core.client.impl.thrift.ThriftNotActiveServiceException) ClientContext(org.apache.accumulo.core.client.impl.ClientContext) 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)

Example 10 with ThriftNotActiveServiceException

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

ThriftNotActiveServiceException (org.apache.accumulo.core.client.impl.thrift.ThriftNotActiveServiceException)11 MasterClientService (org.apache.accumulo.core.master.thrift.MasterClientService)9 ClientContext (org.apache.accumulo.core.client.impl.ClientContext)7 Credentials (org.apache.accumulo.core.client.impl.Credentials)7 MasterMonitorInfo (org.apache.accumulo.core.master.thrift.MasterMonitorInfo)7 TableInfo (org.apache.accumulo.core.master.thrift.TableInfo)6 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)5 TabletServerStatus (org.apache.accumulo.core.master.thrift.TabletServerStatus)5 AccumuloException (org.apache.accumulo.core.client.AccumuloException)4 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)4 Instance (org.apache.accumulo.core.client.Instance)4 ThriftSecurityException (org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException)4 BatchWriterOpts (org.apache.accumulo.core.cli.BatchWriterOpts)3 Connector (org.apache.accumulo.core.client.Connector)3 TestIngest (org.apache.accumulo.test.TestIngest)3 TException (org.apache.thrift.TException)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 ClientConfiguration (org.apache.accumulo.core.client.ClientConfiguration)2 NamespaceNotFoundException (org.apache.accumulo.core.client.NamespaceNotFoundException)2