accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From md...@apache.org
Subject [08/16] git commit: ACCUMULO-2399 Alert user CI table should exist
Date Tue, 04 Mar 2014 14:17:34 GMT
ACCUMULO-2399 Alert user CI table should exist

Extract common table checking functionality for continuous clients and
fail fast when the table does not exist. No longer create the table in
ingest to make the requirement explicit.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/759582b7
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/759582b7
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/759582b7

Branch: refs/heads/1.5.2-SNAPSHOT
Commit: 759582b78d5d72870a4a8c359ef6134c4dd97993
Parents: a8bbb91
Author: Mike Drob <mdrob@cloudera.com>
Authored: Tue Feb 25 15:40:12 2014 -0500
Committer: Mike Drob <mdrob@cloudera.com>
Committed: Tue Mar 4 08:36:13 2014 -0500

----------------------------------------------------------------------
 .../test/continuous/ContinuousBatchWalker.java  |  2 +-
 .../test/continuous/ContinuousIngest.java       |  9 ++--
 .../server/test/continuous/ContinuousQuery.java |  2 +-
 .../test/continuous/ContinuousScanner.java      |  2 +-
 .../server/test/continuous/ContinuousUtil.java  | 49 ++++++++++++++++++++
 .../server/test/continuous/ContinuousWalk.java  |  2 +-
 6 files changed, 57 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/759582b7/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousBatchWalker.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousBatchWalker.java
b/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousBatchWalker.java
index 4659aff..fe738b6 100644
--- a/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousBatchWalker.java
+++ b/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousBatchWalker.java
@@ -98,7 +98,7 @@ public class ContinuousBatchWalker {
     Authorizations auths = randomAuths.getAuths(r);
 
     Connector conn = new ZooKeeperInstance(instanceName, zooKeepers).getConnector(user, password.getBytes());
-    Scanner scanner = conn.createScanner(table, auths);
+    Scanner scanner = ContinuousUtil.createScanner(conn, table, auths);
     BatchScanner bs = conn.createBatchScanner(table, auths, numQueryThreads);
 
     while (true) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/759582b7/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousIngest.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousIngest.java
b/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousIngest.java
index b63efbc..1699ab4 100644
--- a/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousIngest.java
+++ b/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousIngest.java
@@ -36,7 +36,7 @@ import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.MutationsRejectedException;
-import org.apache.accumulo.core.client.TableExistsException;
+import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.client.ZooKeeperInstance;
 import org.apache.accumulo.core.data.Mutation;
 import org.apache.accumulo.core.data.Value;
@@ -150,10 +150,9 @@ public class ContinuousIngest {
     String path = ZooUtil.getRoot(instance) + Constants.ZTRACERS;
     Tracer.getInstance().addReceiver(new ZooSpanClient(zooKeepers, path, localhost, "cingest",
1000));
     
-    if (!conn.tableOperations().exists(table))
-      try {
-        conn.tableOperations().create(table);
-      } catch (TableExistsException tee) {}
+    if (!conn.tableOperations().exists(table)) {
+      throw new TableNotFoundException(null, table, "Consult the README and create the table
before starting ingest.");
+    }
 
     BatchWriter bw = conn.createBatchWriter(table, maxMemory, maxLatency, maxWriteThreads);
     bw = Trace.wrapAll(bw, new CountSampler(1024));

http://git-wip-us.apache.org/repos/asf/accumulo/blob/759582b7/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousQuery.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousQuery.java
b/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousQuery.java
index c8ae6ec..accd867 100644
--- a/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousQuery.java
+++ b/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousQuery.java
@@ -50,7 +50,7 @@ public class ContinuousQuery {
     long sleepTime = Long.parseLong(args[7]);
     
     Connector conn = new ZooKeeperInstance(instanceName, zooKeepers).getConnector(user, password.getBytes());
-    Scanner scanner = conn.createScanner(table, new Authorizations());
+    Scanner scanner = ContinuousUtil.createScanner(conn, table, new Authorizations());
     
     Random r = new Random();
     

http://git-wip-us.apache.org/repos/asf/accumulo/blob/759582b7/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousScanner.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousScanner.java
b/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousScanner.java
index 0ac3df6..13a91db 100644
--- a/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousScanner.java
+++ b/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousScanner.java
@@ -97,7 +97,7 @@ public class ContinuousScanner {
     Instance instance = new ZooKeeperInstance(instanceName, zooKeepers);
     Connector conn = instance.getConnector(user, password.getBytes());
     Authorizations auths = randomAuths.getAuths(r);
-    Scanner scanner = conn.createScanner(table, auths);
+    Scanner scanner = ContinuousUtil.createScanner(conn, table, auths);
     
     double delta = Math.min(.05, .05 / (numToScan / 1000.0));
     // System.out.println("Delta "+delta);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/759582b7/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousUtil.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousUtil.java
b/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousUtil.java
new file mode 100644
index 0000000..a788b59
--- /dev/null
+++ b/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousUtil.java
@@ -0,0 +1,49 @@
+/*
+ * 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.server.test.continuous;
+
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.security.Authorizations;
+
+/**
+ * Useful utility methods common to the Continuous test suite.
+ */
+final class ContinuousUtil {
+  private ContinuousUtil() {}
+
+  /**
+   * Attempt to create a table scanner, or fail if the table does not exist.
+   *
+   * @param connector
+   *          A populated connector object
+   * @param table
+   *          The table name to scan over
+   * @param auths
+   *          The authorizations to use for the scanner
+   * @return a scanner for the requested table
+   * @throws TableNotFoundException
+   *           If the table does not exist
+   */
+  static Scanner createScanner(Connector connector, String table, Authorizations auths) throws
TableNotFoundException {
+    if (!connector.tableOperations().exists(table)) {
+      throw new TableNotFoundException(null, table, "Consult the README and create the table
before starting test processes.");
+    }
+    return connector.createScanner(table, auths);
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/759582b7/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousWalk.java
----------------------------------------------------------------------
diff --git a/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousWalk.java
b/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousWalk.java
index 7d1e7f9..15b6090 100644
--- a/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousWalk.java
+++ b/src/server/src/main/java/org/apache/accumulo/server/test/continuous/ContinuousWalk.java
@@ -154,7 +154,7 @@ public class ContinuousWalk {
     ArrayList<Value> values = new ArrayList<Value>();
     
     while (true) {
-      Scanner scanner = conn.createScanner(table, randomAuths.getAuths(r));
+      Scanner scanner = ContinuousUtil.createScanner(conn, table, randomAuths.getAuths(r));
       String row = findAStartRow(min, max, scanner, r);
       
       while (row != null) {


Mime
View raw message