Search in sources :

Example 36 with NewTableConfiguration

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);
}
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 37 with NewTableConfiguration

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));
}
Also used : Connector(org.apache.accumulo.core.client.Connector) NewTableConfiguration(org.apache.accumulo.core.client.admin.NewTableConfiguration) Test(org.junit.Test)

Example 38 with NewTableConfiguration

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());
}
Also used : Connector(org.apache.accumulo.core.client.Connector) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) NewTableConfiguration(org.apache.accumulo.core.client.admin.NewTableConfiguration) EnumSet(java.util.EnumSet) Test(org.junit.Test)

Example 39 with NewTableConfiguration

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")));
}
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 40 with NewTableConfiguration

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());
}
Also used : Connector(org.apache.accumulo.core.client.Connector) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) NewTableConfiguration(org.apache.accumulo.core.client.admin.NewTableConfiguration) EnumSet(java.util.EnumSet) IteratorScope(org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope) 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