Skip to content

Commit 1410895

Browse files
committed
Modified ServerUtilOpts to extent Help, not ClientOpts
1 parent e5a0a3f commit 1410895

File tree

7 files changed

+32
-38
lines changed

7 files changed

+32
-38
lines changed

server/base/src/main/java/org/apache/accumulo/server/cli/ServerUtilOpts.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,17 @@
1818
*/
1919
package org.apache.accumulo.server.cli;
2020

21-
import org.apache.accumulo.core.cli.ClientOpts;
22-
import org.apache.accumulo.core.clientImpl.ClientInfo;
21+
import org.apache.accumulo.core.cli.Help;
2322
import org.apache.accumulo.core.conf.SiteConfiguration;
2423
import org.apache.accumulo.server.ServerContext;
2524

26-
public class ServerUtilOpts extends ClientOpts {
25+
public class ServerUtilOpts extends Help {
2726

2827
private ServerContext context;
2928

3029
public synchronized ServerContext getServerContext() {
3130
if (context == null) {
32-
context = getClientConfigFile() == null ? new ServerContext(SiteConfiguration.auto())
33-
: ServerContext.withClientInfo(SiteConfiguration.auto(),
34-
ClientInfo.from(getClientProps()));
31+
context = new ServerContext(SiteConfiguration.auto());
3532
}
3633
return context;
3734
}

server/base/src/main/java/org/apache/accumulo/server/util/Admin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ public void execute(final String[] args) {
547547
} else if (cl.getParsedCommand().equals("volumes")) {
548548
ListVolumesUsed.listVolumes(context);
549549
} else if (cl.getParsedCommand().equals("verifyTabletAssigns")) {
550-
VerifyTabletAssignments.execute(opts.getClientProps(), verifyTabletAssignmentsOpts.verbose);
550+
VerifyTabletAssignments.execute(context, verifyTabletAssignmentsOpts.verbose);
551551
} else if (cl.getParsedCommand().equals("changeSecret")) {
552552
ChangeSecret.execute(context, conf);
553553
} else if (cl.getParsedCommand().equals("deleteZooInstance")) {

server/base/src/main/java/org/apache/accumulo/server/util/CheckForMetadataProblems.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
import java.util.TreeSet;
2626
import java.util.function.Consumer;
2727

28-
import org.apache.accumulo.core.client.Accumulo;
29-
import org.apache.accumulo.core.client.AccumuloClient;
3028
import org.apache.accumulo.core.client.Scanner;
3129
import org.apache.accumulo.core.client.TableNotFoundException;
3230
import org.apache.accumulo.core.data.Key;
@@ -124,8 +122,8 @@ public static boolean checkMetadataAndRootTableEntries(String tableNameToCheck,
124122
Map<TableId,TreeSet<KeyExtent>> tables = new HashMap<>();
125123
boolean sawProblems = false;
126124

127-
try (AccumuloClient client = Accumulo.newClient().from(opts.getClientProps()).build();
128-
Scanner scanner = client.createScanner(tableNameToCheck, Authorizations.EMPTY)) {
125+
try (Scanner scanner =
126+
opts.getServerContext().createScanner(tableNameToCheck, Authorizations.EMPTY)) {
129127

130128
scanner.setRange(TabletsSection.getRange());
131129
TabletColumnFamily.PREV_ROW_COLUMN.fetch(scanner);

server/base/src/main/java/org/apache/accumulo/server/util/TableDiskUsage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import java.util.TreeMap;
3737
import java.util.TreeSet;
3838

39+
import org.apache.accumulo.core.cli.ClientOpts;
3940
import org.apache.accumulo.core.client.Accumulo;
4041
import org.apache.accumulo.core.client.AccumuloClient;
4142
import org.apache.accumulo.core.client.TableNotFoundException;
@@ -45,7 +46,6 @@
4546
import org.apache.accumulo.core.metadata.schema.DataFileValue;
4647
import org.apache.accumulo.core.trace.TraceUtil;
4748
import org.apache.accumulo.core.util.NumUtil;
48-
import org.apache.accumulo.server.cli.ServerUtilOpts;
4949
import org.slf4j.Logger;
5050
import org.slf4j.LoggerFactory;
5151

@@ -319,7 +319,7 @@ public static void printDiskUsage(Collection<String> tableNames, AccumuloClient
319319
}
320320
}
321321

322-
static class Opts extends ServerUtilOpts {
322+
static class Opts extends ClientOpts {
323323
@Parameter(required = true, description = " <table> { <table> ... } ")
324324
List<String> tables = new ArrayList<>();
325325
}

server/base/src/main/java/org/apache/accumulo/server/util/VerifyTabletAssignments.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,10 @@
2626
import java.util.List;
2727
import java.util.Map;
2828
import java.util.Map.Entry;
29-
import java.util.Properties;
3029
import java.util.TreeMap;
3130
import java.util.concurrent.ExecutorService;
3231
import java.util.concurrent.TimeUnit;
3332

34-
import org.apache.accumulo.core.client.Accumulo;
35-
import org.apache.accumulo.core.client.AccumuloClient;
3633
import org.apache.accumulo.core.clientImpl.ClientContext;
3734
import org.apache.accumulo.core.clientImpl.thrift.TInfo;
3835
import org.apache.accumulo.core.data.Range;
@@ -52,6 +49,7 @@
5249
import org.apache.accumulo.core.trace.TraceUtil;
5350
import org.apache.accumulo.core.util.HostAndPortComparator;
5451
import org.apache.accumulo.core.util.threads.ThreadPools;
52+
import org.apache.accumulo.server.ServerContext;
5553
import org.apache.hadoop.io.Text;
5654
import org.apache.thrift.TException;
5755
import org.apache.thrift.TServiceClient;
@@ -66,12 +64,12 @@
6664
public class VerifyTabletAssignments {
6765
private static final Logger log = LoggerFactory.getLogger(VerifyTabletAssignments.class);
6866

69-
public static void execute(Properties clientProps, boolean verbose) throws Exception {
67+
public static void execute(ServerContext context, boolean verbose) throws Exception {
7068
Span span = TraceUtil.startSpan(VerifyTabletAssignments.class, "main");
7169
try (Scope scope = span.makeCurrent()) {
72-
try (AccumuloClient client = Accumulo.newClient().from(clientProps).build()) {
73-
for (String table : client.tableOperations().list()) {
74-
checkTable((ClientContext) client, verbose, table, null);
70+
try {
71+
for (String table : context.tableOperations().list()) {
72+
checkTable(context, verbose, table, null);
7573
}
7674
} finally {
7775
span.end();

test/src/main/java/org/apache/accumulo/test/TestBinaryRows.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.Map.Entry;
2626
import java.util.TreeSet;
2727

28+
import org.apache.accumulo.core.cli.ClientOpts;
2829
import org.apache.accumulo.core.client.Accumulo;
2930
import org.apache.accumulo.core.client.AccumuloClient;
3031
import org.apache.accumulo.core.client.BatchWriter;
@@ -35,7 +36,6 @@
3536
import org.apache.accumulo.core.data.Range;
3637
import org.apache.accumulo.core.data.Value;
3738
import org.apache.accumulo.core.util.TextUtil;
38-
import org.apache.accumulo.server.cli.ServerUtilOpts;
3939
import org.apache.hadoop.io.Text;
4040

4141
import com.beust.jcommander.Parameter;
@@ -80,7 +80,7 @@ static long decodeLong(byte[] ba) {
8080
return l;
8181
}
8282

83-
public static class Opts extends ServerUtilOpts {
83+
public static class Opts extends ClientOpts {
8484
@Parameter(names = "--mode",
8585
description = "either 'ingest', 'delete', 'randomLookups', 'split',"
8686
+ " 'verify', 'verifyDeleted'",

test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import java.util.concurrent.ExecutorService;
3737
import java.util.concurrent.Executors;
3838

39-
import org.apache.accumulo.core.client.Accumulo;
39+
import org.apache.accumulo.core.cli.ClientOpts.AuthConverter;
4040
import org.apache.accumulo.core.client.AccumuloClient;
4141
import org.apache.accumulo.core.client.Scanner;
4242
import org.apache.accumulo.core.clientImpl.ClientContext;
@@ -91,6 +91,9 @@ public class CollectTabletStats {
9191
private static final Logger log = LoggerFactory.getLogger(CollectTabletStats.class);
9292

9393
static class CollectOptions extends ServerUtilOpts {
94+
@Parameter(names = {"-auths", "--auths"}, converter = AuthConverter.class,
95+
description = "the authorizations to use when reading or writing")
96+
public Authorizations auths = Authorizations.EMPTY;
9497
@Parameter(names = {"-t", "--table"}, required = true, description = "table to use")
9598
String tableName;
9699
@Parameter(names = "--iterations", description = "number of iterations")
@@ -217,26 +220,24 @@ public int runTest() throws Exception {
217220
runTest("read tablet files w/ table iter stack", tests, opts.numThreads, threadPool);
218221
}
219222

220-
try (AccumuloClient client = Accumulo.newClient().from(opts.getClientProps()).build()) {
221-
for (int i = 0; i < opts.iterations; i++) {
222-
ArrayList<Test> tests = new ArrayList<>();
223-
for (final KeyExtent ke : tabletsToTest) {
224-
Test test = new Test(ke) {
225-
@Override
226-
public int runTest() throws Exception {
227-
return scanTablet(client, opts.tableName, opts.auths, ke.prevEndRow(), ke.endRow(),
228-
columns);
229-
}
230-
};
231-
tests.add(test);
232-
}
233-
runTest("read tablet data through accumulo", tests, opts.numThreads, threadPool);
223+
for (int i = 0; i < opts.iterations; i++) {
224+
ArrayList<Test> tests = new ArrayList<>();
225+
for (final KeyExtent ke : tabletsToTest) {
226+
Test test = new Test(ke) {
227+
@Override
228+
public int runTest() throws Exception {
229+
return scanTablet(context, opts.tableName, opts.auths, ke.prevEndRow(), ke.endRow(),
230+
columns);
231+
}
232+
};
233+
tests.add(test);
234234
}
235+
runTest("read tablet data through accumulo", tests, opts.numThreads, threadPool);
235236

236237
for (final KeyExtent ke : tabletsToTest) {
237238
threadPool.execute(() -> {
238239
try {
239-
calcTabletStats(client, opts.tableName, opts.auths, ke, columns);
240+
calcTabletStats(context, opts.tableName, opts.auths, ke, columns);
240241
} catch (Exception e) {
241242
log.error("Failed to calculate tablet stats.", e);
242243
}

0 commit comments

Comments
 (0)