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);
}
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);
}
}
}
}
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);
}
}
Aggregations