use of org.apache.accumulo.core.client.ClientConfiguration in project accumulo by apache.
the class WriteLotsIT method writeLots.
@Test
public void writeLots() throws Exception {
final Connector c = getConnector();
final String tableName = getUniqueNames(1)[0];
c.tableOperations().create(tableName);
final AtomicReference<Exception> ref = new AtomicReference<>();
final ClientConfiguration clientConfig = getCluster().getClientConfig();
final int THREADS = 5;
ThreadPoolExecutor tpe = new ThreadPoolExecutor(0, THREADS, 0, TimeUnit.SECONDS, new ArrayBlockingQueue<>(THREADS));
for (int i = 0; i < THREADS; i++) {
final int index = i;
Runnable r = new Runnable() {
@Override
public void run() {
try {
TestIngest.Opts opts = new TestIngest.Opts();
opts.startRow = index * 10000;
opts.rows = 10000;
opts.setTableName(tableName);
if (clientConfig.hasSasl()) {
opts.updateKerberosCredentials(clientConfig);
} else {
opts.setPrincipal(getAdminPrincipal());
}
BatchWriterOpts bwOpts = new BatchWriterOpts();
bwOpts.batchMemory = 1024L * 1024;
bwOpts.batchThreads = 2;
TestIngest.ingest(c, opts, new BatchWriterOpts());
} catch (Exception ex) {
ref.set(ex);
}
}
};
tpe.execute(r);
}
tpe.shutdown();
tpe.awaitTermination(90, TimeUnit.SECONDS);
if (ref.get() != null) {
throw ref.get();
}
VerifyIngest.Opts vopts = new VerifyIngest.Opts();
vopts.rows = 10000 * THREADS;
vopts.setTableName(tableName);
if (clientConfig.hasSasl()) {
vopts.updateKerberosCredentials(clientConfig);
} else {
vopts.setPrincipal(getAdminPrincipal());
}
VerifyIngest.verifyIngest(c, vopts, new ScannerOpts());
}
use of org.apache.accumulo.core.client.ClientConfiguration in project accumulo by apache.
the class RenameIT method renameTest.
@Test
public void renameTest() throws Exception {
String[] tableNames = getUniqueNames(2);
String name1 = tableNames[0];
String name2 = tableNames[1];
BatchWriterOpts bwOpts = new BatchWriterOpts();
ScannerOpts scanOpts = new ScannerOpts();
TestIngest.Opts opts = new TestIngest.Opts();
opts.createTable = true;
opts.setTableName(name1);
final ClientConfiguration clientConfig = cluster.getClientConfig();
if (clientConfig.hasSasl()) {
opts.updateKerberosCredentials(clientConfig);
} else {
opts.setPrincipal(getAdminPrincipal());
}
Connector c = getConnector();
TestIngest.ingest(c, opts, bwOpts);
c.tableOperations().rename(name1, name2);
TestIngest.ingest(c, opts, bwOpts);
VerifyIngest.Opts vopts = new VerifyIngest.Opts();
if (clientConfig.hasSasl()) {
vopts.updateKerberosCredentials(clientConfig);
} else {
vopts.setPrincipal(getAdminPrincipal());
}
vopts.setTableName(name2);
VerifyIngest.verifyIngest(c, vopts, scanOpts);
c.tableOperations().delete(name1);
c.tableOperations().rename(name2, name1);
vopts.setTableName(name1);
VerifyIngest.verifyIngest(c, vopts, scanOpts);
FunctionalTestUtils.assertNoDanglingFateLocks(getConnector().getInstance(), getCluster());
}
use of org.apache.accumulo.core.client.ClientConfiguration in project accumulo by apache.
the class RestartIT method killedTabletServerDuringShutdown.
@Test
public void killedTabletServerDuringShutdown() throws Exception {
Connector c = getConnector();
String tableName = getUniqueNames(1)[0];
c.tableOperations().create(tableName);
OPTS.setTableName(tableName);
ClientConfiguration clientConfig = cluster.getClientConfig();
if (clientConfig.hasSasl()) {
OPTS.updateKerberosCredentials(clientConfig);
} else {
OPTS.setPrincipal(getAdminPrincipal());
}
TestIngest.ingest(c, OPTS, BWOPTS);
try {
getCluster().getClusterControl().stopAllServers(ServerType.TABLET_SERVER);
getCluster().getClusterControl().adminStopAll();
} finally {
getCluster().start();
}
}
use of org.apache.accumulo.core.client.ClientConfiguration in project accumulo by apache.
the class RestartIT method restartMasterSplit.
@Test
public void restartMasterSplit() throws Exception {
Connector c = getConnector();
final String tableName = getUniqueNames(1)[0];
final AuthenticationToken token = getAdminToken();
final ClusterControl control = getCluster().getClusterControl();
VOPTS.setTableName(tableName);
c.tableOperations().create(tableName);
c.tableOperations().setProperty(tableName, Property.TABLE_SPLIT_THRESHOLD.getKey(), "5K");
final String[] args;
if (token instanceof PasswordToken) {
byte[] password = ((PasswordToken) token).getPassword();
args = new String[] { "-u", getAdminPrincipal(), "-p", new String(password, UTF_8), "-i", cluster.getInstanceName(), "-z", cluster.getZooKeepers(), "--rows", Integer.toString(VOPTS.rows), "--table", tableName };
OPTS.setPrincipal(getAdminPrincipal());
VOPTS.setPrincipal(getAdminPrincipal());
} else if (token instanceof KerberosToken) {
ClusterUser rootUser = getAdminUser();
args = new String[] { "-u", getAdminPrincipal(), "--keytab", rootUser.getKeytab().getAbsolutePath(), "-i", cluster.getInstanceName(), "-z", cluster.getZooKeepers(), "--rows", Integer.toString(VOPTS.rows), "--table", tableName };
ClientConfiguration clientConfig = cluster.getClientConfig();
OPTS.updateKerberosCredentials(clientConfig);
VOPTS.updateKerberosCredentials(clientConfig);
} else {
throw new RuntimeException("Unknown token");
}
Future<Integer> ret = svc.submit(new Callable<Integer>() {
@Override
public Integer call() {
try {
return control.exec(TestIngest.class, args);
} catch (Exception e) {
log.error("Error running TestIngest", e);
return -1;
}
}
});
control.stopAllServers(ServerType.MASTER);
ZooReader zreader = new ZooReader(c.getInstance().getZooKeepers(), c.getInstance().getZooKeepersSessionTimeOut());
ZooCache zcache = new ZooCache(zreader, null);
byte[] masterLockData;
do {
masterLockData = ZooLock.getLockData(zcache, ZooUtil.getRoot(c.getInstance()) + Constants.ZMASTER_LOCK, null);
if (null != masterLockData) {
log.info("Master lock is still held");
Thread.sleep(1000);
}
} while (null != masterLockData);
cluster.start();
assertEquals(0, ret.get().intValue());
VerifyIngest.verifyIngest(c, VOPTS, SOPTS);
}
use of org.apache.accumulo.core.client.ClientConfiguration in project accumulo by apache.
the class RestartIT method killedTabletServer.
@Test
public void killedTabletServer() throws Exception {
Connector c = getConnector();
String tableName = getUniqueNames(1)[0];
c.tableOperations().create(tableName);
OPTS.setTableName(tableName);
VOPTS.setTableName(tableName);
ClientConfiguration clientConfig = cluster.getClientConfig();
if (clientConfig.hasSasl()) {
OPTS.updateKerberosCredentials(clientConfig);
VOPTS.updateKerberosCredentials(clientConfig);
} else {
OPTS.setPrincipal(getAdminPrincipal());
VOPTS.setPrincipal(getAdminPrincipal());
}
TestIngest.ingest(c, OPTS, BWOPTS);
VerifyIngest.verifyIngest(c, VOPTS, SOPTS);
cluster.getClusterControl().stopAllServers(ServerType.TABLET_SERVER);
cluster.start();
VerifyIngest.verifyIngest(c, VOPTS, SOPTS);
}
Aggregations