use of org.apache.accumulo.core.client.admin.NewTableConfiguration 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 {
Connector conn = getConnector();
String tableName = getUniqueNames(2)[0];
NewTableConfiguration ntc = new NewTableConfiguration();
IteratorSetting setting = new IteratorSetting(10, "someName", "foo.bar");
ntc.attachIterator(setting);
conn.tableOperations().create(tableName, ntc);
Map<String, EnumSet<IteratorScope>> iteratorList = conn.tableOperations().listIterators(tableName);
// should count the created iterator plus the default iterator
assertEquals(2, iteratorList.size());
verifyIterators(conn, tableName, new String[] { "table.iterator.scan.someName=10,foo.bar" }, true);
conn.tableOperations().removeIterator(tableName, "someName", EnumSet.allOf((IteratorScope.class)));
verifyIterators(conn, tableName, new String[] {}, true);
Map<String, EnumSet<IteratorScope>> iteratorList2 = conn.tableOperations().listIterators(tableName);
assertEquals(1, iteratorList2.size());
}
use of org.apache.accumulo.core.client.admin.NewTableConfiguration in project accumulo by apache.
the class NewTableConfigurationIT method testSetPropertiesOverwriteOlderProperties.
/**
* Test that setting properties more than once overwrites the previous property settings.
*/
@Test
public void testSetPropertiesOverwriteOlderProperties() throws AccumuloSecurityException, AccumuloException, TableExistsException, TableNotFoundException {
Connector conn = getConnector();
String tableName = getUniqueNames(2)[0];
NewTableConfiguration ntc = new NewTableConfiguration();
Map<String, String> initialProps = new HashMap<>();
initialProps.put(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "prop1", "val1");
initialProps.put(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "prop2", "val2");
ntc.setProperties(initialProps);
// Create a new set of properties and set them with setProperties
Map<String, String> updatedProps = new HashMap<>();
updatedProps.put(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "newerprop1", "newerval1");
updatedProps.put(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "newerprop2", "newerval2");
ntc.setProperties(updatedProps);
conn.tableOperations().create(tableName, ntc);
// verify
Map<String, String> props = ntc.getProperties();
assertEquals(props.get(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "newerprop1"), "newerval1");
assertEquals(props.get(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "newerprop2"), "newerval2");
assertFalse(props.keySet().contains(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "prop1"));
assertFalse(props.keySet().contains(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "prop2"));
}
use of org.apache.accumulo.core.client.admin.NewTableConfiguration in project accumulo by apache.
the class NewTableConfigurationIT method addCustomPropAndChangeExisting.
@SuppressWarnings("deprecation")
@Test
public void addCustomPropAndChangeExisting() throws Exception {
log.info("Starting addCustomPropAndChangeExisting");
// Create and populate initial properties map for creating table 1
Map<String, String> properties = new HashMap<>();
String propertyName = Property.TABLE_SPLIT_THRESHOLD.getKey();
String volume = "10K";
properties.put(propertyName, volume);
String propertyName2 = "table.custom.testProp";
String volume2 = "Test property";
properties.put(propertyName2, volume2);
// Create a table with the initial properties
Connector connector = getConnector();
String tableName = getUniqueNames(2)[0];
connector.tableOperations().create(tableName, new NewTableConfiguration().setProperties(properties));
String tableNameOrig = "originalWithTableName";
connector.tableOperations().create(tableNameOrig, true);
int countNew = numProperties(connector, tableName);
int countOrig = compareProperties(connector, tableNameOrig, tableName, propertyName);
for (Entry<String, String> entry : connector.tableOperations().getProperties(tableName)) {
if (entry.getKey().equals(Property.TABLE_SPLIT_THRESHOLD.getKey()))
Assert.assertTrue("TABLE_SPLIT_THRESHOLD has been changed", entry.getValue().equals("10K"));
if (entry.getKey().equals("table.custom.testProp"))
Assert.assertTrue("table.custom.testProp has been changed", entry.getValue().equals("Test property"));
}
Assert.assertEquals("Extra properties using the new create method", countOrig + 1, 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 tableNameLimitVersionAndTimeType.
@SuppressWarnings("deprecation")
@Test
public void tableNameLimitVersionAndTimeType() throws Exception {
log.info("Starting tableNameLimitVersionAndTimeType");
// Create a table with the initial properties
Connector connector = getConnector();
String tableName = getUniqueNames(2)[0];
boolean limitVersion = false;
TimeType tt = TimeType.LOGICAL;
connector.tableOperations().create(tableName, new NewTableConfiguration().withoutDefaultIterators().setTimeType(tt));
String tableNameOrig = "originalWithLimitVersionAndTimeType";
connector.tableOperations().create(tableNameOrig, limitVersion, tt);
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, tt));
}
use of org.apache.accumulo.core.client.admin.NewTableConfiguration in project accumulo by apache.
the class NewTableConfigurationIT method testAttachIteratorDisjointCheck.
/**
* Verify checkDisjoint works with iterators groups.
*/
@Test(expected = IllegalArgumentException.class)
public void testAttachIteratorDisjointCheck() throws AccumuloException {
NewTableConfiguration ntc = new NewTableConfiguration();
Map<String, String> props = new HashMap<>();
props.put("table.iterator.scan.someName", "10");
ntc.setProperties(props);
IteratorSetting setting = new IteratorSetting(10, "someName", "foo.bar");
ntc.attachIterator(setting, EnumSet.of(IteratorScope.scan));
}
Aggregations