Search in sources :

Example 1 with Client

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

the class SecurityOperationsImpl method getDelegationToken.

@Override
public DelegationToken getDelegationToken(DelegationTokenConfig cfg) throws AccumuloException, AccumuloSecurityException {
    final TDelegationTokenConfig tConfig;
    if (null != cfg) {
        tConfig = DelegationTokenConfigSerializer.serialize(cfg);
    } else {
        tConfig = new TDelegationTokenConfig();
    }
    TDelegationToken thriftToken;
    try {
        thriftToken = MasterClient.execute(context, new ClientExecReturn<TDelegationToken, Client>() {

            @Override
            public TDelegationToken execute(Client client) throws Exception {
                return client.getDelegationToken(Tracer.traceInfo(), context.rpcCreds(), tConfig);
            }
        });
    } catch (TableNotFoundException e) {
        // should never happen
        throw new AssertionError("Received TableNotFoundException on method which should not throw that exception", e);
    }
    AuthenticationTokenIdentifier identifier = new AuthenticationTokenIdentifier(thriftToken.getIdentifier());
    // Get the password out of the thrift delegation token
    return new DelegationTokenImpl(thriftToken.getPassword(), identifier);
}
Also used : TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) TDelegationTokenConfig(org.apache.accumulo.core.security.thrift.TDelegationTokenConfig) TDelegationToken(org.apache.accumulo.core.security.thrift.TDelegationToken) Client(org.apache.accumulo.core.master.thrift.MasterClientService.Client)

Example 2 with Client

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

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

Client (org.apache.accumulo.core.master.thrift.MasterClientService.Client)3 ClientContext (org.apache.accumulo.core.client.impl.ClientContext)2 Credentials (org.apache.accumulo.core.client.impl.Credentials)2 MasterClient (org.apache.accumulo.core.client.impl.MasterClient)2 ThriftNotActiveServiceException (org.apache.accumulo.core.client.impl.thrift.ThriftNotActiveServiceException)2 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)2 TreeSet (java.util.TreeSet)1 Connector (org.apache.accumulo.core.client.Connector)1 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)1 MasterMonitorInfo (org.apache.accumulo.core.master.thrift.MasterMonitorInfo)1 TableInfo (org.apache.accumulo.core.master.thrift.TableInfo)1 TabletServerStatus (org.apache.accumulo.core.master.thrift.TabletServerStatus)1 TDelegationToken (org.apache.accumulo.core.security.thrift.TDelegationToken)1 TDelegationTokenConfig (org.apache.accumulo.core.security.thrift.TDelegationTokenConfig)1 Text (org.apache.hadoop.io.Text)1 Test (org.junit.Test)1