Search in sources :

Example 21 with NewTableConfiguration

use of org.apache.accumulo.core.client.admin.NewTableConfiguration in project accumulo by apache.

the class NewTableConfigurationIT method testSetLocalityGroupsDisjointCheck.

/**
 * Verify checkDisjoint works with locality groups.
 */
@Test(expected = IllegalArgumentException.class)
public void testSetLocalityGroupsDisjointCheck() {
    NewTableConfiguration ntc = new NewTableConfiguration();
    Map<String, String> props = new HashMap<>();
    props.put("table.group.lg1", "cat");
    ntc.setProperties(props);
    Map<String, Set<Text>> lgroups = new HashMap<>();
    lgroups.put("lg1", ImmutableSet.of(new Text("dog")));
    ntc.setLocalityGroups(lgroups);
}
Also used : EnumSet(java.util.EnumSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) HashMap(java.util.HashMap) NewTableConfiguration(org.apache.accumulo.core.client.admin.NewTableConfiguration) Text(org.apache.hadoop.io.Text) Test(org.junit.Test)

Example 22 with NewTableConfiguration

use of org.apache.accumulo.core.client.admin.NewTableConfiguration in project accumulo by apache.

the class NewTableConfigurationIT method testIteratorConflictFound2.

@Test(expected = IllegalArgumentException.class)
public void testIteratorConflictFound2() 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(10, "anotherName", "foo2.bar");
    ntc.attachIterator(setting, EnumSet.of(IteratorScope.scan));
    conn.tableOperations().create(tableName, ntc);
}
Also used : Connector(org.apache.accumulo.core.client.Connector) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) NewTableConfiguration(org.apache.accumulo.core.client.admin.NewTableConfiguration) Test(org.junit.Test)

Example 23 with NewTableConfiguration

use of org.apache.accumulo.core.client.admin.NewTableConfiguration in project accumulo by apache.

the class NewTableConfigurationIT method testMulitpleCallsToSetLocalityGroups.

/**
 * Verify that setting locality groups more than once overwrite initial locality settings.
 */
@Test
public void testMulitpleCallsToSetLocalityGroups() throws AccumuloSecurityException, AccumuloException, TableExistsException, TableNotFoundException {
    Connector conn = getConnector();
    String tableName = getUniqueNames(2)[0];
    NewTableConfiguration ntc = new NewTableConfiguration();
    // set first locality groups map
    Map<String, Set<Text>> initalGroup = new HashMap<>();
    initalGroup.put("lg1", ImmutableSet.of(new Text("dog"), new Text("cat")));
    ntc.setLocalityGroups(initalGroup);
    // set a second locality groups map and set in method call
    Map<String, Set<Text>> secondGroup = new HashMap<>();
    secondGroup.put("lg1", ImmutableSet.of(new Text("blue"), new Text("red")));
    ntc.setLocalityGroups(secondGroup);
    conn.tableOperations().create(tableName, ntc);
    // verify
    Map<String, Set<Text>> createdLocalityGroups = conn.tableOperations().getLocalityGroups(tableName);
    assertEquals(1, createdLocalityGroups.size());
    assertEquals(createdLocalityGroups.get("lg1"), ImmutableSet.of(new Text("red"), new Text("blue")));
}
Also used : Connector(org.apache.accumulo.core.client.Connector) EnumSet(java.util.EnumSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) HashMap(java.util.HashMap) NewTableConfiguration(org.apache.accumulo.core.client.admin.NewTableConfiguration) Text(org.apache.hadoop.io.Text) Test(org.junit.Test)

Example 24 with NewTableConfiguration

use of org.apache.accumulo.core.client.admin.NewTableConfiguration in project accumulo by apache.

the class NewTableConfigurationIT method testInvalidTablePropertiesSet.

/**
 * Verify that properties set using NewTableConfiguration must be table properties.
 */
@Test(expected = IllegalArgumentException.class)
public void testInvalidTablePropertiesSet() throws AccumuloSecurityException, AccumuloException, TableExistsException, TableNotFoundException {
    NewTableConfiguration ntc = new NewTableConfiguration();
    Map<String, String> props = new HashMap<>();
    // These properties should work just with no issue
    props.put(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "prop1", "val1");
    props.put(Property.TABLE_ARBITRARY_PROP_PREFIX.getKey() + "prop2", "val2");
    ntc.setProperties(props);
    // These properties should result in an illegalArgumentException
    props.put("invalidProp1", "value1");
    props.put("invalidProp2", "value2");
    ntc.setProperties(props);
}
Also used : HashMap(java.util.HashMap) NewTableConfiguration(org.apache.accumulo.core.client.admin.NewTableConfiguration) Test(org.junit.Test)

Example 25 with NewTableConfiguration

use of org.apache.accumulo.core.client.admin.NewTableConfiguration 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 {
    Connector conn = getConnector();
    String tableName = getUniqueNames(2)[0];
    NewTableConfiguration ntc = new NewTableConfiguration().withoutDefaultIterators();
    Map<String, Set<Text>> lgroups = new HashMap<>();
    lgroups.put("lg1", ImmutableSet.of(new Text("colF")));
    ntc.setLocalityGroups(lgroups);
    conn.tableOperations().create(tableName, ntc);
    // verify groups and verify no iterators
    Map<String, Set<Text>> createdLocalityGroups = conn.tableOperations().getLocalityGroups(tableName);
    assertEquals(1, createdLocalityGroups.size());
    assertEquals(createdLocalityGroups.get("lg1"), ImmutableSet.of(new Text("colF")));
    Map<String, EnumSet<IteratorScope>> iterators = conn.tableOperations().listIterators(tableName);
    assertEquals(0, iterators.size());
}
Also used : Connector(org.apache.accumulo.core.client.Connector) EnumSet(java.util.EnumSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) HashMap(java.util.HashMap) NewTableConfiguration(org.apache.accumulo.core.client.admin.NewTableConfiguration) EnumSet(java.util.EnumSet) Text(org.apache.hadoop.io.Text) Test(org.junit.Test)

Aggregations

NewTableConfiguration (org.apache.accumulo.core.client.admin.NewTableConfiguration)54 Test (org.junit.Test)47 Connector (org.apache.accumulo.core.client.Connector)40 HashMap (java.util.HashMap)22 Text (org.apache.hadoop.io.Text)22 BatchWriter (org.apache.accumulo.core.client.BatchWriter)20 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)18 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)17 EnumSet (java.util.EnumSet)13 Mutation (org.apache.accumulo.core.data.Mutation)13 Value (org.apache.accumulo.core.data.Value)13 Set (java.util.Set)12 ImmutableSet (com.google.common.collect.ImmutableSet)11 Scanner (org.apache.accumulo.core.client.Scanner)10 Key (org.apache.accumulo.core.data.Key)10 SummarizerConfiguration (org.apache.accumulo.core.client.summary.SummarizerConfiguration)9 Summary (org.apache.accumulo.core.client.summary.Summary)8 TreeSet (java.util.TreeSet)7 CounterSummary (org.apache.accumulo.core.client.summary.CounterSummary)7 Range (org.apache.accumulo.core.data.Range)5