use of org.apache.accumulo.server.cli.ServerUtilOpts in project accumulo by apache.
the class MergeStats method main.
public static void main(String[] args) throws Exception {
ServerUtilOpts opts = new ServerUtilOpts();
opts.parseArgs(MergeStats.class.getName(), args);
Span span = TraceUtil.startSpan(MergeStats.class, "main");
try (Scope scope = span.makeCurrent()) {
try (AccumuloClient client = Accumulo.newClient().from(opts.getClientProps()).build()) {
Map<String, String> tableIdMap = client.tableOperations().tableIdMap();
ZooReaderWriter zooReaderWriter = opts.getServerContext().getZooReaderWriter();
for (Entry<String, String> entry : tableIdMap.entrySet()) {
final String table = entry.getKey(), tableId = entry.getValue();
String path = ZooUtil.getRoot(client.instanceOperations().getInstanceId()) + Constants.ZTABLES + "/" + tableId + "/merge";
MergeInfo info = new MergeInfo();
if (zooReaderWriter.exists(path)) {
byte[] data = zooReaderWriter.getData(path);
DataInputBuffer in = new DataInputBuffer();
in.reset(data, data.length);
info.readFields(in);
}
System.out.printf("%25s %10s %10s %s%n", table, info.getState(), info.getOperation(), info.getExtent());
}
}
} finally {
span.end();
}
}
use of org.apache.accumulo.server.cli.ServerUtilOpts in project accumulo by apache.
the class FindOfflineTablets method main.
public static void main(String[] args) throws Exception {
ServerUtilOpts opts = new ServerUtilOpts();
opts.parseArgs(FindOfflineTablets.class.getName(), args);
Span span = TraceUtil.startSpan(FindOfflineTablets.class, "main");
try (Scope scope = span.makeCurrent()) {
ServerContext context = opts.getServerContext();
findOffline(context, null);
} finally {
span.end();
}
}
use of org.apache.accumulo.server.cli.ServerUtilOpts in project accumulo by apache.
the class LocalityCheck method run.
public int run(String[] args) throws Exception {
ServerUtilOpts opts = new ServerUtilOpts();
opts.parseArgs(LocalityCheck.class.getName(), args);
Span span = TraceUtil.startSpan(LocalityCheck.class, "run");
try (Scope scope = span.makeCurrent()) {
VolumeManager fs = opts.getServerContext().getVolumeManager();
try (AccumuloClient accumuloClient = Accumulo.newClient().from(opts.getClientProps()).build()) {
Scanner scanner = accumuloClient.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
scanner.fetchColumnFamily(CurrentLocationColumnFamily.NAME);
scanner.fetchColumnFamily(DataFileColumnFamily.NAME);
scanner.setRange(TabletsSection.getRange());
Map<String, Long> totalBlocks = new HashMap<>();
Map<String, Long> localBlocks = new HashMap<>();
ArrayList<String> files = new ArrayList<>();
for (Entry<Key, Value> entry : scanner) {
Key key = entry.getKey();
if (key.compareColumnFamily(CurrentLocationColumnFamily.NAME) == 0) {
String location = entry.getValue().toString();
String[] parts = location.split(":");
String host = parts[0];
addBlocks(fs, host, files, totalBlocks, localBlocks);
files.clear();
} else if (key.compareColumnFamily(DataFileColumnFamily.NAME) == 0) {
files.add(TabletFileUtil.validate(key.getColumnQualifierData().toString()));
}
}
System.out.println(" Server %local total blocks");
for (Entry<String, Long> entry : totalBlocks.entrySet()) {
final String host = entry.getKey();
final Long blocksForHost = entry.getValue();
System.out.printf("%15s %5.1f %8d%n", host, localBlocks.get(host) * 100.0 / blocksForHost, blocksForHost);
}
}
return 0;
} finally {
span.end();
}
}
use of org.apache.accumulo.server.cli.ServerUtilOpts in project accumulo by apache.
the class CheckForMetadataProblems method main.
public static void main(String[] args) throws Exception {
opts = new ServerUtilOpts();
opts.parseArgs(CheckForMetadataProblems.class.getName(), args);
Span span = TraceUtil.startSpan(CheckForMetadataProblems.class, "main");
try (Scope scope = span.makeCurrent()) {
checkMetadataAndRootTableEntries(RootTable.NAME, opts);
System.out.println();
checkMetadataAndRootTableEntries(MetadataTable.NAME, opts);
if (sawProblems)
throw new RuntimeException();
} catch (Exception e) {
TraceUtil.setException(span, e, true);
throw e;
} finally {
span.end();
}
}
use of org.apache.accumulo.server.cli.ServerUtilOpts in project accumulo by apache.
the class ECAdmin method execute.
@SuppressFBWarnings(value = "DM_EXIT", justification = "System.exit okay for CLI tool")
@Override
public void execute(final String[] args) {
ServerUtilOpts opts = new ServerUtilOpts();
JCommander cl = new JCommander(opts);
cl.setProgramName("accumulo ec-admin");
CancelCommand cancelOps = new CancelCommand();
cl.addCommand("cancel", cancelOps);
ListCompactorsCommand listCompactorsOpts = new ListCompactorsCommand();
cl.addCommand("listCompactors", listCompactorsOpts);
RunningCommand runningOpts = new RunningCommand();
cl.addCommand("running", runningOpts);
cl.parse(args);
if (opts.help || cl.getParsedCommand() == null) {
cl.usage();
return;
}
ServerContext context = opts.getServerContext();
try {
if (cl.getParsedCommand().equals("listCompactors")) {
listCompactorsByQueue(context);
} else if (cl.getParsedCommand().equals("cancel")) {
cancelCompaction(context, cancelOps.ecid);
} else if (cl.getParsedCommand().equals("running")) {
runningCompactions(context, runningOpts.details);
} else {
log.error("Unknown command {}", cl.getParsedCommand());
cl.usage();
System.exit(1);
}
} catch (Exception e) {
log.error("{}", e.getMessage(), e);
System.exit(1);
} finally {
SingletonManager.setMode(Mode.CLOSED);
}
}
Aggregations