Search in sources :

Example 36 with IteratorScope

use of org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope in project accumulo by apache.

the class ReplicationIT method verifyReplicationTableConfig.

@Test
public void verifyReplicationTableConfig() throws AccumuloException, TableNotFoundException, AccumuloSecurityException {
    try (AccumuloClient client = Accumulo.newClient().from(getClientProperties()).build()) {
        TableOperations tops = client.tableOperations();
        Map<String, EnumSet<IteratorScope>> iterators = tops.listIterators(ReplicationTable.NAME);
        // verify combiners are only iterators (no versioning)
        assertEquals(1, iterators.size());
        // look for combiner
        assertTrue(iterators.containsKey(ReplicationTable.COMBINER_NAME));
        assertTrue(iterators.get(ReplicationTable.COMBINER_NAME).containsAll(EnumSet.allOf(IteratorScope.class)));
        for (IteratorScope scope : EnumSet.allOf(IteratorScope.class)) {
            IteratorSetting is = tops.getIteratorSetting(ReplicationTable.NAME, ReplicationTable.COMBINER_NAME, scope);
            assertEquals(30, is.getPriority());
            assertEquals(StatusCombiner.class.getName(), is.getIteratorClass());
            assertEquals(1, is.getOptions().size());
            assertTrue(is.getOptions().containsKey("columns"));
            String cols = is.getOptions().get("columns");
            Column statusSectionCol = new Column(StatusSection.NAME);
            Column workSectionCol = new Column(WorkSection.NAME);
            assertEquals(ColumnSet.encodeColumns(statusSectionCol.getColumnFamily(), statusSectionCol.getColumnQualifier()) + "," + ColumnSet.encodeColumns(workSectionCol.getColumnFamily(), workSectionCol.getColumnQualifier()), cols);
        }
        boolean foundLocalityGroups = false;
        boolean foundLocalityGroupDef1 = false;
        boolean foundLocalityGroupDef2 = false;
        boolean foundFormatter = false;
        Joiner j = Joiner.on(",");
        for (Entry<String, String> p : tops.getProperties(ReplicationTable.NAME)) {
            String key = p.getKey();
            String val = p.getValue();
            // STATUS_LG_NAME, STATUS_LG_COLFAMS, WORK_LG_NAME, WORK_LG_COLFAMS
            if (key.equals(Property.TABLE_FORMATTER_CLASS.getKey()) && val.equals(StatusFormatter.class.getName())) {
                // look for formatter
                foundFormatter = true;
            } else if (key.equals(Property.TABLE_LOCALITY_GROUPS.getKey()) && val.equals(j.join(ReplicationTable.LOCALITY_GROUPS.keySet()))) {
                // look for locality groups enabled
                foundLocalityGroups = true;
            } else if (key.startsWith(Property.TABLE_LOCALITY_GROUP_PREFIX.getKey())) {
                // look for locality group column family definitions
                if (key.equals(Property.TABLE_LOCALITY_GROUP_PREFIX.getKey() + ReplicationTable.STATUS_LG_NAME) && val.equals(j.join(Iterables.transform(ReplicationTable.STATUS_LG_COLFAMS, Text::toString)))) {
                    foundLocalityGroupDef1 = true;
                } else if (key.equals(Property.TABLE_LOCALITY_GROUP_PREFIX.getKey() + ReplicationTable.WORK_LG_NAME) && val.equals(j.join(Iterables.transform(ReplicationTable.WORK_LG_COLFAMS, Text::toString)))) {
                    foundLocalityGroupDef2 = true;
                }
            }
        }
        assertTrue(foundLocalityGroups);
        assertTrue(foundLocalityGroupDef1);
        assertTrue(foundLocalityGroupDef2);
        assertTrue(foundFormatter);
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) Joiner(com.google.common.base.Joiner) EnumSet(java.util.EnumSet) Text(org.apache.hadoop.io.Text) TableOperations(org.apache.accumulo.core.client.admin.TableOperations) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) Column(org.apache.accumulo.core.client.IteratorSetting.Column) StatusCombiner(org.apache.accumulo.server.replication.StatusCombiner) IteratorScope(org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope) Test(org.junit.Test)

Example 37 with IteratorScope

use of org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope in project accumulo by apache.

the class SummingCombinerTest method getIteratorInput.

private static IteratorTestInput getIteratorInput() {
    IteratorSetting setting = new IteratorSetting(50, SummingCombiner.class);
    LongCombiner.setEncodingType(setting, LongCombiner.Type.STRING);
    Combiner.setCombineAllColumns(setting, true);
    Combiner.setReduceOnFullCompactionOnly(setting, false);
    return new IteratorTestInput(SummingCombiner.class, setting.getOptions(), new Range(), INPUT_DATA, new SimpleIteratorEnvironment() {

        @Override
        public IteratorScope getIteratorScope() {
            return IteratorScope.majc;
        }
    });
}
Also used : SimpleIteratorEnvironment(org.apache.accumulo.iteratortest.environments.SimpleIteratorEnvironment) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) IteratorTestInput(org.apache.accumulo.iteratortest.IteratorTestInput) IteratorScope(org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope) Range(org.apache.accumulo.core.data.Range)

Example 38 with IteratorScope

use of org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope in project accumulo by apache.

the class NewTableConfigurationIT method testSetIteratorWithoutDefaultIterators.

/**
 * Set up a pre-configured iterator while disabling the default iterators
 */
@Test
public void testSetIteratorWithoutDefaultIterators() throws AccumuloException, TableNotFoundException, AccumuloSecurityException, TableExistsException {
    try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
        String tableName = getUniqueNames(2)[0];
        NewTableConfiguration ntc = new NewTableConfiguration().withoutDefaultIterators();
        IteratorSetting setting = new IteratorSetting(10, "myIterator", "my.class");
        ntc.attachIterator(setting);
        client.tableOperations().create(tableName, ntc);
        Map<String, EnumSet<IteratorScope>> iteratorList = client.tableOperations().listIterators(tableName);
        assertEquals(1, iteratorList.size());
        verifyIterators(client, tableName, new String[] { "table.iterator.scan.myIterator=10,my.class" }, false);
        client.tableOperations().removeIterator(tableName, "myIterator", EnumSet.allOf(IteratorScope.class));
        verifyIterators(client, tableName, new String[] {}, false);
        Map<String, EnumSet<IteratorScope>> iteratorList2 = client.tableOperations().listIterators(tableName);
        assertEquals(0, iteratorList2.size());
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) NewTableConfiguration(org.apache.accumulo.core.client.admin.NewTableConfiguration) EnumSet(java.util.EnumSet) IteratorScope(org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope) Test(org.junit.Test)

Example 39 with IteratorScope

use of org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope in project accumulo by apache.

the class SetIterCommand method setTableProperties.

protected void setTableProperties(final CommandLine cl, final Shell shellState, final int priority, final Map<String, String> options, final String classname, final String name) throws AccumuloException, AccumuloSecurityException, ShellCommandException, TableNotFoundException {
    // remove empty values
    final String tableName = OptUtil.getTableOpt(cl, shellState);
    ScanCommand.ensureTserversCanLoadIterator(shellState, tableName, classname);
    options.values().removeIf(v -> v == null || v.isEmpty());
    final EnumSet<IteratorScope> scopes = EnumSet.noneOf(IteratorScope.class);
    if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(mincScopeOpt.getOpt())) {
        scopes.add(IteratorScope.minc);
    }
    if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(majcScopeOpt.getOpt())) {
        scopes.add(IteratorScope.majc);
    }
    if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(scanScopeOpt.getOpt())) {
        scopes.add(IteratorScope.scan);
    }
    if (scopes.isEmpty()) {
        throw new IllegalArgumentException("You must select at least one scope to configure");
    }
    final IteratorSetting setting = new IteratorSetting(priority, name, classname, options);
    shellState.getAccumuloClient().tableOperations().attachIterator(tableName, setting, scopes);
}
Also used : IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) IteratorScope(org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope)

Example 40 with IteratorScope

use of org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope in project geowave by locationtech.

the class AccumuloOperations method toEnumSet.

private static EnumSet<IteratorScope> toEnumSet(final ImmutableSet<ServerOpScope> scopes) {
    final Collection<IteratorScope> c = Collections2.transform(scopes, scope -> toAccumulo(scope));
    EnumSet<IteratorScope> itSet;
    if (!c.isEmpty()) {
        final Iterator<IteratorScope> it = c.iterator();
        final IteratorScope first = it.next();
        final IteratorScope[] rest = new IteratorScope[c.size() - 1];
        int i = 0;
        while (it.hasNext()) {
            rest[i++] = it.next();
        }
        itSet = EnumSet.of(first, rest);
    } else {
        itSet = EnumSet.noneOf(IteratorScope.class);
    }
    return itSet;
}
Also used : IteratorScope(org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope)

Aggregations

IteratorScope (org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope)47 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)18 EnumSet (java.util.EnumSet)13 TreeMap (java.util.TreeMap)10 AccumuloException (org.apache.accumulo.core.client.AccumuloException)10 Test (org.junit.Test)10 HashMap (java.util.HashMap)4 AccumuloClient (org.apache.accumulo.core.client.AccumuloClient)4 NamespaceNotFoundException (org.apache.accumulo.core.client.NamespaceNotFoundException)4 HashSet (java.util.HashSet)3 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)3 KeepCountOnlyUidAggregator (datawave.ingest.table.aggregator.KeepCountOnlyUidAggregator)2 ShardIndexKeyFunctor (datawave.ingest.table.bloomfilter.ShardIndexKeyFunctor)2 Map (java.util.Map)2 Column (org.apache.accumulo.core.client.IteratorSetting.Column)2 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)2 NewTableConfiguration (org.apache.accumulo.core.client.admin.NewTableConfiguration)2 TableOperations (org.apache.accumulo.core.client.admin.TableOperations)2 Range (org.apache.accumulo.core.data.Range)2 Test (org.junit.jupiter.api.Test)2