use of org.apache.accumulo.core.client.Connector in project accumulo by apache.
the class BadIteratorMincIT method test.
@Test
public void test() throws Exception {
Connector c = getConnector();
String tableName = getUniqueNames(1)[0];
c.tableOperations().create(tableName);
IteratorSetting is = new IteratorSetting(30, BadIterator.class);
c.tableOperations().attachIterator(tableName, is, EnumSet.of(IteratorScope.minc));
BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
Mutation m = new Mutation(new Text("r1"));
m.put(new Text("acf"), new Text(tableName), new Value("1".getBytes(UTF_8)));
bw.addMutation(m);
bw.close();
c.tableOperations().flush(tableName, null, null, false);
sleepUninterruptibly(1, TimeUnit.SECONDS);
// minc should fail, so there should be no files
FunctionalTestUtils.checkRFiles(c, tableName, 1, 1, 0, 0);
// try to scan table
try (Scanner scanner = c.createScanner(tableName, Authorizations.EMPTY)) {
int count = Iterators.size(scanner.iterator());
assertEquals("Did not see expected # entries " + count, 1, count);
// remove the bad iterator
c.tableOperations().removeIterator(tableName, BadIterator.class.getSimpleName(), EnumSet.of(IteratorScope.minc));
sleepUninterruptibly(5, TimeUnit.SECONDS);
// minc should complete
FunctionalTestUtils.checkRFiles(c, tableName, 1, 1, 1, 1);
count = Iterators.size(scanner.iterator());
if (count != 1)
throw new Exception("Did not see expected # entries " + count);
// now try putting bad iterator back and deleting the table
c.tableOperations().attachIterator(tableName, is, EnumSet.of(IteratorScope.minc));
bw = c.createBatchWriter(tableName, new BatchWriterConfig());
m = new Mutation(new Text("r2"));
m.put(new Text("acf"), new Text(tableName), new Value("1".getBytes(UTF_8)));
bw.addMutation(m);
bw.close();
// make sure property is given time to propagate
sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
c.tableOperations().flush(tableName, null, null, false);
// make sure the flush has time to start
sleepUninterruptibly(1, TimeUnit.SECONDS);
// this should not hang
c.tableOperations().delete(tableName);
}
}
use of org.apache.accumulo.core.client.Connector in project accumulo by apache.
the class BalanceAfterCommsFailureIT method test.
@Test
public void test() throws Exception {
Connector c = this.getConnector();
c.tableOperations().create("test");
Collection<ProcessReference> tservers = getCluster().getProcesses().get(ServerType.TABLET_SERVER);
ArrayList<Integer> tserverPids = new ArrayList<>(tservers.size());
for (ProcessReference tserver : tservers) {
Process p = tserver.getProcess();
if (!p.getClass().getName().equals("java.lang.UNIXProcess")) {
log.info("Found process that was not UNIXProcess, exiting test");
return;
}
Field f = p.getClass().getDeclaredField("pid");
f.setAccessible(true);
tserverPids.add(f.getInt(p));
}
for (int pid : tserverPids) {
assertEquals(0, Runtime.getRuntime().exec(new String[] { "kill", "-SIGSTOP", Integer.toString(pid) }).waitFor());
}
UtilWaitThread.sleep(20 * 1000);
for (int pid : tserverPids) {
assertEquals(0, Runtime.getRuntime().exec(new String[] { "kill", "-SIGCONT", Integer.toString(pid) }).waitFor());
}
SortedSet<Text> splits = new TreeSet<>();
for (String split : "a b c d e f g h i j k l m n o p q r s t u v w x y z".split(" ")) {
splits.add(new Text(split));
}
c.tableOperations().addSplits("test", splits);
// Ensure all of the tablets are actually assigned
assertEquals(0, Iterables.size(c.createScanner("test", Authorizations.EMPTY)));
UtilWaitThread.sleep(30 * 1000);
checkBalance(c);
}
use of org.apache.accumulo.core.client.Connector in project accumulo by apache.
the class BalanceInPresenceOfOfflineTableIT method setupTables.
@Before
public void setupTables() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException {
Connector conn = getConnector();
// Need at least two tservers
Assume.assumeTrue("Not enough tservers to run test", conn.instanceOperations().getTabletServers().size() >= 2);
// set up splits
final SortedSet<Text> splits = new TreeSet<>();
for (int i = 0; i < NUM_SPLITS; i++) {
splits.add(new Text(String.format("%08x", i * 1000)));
}
String[] names = getUniqueNames(2);
UNUSED_TABLE = names[0];
TEST_TABLE = names[1];
// load into a table we won't use
connector = getConnector();
connector.tableOperations().create(UNUSED_TABLE);
connector.tableOperations().addSplits(UNUSED_TABLE, splits);
// mark the table offline before it can rebalance.
connector.tableOperations().offline(UNUSED_TABLE);
// actual test table
connector.tableOperations().create(TEST_TABLE);
connector.tableOperations().setProperty(TEST_TABLE, Property.TABLE_SPLIT_THRESHOLD.getKey(), "10K");
}
use of org.apache.accumulo.core.client.Connector in project accumulo by apache.
the class BatchWriterFlushIT method run.
@Test
public void run() throws Exception {
Connector c = getConnector();
String[] tableNames = getUniqueNames(2);
String bwft = tableNames[0];
c.tableOperations().create(bwft);
String bwlt = tableNames[1];
c.tableOperations().create(bwlt);
runFlushTest(bwft);
runLatencyTest(bwlt);
}
use of org.apache.accumulo.core.client.Connector in project accumulo by apache.
the class DeletedTablesDontFlushIT method test.
@Test
public void test() throws Exception {
Connector c = getConnector();
String tableName = getUniqueNames(1)[0];
c.tableOperations().create(tableName);
IteratorSetting setting = new IteratorSetting(100, SlowIterator.class);
SlowIterator.setSleepTime(setting, 1000);
c.tableOperations().attachIterator(tableName, setting, EnumSet.of(IteratorScope.minc));
// let the configuration change propagate through zookeeper
UtilWaitThread.sleep(1000);
Mutation m = new Mutation("xyzzy");
for (int i = 0; i < 100; i++) {
m.put("cf", "" + i, new Value(new byte[] {}));
}
BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
bw.addMutation(m);
bw.close();
// should go fast
c.tableOperations().delete(tableName);
}
Aggregations