Search in sources :

Example 16 with IteratorScope

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

the class TableOperationsHelper method attachIterator.

@Override
public void attachIterator(String tableName, IteratorSetting setting, EnumSet<IteratorScope> scopes) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
    checkArgument(tableName != null, "tableName is null");
    checkArgument(setting != null, "setting is null");
    checkArgument(scopes != null, "scopes is null");
    checkIteratorConflicts(tableName, setting, scopes);
    for (IteratorScope scope : scopes) {
        String root = String.format("%s%s.%s", Property.TABLE_ITERATOR_PREFIX, scope.name().toLowerCase(), setting.getName());
        for (Entry<String, String> prop : setting.getOptions().entrySet()) {
            this.setProperty(tableName, root + ".opt." + prop.getKey(), prop.getValue());
        }
        this.setProperty(tableName, root, setting.getPriority() + "," + setting.getIteratorClass());
    }
}
Also used : IteratorScope(org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope)

Example 17 with IteratorScope

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

the class TableOperationsHelper method checkIteratorConflicts.

public static void checkIteratorConflicts(Map<String, String> props, IteratorSetting setting, EnumSet<IteratorScope> scopes) throws AccumuloException {
    checkArgument(setting != null, "setting is null");
    checkArgument(scopes != null, "scopes is null");
    for (IteratorScope scope : scopes) {
        String scopeStr = String.format("%s%s", Property.TABLE_ITERATOR_PREFIX, scope.name().toLowerCase());
        String nameStr = String.format("%s.%s", scopeStr, setting.getName());
        String optStr = String.format("%s.opt.", nameStr);
        Map<String, String> optionConflicts = new TreeMap<>();
        for (Entry<String, String> property : props.entrySet()) {
            if (property.getKey().startsWith(scopeStr)) {
                if (property.getKey().equals(nameStr))
                    throw new AccumuloException(new IllegalArgumentException("iterator name conflict for " + setting.getName() + ": " + property.getKey() + "=" + property.getValue()));
                if (property.getKey().startsWith(optStr))
                    optionConflicts.put(property.getKey(), property.getValue());
                if (property.getKey().contains(".opt."))
                    continue;
                String[] parts = property.getValue().split(",");
                if (parts.length != 2)
                    throw new AccumuloException("Bad value for existing iterator setting: " + property.getKey() + "=" + property.getValue());
                try {
                    if (Integer.parseInt(parts[0]) == setting.getPriority())
                        throw new AccumuloException(new IllegalArgumentException("iterator priority conflict: " + property.getKey() + "=" + property.getValue()));
                } catch (NumberFormatException e) {
                    throw new AccumuloException("Bad value for existing iterator setting: " + property.getKey() + "=" + property.getValue());
                }
            }
        }
        if (optionConflicts.size() > 0)
            throw new AccumuloException(new IllegalArgumentException("iterator options conflict for " + setting.getName() + ": " + optionConflicts));
    }
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) IteratorScope(org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope) TreeMap(java.util.TreeMap)

Example 18 with IteratorScope

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

the class AbstractTableConfigHelper method generateInitialTableProperties.

/**
 * Copied from Accumulo 1.9 IteratorUtil
 */
public static Map<String, String> generateInitialTableProperties() {
    TreeMap<String, String> props = new TreeMap<>();
    for (IteratorScope iterScope : IteratorScope.values()) {
        props.put(Property.TABLE_ITERATOR_PREFIX + iterScope.name() + ".vers", "20," + VersioningIterator.class.getName());
        props.put(Property.TABLE_ITERATOR_PREFIX + iterScope.name() + ".vers.opt.maxVersions", "1");
    }
    props.put(Property.TABLE_CONSTRAINT_PREFIX + "1", DefaultKeySizeConstraint.class.getName());
    return props;
}
Also used : IteratorScope(org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope) TreeMap(java.util.TreeMap) DefaultKeySizeConstraint(org.apache.accumulo.core.constraints.DefaultKeySizeConstraint)

Example 19 with IteratorScope

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

the class AtomTableConfigHelper method configure.

@Override
public void configure(TableOperations tops) {
    if (null != this.ageoff) {
        EnumSet<IteratorScope> scopes = EnumSet.of(IteratorScope.scan, IteratorScope.minc, IteratorScope.majc);
        HashMap<String, String> properties = new HashMap<>();
        properties.put("ttl", ageoff);
        IteratorSetting settings = new IteratorSetting(19, AgeOffFilter.class, properties);
        try {
            tops.attachIterator(tableName, settings, scopes);
        } catch (IllegalArgumentException | AccumuloException iaEx) {
            String msg = iaEx.getMessage();
            if (msg.contains("name conflict"))
                log.info("Iterator, 'age-off' already exists for table: " + tableName + "\n" + iaEx.getMessage());
            else
                log.error("Error setting up age-off iterator on table: " + tableName, iaEx);
        } catch (Exception e) {
            log.error("Error setting up age-off iterator on table: " + tableName, e);
        }
    }
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) HashMap(java.util.HashMap) IteratorScope(org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope) AccumuloException(org.apache.accumulo.core.client.AccumuloException)

Example 20 with IteratorScope

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

the class DateIndexTableConfigHelper method configureDateIndexTable.

protected void configureDateIndexTable(TableOperations tops) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
    // Add the DATE aggregator
    for (IteratorScope scope : IteratorScope.values()) {
        String stem = String.format("%s%s.%s", Property.TABLE_ITERATOR_PREFIX, scope.name(), "DATEAggregator");
        setPropertyIfNecessary(tableName, stem, "19,datawave.iterators.TotalAggregatingIterator", tops, log);
        stem += ".opt.";
        setPropertyIfNecessary(tableName, stem + "*", "datawave.ingest.table.aggregator.DateIndexDateAggregator", tops, log);
    }
    setPropertyIfNecessary(tableName, Property.TABLE_BLOOM_ENABLED.getKey(), Boolean.toString(false), tops, log);
    // Set the locality group for the full content column family
    setLocalityGroupConfigurationIfNecessary(tableName, localityGroups, tops, log);
}
Also used : IteratorScope(org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope)

Aggregations

IteratorScope (org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope)42 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)17 EnumSet (java.util.EnumSet)13 TreeMap (java.util.TreeMap)10 AccumuloException (org.apache.accumulo.core.client.AccumuloException)10 Test (org.junit.Test)6 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 Test (org.junit.jupiter.api.Test)2 IteratorSettingException (uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException)2