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 #575: Add splits to table at time of table creation #573
Date Wed, 05 Sep 2018 17:42:47 GMT
keith-turner commented on a change in pull request #575: Add splits to table at time of table
creation #573
URL: https://github.com/apache/accumulo/pull/575#discussion_r215363871
 
 

 ##########
 File path: test/src/main/java/org/apache/accumulo/test/functional/CreateInitialSplitsIT.java
 ##########
 @@ -0,0 +1,218 @@
+/*
+ * 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.functional;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Base64;
+import java.util.Collection;
+import java.util.Random;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.UUID;
+
+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.TableExistsException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.client.admin.NewTableConfiguration;
+import org.apache.accumulo.core.util.TextUtil;
+import org.apache.accumulo.harness.AccumuloClusterHarness;
+import org.apache.accumulo.minicluster.MemoryUnit;
+import org.apache.accumulo.minicluster.ServerType;
+import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.RawLocalFileSystem;
+import org.apache.hadoop.io.Text;
+import org.junit.Before;
+import org.junit.Test;
+
+@SuppressWarnings("SpellCheckingInspection")
+public class CreateInitialSplitsIT extends AccumuloClusterHarness {
+
+  private Connector connector;
+  private String tableName;
+
+  @Override
+  public void configureMiniCluster(MiniAccumuloConfigImpl cfg, Configuration conf) {
+    cfg.setMemory(ServerType.TABLET_SERVER, 128 * 4, MemoryUnit.MEGABYTE);
+
+    // use raw local file system
+    conf.set("fs.file.impl", RawLocalFileSystem.class.getName());
+  }
+
+  @Override
+  protected int defaultTimeoutSeconds() {
+    return 2 * 60;
+  }
+
+  @Before
+  public void setupInitialSplits() {
+    connector = getConnector();
+  }
+
+  /**
+   * Verify normal table creation did not get broken.
+   */
+  @Test
+  public void testCreateTableWithNoSplits()
+      throws TableExistsException, AccumuloSecurityException, AccumuloException {
+    tableName = getUniqueNames(1)[0];
+    connector.tableOperations().create(tableName);
+    assertTrue(connector.tableOperations().exists(tableName));
+  }
+
+  /**
+   * Create initial splits by providing splits from a Java Collection.
+   */
+  @Test
+  public void testCreateInitialSplits() throws TableExistsException, AccumuloSecurityException,
+      AccumuloException, TableNotFoundException {
+    tableName = getUniqueNames(1)[0];
+    SortedSet<Text> expectedSplits = generateNonBinarySplits(3000, 32);
+    NewTableConfiguration ntc = new NewTableConfiguration().withSplits(expectedSplits);
+    assertFalse(connector.tableOperations().exists(tableName));
+    connector.tableOperations().create(tableName, ntc);
+    assertTrue(connector.tableOperations().exists(tableName));
+    Collection<Text> createdSplits = connector.tableOperations().listSplits(tableName);
+    assertEquals(expectedSplits, new TreeSet<>(createdSplits));
+  }
+
+  @Test
+  public void testCreateInitialSplitsWithEncodedSplits() throws TableExistsException,
+      AccumuloSecurityException, AccumuloException, TableNotFoundException {
+    tableName = getUniqueNames(1)[0];
+    SortedSet<Text> expectedSplits = generateNonBinarySplits(3000, 32, true);
+    NewTableConfiguration ntc = new NewTableConfiguration().withSplits(expectedSplits);
+    assertFalse(connector.tableOperations().exists(tableName));
+    connector.tableOperations().create(tableName, ntc);
+    assertTrue(connector.tableOperations().exists(tableName));
+    Collection<Text> createdSplits = connector.tableOperations().listSplits(tableName);
+    assertEquals(expectedSplits, new TreeSet<>(createdSplits));
 
 Review comment:
   It would also be nice to do the following to ensure a table created in this way does not
have any quirks.
   
    1. Write some data to multiple tablets
    2. Verify data
    3. Compact table
    4. Verify data
    5. Delete table.

----------------------------------------------------------------
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