Search in sources :

Example 1 with ServerUtilOpts

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();
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) MergeInfo(org.apache.accumulo.server.manager.state.MergeInfo) DataInputBuffer(org.apache.hadoop.io.DataInputBuffer) Scope(io.opentelemetry.context.Scope) ZooReaderWriter(org.apache.accumulo.fate.zookeeper.ZooReaderWriter) ServerUtilOpts(org.apache.accumulo.server.cli.ServerUtilOpts) Span(io.opentelemetry.api.trace.Span)

Example 2 with ServerUtilOpts

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();
    }
}
Also used : Scope(io.opentelemetry.context.Scope) ServerContext(org.apache.accumulo.server.ServerContext) ServerUtilOpts(org.apache.accumulo.server.cli.ServerUtilOpts) Span(io.opentelemetry.api.trace.Span)

Example 3 with ServerUtilOpts

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();
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) VolumeManager(org.apache.accumulo.server.fs.VolumeManager) Scanner(org.apache.accumulo.core.client.Scanner) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ServerUtilOpts(org.apache.accumulo.server.cli.ServerUtilOpts) Span(io.opentelemetry.api.trace.Span) Scope(io.opentelemetry.context.Scope) Value(org.apache.accumulo.core.data.Value) Key(org.apache.accumulo.core.data.Key)

Example 4 with ServerUtilOpts

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();
    }
}
Also used : Scope(io.opentelemetry.context.Scope) ServerUtilOpts(org.apache.accumulo.server.cli.ServerUtilOpts) Span(io.opentelemetry.api.trace.Span) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException)

Example 5 with ServerUtilOpts

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);
    }
}
Also used : ServerContext(org.apache.accumulo.server.ServerContext) JCommander(com.beust.jcommander.JCommander) ServerUtilOpts(org.apache.accumulo.server.cli.ServerUtilOpts) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

ServerUtilOpts (org.apache.accumulo.server.cli.ServerUtilOpts)5 Span (io.opentelemetry.api.trace.Span)4 Scope (io.opentelemetry.context.Scope)4 AccumuloClient (org.apache.accumulo.core.client.AccumuloClient)2 ServerContext (org.apache.accumulo.server.ServerContext)2 JCommander (com.beust.jcommander.JCommander)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Scanner (org.apache.accumulo.core.client.Scanner)1 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)1 Key (org.apache.accumulo.core.data.Key)1 Value (org.apache.accumulo.core.data.Value)1 ZooReaderWriter (org.apache.accumulo.fate.zookeeper.ZooReaderWriter)1 VolumeManager (org.apache.accumulo.server.fs.VolumeManager)1 MergeInfo (org.apache.accumulo.server.manager.state.MergeInfo)1 DataInputBuffer (org.apache.hadoop.io.DataInputBuffer)1