Search in sources :

Example 1 with PluginConfig

use of org.apache.accumulo.core.client.admin.PluginConfig 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 2 with PluginConfig

use of org.apache.accumulo.core.client.admin.PluginConfig 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)

Example 3 with PluginConfig

use of org.apache.accumulo.core.client.admin.PluginConfig in project accumulo by apache.

the class CompactionExecutorIT method testIncorrectConfigurerType.

@Test
public void testIncorrectConfigurerType() throws Exception {
    String tableName = "tict";
    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().setConfigurer(new PluginConfig(TooManyDeletesSelector.class.getName())).setWait(true));
        }).getMessage();
        assertTrue("Unexpected message : " + msg, msg.contains("TabletServer could not load CompactionConfigurer"));
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) PluginConfig(org.apache.accumulo.core.client.admin.PluginConfig) AccumuloException(org.apache.accumulo.core.client.AccumuloException) TooManyDeletesSelector(org.apache.accumulo.core.client.admin.compaction.TooManyDeletesSelector) CompactionConfig(org.apache.accumulo.core.client.admin.CompactionConfig) Test(org.junit.Test)

Example 4 with PluginConfig

use of org.apache.accumulo.core.client.admin.PluginConfig in project accumulo by apache.

the class CompactCommand method execute.

@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
    if (cl.hasOption(cancelOpt.getLongOpt())) {
        cancel = true;
        if (cl.getOptions().length > 2) {
            throw new IllegalArgumentException("Can not specify other options with cancel");
        }
    } else {
        cancel = false;
    }
    compactionConfig = new CompactionConfig();
    compactionConfig.setFlush(!cl.hasOption(noFlushOption.getOpt()));
    compactionConfig.setWait(cl.hasOption(waitOpt.getOpt()));
    compactionConfig.setStartRow(OptUtil.getStartRow(cl));
    compactionConfig.setEndRow(OptUtil.getEndRow(cl));
    if (cl.hasOption(profileOpt.getOpt())) {
        List<IteratorSetting> iterators = shellState.iteratorProfiles.get(cl.getOptionValue(profileOpt.getOpt()));
        if (iterators == null) {
            Shell.log.error("Profile {} does not exist", cl.getOptionValue(profileOpt.getOpt()));
            return -1;
        }
        compactionConfig.setIterators(new ArrayList<>(iterators));
    }
    setupConfigurableCompaction(cl, compactionConfig);
    if (cl.hasOption(strategyOpt.getOpt())) {
        if (cl.hasOption(selectorOpt.getLongOpt()) || cl.hasOption(configurerOpt.getLongOpt())) {
            throw new IllegalArgumentException("Can not specify a strategy with a selector or configurer");
        }
        configureCompactionStrat(cl);
    } else {
        if (cl.hasOption(selectorOpt.getLongOpt())) {
            compactionConfig.setSelector(new PluginConfig(cl.getOptionValue(selectorOpt.getLongOpt()), ShellUtil.parseMapOpt(cl, selectorConfigOpt)));
        }
        if (cl.hasOption(configurerOpt.getLongOpt())) {
            compactionConfig.setConfigurer(new PluginConfig(cl.getOptionValue(configurerOpt.getLongOpt()), ShellUtil.parseMapOpt(cl, configurerConfigOpt)));
        }
    }
    if (cl.hasOption(hintsOption.getLongOpt())) {
        compactionConfig.setExecutionHints(ShellUtil.parseMapOpt(cl, hintsOption));
    }
    return super.execute(fullCommand, cl, shellState);
}
Also used : PluginConfig(org.apache.accumulo.core.client.admin.PluginConfig) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) CompactionConfig(org.apache.accumulo.core.client.admin.CompactionConfig)

Example 5 with PluginConfig

use of org.apache.accumulo.core.client.admin.PluginConfig in project accumulo by apache.

the class CompactCommand method setupConfigurableCompaction.

private void setupConfigurableCompaction(CommandLine cl, CompactionConfig compactionConfig) {
    Map<String, String> sopts = new HashMap<>();
    Map<String, String> copts = new HashMap<>();
    put(cl, sopts, copts, extraSummaryOption, CompactionSettings.SF_EXTRA_SUMMARY);
    put(cl, sopts, copts, enoSummaryOption, CompactionSettings.SF_NO_SUMMARY);
    put(cl, sopts, copts, enoSampleOption, CompactionSettings.SF_NO_SAMPLE);
    put(cl, sopts, copts, enameOption, CompactionSettings.SF_NAME_RE_OPT);
    put(cl, sopts, copts, epathOption, CompactionSettings.SF_PATH_RE_OPT);
    put(cl, sopts, copts, sizeLtOption, CompactionSettings.SF_LT_ESIZE_OPT);
    put(cl, sopts, copts, sizeGtOption, CompactionSettings.SF_GT_ESIZE_OPT);
    put(cl, sopts, copts, minFilesOption, CompactionSettings.MIN_FILES_OPT);
    put(cl, sopts, copts, outCompressionOpt, CompactionSettings.OUTPUT_COMPRESSION_OPT);
    put(cl, sopts, copts, outBlockSizeOpt, CompactionSettings.OUTPUT_BLOCK_SIZE_OPT);
    put(cl, sopts, copts, outHdfsBlockSizeOpt, CompactionSettings.OUTPUT_HDFS_BLOCK_SIZE_OPT);
    put(cl, sopts, copts, outIndexBlockSizeOpt, CompactionSettings.OUTPUT_INDEX_BLOCK_SIZE_OPT);
    put(cl, sopts, copts, outReplication, CompactionSettings.OUTPUT_REPLICATION_OPT);
    if ((!sopts.isEmpty() || !copts.isEmpty()) && (cl.hasOption(strategyOpt.getOpt()) || cl.hasOption(selectorOpt.getLongOpt()) || cl.hasOption(configurerOpt.getLongOpt()))) {
        throw new IllegalArgumentException("Can not specify compaction strategy/selector/configurer with file selection and file output options.");
    }
    if (!sopts.isEmpty()) {
        PluginConfig selectorCfg = new PluginConfig("org.apache.accumulo.tserver.compaction.strategies.ConfigurableCompactionStrategy", sopts);
        compactionConfig.setSelector(selectorCfg);
    }
    if (!copts.isEmpty()) {
        PluginConfig configurerConfig = new PluginConfig("org.apache.accumulo.tserver.compaction.strategies.ConfigurableCompactionStrategy", copts);
        compactionConfig.setConfigurer(configurerConfig);
    }
}
Also used : PluginConfig(org.apache.accumulo.core.client.admin.PluginConfig) HashMap(java.util.HashMap)

Aggregations

PluginConfig (org.apache.accumulo.core.client.admin.PluginConfig)14 CompactionConfig (org.apache.accumulo.core.client.admin.CompactionConfig)12 Test (org.junit.Test)10 AccumuloClient (org.apache.accumulo.core.client.AccumuloClient)9 Mutation (org.apache.accumulo.core.data.Mutation)6 NewTableConfiguration (org.apache.accumulo.core.client.admin.NewTableConfiguration)5 CompressionConfigurer (org.apache.accumulo.core.client.admin.compaction.CompressionConfigurer)4 Value (org.apache.accumulo.core.data.Value)4 BatchWriter (org.apache.accumulo.core.client.BatchWriter)3 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)3 HashMap (java.util.HashMap)2 AccumuloException (org.apache.accumulo.core.client.AccumuloException)2 Scanner (org.apache.accumulo.core.client.Scanner)2 TooManyDeletesSelector (org.apache.accumulo.core.client.admin.compaction.TooManyDeletesSelector)2 Key (org.apache.accumulo.core.data.Key)2 Preconditions (com.google.common.base.Preconditions)1 Cache (com.google.common.cache.Cache)1 CacheBuilder (com.google.common.cache.CacheBuilder)1 Collections2 (com.google.common.collect.Collections2)1 IOException (java.io.IOException)1