Search in sources :

Example 56 with CompactionConfig

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();
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) ArrayList(java.util.ArrayList) CountDownLatch(java.util.concurrent.CountDownLatch) ExecutorService(java.util.concurrent.ExecutorService) CompactionConfig(org.apache.accumulo.core.client.admin.CompactionConfig) Future(java.util.concurrent.Future) Test(org.junit.Test)

Example 57 with CompactionConfig

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);
    }
}
Also used : Scanner(org.apache.accumulo.core.client.Scanner) CompactionConfig(org.apache.accumulo.core.client.admin.CompactionConfig) Value(org.apache.accumulo.core.data.Value) BatchWriter(org.apache.accumulo.core.client.BatchWriter) Mutation(org.apache.accumulo.core.data.Mutation) Key(org.apache.accumulo.core.data.Key) PartialKey(org.apache.accumulo.core.data.PartialKey)

Aggregations

CompactionConfig (org.apache.accumulo.core.client.admin.CompactionConfig)57 Test (org.junit.Test)36 AccumuloClient (org.apache.accumulo.core.client.AccumuloClient)32 Mutation (org.apache.accumulo.core.data.Mutation)21 BatchWriter (org.apache.accumulo.core.client.BatchWriter)20 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)17 Value (org.apache.accumulo.core.data.Value)14 PluginConfig (org.apache.accumulo.core.client.admin.PluginConfig)12 Scanner (org.apache.accumulo.core.client.Scanner)11 CompactionStrategyConfig (org.apache.accumulo.core.client.admin.CompactionStrategyConfig)11 NewTableConfiguration (org.apache.accumulo.core.client.admin.NewTableConfiguration)11 Text (org.apache.hadoop.io.Text)10 AccumuloException (org.apache.accumulo.core.client.AccumuloException)9 Connector (org.apache.accumulo.core.client.Connector)9 Key (org.apache.accumulo.core.data.Key)9 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)6 File (java.io.File)5 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)5