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