accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwa...@apache.org
Subject [accumulo] branch master updated: Consolidate option parsing classes (#993)
Date Wed, 27 Feb 2019 20:25:52 GMT
This is an automated email from the ASF dual-hosted git repository.

mwalch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/master by this push:
     new ecd896d  Consolidate option parsing classes (#993)
ecd896d is described below

commit ecd896d181c797b89d7815d9bd8f6fa9e24f9b7c
Author: Mike Walch <mwalch@apache.org>
AuthorDate: Wed Feb 27 15:25:48 2019 -0500

    Consolidate option parsing classes (#993)
---
 .../apache/accumulo/core/cli/BatchScannerOpts.java | 31 ----------------
 .../accumulo/core/cli/ClientOnDefaultTable.java    | 37 -------------------
 .../accumulo/core/cli/ClientOnRequiredTable.java   | 32 ----------------
 .../java/org/apache/accumulo/core/util/Merge.java  | 16 ++++----
 .../core/cli/ClientOnDefaultTableTest.java         | 43 ----------------------
 ...erUtilOnRequiredTable.java => ContextOpts.java} |  4 +-
 .../apache/accumulo/server/util/RandomWriter.java  | 15 +++-----
 .../accumulo/server/util/RandomizeVolumes.java     | 13 +++++--
 .../java/org/apache/accumulo/tracer/TraceDump.java | 14 +++----
 .../apache/accumulo/tracer/TraceTableStats.java    | 13 ++++---
 .../org/apache/accumulo/test/TestBinaryRows.java   | 18 +++++----
 .../java/org/apache/accumulo/test/TestIngest.java  | 18 +++++----
 .../apache/accumulo/test/TestRandomDeletes.java    | 30 ++++++++-------
 .../org/apache/accumulo/test/VerifyIngest.java     |  2 +-
 .../apache/accumulo/test/functional/BinaryIT.java  |  2 +-
 .../test/performance/ContinuousIngest.java         | 17 ++++++---
 .../test/performance/scan/CollectTabletStats.java  | 18 +++++----
 .../performance/scan/CollectTabletStatsTest.java   |  4 +-
 18 files changed, 103 insertions(+), 224 deletions(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/cli/BatchScannerOpts.java b/core/src/main/java/org/apache/accumulo/core/cli/BatchScannerOpts.java
deleted file mode 100644
index 2706468..0000000
--- a/core/src/main/java/org/apache/accumulo/core/cli/BatchScannerOpts.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.core.cli;
-
-import org.apache.accumulo.core.cli.ClientOpts.TimeConverter;
-
-import com.beust.jcommander.Parameter;
-
-public class BatchScannerOpts {
-  @Parameter(names = "--scanThreads", description = "Number of threads to use when batch
scanning")
-  public Integer scanThreads = 10;
-
-  @Parameter(names = "--scanTimeout", converter = TimeConverter.class,
-      description = "timeout used to fail a batch scan")
-  public Long scanTimeout = Long.MAX_VALUE;
-
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/cli/ClientOnDefaultTable.java b/core/src/main/java/org/apache/accumulo/core/cli/ClientOnDefaultTable.java
deleted file mode 100644
index 42dec8f..0000000
--- a/core/src/main/java/org/apache/accumulo/core/cli/ClientOnDefaultTable.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.core.cli;
-
-import com.beust.jcommander.Parameter;
-
-public class ClientOnDefaultTable extends ClientOpts {
-  @Parameter(names = "--table", description = "table to use")
-  private String tableName;
-
-  public ClientOnDefaultTable(String table) {
-    this.tableName = table;
-  }
-
-  public String getTableName() {
-    return tableName;
-  }
-
-  public void setTableName(String tableName) {
-    this.tableName = tableName;
-  }
-
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/cli/ClientOnRequiredTable.java b/core/src/main/java/org/apache/accumulo/core/cli/ClientOnRequiredTable.java
deleted file mode 100644
index e41e351..0000000
--- a/core/src/main/java/org/apache/accumulo/core/cli/ClientOnRequiredTable.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.core.cli;
-
-import com.beust.jcommander.Parameter;
-
-public class ClientOnRequiredTable extends ClientOpts {
-  @Parameter(names = {"-t", "--table"}, required = true, description = "table to use")
-  private String tableName;
-
-  public String getTableName() {
-    return tableName;
-  }
-
-  public void setTableName(String tableName) {
-    this.tableName = tableName;
-  }
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/util/Merge.java b/core/src/main/java/org/apache/accumulo/core/util/Merge.java
index 9865782..1a1c402 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/Merge.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/Merge.java
@@ -20,7 +20,7 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.accumulo.core.cli.ClientOnRequiredTable;
+import org.apache.accumulo.core.cli.ClientOpts;
 import org.apache.accumulo.core.client.AccumuloClient;
 import org.apache.accumulo.core.clientImpl.ClientContext;
 import org.apache.accumulo.core.clientImpl.Tables;
@@ -63,7 +63,9 @@ public class Merge {
     }
   }
 
-  static class Opts extends ClientOnRequiredTable {
+  static class Opts extends ClientOpts {
+    @Parameter(names = {"-t", "--table"}, required = true, description = "table to use")
+    String tableName;
     @Parameter(names = {"-s", "--size"}, description = "merge goal size",
         converter = MemoryConverter.class)
     Long goalSize = null;
@@ -84,18 +86,18 @@ public class Merge {
 
       try (AccumuloClient client = opts.createClient()) {
 
-        if (!client.tableOperations().exists(opts.getTableName())) {
-          System.err.println("table " + opts.getTableName() + " does not exist");
+        if (!client.tableOperations().exists(opts.tableName)) {
+          System.err.println("table " + opts.tableName + " does not exist");
           return;
         }
         if (opts.goalSize == null || opts.goalSize < 1) {
           AccumuloConfiguration tableConfig = new ConfigurationCopy(
-              client.tableOperations().getProperties(opts.getTableName()));
+              client.tableOperations().getProperties(opts.tableName));
           opts.goalSize = tableConfig.getAsBytes(Property.TABLE_SPLIT_THRESHOLD);
         }
 
-        message("Merging tablets in table %s to %d bytes", opts.getTableName(), opts.goalSize);
-        mergomatic(client, opts.getTableName(), opts.begin, opts.end, opts.goalSize, opts.force);
+        message("Merging tablets in table %s to %d bytes", opts.tableName, opts.goalSize);
+        mergomatic(client, opts.tableName, opts.begin, opts.end, opts.goalSize, opts.force);
       } catch (Exception ex) {
         throw new MergeException(ex);
       }
diff --git a/core/src/test/java/org/apache/accumulo/core/cli/ClientOnDefaultTableTest.java
b/core/src/test/java/org/apache/accumulo/core/cli/ClientOnDefaultTableTest.java
deleted file mode 100644
index 78c0f1e..0000000
--- a/core/src/test/java/org/apache/accumulo/core/cli/ClientOnDefaultTableTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.core.cli;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Before;
-import org.junit.Test;
-
-public class ClientOnDefaultTableTest {
-
-  ClientOnDefaultTable client;
-
-  @Before
-  public void setUp() {
-    client = new ClientOnDefaultTable("test");
-  }
-
-  @Test
-  public void testDefaultTable() {
-    assertEquals("test", client.getTableName());
-  }
-
-  @Test
-  public void testNonDefaultTable() {
-    client.parseArgs("program", new String[] {"--table", "other"});
-    assertEquals("other", client.getTableName());
-  }
-}
diff --git a/server/base/src/main/java/org/apache/accumulo/server/cli/ServerUtilOnRequiredTable.java
b/server/base/src/main/java/org/apache/accumulo/server/cli/ContextOpts.java
similarity index 91%
rename from server/base/src/main/java/org/apache/accumulo/server/cli/ServerUtilOnRequiredTable.java
rename to server/base/src/main/java/org/apache/accumulo/server/cli/ContextOpts.java
index c44210d..c596d23 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/cli/ServerUtilOnRequiredTable.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/cli/ContextOpts.java
@@ -16,11 +16,11 @@
  */
 package org.apache.accumulo.server.cli;
 
-import org.apache.accumulo.core.cli.ClientOnRequiredTable;
+import org.apache.accumulo.core.cli.ClientOpts;
 import org.apache.accumulo.core.conf.SiteConfiguration;
 import org.apache.accumulo.server.ServerContext;
 
-public class ServerUtilOnRequiredTable extends ClientOnRequiredTable {
+public class ContextOpts extends ClientOpts {
   {
     setPrincipal("root");
   }
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/RandomWriter.java b/server/base/src/main/java/org/apache/accumulo/server/util/RandomWriter.java
index 89d42b5..c0d3a84 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/RandomWriter.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/RandomWriter.java
@@ -20,7 +20,7 @@ import java.security.SecureRandom;
 import java.util.Iterator;
 import java.util.Random;
 
-import org.apache.accumulo.core.cli.ClientOnDefaultTable;
+import org.apache.accumulo.core.cli.ClientOpts;
 import org.apache.accumulo.core.client.AccumuloClient;
 import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.data.Mutation;
@@ -34,7 +34,6 @@ import com.beust.jcommander.Parameter;
 
 public class RandomWriter {
 
-  private static String table_name = "test_write_table";
   private static int num_columns_per_row = 1;
   private static int num_payload_bytes = 1024;
   private static final Logger log = LoggerFactory.getLogger(RandomWriter.class);
@@ -83,23 +82,21 @@ public class RandomWriter {
     }
   }
 
-  static class Opts extends ClientOnDefaultTable {
+  static class Opts extends ClientOpts {
     @Parameter(names = "--count", description = "number of mutations to write", required
= true)
     long count;
-
-    Opts(String table) {
-      super(table);
-    }
+    @Parameter(names = "--table", description = "table to use")
+    String tableName = "test_write_table";
   }
 
   public static void main(String[] args) throws Exception {
-    Opts opts = new Opts(table_name);
+    Opts opts = new Opts();
     opts.setPrincipal("root");
     try (TraceScope clientSpan = opts.parseArgsAndTrace(RandomWriter.class.getName(), args))
{
       long start = System.currentTimeMillis();
       log.info("starting at {} for user {}", start, opts.getPrincipal());
       try (AccumuloClient accumuloClient = opts.createClient();
-          BatchWriter bw = accumuloClient.createBatchWriter(opts.getTableName())) {
+          BatchWriter bw = accumuloClient.createBatchWriter(opts.tableName)) {
         log.info("Writing {} mutations...", opts.count);
         bw.addMutations(new RandomMutationGenerator(opts.count));
       } catch (Exception e) {
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/RandomizeVolumes.java
b/server/base/src/main/java/org/apache/accumulo/server/util/RandomizeVolumes.java
index e4cb695..242687f 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/RandomizeVolumes.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/RandomizeVolumes.java
@@ -40,7 +40,7 @@ import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.core.util.SimpleThreadPool;
 import org.apache.accumulo.server.ServerConstants;
 import org.apache.accumulo.server.ServerContext;
-import org.apache.accumulo.server.cli.ServerUtilOnRequiredTable;
+import org.apache.accumulo.server.cli.ContextOpts;
 import org.apache.accumulo.server.fs.VolumeChooserEnvironment;
 import org.apache.accumulo.server.fs.VolumeChooserEnvironmentImpl;
 import org.apache.accumulo.server.fs.VolumeManager;
@@ -50,15 +50,22 @@ import org.apache.htrace.TraceScope;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.beust.jcommander.Parameter;
+
 public class RandomizeVolumes {
   private static final Logger log = LoggerFactory.getLogger(RandomizeVolumes.class);
 
+  static class RandomizeOpts extends ContextOpts {
+    @Parameter(names = {"-t", "--table"}, required = true, description = "table to use")
+    String tableName;
+  }
+
   public static void main(String[] args) {
-    ServerUtilOnRequiredTable opts = new ServerUtilOnRequiredTable();
+    RandomizeOpts opts = new RandomizeOpts();
     try (TraceScope clientSpan = opts.parseArgsAndTrace(RandomizeVolumes.class.getName(),
args)) {
       ServerContext context = opts.getServerContext();
       try {
-        int status = randomize(context, opts.getTableName());
+        int status = randomize(context, opts.tableName);
         System.exit(status);
       } catch (Exception ex) {
         log.error("{}", ex.getMessage(), ex);
diff --git a/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceDump.java b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceDump.java
index 396345d..8658eb5 100644
--- a/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceDump.java
+++ b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceDump.java
@@ -27,7 +27,7 @@ import java.util.List;
 import java.util.Map.Entry;
 import java.util.Set;
 
-import org.apache.accumulo.core.cli.ClientOnDefaultTable;
+import org.apache.accumulo.core.cli.ClientOpts;
 import org.apache.accumulo.core.client.AccumuloClient;
 import org.apache.accumulo.core.client.Scanner;
 import org.apache.accumulo.core.data.Key;
@@ -41,7 +41,9 @@ import com.beust.jcommander.Parameter;
 public class TraceDump {
   static final long DEFAULT_TIME_IN_MILLIS = 10 * 60 * 1000L;
 
-  static class Opts extends ClientOnDefaultTable {
+  static class Opts extends ClientOpts {
+    @Parameter(names = "--table", description = "table to use")
+    String tableName = "trace";
     @Parameter(names = {"-r", "--recent"}, description = "List recent traces")
     boolean list = false;
     @Parameter(names = {"-ms", "--ms"}, description = "Time period of recent traces to list
in ms")
@@ -50,10 +52,6 @@ public class TraceDump {
     boolean dump = false;
     @Parameter(description = " <trace id> { <trace id> ... }")
     List<String> traceIds = new ArrayList<>();
-
-    Opts() {
-      super("trace");
-    }
   }
 
   public static void main(String[] args) throws Exception {
@@ -80,7 +78,7 @@ public class TraceDump {
     long endTime = System.currentTimeMillis();
     long startTime = endTime - opts.length;
     try (AccumuloClient client = opts.createClient()) {
-      Scanner scanner = client.createScanner(opts.getTableName(), opts.auths);
+      Scanner scanner = client.createScanner(opts.tableName, opts.auths);
       Range range = new Range(new Text("start:" + Long.toHexString(startTime)),
           new Text("start:" + Long.toHexString(endTime)));
       scanner.setRange(range);
@@ -104,7 +102,7 @@ public class TraceDump {
     int count = 0;
     try (AccumuloClient client = opts.createClient()) {
       for (String traceId : opts.traceIds) {
-        Scanner scanner = client.createScanner(opts.getTableName(), opts.auths);
+        Scanner scanner = client.createScanner(opts.tableName, opts.auths);
         Range range = new Range(new Text(traceId));
         scanner.setRange(range);
         count = printTrace(scanner, out::println);
diff --git a/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceTableStats.java b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceTableStats.java
index fd11850..5a7e56d 100644
--- a/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceTableStats.java
+++ b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceTableStats.java
@@ -23,7 +23,7 @@ import java.util.Map.Entry;
 import java.util.Set;
 import java.util.TreeMap;
 
-import org.apache.accumulo.core.cli.ClientOnDefaultTable;
+import org.apache.accumulo.core.cli.ClientOpts;
 import org.apache.accumulo.core.client.AccumuloClient;
 import org.apache.accumulo.core.client.Scanner;
 import org.apache.accumulo.core.client.TableNotFoundException;
@@ -33,14 +33,15 @@ import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.tracer.thrift.RemoteSpan;
 
+import com.beust.jcommander.Parameter;
+
 /**
  * Reads the trace table and prints out some stats about the spans found.
  */
 public class TraceTableStats {
-  static class Opts extends ClientOnDefaultTable {
-    public Opts() {
-      super("trace");
-    }
+  static class Opts extends ClientOpts {
+    @Parameter(names = "--table", description = "table to use")
+    String tableName = "trace";
   }
 
   static class SpanTypeCount {
@@ -82,7 +83,7 @@ public class TraceTableStats {
     double maxSpanLengthMS = 0;
 
     try (AccumuloClient client = opts.createClient()) {
-      Scanner scanner = client.createScanner(opts.getTableName(), Authorizations.EMPTY);
+      Scanner scanner = client.createScanner(opts.tableName, Authorizations.EMPTY);
       scanner.setRange(new Range(null, true, "idx:", false));
       for (Entry<Key,Value> entry : scanner) {
         numSpans++;
diff --git a/test/src/main/java/org/apache/accumulo/test/TestBinaryRows.java b/test/src/main/java/org/apache/accumulo/test/TestBinaryRows.java
index da71cdd..eb8d002 100644
--- a/test/src/main/java/org/apache/accumulo/test/TestBinaryRows.java
+++ b/test/src/main/java/org/apache/accumulo/test/TestBinaryRows.java
@@ -32,7 +32,7 @@ import org.apache.accumulo.core.data.Mutation;
 import org.apache.accumulo.core.data.Range;
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.util.TextUtil;
-import org.apache.accumulo.server.cli.ServerUtilOnRequiredTable;
+import org.apache.accumulo.server.cli.ContextOpts;
 import org.apache.hadoop.io.Text;
 
 import com.beust.jcommander.Parameter;
@@ -73,7 +73,7 @@ public class TestBinaryRows {
     return l;
   }
 
-  public static class Opts extends ServerUtilOnRequiredTable {
+  public static class Opts extends ContextOpts {
     @Parameter(names = "--mode",
         description = "either 'ingest', 'delete', 'randomLookups', 'split',"
             + " 'verify', 'verifyDeleted'",
@@ -83,6 +83,8 @@ public class TestBinaryRows {
     public long start = 0;
     @Parameter(names = "--count", description = "number of rows to ingest", required = true)
     public long num = 0;
+    @Parameter(names = {"-t", "--table"}, required = true, description = "table to use")
+    public String tableName;
   }
 
   public static void runTest(AccumuloClient accumuloClient, Opts opts) throws Exception {
@@ -90,7 +92,7 @@ public class TestBinaryRows {
     final Text CF = new Text("cf"), CQ = new Text("cq");
     final byte[] CF_BYTES = "cf".getBytes(UTF_8), CQ_BYTES = "cq".getBytes(UTF_8);
     if (opts.mode.equals("ingest") || opts.mode.equals("delete")) {
-      try (BatchWriter bw = accumuloClient.createBatchWriter(opts.getTableName())) {
+      try (BatchWriter bw = accumuloClient.createBatchWriter(opts.tableName)) {
         boolean delete = opts.mode.equals("delete");
 
         for (long i = 0; i < opts.num; i++) {
@@ -107,7 +109,7 @@ public class TestBinaryRows {
         }
       }
     } else if (opts.mode.equals("verifyDeleted")) {
-      try (Scanner s = accumuloClient.createScanner(opts.getTableName(), opts.auths)) {
+      try (Scanner s = accumuloClient.createScanner(opts.tableName, opts.auths)) {
         Key startKey = new Key(encodeLong(opts.start), CF_BYTES, CQ_BYTES, new byte[0],
             Long.MAX_VALUE);
         Key stopKey = new Key(encodeLong(opts.start + opts.num - 1), CF_BYTES, CQ_BYTES,
@@ -123,7 +125,7 @@ public class TestBinaryRows {
     } else if (opts.mode.equals("verify")) {
       long t1 = System.currentTimeMillis();
 
-      try (Scanner s = accumuloClient.createScanner(opts.getTableName(), opts.auths)) {
+      try (Scanner s = accumuloClient.createScanner(opts.tableName, opts.auths)) {
         Key startKey = new Key(encodeLong(opts.start), CF_BYTES, CQ_BYTES, new byte[0],
             Long.MAX_VALUE);
         Key stopKey = new Key(encodeLong(opts.start + opts.num - 1), CF_BYTES, CQ_BYTES,
@@ -161,7 +163,7 @@ public class TestBinaryRows {
       for (int i = 0; i < numLookups; i++) {
         long row = ((r.nextLong() & 0x7fffffffffffffffL) % opts.num) + opts.start;
 
-        try (Scanner s = accumuloClient.createScanner(opts.getTableName(), opts.auths)) {
+        try (Scanner s = accumuloClient.createScanner(opts.tableName, opts.auths)) {
           Key startKey = new Key(encodeLong(row), CF_BYTES, CQ_BYTES, new byte[0], Long.MAX_VALUE);
           Key stopKey = new Key(encodeLong(row), CF_BYTES, CQ_BYTES, new byte[0], 0);
           s.setRange(new Range(startKey, stopKey));
@@ -203,8 +205,8 @@ public class TestBinaryRows {
         System.out.printf("added split point 0x%016x  %,12d%n", splitPoint, splitPoint);
       }
 
-      accumuloClient.tableOperations().create(opts.getTableName());
-      accumuloClient.tableOperations().addSplits(opts.getTableName(), splits);
+      accumuloClient.tableOperations().create(opts.tableName);
+      accumuloClient.tableOperations().addSplits(opts.tableName, splits);
 
     } else {
       throw new Exception("ERROR : " + opts.mode + " is not a valid operation.");
diff --git a/test/src/main/java/org/apache/accumulo/test/TestIngest.java b/test/src/main/java/org/apache/accumulo/test/TestIngest.java
index 767e397..2dc0d15 100644
--- a/test/src/main/java/org/apache/accumulo/test/TestIngest.java
+++ b/test/src/main/java/org/apache/accumulo/test/TestIngest.java
@@ -25,7 +25,7 @@ import java.util.Random;
 import java.util.Set;
 import java.util.TreeSet;
 
-import org.apache.accumulo.core.cli.ClientOnDefaultTable;
+import org.apache.accumulo.core.cli.ClientOpts;
 import org.apache.accumulo.core.client.AccumuloClient;
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
@@ -64,7 +64,9 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 public class TestIngest {
   public static final Authorizations AUTHS = new Authorizations("L1", "L2", "G1", "GROUP2");
 
-  public static class Opts extends ClientOnDefaultTable {
+  public static class Opts extends ClientOpts {
+    @Parameter(names = "--table", description = "table to use")
+    String tableName = "test_ingest";
 
     @Parameter(names = "--createTable")
     public boolean createTable = false;
@@ -112,8 +114,8 @@ public class TestIngest {
     public Configuration conf = null;
     public FileSystem fs = null;
 
-    public Opts() {
-      super("test_ingest");
+    public void setTableName(String tableName) {
+      this.tableName = tableName;
     }
   }
 
@@ -123,10 +125,10 @@ public class TestIngest {
       TreeSet<Text> splits = getSplitPoints(args.startRow, args.startRow + args.rows,
           args.numsplits);
 
-      if (!client.tableOperations().exists(args.getTableName()))
-        client.tableOperations().create(args.getTableName());
+      if (!client.tableOperations().exists(args.tableName))
+        client.tableOperations().create(args.tableName);
       try {
-        client.tableOperations().addSplits(args.getTableName(), splits);
+        client.tableOperations().addSplits(args.tableName, splits);
       } catch (TableNotFoundException ex) {
         // unlikely
         throw new RuntimeException(ex);
@@ -231,7 +233,7 @@ public class TestIngest {
           .withTableConfiguration(DefaultConfiguration.getInstance()).build();
       writer.startDefaultLocalityGroup();
     } else {
-      bw = accumuloClient.createBatchWriter(opts.getTableName());
+      bw = accumuloClient.createBatchWriter(opts.tableName);
       accumuloClient.securityOperations().changeUserAuthorizations(opts.getPrincipal(), AUTHS);
     }
     Text labBA = new Text(opts.columnVisibility.getExpression());
diff --git a/test/src/main/java/org/apache/accumulo/test/TestRandomDeletes.java b/test/src/main/java/org/apache/accumulo/test/TestRandomDeletes.java
index ad9e75d..b0e8e72 100644
--- a/test/src/main/java/org/apache/accumulo/test/TestRandomDeletes.java
+++ b/test/src/main/java/org/apache/accumulo/test/TestRandomDeletes.java
@@ -22,7 +22,7 @@ import java.util.Objects;
 import java.util.Set;
 import java.util.TreeSet;
 
-import org.apache.accumulo.core.cli.ClientOnDefaultTable;
+import org.apache.accumulo.core.cli.ClientOpts;
 import org.apache.accumulo.core.client.AccumuloClient;
 import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.Scanner;
@@ -37,6 +37,8 @@ import org.apache.hadoop.io.Text;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.beust.jcommander.Parameter;
+
 public class TestRandomDeletes {
   private static final Logger log = LoggerFactory.getLogger(TestRandomDeletes.class);
   private static Authorizations auths = new Authorizations("L1", "L2", "G1", "GROUP2");
@@ -77,11 +79,10 @@ public class TestRandomDeletes {
     }
   }
 
-  private static TreeSet<RowColumn> scanAll(ClientOnDefaultTable opts, String tableName)
-      throws Exception {
+  private static TreeSet<RowColumn> scanAll(TestOpts opts) throws Exception {
     TreeSet<RowColumn> result = new TreeSet<>();
     try (AccumuloClient client = opts.createClient();
-        Scanner scanner = client.createScanner(tableName, auths)) {
+        Scanner scanner = client.createScanner(opts.tableName, auths)) {
       for (Entry<Key,Value> entry : scanner) {
         Key key = entry.getKey();
         Column column = new Column(TextUtil.getBytes(key.getColumnFamily()),
@@ -93,14 +94,14 @@ public class TestRandomDeletes {
     return result;
   }
 
-  private static long scrambleDeleteHalfAndCheck(ClientOnDefaultTable opts, String tableName,
-      Set<RowColumn> rows) throws Exception {
+  private static long scrambleDeleteHalfAndCheck(TestOpts opts, Set<RowColumn> rows)
+      throws Exception {
     int result = 0;
     ArrayList<RowColumn> entries = new ArrayList<>(rows);
     java.util.Collections.shuffle(entries);
 
     try (AccumuloClient accumuloClient = opts.createClient();
-        BatchWriter bw = accumuloClient.createBatchWriter(tableName)) {
+        BatchWriter bw = accumuloClient.createBatchWriter(opts.tableName)) {
 
       for (int i = 0; i < (entries.size() + 1) / 2; i++) {
         RowColumn rc = entries.get(i);
@@ -113,7 +114,7 @@ public class TestRandomDeletes {
       }
     }
 
-    Set<RowColumn> current = scanAll(opts, tableName);
+    Set<RowColumn> current = scanAll(opts);
     current.removeAll(rows);
     if (current.size() > 0) {
       throw new RuntimeException(current.size() + " records not deleted");
@@ -121,9 +122,14 @@ public class TestRandomDeletes {
     return result;
   }
 
+  static class TestOpts extends ClientOpts {
+    @Parameter(names = "--table", description = "table to use")
+    String tableName = "test_ingest";
+  }
+
   public static void main(String[] args) {
 
-    ClientOnDefaultTable opts = new ClientOnDefaultTable("test_ingest");
+    TestOpts opts = new TestOpts();
     opts.parseArgs(TestRandomDeletes.class.getName(), args);
 
     log.info("starting random delete test");
@@ -131,14 +137,12 @@ public class TestRandomDeletes {
     try {
       long deleted = 0;
 
-      String tableName = opts.getTableName();
-
-      TreeSet<RowColumn> doomed = scanAll(opts, tableName);
+      TreeSet<RowColumn> doomed = scanAll(opts);
       log.info("Got {} rows", doomed.size());
 
       long startTime = System.currentTimeMillis();
       while (true) {
-        long half = scrambleDeleteHalfAndCheck(opts, tableName, doomed);
+        long half = scrambleDeleteHalfAndCheck(opts, doomed);
         deleted += half;
         if (half == 0)
           break;
diff --git a/test/src/main/java/org/apache/accumulo/test/VerifyIngest.java b/test/src/main/java/org/apache/accumulo/test/VerifyIngest.java
index 777be8b..1a22939 100644
--- a/test/src/main/java/org/apache/accumulo/test/VerifyIngest.java
+++ b/test/src/main/java/org/apache/accumulo/test/VerifyIngest.java
@@ -159,7 +159,7 @@ public class VerifyIngest {
 
         Key startKey = new Key(new Text("row_" + String.format("%010d", expectedRow)));
 
-        try (Scanner scanner = accumuloClient.createScanner(opts.getTableName(), labelAuths))
{
+        try (Scanner scanner = accumuloClient.createScanner(opts.tableName, labelAuths))
{
           scanner.setRange(new Range(startKey, endKey));
           for (int j = 0; j < opts.cols; j++) {
             scanner.fetchColumn(new Text(opts.columnFamily),
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/BinaryIT.java b/test/src/main/java/org/apache/accumulo/test/functional/BinaryIT.java
index ac70384..bc3b2ab 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/BinaryIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/BinaryIT.java
@@ -56,7 +56,7 @@ public class BinaryIT extends AccumuloClusterHarness {
 
   public static void runTest(AccumuloClient c, String tableName) throws Exception {
     TestBinaryRows.Opts opts = new TestBinaryRows.Opts();
-    opts.setTableName(tableName);
+    opts.tableName = tableName;
     opts.start = 0;
     opts.num = 100000;
     opts.mode = "ingest";
diff --git a/test/src/main/java/org/apache/accumulo/test/performance/ContinuousIngest.java
b/test/src/main/java/org/apache/accumulo/test/performance/ContinuousIngest.java
index 7859120..3149834 100644
--- a/test/src/main/java/org/apache/accumulo/test/performance/ContinuousIngest.java
+++ b/test/src/main/java/org/apache/accumulo/test/performance/ContinuousIngest.java
@@ -29,7 +29,7 @@ import java.util.UUID;
 import java.util.zip.CRC32;
 import java.util.zip.Checksum;
 
-import org.apache.accumulo.core.cli.ClientOnDefaultTable;
+import org.apache.accumulo.core.cli.ClientOpts;
 import org.apache.accumulo.core.client.AccumuloClient;
 import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.MutationsRejectedException;
@@ -46,6 +46,8 @@ import org.apache.hadoop.io.Text;
 import org.apache.htrace.TraceScope;
 import org.apache.htrace.wrappers.TraceProxy;
 
+import com.beust.jcommander.Parameter;
+
 public class ContinuousIngest {
 
   private static final byte[] EMPTY_BYTES = new byte[0];
@@ -77,10 +79,15 @@ public class ContinuousIngest {
     return visibilities.get(rand.nextInt(visibilities.size()));
   }
 
+  static class TestOpts extends ClientOpts {
+    @Parameter(names = "--table", description = "table to use")
+    String tableName = "ci";
+  }
+
   public static void main(String[] args) throws Exception {
 
     ContinuousOpts opts = new ContinuousOpts();
-    ClientOnDefaultTable clientOpts = new ClientOnDefaultTable("ci");
+    TestOpts clientOpts = new TestOpts();
     try (TraceScope clientSpan = clientOpts.parseArgsAndTrace(ContinuousIngest.class.getName(),
         args, opts)) {
 
@@ -91,12 +98,12 @@ public class ContinuousIngest {
       }
       try (AccumuloClient client = clientOpts.createClient()) {
 
-        if (!client.tableOperations().exists(clientOpts.getTableName())) {
-          throw new TableNotFoundException(null, clientOpts.getTableName(),
+        if (!client.tableOperations().exists(clientOpts.tableName)) {
+          throw new TableNotFoundException(null, clientOpts.tableName,
               "Consult the README and create the table before starting ingest.");
         }
 
-        BatchWriter bw = client.createBatchWriter(clientOpts.getTableName());
+        BatchWriter bw = client.createBatchWriter(clientOpts.tableName);
         bw = TraceProxy.trace(bw, TraceUtil.countSampler(1024));
 
         Random r = new SecureRandom();
diff --git a/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java
b/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java
index 7fce284..929226d 100644
--- a/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java
+++ b/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java
@@ -67,7 +67,7 @@ import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.core.util.HostAndPort;
 import org.apache.accumulo.core.util.Stat;
 import org.apache.accumulo.server.ServerContext;
-import org.apache.accumulo.server.cli.ServerUtilOnRequiredTable;
+import org.apache.accumulo.server.cli.ContextOpts;
 import org.apache.accumulo.server.conf.ServerConfigurationFactory;
 import org.apache.accumulo.server.conf.TableConfiguration;
 import org.apache.accumulo.server.fs.FileRef;
@@ -88,7 +88,9 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 public class CollectTabletStats {
   private static final Logger log = LoggerFactory.getLogger(CollectTabletStats.class);
 
-  static class CollectOptions extends ServerUtilOnRequiredTable {
+  static class CollectOptions extends ContextOpts {
+    @Parameter(names = {"-t", "--table"}, required = true, description = "table to use")
+    String tableName;
     @Parameter(names = "--iterations", description = "number of iterations")
     int iterations = 3;
     @Parameter(names = "--numThreads", description = "number of threads")
@@ -113,14 +115,14 @@ public class CollectTabletStats {
     final VolumeManager fs = context.getVolumeManager();
     ServerConfigurationFactory sconf = context.getServerConfFactory();
 
-    TableId tableId = Tables.getTableId(context, opts.getTableName());
+    TableId tableId = Tables.getTableId(context, opts.tableName);
     if (tableId == null) {
-      log.error("Unable to find table named {}", opts.getTableName());
+      log.error("Unable to find table named {}", opts.tableName);
       System.exit(-1);
     }
 
     TreeMap<KeyExtent,String> tabletLocations = new TreeMap<>();
-    List<KeyExtent> candidates = findTablets(context, !opts.selectFarTablets, opts.getTableName(),
+    List<KeyExtent> candidates = findTablets(context, !opts.selectFarTablets, opts.tableName,
         tabletLocations);
 
     if (candidates.size() < opts.numThreads) {
@@ -142,7 +144,7 @@ public class CollectTabletStats {
     System.out.println("run location      : " + InetAddress.getLocalHost().getHostName()
+ "/"
         + InetAddress.getLocalHost().getHostAddress());
     System.out.println("num threads       : " + opts.numThreads);
-    System.out.println("table             : " + opts.getTableName());
+    System.out.println("table             : " + opts.tableName);
     System.out.println("table id          : " + tableId);
 
     for (KeyExtent ke : tabletsToTest) {
@@ -220,7 +222,7 @@ public class CollectTabletStats {
           Test test = new Test(ke) {
             @Override
             public int runTest() throws Exception {
-              return scanTablet(client, opts.getTableName(), opts.auths, ke.getPrevEndRow(),
+              return scanTablet(client, opts.tableName, opts.auths, ke.getPrevEndRow(),
                   ke.getEndRow(), columns);
             }
           };
@@ -232,7 +234,7 @@ public class CollectTabletStats {
       for (final KeyExtent ke : tabletsToTest) {
         threadPool.submit(() -> {
           try {
-            calcTabletStats(client, opts.getTableName(), opts.auths, ke, columns);
+            calcTabletStats(client, opts.tableName, opts.auths, ke, columns);
           } catch (Exception e) {
             log.error("Failed to calculate tablet stats.", e);
           }
diff --git a/test/src/test/java/org/apache/accumulo/test/performance/scan/CollectTabletStatsTest.java
b/test/src/test/java/org/apache/accumulo/test/performance/scan/CollectTabletStatsTest.java
index 6413f5e..1ac72c7 100644
--- a/test/src/test/java/org/apache/accumulo/test/performance/scan/CollectTabletStatsTest.java
+++ b/test/src/test/java/org/apache/accumulo/test/performance/scan/CollectTabletStatsTest.java
@@ -36,7 +36,7 @@ public class CollectTabletStatsTest {
     opts.parseArgs(CollectTabletStats.class.getName(), args);
 
     assertEquals("Check iterations is set, default is 3", 2, opts.iterations);
-    assertEquals("Check tablename is set", 0, tablename.compareTo(opts.getTableName()));
+    assertEquals("Check tablename is set", 0, tablename.compareTo(opts.tableName));
     assertEquals("Check default numThreads", 1, opts.numThreads);
 
   }
@@ -52,7 +52,7 @@ public class CollectTabletStatsTest {
     opts.parseArgs(CollectTabletStats.class.getName(), args);
 
     assertEquals("Check iterations is set, default is 3", 2, opts.iterations);
-    assertEquals("Check tablename is set", 0, tablename.compareTo(opts.getTableName()));
+    assertEquals("Check tablename is set", 0, tablename.compareTo(opts.tableName));
     assertEquals("Check numThreads is set", 99, opts.numThreads);
 
   }


Mime
View raw message