use of org.apache.accumulo.core.client.admin.NewTableConfiguration in project accumulo by apache.
the class NewTableConfigurationIT method testPreconfigureIteratorWithDefaultIterator1.
/**
* Test pre-configuring iterator along with default iterator. Configure IteratorSetting values within method call.
*/
@Test
public void testPreconfigureIteratorWithDefaultIterator1() throws AccumuloException, TableNotFoundException, AccumuloSecurityException, TableExistsException {
Connector conn = getConnector();
String tableName = getUniqueNames(2)[0];
NewTableConfiguration ntc = new NewTableConfiguration();
ntc.attachIterator(new IteratorSetting(10, "anIterator", "it.class", Collections.emptyMap()), EnumSet.of(IteratorScope.scan));
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.anIterator=10,it.class" }, true);
conn.tableOperations().removeIterator(tableName, "anIterator", 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 testOverlappingGroupsFail.
/**
* Verify that you cannot have overlapping locality groups.
*
* Attempt to set a locality group with overlapping groups. This test should throw an IllegalArgumentException indicating that groups overlap.
*/
@Test(expected = IllegalArgumentException.class)
public void testOverlappingGroupsFail() throws AccumuloSecurityException, AccumuloException, TableExistsException {
NewTableConfiguration ntc = new NewTableConfiguration();
Map<String, Set<Text>> lgroups = new HashMap<>();
lgroups.put("lg1", ImmutableSet.of(new Text("colFamA"), new Text("colFamB")));
lgroups.put("lg2", ImmutableSet.of(new Text("colFamC"), new Text("colFamB")));
ntc.setLocalityGroups(lgroups);
}
use of org.apache.accumulo.core.client.admin.NewTableConfiguration in project accumulo by apache.
the class NewTableConfigurationIT method testGroupsIteratorAndPropsTogether.
/**
* Verify use of all three ntc methods - setProperties, setLocalityGroups and attachIterator
*/
@Test
public void testGroupsIteratorAndPropsTogether() 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));
Map<String, String> props = new HashMap<>();
props.put(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "prop1", "val1");
ntc.setProperties(props);
Map<String, Set<Text>> lgroups = new HashMap<>();
lgroups.put("lg1", ImmutableSet.of(new Text("colF")));
ntc.setLocalityGroups(lgroups);
conn.tableOperations().create(tableName, ntc);
// verify user table properties
int count = 0;
for (Entry<String, String> property : conn.tableOperations().getProperties(tableName)) {
if (property.getKey().equals(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "prop1")) {
assertEquals(property.getValue(), "val1");
count++;
}
}
assertEquals(1, count);
// verify locality groups
Map<String, Set<Text>> createdLocalityGroups = conn.tableOperations().getLocalityGroups(tableName);
assertEquals(1, createdLocalityGroups.size());
assertEquals(createdLocalityGroups.get("lg1"), ImmutableSet.of(new Text("colF")));
// verify iterators
verifyIterators(conn, tableName, new String[] { "table.iterator.scan.someName=10,foo.bar" }, true);
conn.tableOperations().removeIterator(tableName, "someName", EnumSet.of(IteratorScope.scan));
verifyIterators(conn, tableName, new String[] {}, true);
}
use of org.apache.accumulo.core.client.admin.NewTableConfiguration in project accumulo by apache.
the class ReadWriteIT method sunnyLGUsingNewTableConfiguration.
/**
* Pretty much identical to sunnyLG, but verifies locality groups are created when configured in NewTableConfiguration prior to table creation.
*/
@Test
public void sunnyLGUsingNewTableConfiguration() throws Exception {
// create a locality group, write to it and ensure it exists in the RFiles that result
final Connector connector = getConnector();
final String tableName = getUniqueNames(1)[0];
NewTableConfiguration ntc = new NewTableConfiguration();
Map<String, Set<Text>> groups = new HashMap<>();
groups.put("g1", Collections.singleton(t("colf")));
ntc.setLocalityGroups(groups);
connector.tableOperations().create(tableName, ntc);
verifyLocalityGroupsInRFile(connector, tableName);
}
use of org.apache.accumulo.core.client.admin.NewTableConfiguration in project accumulo by apache.
the class LogicalTimeIT method runMergeTest.
private void runMergeTest(Connector conn, String table, String[] splits, String[] inserts, String start, String end, String last, long expected) throws Exception {
log.info("table {}", table);
conn.tableOperations().create(table, new NewTableConfiguration().setTimeType(TimeType.LOGICAL));
TreeSet<Text> splitSet = new TreeSet<>();
for (String split : splits) {
splitSet.add(new Text(split));
}
conn.tableOperations().addSplits(table, splitSet);
BatchWriter bw = conn.createBatchWriter(table, new BatchWriterConfig());
for (String row : inserts) {
Mutation m = new Mutation(row);
m.put("cf", "cq", "v");
bw.addMutation(m);
}
bw.flush();
conn.tableOperations().merge(table, start == null ? null : new Text(start), end == null ? null : new Text(end));
Mutation m = new Mutation(last);
m.put("cf", "cq", "v");
bw.addMutation(m);
bw.flush();
try (Scanner scanner = conn.createScanner(table, Authorizations.EMPTY)) {
scanner.setRange(new Range(last));
bw.close();
long time = scanner.iterator().next().getKey().getTimestamp();
if (time != expected) {
throw new RuntimeException("unexpected time " + time + " " + expected);
}
}
}
Aggregations