Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,17 @@
*/
package org.apache.accumulo.server.cli;

import org.apache.accumulo.core.cli.ClientOpts;
import org.apache.accumulo.core.clientImpl.ClientInfo;
import org.apache.accumulo.core.cli.Help;
import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.server.ServerContext;

public class ServerUtilOpts extends ClientOpts {
public class ServerUtilOpts extends Help {

private ServerContext context;

public synchronized ServerContext getServerContext() {
if (context == null) {
context = getClientConfigFile() == null ? new ServerContext(SiteConfiguration.auto())
: ServerContext.withClientInfo(SiteConfiguration.auto(),
ClientInfo.from(getClientProps()));
context = new ServerContext(SiteConfiguration.auto());
}
return context;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ public void execute(final String[] args) {
} else if (cl.getParsedCommand().equals("volumes")) {
ListVolumesUsed.listVolumes(context);
} else if (cl.getParsedCommand().equals("verifyTabletAssigns")) {
VerifyTabletAssignments.execute(opts.getClientProps(), verifyTabletAssignmentsOpts.verbose);
VerifyTabletAssignments.execute(context, verifyTabletAssignmentsOpts.verbose);
} else if (cl.getParsedCommand().equals("changeSecret")) {
ChangeSecret.execute(context, conf);
} else if (cl.getParsedCommand().equals("deleteZooInstance")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import java.util.TreeSet;
import java.util.function.Consumer;

import org.apache.accumulo.core.client.Accumulo;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.data.Key;
Expand Down Expand Up @@ -124,8 +122,8 @@ public static boolean checkMetadataAndRootTableEntries(String tableNameToCheck,
Map<TableId,TreeSet<KeyExtent>> tables = new HashMap<>();
boolean sawProblems = false;

try (AccumuloClient client = Accumulo.newClient().from(opts.getClientProps()).build();
Scanner scanner = client.createScanner(tableNameToCheck, Authorizations.EMPTY)) {
try (Scanner scanner =
opts.getServerContext().createScanner(tableNameToCheck, Authorizations.EMPTY)) {

scanner.setRange(TabletsSection.getRange());
TabletColumnFamily.PREV_ROW_COLUMN.fetch(scanner);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.TreeMap;
import java.util.TreeSet;

import org.apache.accumulo.core.cli.ClientOpts;
import org.apache.accumulo.core.client.Accumulo;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.TableNotFoundException;
Expand All @@ -45,7 +46,6 @@
import org.apache.accumulo.core.metadata.schema.DataFileValue;
import org.apache.accumulo.core.trace.TraceUtil;
import org.apache.accumulo.core.util.NumUtil;
import org.apache.accumulo.server.cli.ServerUtilOpts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -319,7 +319,7 @@ public static void printDiskUsage(Collection<String> tableNames, AccumuloClient
}
}

static class Opts extends ServerUtilOpts {
static class Opts extends ClientOpts {
@Parameter(required = true, description = " <table> { <table> ... } ")
List<String> tables = new ArrayList<>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.TreeMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;

import org.apache.accumulo.core.client.Accumulo;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.clientImpl.ClientContext;
import org.apache.accumulo.core.clientImpl.thrift.TInfo;
import org.apache.accumulo.core.data.Range;
Expand All @@ -52,6 +49,7 @@
import org.apache.accumulo.core.trace.TraceUtil;
import org.apache.accumulo.core.util.HostAndPortComparator;
import org.apache.accumulo.core.util.threads.ThreadPools;
import org.apache.accumulo.server.ServerContext;
import org.apache.hadoop.io.Text;
import org.apache.thrift.TException;
import org.apache.thrift.TServiceClient;
Expand All @@ -66,12 +64,12 @@
public class VerifyTabletAssignments {
private static final Logger log = LoggerFactory.getLogger(VerifyTabletAssignments.class);

public static void execute(Properties clientProps, boolean verbose) throws Exception {
public static void execute(ServerContext context, boolean verbose) throws Exception {
Span span = TraceUtil.startSpan(VerifyTabletAssignments.class, "main");
try (Scope scope = span.makeCurrent()) {
try (AccumuloClient client = Accumulo.newClient().from(clientProps).build()) {
for (String table : client.tableOperations().list()) {
checkTable((ClientContext) client, verbose, table, null);
try {
for (String table : context.tableOperations().list()) {
checkTable(context, verbose, table, null);
}
} finally {
span.end();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Map.Entry;
import java.util.TreeSet;

import org.apache.accumulo.core.cli.ClientOpts;
import org.apache.accumulo.core.client.Accumulo;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
Expand All @@ -35,7 +36,6 @@
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.ServerUtilOpts;
import org.apache.hadoop.io.Text;

import com.beust.jcommander.Parameter;
Expand Down Expand Up @@ -80,7 +80,7 @@ static long decodeLong(byte[] ba) {
return l;
}

public static class Opts extends ServerUtilOpts {
public static class Opts extends ClientOpts {
@Parameter(names = "--mode",
description = "either 'ingest', 'delete', 'randomLookups', 'split',"
+ " 'verify', 'verifyDeleted'",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

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

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

try (AccumuloClient client = Accumulo.newClient().from(opts.getClientProps()).build()) {
for (int i = 0; i < opts.iterations; i++) {
ArrayList<Test> tests = new ArrayList<>();
for (final KeyExtent ke : tabletsToTest) {
Test test = new Test(ke) {
@Override
public int runTest() throws Exception {
return scanTablet(client, opts.tableName, opts.auths, ke.prevEndRow(), ke.endRow(),
columns);
}
};
tests.add(test);
}
runTest("read tablet data through accumulo", tests, opts.numThreads, threadPool);
for (int i = 0; i < opts.iterations; i++) {
ArrayList<Test> tests = new ArrayList<>();
for (final KeyExtent ke : tabletsToTest) {
Test test = new Test(ke) {
@Override
public int runTest() throws Exception {
return scanTablet(context, opts.tableName, opts.auths, ke.prevEndRow(), ke.endRow(),
columns);
}
};
tests.add(test);
}
runTest("read tablet data through accumulo", tests, opts.numThreads, threadPool);

for (final KeyExtent ke : tabletsToTest) {
threadPool.execute(() -> {
try {
calcTabletStats(client, opts.tableName, opts.auths, ke, columns);
calcTabletStats(context, opts.tableName, opts.auths, ke, columns);
} catch (Exception e) {
log.error("Failed to calculate tablet stats.", e);
}
Expand Down
Loading