use of org.apache.accumulo.cluster.ClusterControl in project accumulo by apache.
the class RecoveryCompactionsAreFlushesIT method test.
@Test
public void test() throws Exception {
// create a table
String tableName = getUniqueNames(1)[0];
Connector c = getConnector();
c.tableOperations().create(tableName);
c.tableOperations().setProperty(tableName, Property.TABLE_MAJC_RATIO.getKey(), "100");
c.tableOperations().setProperty(tableName, Property.TABLE_FILE_MAX.getKey(), "3");
// create 3 flush files
BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
Mutation m = new Mutation("a");
m.put("b", "c", new Value("v".getBytes()));
for (int i = 0; i < 3; i++) {
bw.addMutation(m);
bw.flush();
c.tableOperations().flush(tableName, null, null, true);
}
// create an unsaved mutation
bw.addMutation(m);
bw.close();
ClusterControl control = cluster.getClusterControl();
// kill the tablet servers
control.stopAllServers(ServerType.TABLET_SERVER);
// recover
control.startAllServers(ServerType.TABLET_SERVER);
// ensure the table is readable
Iterators.size(c.createScanner(tableName, Authorizations.EMPTY).iterator());
// ensure that the recovery was not a merging minor compaction
try (Scanner s = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
for (Entry<Key, Value> entry : s) {
String filename = entry.getKey().getColumnQualifier().toString();
String[] parts = filename.split("/");
Assert.assertFalse(parts[parts.length - 1].startsWith("M"));
}
}
}
use of org.apache.accumulo.cluster.ClusterControl in project accumulo by apache.
the class ReadWriteIT method multiTableTest.
@Test
public void multiTableTest() throws Exception {
// Write to multiple tables
final String instance = cluster.getInstanceName();
final String keepers = cluster.getZooKeepers();
final ClusterControl control = cluster.getClusterControl();
final String prefix = getClass().getSimpleName() + "_" + testName.getMethodName();
ExecutorService svc = Executors.newFixedThreadPool(2);
Future<Integer> p1 = svc.submit(new Callable<Integer>() {
@Override
public Integer call() {
try {
ClientConfiguration clientConf = cluster.getClientConfig();
// Need to pass along the keytab because of that.
if (clientConf.hasSasl()) {
String principal = getAdminPrincipal();
AuthenticationToken token = getAdminToken();
assertTrue("Expected KerberosToken, but was " + token.getClass(), token instanceof KerberosToken);
KerberosToken kt = (KerberosToken) token;
assertNotNull("Expected keytab in token", kt.getKeytab());
return control.exec(TestMultiTableIngest.class, args("--count", Integer.toString(ROWS), "-i", instance, "-z", keepers, "--tablePrefix", prefix, "--keytab", kt.getKeytab().getAbsolutePath(), "-u", principal));
}
return control.exec(TestMultiTableIngest.class, args("--count", Integer.toString(ROWS), "-u", getAdminPrincipal(), "-i", instance, "-z", keepers, "-p", new String(((PasswordToken) getAdminToken()).getPassword(), UTF_8), "--tablePrefix", prefix));
} catch (IOException e) {
log.error("Error running MultiTableIngest", e);
return -1;
}
}
});
Future<Integer> p2 = svc.submit(new Callable<Integer>() {
@Override
public Integer call() {
try {
ClientConfiguration clientConf = cluster.getClientConfig();
// Need to pass along the keytab because of that.
if (clientConf.hasSasl()) {
String principal = getAdminPrincipal();
AuthenticationToken token = getAdminToken();
assertTrue("Expected KerberosToken, but was " + token.getClass(), token instanceof KerberosToken);
KerberosToken kt = (KerberosToken) token;
assertNotNull("Expected keytab in token", kt.getKeytab());
return control.exec(TestMultiTableIngest.class, args("--count", Integer.toString(ROWS), "--readonly", "-i", instance, "-z", keepers, "--tablePrefix", prefix, "--keytab", kt.getKeytab().getAbsolutePath(), "-u", principal));
}
return control.exec(TestMultiTableIngest.class, args("--count", Integer.toString(ROWS), "--readonly", "-u", getAdminPrincipal(), "-i", instance, "-z", keepers, "-p", new String(((PasswordToken) getAdminToken()).getPassword(), UTF_8), "--tablePrefix", prefix));
} catch (IOException e) {
log.error("Error running MultiTableIngest", e);
return -1;
}
}
});
svc.shutdown();
while (!svc.isTerminated()) {
svc.awaitTermination(15, TimeUnit.SECONDS);
}
assertEquals(0, p1.get().intValue());
assertEquals(0, p2.get().intValue());
}
use of org.apache.accumulo.cluster.ClusterControl in project accumulo by apache.
the class RestartIT method killedTabletServer2.
@Test
public void killedTabletServer2() throws Exception {
final Connector c = getConnector();
final String[] names = getUniqueNames(2);
final String tableName = names[0];
final ClusterControl control = getCluster().getClusterControl();
c.tableOperations().create(tableName);
// Original test started and then stopped a GC. Not sure why it did this. The GC was
// already running by default, and it would have nothing to do after only creating a table
control.stopAllServers(ServerType.TABLET_SERVER);
cluster.start();
c.tableOperations().create(names[1]);
}
use of org.apache.accumulo.cluster.ClusterControl in project accumulo by apache.
the class RestartIT method restartMaster.
@Test
public void restartMaster() throws Exception {
Connector c = getConnector();
final String tableName = getUniqueNames(1)[0];
OPTS.setTableName(tableName);
VOPTS.setTableName(tableName);
c.tableOperations().create(tableName);
final AuthenticationToken token = getAdminToken();
final ClusterControl control = getCluster().getClusterControl();
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", "" + OPTS.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", "" + OPTS.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 (IOException e) {
log.error("Error running TestIngest", e);
return -1;
}
}
});
control.stopAllServers(ServerType.MASTER);
control.startAllServers(ServerType.MASTER);
assertEquals(0, ret.get().intValue());
VerifyIngest.verifyIngest(c, VOPTS, SOPTS);
}
use of org.apache.accumulo.cluster.ClusterControl in project accumulo by apache.
the class RestartStressIT method test.
@Test
public void test() throws Exception {
final Connector c = getConnector();
final String tableName = getUniqueNames(1)[0];
final AuthenticationToken token = getAdminToken();
c.tableOperations().create(tableName);
c.tableOperations().setProperty(tableName, Property.TABLE_SPLIT_THRESHOLD.getKey(), "500K");
final ClusterControl control = getCluster().getClusterControl();
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", "" + VOPTS.rows, "--table", tableName };
} else if (token instanceof KerberosToken) {
ClusterUser rootUser = getAdminUser();
args = new String[] { "-u", getAdminPrincipal(), "--keytab", rootUser.getKeytab().getAbsolutePath(), "-i", cluster.getInstanceName(), "-z", cluster.getZooKeepers(), "--rows", "" + VOPTS.rows, "--table", tableName };
} else {
throw new RuntimeException("Unrecognized token");
}
Future<Integer> retCode = 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;
}
}
});
for (int i = 0; i < 2; i++) {
sleepUninterruptibly(10, TimeUnit.SECONDS);
control.stopAllServers(ServerType.TABLET_SERVER);
control.startAllServers(ServerType.TABLET_SERVER);
}
assertEquals(0, retCode.get().intValue());
VOPTS.setTableName(tableName);
if (token instanceof PasswordToken) {
VOPTS.setPrincipal(getAdminPrincipal());
} else if (token instanceof KerberosToken) {
VOPTS.updateKerberosCredentials(cluster.getClientConfig());
} else {
throw new RuntimeException("Unrecognized token");
}
VerifyIngest.verifyIngest(c, VOPTS, SOPTS);
}
Aggregations