use of java.util.EnumSet in project accumulo by apache.
the class StatusCombinerMacIT method testCombinerSetOnMetadata.
@Test
public void testCombinerSetOnMetadata() throws Exception {
try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
TableOperations tops = client.tableOperations();
Map<String, EnumSet<IteratorScope>> iterators = tops.listIterators(MetadataTable.NAME);
assertTrue(iterators.containsKey(ReplicationTableUtil.COMBINER_NAME));
EnumSet<IteratorScope> scopes = iterators.get(ReplicationTableUtil.COMBINER_NAME);
assertEquals(3, scopes.size());
assertTrue(scopes.contains(IteratorScope.scan));
assertTrue(scopes.contains(IteratorScope.minc));
assertTrue(scopes.contains(IteratorScope.majc));
Map<String, String> config = tops.getConfiguration(MetadataTable.NAME);
Map<String, String> properties = Map.copyOf(config);
for (IteratorScope scope : scopes) {
String key = Property.TABLE_ITERATOR_PREFIX.getKey() + scope.name() + "." + ReplicationTableUtil.COMBINER_NAME + ".opt.columns";
assertTrue("Properties did not contain key : " + key, properties.containsKey(key));
assertEquals(ReplicationSection.COLF.toString(), properties.get(key));
}
}
}
use of java.util.EnumSet in project accumulo by apache.
the class ReplicationTableUtilTest method setsCombinerOnMetadataCorrectly.
@Test
public void setsCombinerOnMetadataCorrectly() throws Exception {
AccumuloClient client = createMock(AccumuloClient.class);
TableOperations tops = createMock(TableOperations.class);
String myMetadataTable = "mymetadata";
Map<String, EnumSet<IteratorScope>> iterators = new HashMap<>();
iterators.put("vers", EnumSet.of(IteratorScope.majc, IteratorScope.minc, IteratorScope.scan));
IteratorSetting combiner = new IteratorSetting(9, "replcombiner", StatusCombiner.class);
Combiner.setColumns(combiner, Collections.singletonList(new Column(ReplicationSection.COLF)));
expect(client.tableOperations()).andReturn(tops);
expect(tops.listIterators(myMetadataTable)).andReturn(iterators);
tops.attachIterator(myMetadataTable, combiner);
expectLastCall().once();
expect(tops.getConfiguration(myMetadataTable)).andReturn(Collections.emptyMap());
tops.setProperty(myMetadataTable, Property.TABLE_FORMATTER_CLASS.getKey(), ReplicationTableUtil.STATUS_FORMATTER_CLASS_NAME);
expectLastCall().once();
replay(client, tops);
ReplicationTableUtil.configureMetadataTable(client, myMetadataTable);
verify(client, tops);
}
use of java.util.EnumSet in project accumulo by apache.
the class NewTableConfigurationIT method testNtcChaining.
/**
* Test NewTableConfiguration chaining.
*/
@Test
public void testNtcChaining() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException {
try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
String tableName = getUniqueNames(2)[0];
IteratorSetting setting = new IteratorSetting(10, "anIterator", "it.class", Collections.emptyMap());
Map<String, Set<Text>> lgroups = new HashMap<>();
lgroups.put("lgp", Set.of(new Text("col")));
NewTableConfiguration ntc = new NewTableConfiguration().withoutDefaultIterators().attachIterator(setting, EnumSet.of(IteratorScope.scan)).setLocalityGroups(lgroups);
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.anIterator=10,it.class" }, false);
client.tableOperations().removeIterator(tableName, "anIterator", EnumSet.of(IteratorScope.scan));
verifyIterators(client, tableName, new String[] {}, false);
iteratorList = client.tableOperations().listIterators(tableName);
assertEquals(0, iteratorList.size());
int count = 0;
for (Entry<String, String> property : client.tableOperations().getProperties(tableName)) {
if (property.getKey().equals("table.group.lgp")) {
assertEquals(property.getValue(), "col");
count++;
}
if (property.getKey().equals("table.groups.enabled")) {
assertEquals(property.getValue(), "lgp");
count++;
}
}
assertEquals(2, count);
Map<String, Set<Text>> createdLocalityGroups = client.tableOperations().getLocalityGroups(tableName);
assertEquals(1, createdLocalityGroups.size());
assertEquals(createdLocalityGroups.get("lgp"), Set.of(new Text("col")));
}
}
use of java.util.EnumSet in project accumulo by apache.
the class NewTableConfigurationIT method testSetGroupsWithoutDefaultIterators.
/**
* Create table with initial locality groups but no default iterators
*/
@Test
public void testSetGroupsWithoutDefaultIterators() throws AccumuloSecurityException, AccumuloException, TableExistsException, TableNotFoundException {
try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
String tableName = getUniqueNames(2)[0];
NewTableConfiguration ntc = new NewTableConfiguration().withoutDefaultIterators();
Map<String, Set<Text>> lgroups = new HashMap<>();
lgroups.put("lg1", Set.of(new Text("colF")));
ntc.setLocalityGroups(lgroups);
client.tableOperations().create(tableName, ntc);
// verify groups and verify no iterators
Map<String, Set<Text>> createdLocalityGroups = client.tableOperations().getLocalityGroups(tableName);
assertEquals(1, createdLocalityGroups.size());
assertEquals(createdLocalityGroups.get("lg1"), Set.of(new Text("colF")));
Map<String, EnumSet<IteratorScope>> iterators = client.tableOperations().listIterators(tableName);
assertEquals(0, iterators.size());
}
}
use of java.util.EnumSet in project accumulo by apache.
the class NewTableConfigurationIT method testPreconfiguredIteratorWithDefaultIterator2.
/**
* Test pre-configuring iterator with default iterator. Configure IteratorSetting values into
* method call.
*/
@Test
public void testPreconfiguredIteratorWithDefaultIterator2() throws AccumuloException, TableNotFoundException, AccumuloSecurityException, TableExistsException {
try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
String tableName = getUniqueNames(2)[0];
NewTableConfiguration ntc = new NewTableConfiguration();
IteratorSetting setting = new IteratorSetting(10, "someName", "foo.bar");
ntc.attachIterator(setting);
client.tableOperations().create(tableName, ntc);
Map<String, EnumSet<IteratorScope>> iteratorList = client.tableOperations().listIterators(tableName);
// should count the created iterator plus the default iterator
assertEquals(2, iteratorList.size());
verifyIterators(client, tableName, new String[] { "table.iterator.scan.someName=10,foo.bar" }, true);
client.tableOperations().removeIterator(tableName, "someName", EnumSet.allOf(IteratorScope.class));
verifyIterators(client, tableName, new String[] {}, true);
Map<String, EnumSet<IteratorScope>> iteratorList2 = client.tableOperations().listIterators(tableName);
assertEquals(1, iteratorList2.size());
}
}
Aggregations