Search in sources :

Example 31 with AccumuloClient

use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.

the class TestRandomDeletes method scanAll.

private static TreeSet<RowColumn> scanAll(TestOpts opts) throws Exception {
    TreeSet<RowColumn> result = new TreeSet<>();
    try (AccumuloClient client = Accumulo.newClient().from(opts.getClientProps()).build();
        Scanner scanner = client.createScanner(opts.tableName, auths)) {
        for (Entry<Key, Value> entry : scanner) {
            Key key = entry.getKey();
            Column column = new Column(TextUtil.getBytes(key.getColumnFamily()), TextUtil.getBytes(key.getColumnQualifier()), TextUtil.getBytes(key.getColumnVisibility()));
            result.add(new RowColumn(key.getRow(), column, key.getTimestamp()));
        }
    }
    return result;
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) Scanner(org.apache.accumulo.core.client.Scanner) Column(org.apache.accumulo.core.data.Column) TreeSet(java.util.TreeSet) Value(org.apache.accumulo.core.data.Value) Key(org.apache.accumulo.core.data.Key)

Example 32 with AccumuloClient

use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.

the class VolumeChooserIT method twoTablesRandomVolumeChooser.

// Test that uses two tables with 10 split points each. They each use the RandomVolumeChooser to
// choose volumes.
@Test
public void twoTablesRandomVolumeChooser() throws Exception {
    log.info("Starting twoTablesRandomVolumeChooser()");
    // Create namespace
    try (AccumuloClient client = Accumulo.newClient().from(getClientProperties()).build()) {
        createAndVerify(client, namespace1, v1 + "," + v2 + "," + v3);
        createAndVerify(client, namespace2, v1 + "," + v2 + "," + v3);
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) Test(org.junit.Test)

Example 33 with AccumuloClient

use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.

the class CompactionExecutorIT method testIncorrectSelectorType.

@Test
public void testIncorrectSelectorType() throws Exception {
    String tableName = "tist";
    try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
        client.tableOperations().create(tableName);
        addFiles(client, tableName, 5);
        var msg = assertThrows(AccumuloException.class, () -> {
            client.tableOperations().compact(tableName, new CompactionConfig().setSelector(new PluginConfig(CompressionConfigurer.class.getName())).setWait(true));
        }).getMessage();
        assertTrue("Unexpected message : " + msg, msg.contains("TabletServer could not load CompactionSelector"));
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) PluginConfig(org.apache.accumulo.core.client.admin.PluginConfig) AccumuloException(org.apache.accumulo.core.client.AccumuloException) CompressionConfigurer(org.apache.accumulo.core.client.admin.compaction.CompressionConfigurer) CompactionConfig(org.apache.accumulo.core.client.admin.CompactionConfig) Test(org.junit.Test)

Example 34 with AccumuloClient

use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.

the class CompactionExecutorIT method testReconfigureCompactionService.

@Test
public void testReconfigureCompactionService() throws Exception {
    try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
        createTable(client, "rctt", "recfg");
        addFiles(client, "rctt", 22);
        while (getFiles(client, "rctt").size() > 2) {
            Thread.sleep(100);
        }
        assertEquals(2, getFiles(client, "rctt").size());
        client.instanceOperations().setProperty(Property.TSERV_COMPACTION_SERVICE_PREFIX.getKey() + "recfg.planner.opts.filesPerCompaction", "5");
        client.instanceOperations().setProperty(Property.TSERV_COMPACTION_SERVICE_PREFIX.getKey() + "recfg.planner.opts.executors", "1");
        addFiles(client, "rctt", 10);
        while (getFiles(client, "rctt").size() > 4) {
            Thread.sleep(100);
        }
        assertEquals(4, getFiles(client, "rctt").size());
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) Test(org.junit.Test)

Example 35 with AccumuloClient

use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.

the class CompactionExecutorIT method testTooManyDeletes.

@Test
public void testTooManyDeletes() throws Exception {
    try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
        Map<String, String> props = Map.of(Property.TABLE_COMPACTION_SELECTOR.getKey(), TooManyDeletesSelector.class.getName(), Property.TABLE_COMPACTION_SELECTOR_OPTS.getKey() + "threshold", ".4");
        var deleteSummarizerCfg = SummarizerConfiguration.builder(DeletesSummarizer.class.getName()).build();
        client.tableOperations().create("tmd_selector", new NewTableConfiguration().setProperties(props).enableSummarization(deleteSummarizerCfg));
        client.tableOperations().create("tmd_control1", new NewTableConfiguration().enableSummarization(deleteSummarizerCfg));
        client.tableOperations().create("tmd_control2", new NewTableConfiguration().enableSummarization(deleteSummarizerCfg));
        client.tableOperations().create("tmd_control3", new NewTableConfiguration().enableSummarization(deleteSummarizerCfg));
        addFile(client, "tmd_selector", 1, 1000, false);
        addFile(client, "tmd_selector", 1, 1000, true);
        addFile(client, "tmd_control1", 1, 1000, false);
        addFile(client, "tmd_control1", 1, 1000, true);
        addFile(client, "tmd_control2", 1, 1000, false);
        addFile(client, "tmd_control2", 1000, 2000, false);
        addFile(client, "tmd_control3", 1, 2000, false);
        addFile(client, "tmd_control3", 1, 1000, true);
        assertEquals(2, getFiles(client, "tmd_control1").size());
        assertEquals(2, getFiles(client, "tmd_control2").size());
        assertEquals(2, getFiles(client, "tmd_control3").size());
        while (getFiles(client, "tmd_selector").size() != 0) {
            Thread.sleep(100);
        }
        assertEquals(2, getFiles(client, "tmd_control1").size());
        assertEquals(2, getFiles(client, "tmd_control2").size());
        assertEquals(2, getFiles(client, "tmd_control3").size());
        var cc1 = new CompactionConfig().setSelector(new PluginConfig(TooManyDeletesSelector.class.getName(), Map.of("threshold", ".99"))).setWait(true);
        client.tableOperations().compact("tmd_control1", cc1);
        client.tableOperations().compact("tmd_control2", cc1);
        client.tableOperations().compact("tmd_control3", cc1);
        assertEquals(0, getFiles(client, "tmd_control1").size());
        assertEquals(2, getFiles(client, "tmd_control2").size());
        assertEquals(2, getFiles(client, "tmd_control3").size());
        var cc2 = new CompactionConfig().setSelector(new PluginConfig(TooManyDeletesSelector.class.getName(), Map.of("threshold", ".40"))).setWait(true);
        client.tableOperations().compact("tmd_control1", cc2);
        client.tableOperations().compact("tmd_control2", cc2);
        client.tableOperations().compact("tmd_control3", cc2);
        assertEquals(0, getFiles(client, "tmd_control1").size());
        assertEquals(2, getFiles(client, "tmd_control2").size());
        assertEquals(1, getFiles(client, "tmd_control3").size());
        client.tableOperations().compact("tmd_control2", new CompactionConfig().setWait(true));
        assertEquals(1, getFiles(client, "tmd_control2").size());
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) PluginConfig(org.apache.accumulo.core.client.admin.PluginConfig) NewTableConfiguration(org.apache.accumulo.core.client.admin.NewTableConfiguration) TooManyDeletesSelector(org.apache.accumulo.core.client.admin.compaction.TooManyDeletesSelector) CompactionConfig(org.apache.accumulo.core.client.admin.CompactionConfig) Test(org.junit.Test)

Aggregations

AccumuloClient (org.apache.accumulo.core.client.AccumuloClient)500 Test (org.junit.Test)411 BatchWriter (org.apache.accumulo.core.client.BatchWriter)149 Text (org.apache.hadoop.io.Text)143 Mutation (org.apache.accumulo.core.data.Mutation)138 Scanner (org.apache.accumulo.core.client.Scanner)122 Value (org.apache.accumulo.core.data.Value)118 Key (org.apache.accumulo.core.data.Key)108 NewTableConfiguration (org.apache.accumulo.core.client.admin.NewTableConfiguration)91 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)64 HashMap (java.util.HashMap)61 Range (org.apache.accumulo.core.data.Range)51 TreeSet (java.util.TreeSet)50 ArrayList (java.util.ArrayList)47 Entry (java.util.Map.Entry)41 Path (org.apache.hadoop.fs.Path)39 CompactionConfig (org.apache.accumulo.core.client.admin.CompactionConfig)34 Authorizations (org.apache.accumulo.core.security.Authorizations)34 BatchScanner (org.apache.accumulo.core.client.BatchScanner)32 HashSet (java.util.HashSet)31