use of org.apache.accumulo.core.client.admin.NewTableConfiguration in project accumulo by apache.
the class NewTableConfigurationIT method testIteratorConflictFound3.
@Test(expected = IllegalArgumentException.class)
public void testIteratorConflictFound3() throws AccumuloException, TableNotFoundException, AccumuloSecurityException, TableExistsException {
Connector conn = getConnector();
String tableName = getUniqueNames(2)[0];
NewTableConfiguration ntc = new NewTableConfiguration();
IteratorSetting setting = new IteratorSetting(10, "someName", "foo.bar");
ntc.attachIterator(setting, EnumSet.of(IteratorScope.scan));
setting = new IteratorSetting(12, "someName", "foo.bar");
ntc.attachIterator(setting, EnumSet.of(IteratorScope.scan));
conn.tableOperations().create(tableName, ntc);
}
use of org.apache.accumulo.core.client.admin.NewTableConfiguration in project accumulo by apache.
the class NewTableConfigurationIT method tableNameAndLimitVersion.
@SuppressWarnings("deprecation")
@Test
public void tableNameAndLimitVersion() throws Exception {
log.info("Starting tableNameAndLimitVersion");
// Create a table with the initial properties
Connector connector = getConnector();
String tableName = getUniqueNames(2)[0];
boolean limitVersion = false;
connector.tableOperations().create(tableName, new NewTableConfiguration().withoutDefaultIterators());
String tableNameOrig = "originalWithLimitVersion";
connector.tableOperations().create(tableNameOrig, limitVersion);
int countNew = numProperties(connector, tableName);
int countOrig = compareProperties(connector, tableNameOrig, tableName, null);
Assert.assertEquals("Extra properties using the new create method", countOrig, countNew);
Assert.assertTrue("Wrong TimeType", checkTimeType(connector, tableName, TimeType.MILLIS));
}
use of org.apache.accumulo.core.client.admin.NewTableConfiguration in project accumulo by apache.
the class NewTableConfigurationIT method testPreconfiguredIteratorWithDefaultIterator3.
/**
* Test pre-configuring iterator with default iterator. Pass in IteratorScope value in method arguments.
*/
@Test
public void testPreconfiguredIteratorWithDefaultIterator3() throws AccumuloException, TableNotFoundException, AccumuloSecurityException, TableExistsException {
Connector conn = getConnector();
String tableName = getUniqueNames(2)[0];
NewTableConfiguration ntc = new NewTableConfiguration();
IteratorSetting setting = new IteratorSetting(10, "someName", "foo.bar");
ntc.attachIterator(setting, EnumSet.of(IteratorScope.scan));
conn.tableOperations().create(tableName, ntc);
verifyIterators(conn, tableName, new String[] { "table.iterator.scan.someName=10,foo.bar" }, true);
Map<String, EnumSet<IteratorScope>> iteratorList = conn.tableOperations().listIterators(tableName);
assertEquals(2, iteratorList.size());
assertEquals(iteratorList.get("someName"), EnumSet.of(IteratorScope.scan));
conn.tableOperations().removeIterator(tableName, "someName", EnumSet.of(IteratorScope.scan));
verifyIterators(conn, tableName, new String[] {}, true);
iteratorList = conn.tableOperations().listIterators(tableName);
assertEquals(1, iteratorList.size());
}
use of org.apache.accumulo.core.client.admin.NewTableConfiguration in project accumulo by apache.
the class NewTableConfigurationIT method testSetPropertiesAndGroups.
/**
* Verify that setting locality groups along with other properties works.
*/
@Test
public void testSetPropertiesAndGroups() throws AccumuloSecurityException, AccumuloException, TableExistsException, TableNotFoundException {
Connector conn = getConnector();
String tableName = getUniqueNames(2)[0];
NewTableConfiguration ntc = new NewTableConfiguration();
Map<String, String> props = new HashMap<>();
props.put(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "prop1", "val1");
props.put(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "prop2", "val2");
ntc.setProperties(props);
Map<String, Set<Text>> lgroups = new HashMap<>();
lgroups.put("lg1", ImmutableSet.of(new Text("dog")));
ntc.setLocalityGroups(lgroups);
conn.tableOperations().create(tableName, ntc);
// verify
int count = 0;
for (Entry<String, String> property : conn.tableOperations().getProperties(tableName)) {
if (property.getKey().equals("table.group.lg1")) {
assertEquals(property.getValue(), "dog");
count++;
}
if (property.getKey().equals("table.groups.enabled")) {
assertEquals(property.getValue(), "lg1");
count++;
}
if (property.getKey().equals(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "prop1")) {
assertEquals(property.getValue(), "val1");
count++;
}
if (property.getKey().equals(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "prop2")) {
assertEquals(property.getValue(), "val2");
count++;
}
}
assertEquals(4, count);
Map<String, Set<Text>> createdLocalityGroups = conn.tableOperations().getLocalityGroups(tableName);
assertEquals(1, createdLocalityGroups.size());
assertEquals(createdLocalityGroups.get("lg1"), ImmutableSet.of(new Text("dog")));
}
use of org.apache.accumulo.core.client.admin.NewTableConfiguration 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 {
Connector conn = getConnector();
String tableName = getUniqueNames(2)[0];
NewTableConfiguration ntc = new NewTableConfiguration().withoutDefaultIterators();
IteratorSetting setting = new IteratorSetting(10, "myIterator", "my.class");
ntc.attachIterator(setting);
conn.tableOperations().create(tableName, ntc);
Map<String, EnumSet<IteratorScope>> iteratorList = conn.tableOperations().listIterators(tableName);
assertEquals(1, iteratorList.size());
verifyIterators(conn, tableName, new String[] { "table.iterator.scan.myIterator=10,my.class" }, false);
conn.tableOperations().removeIterator(tableName, "myIterator", EnumSet.allOf(IteratorScope.class));
verifyIterators(conn, tableName, new String[] {}, false);
Map<String, EnumSet<IteratorScope>> iteratorList2 = conn.tableOperations().listIterators(tableName);
assertEquals(0, iteratorList2.size());
}
Aggregations