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());
}
}
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));
}
}
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;
}
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);
}
}
}
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);
}
Aggregations