accumulo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] keith-turner commented on a change in pull request #337: ACCUMULO-4732 No APIs to configure iterators or locality groups for new tables
Date Thu, 01 Jan 1970 00:00:00 GMT
keith-turner commented on a change in pull request #337: ACCUMULO-4732 No APIs to configure
iterators or locality groups for new tables
URL: https://github.com/apache/accumulo/pull/337#discussion_r156539970
 
 

 ##########
 File path: test/src/main/java/org/apache/accumulo/test/NewConfigurationTestIT.java
 ##########
 @@ -0,0 +1,473 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TreeMap;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.client.TableExistsException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.client.admin.NewTableConfiguration;
+import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
+import org.apache.accumulo.harness.SharedMiniClusterBase;
+import org.apache.hadoop.io.Text;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableSet;
+
+public class NewConfigurationTestIT extends SharedMiniClusterBase {
+
+  private static final Logger log = LoggerFactory.getLogger(NewConfigurationTestIT.class);
+
+  @Override
+  protected int defaultTimeoutSeconds() {
+    return 30;
+  }
+
+  @BeforeClass
+  public static void setup() throws Exception {
+    SharedMiniClusterBase.startMiniCluster();
+  }
+
+  @AfterClass
+  public static void teardown() throws Exception {
+    SharedMiniClusterBase.stopMiniCluster();
+  }
+
+  /**
+   * 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("prop1", "val1");
+    initialProps.put("prop2", "val2");
+    ntc.setProperties(initialProps);
+    // Create a new set of properties and set them with setProperties
+    Map<String,String> updatedProps = new HashMap<>();
+    updatedProps.put("newerprop1", "newerval1");
+    updatedProps.put("newerprop2", "newerval2");
+    ntc.setProperties(updatedProps);
+    conn.tableOperations().create(tableName, ntc);
+    // verify
+    Map<String,String> props = ntc.getProperties();
+    assertEquals(props.get("newerprop1"), "newerval1");
+    assertEquals(props.get("newerprop2"), "newerval2");
+    assertFalse(props.keySet().contains("prop1"));
+    assertFalse(props.keySet().contains("prop2"));
+  }
+
+  /**
+   * 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 {
+    Connector conn = getConnector();
+    String tableName = getUniqueNames(2)[0];
+
+    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);
+    conn.tableOperations().create(tableName, ntc);
 
 Review comment:
   can this line be omitted?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message