Search in sources :

Example 16 with NewTableConfiguration

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

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

Example 18 with NewTableConfiguration

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

Example 19 with NewTableConfiguration

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

Example 20 with NewTableConfiguration

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