use of org.apache.accumulo.core.client.Connector in project accumulo by apache.
the class DynamicThreadPoolsIT method updateMajcDelay.
@Before
public void updateMajcDelay() throws Exception {
Connector c = getConnector();
majcDelay = c.instanceOperations().getSystemConfiguration().get(Property.TSERV_MAJC_DELAY.getKey());
c.instanceOperations().setProperty(Property.TSERV_MAJC_DELAY.getKey(), "100ms");
if (getClusterType() == ClusterType.STANDALONE) {
Thread.sleep(ConfigurationTypeHelper.getTimeInMillis(majcDelay));
}
}
use of org.apache.accumulo.core.client.Connector in project accumulo by apache.
the class FateStarvationIT method run.
@Test
public void run() throws Exception {
String tableName = getUniqueNames(1)[0];
Connector c = getConnector();
c.tableOperations().create(tableName);
c.tableOperations().addSplits(tableName, TestIngest.getSplitPoints(0, 100000, 50));
TestIngest.Opts opts = new TestIngest.Opts();
opts.random = 89;
opts.timestamp = 7;
opts.dataSize = 50;
opts.rows = 100000;
opts.cols = 1;
opts.setTableName(tableName);
ClientConfiguration clientConf = cluster.getClientConfig();
if (clientConf.hasSasl()) {
opts.updateKerberosCredentials(clientConf);
} else {
opts.setPrincipal(getAdminPrincipal());
}
TestIngest.ingest(c, opts, new BatchWriterOpts());
c.tableOperations().flush(tableName, null, null, true);
List<Text> splits = new ArrayList<>(TestIngest.getSplitPoints(0, 100000, 67));
Random rand = new Random();
for (int i = 0; i < 100; i++) {
int idx1 = rand.nextInt(splits.size() - 1);
int idx2 = rand.nextInt(splits.size() - (idx1 + 1)) + idx1 + 1;
c.tableOperations().compact(tableName, splits.get(idx1), splits.get(idx2), false, false);
}
c.tableOperations().offline(tableName);
FunctionalTestUtils.assertNoDanglingFateLocks(getConnector().getInstance(), getCluster());
}
use of org.apache.accumulo.core.client.Connector in project accumulo by apache.
the class HalfDeadTServerIT method test.
public String test(int seconds, boolean expectTserverDied) throws Exception {
if (!makeDiskFailureLibrary())
return null;
Connector c = getConnector();
assertEquals(1, c.instanceOperations().getTabletServers().size());
// create our own tablet server with the special test library
String javaHome = System.getProperty("java.home");
String javaBin = javaHome + File.separator + "bin" + File.separator + "java";
String classpath = System.getProperty("java.class.path");
classpath = new File(cluster.getConfig().getDir(), "conf") + File.pathSeparator + classpath;
String className = TabletServer.class.getName();
ArrayList<String> argList = new ArrayList<>();
argList.addAll(Arrays.asList(javaBin, "-cp", classpath));
argList.addAll(Arrays.asList(Main.class.getName(), className));
ProcessBuilder builder = new ProcessBuilder(argList);
Map<String, String> env = builder.environment();
env.put("ACCUMULO_HOME", cluster.getConfig().getDir().getAbsolutePath());
env.put("ACCUMULO_LOG_DIR", cluster.getConfig().getLogDir().getAbsolutePath());
String trickFilename = cluster.getConfig().getLogDir().getAbsolutePath() + "/TRICK_FILE";
env.put("TRICK_FILE", trickFilename);
String libPath = System.getProperty("user.dir") + "/target/fake_disk_failure.so";
env.put("LD_PRELOAD", libPath);
env.put("DYLD_INSERT_LIBRARIES", libPath);
env.put("DYLD_FORCE_FLAT_NAMESPACE", "true");
Process ingest = null;
Process tserver = builder.start();
DumpOutput t = new DumpOutput(tserver.getInputStream());
try {
t.start();
sleepUninterruptibly(1, TimeUnit.SECONDS);
// don't need the regular tablet server
cluster.killProcess(ServerType.TABLET_SERVER, cluster.getProcesses().get(ServerType.TABLET_SERVER).iterator().next());
sleepUninterruptibly(1, TimeUnit.SECONDS);
c.tableOperations().create("test_ingest");
assertEquals(1, c.instanceOperations().getTabletServers().size());
int rows = 100 * 1000;
ingest = cluster.exec(TestIngest.class, "-u", "root", "-i", cluster.getInstanceName(), "-z", cluster.getZooKeepers(), "-p", ROOT_PASSWORD, "--rows", rows + "");
sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
// block I/O with some side-channel trickiness
File trickFile = new File(trickFilename);
try {
assertTrue(trickFile.createNewFile());
sleepUninterruptibly(seconds, TimeUnit.SECONDS);
} finally {
if (!trickFile.delete()) {
log.error("Couldn't delete {}", trickFile);
}
}
if (seconds <= 10) {
assertEquals(0, ingest.waitFor());
VerifyIngest.Opts vopts = new VerifyIngest.Opts();
vopts.rows = rows;
vopts.setPrincipal("root");
VerifyIngest.verifyIngest(c, vopts, new ScannerOpts());
} else {
sleepUninterruptibly(5, TimeUnit.SECONDS);
tserver.waitFor();
t.join();
tserver = null;
}
// verify the process was blocked
String results = t.toString();
assertTrue(results.contains("sleeping\nsleeping\nsleeping\n"));
return results;
} finally {
if (ingest != null) {
ingest.destroy();
ingest.waitFor();
}
if (tserver != null) {
try {
if (expectTserverDied) {
try {
tserver.exitValue();
} catch (IllegalThreadStateException e) {
fail("Expected TServer to kill itself, but it is still running");
}
}
} finally {
tserver.destroy();
tserver.waitFor();
t.join();
}
}
}
}
use of org.apache.accumulo.core.client.Connector in project accumulo by apache.
the class ConstraintIT method run.
@Test
public void run() throws Exception {
String[] tableNames = getUniqueNames(3);
Connector c = getConnector();
for (String table : tableNames) {
c.tableOperations().create(table);
c.tableOperations().addConstraint(table, NumericValueConstraint.class.getName());
c.tableOperations().addConstraint(table, AlphaNumKeyConstraint.class.getName());
}
// A static sleep to just let ZK do its thing
Thread.sleep(10 * 1000);
// Then check that the client has at least gotten the updates
for (String table : tableNames) {
log.debug("Checking constraints on {}", table);
Map<String, Integer> constraints = c.tableOperations().listConstraints(table);
while (!constraints.containsKey(NumericValueConstraint.class.getName()) || !constraints.containsKey(AlphaNumKeyConstraint.class.getName())) {
log.debug("Failed to verify constraints. Sleeping and retrying");
Thread.sleep(2000);
constraints = c.tableOperations().listConstraints(table);
}
log.debug("Verified all constraints on {}", table);
}
log.debug("Verified constraints on all tables. Running tests");
test1(tableNames[0]);
test2(tableNames[1], false);
test2(tableNames[2], true);
}
use of org.apache.accumulo.core.client.Connector in project accumulo by apache.
the class CreateManyScannersIT method run.
@Test
public void run() throws Exception {
Connector c = getConnector();
String tableName = getUniqueNames(1)[0];
c.tableOperations().create(tableName);
for (int i = 0; i < 100000; i++) {
c.createScanner(tableName, Authorizations.EMPTY);
}
}
Aggregations