use of org.apache.accumulo.core.client.admin.CompactionConfig in project accumulo by apache.
the class ConcurrentDeleteTableIT method testConcurrentFateOpsWithDelete.
@Test
public void testConcurrentFateOpsWithDelete() throws Exception {
try (AccumuloClient c = Accumulo.newClient().from(getClientProps()).build()) {
String[] tables = getUniqueNames(NUM_TABLES);
int numOperations = 8;
ExecutorService es = Executors.newFixedThreadPool(numOperations);
int count = 0;
for (final String table : tables) {
c.tableOperations().create(table, ntc);
writeData(c, table);
// flush last table
if (count == tables.length - 1) {
c.tableOperations().flush(table, null, null, true);
}
count++;
// increment this for each test
final CountDownLatch cdl = new CountDownLatch(numOperations);
List<Future<?>> futures = new ArrayList<>();
futures.add(es.submit(() -> {
try {
cdl.countDown();
cdl.await();
c.tableOperations().delete(table);
} catch (TableNotFoundException | TableOfflineException e) {
// expected
} catch (InterruptedException | AccumuloException | AccumuloSecurityException e) {
throw new RuntimeException(e);
}
}));
futures.add(es.submit(new DelayedTableOp(cdl) {
@Override
protected void doTableOp() throws Exception {
c.tableOperations().compact(table, new CompactionConfig());
}
}));
futures.add(es.submit(new DelayedTableOp(cdl) {
@Override
protected void doTableOp() throws Exception {
c.tableOperations().merge(table, null, null);
}
}));
futures.add(es.submit(new DelayedTableOp(cdl) {
@Override
protected void doTableOp() throws Exception {
Map<String, String> m = Collections.emptyMap();
Set<String> s = Collections.emptySet();
c.tableOperations().clone(table, table + "_clone", true, m, s);
}
}));
futures.add(es.submit(new DelayedTableOp(cdl) {
@Override
protected void doTableOp() throws Exception {
c.tableOperations().deleteRows(table, null, null);
}
}));
futures.add(es.submit(new DelayedTableOp(cdl) {
@Override
protected void doTableOp() throws Exception {
c.tableOperations().cancelCompaction(table);
}
}));
futures.add(es.submit(new DelayedTableOp(cdl) {
@Override
protected void doTableOp() throws Exception {
c.tableOperations().rename(table, table + "_renamed");
}
}));
futures.add(es.submit(new DelayedTableOp(cdl) {
@Override
protected void doTableOp() throws Exception {
c.tableOperations().offline(table);
}
}));
assertEquals(numOperations, futures.size());
for (Future<?> future : futures) {
future.get();
}
assertThrows("Expected table " + table + " to be gone.", TableNotFoundException.class, () -> c.createScanner(table, Authorizations.EMPTY));
FunctionalTestUtils.assertNoDanglingFateLocks((ClientContext) c, getCluster());
}
es.shutdown();
}
}
use of org.apache.accumulo.core.client.admin.CompactionConfig in project accumulo by apache.
the class KerberosRenewalIT method createReadWriteDrop.
/**
* Creates a table, adds a record to it, and then compacts the table. A simple way to make sure
* that the system user exists (since the manager does an RPC to the tserver which will create the
* system user if it doesn't already exist).
*/
private void createReadWriteDrop(AccumuloClient client) throws TableNotFoundException, AccumuloSecurityException, AccumuloException, TableExistsException {
final String table = testName.getMethodName() + "_table";
client.tableOperations().create(table);
try (BatchWriter bw = client.createBatchWriter(table)) {
Mutation m = new Mutation("a");
m.put("b", "c", "d");
bw.addMutation(m);
}
client.tableOperations().compact(table, new CompactionConfig().setFlush(true).setWait(true));
try (Scanner s = client.createScanner(table, Authorizations.EMPTY)) {
Entry<Key, Value> entry = Iterables.getOnlyElement(s);
assertEquals("Did not find the expected key", 0, new Key("a", "b", "c").compareTo(entry.getKey(), PartialKey.ROW_COLFAM_COLQUAL));
assertEquals("d", entry.getValue().toString());
client.tableOperations().delete(table);
}
}
Aggregations