Search in sources :

Example 1 with ClientOpts

use of org.apache.accumulo.server.cli.ClientOpts in project accumulo by apache.

the class LocalityCheck method run.

public int run(String[] args) throws Exception {
    ClientOpts opts = new ClientOpts();
    opts.parseArgs(LocalityCheck.class.getName(), args);
    VolumeManager fs = VolumeManagerImpl.get();
    Connector connector = opts.getConnector();
    Scanner scanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
    scanner.fetchColumnFamily(TabletsSection.CurrentLocationColumnFamily.NAME);
    scanner.fetchColumnFamily(DataFileColumnFamily.NAME);
    scanner.setRange(MetadataSchema.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(TabletsSection.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(fs.getFullPath(key).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.println(String.format("%15s %5.1f %8d", host, (localBlocks.get(host) * 100.) / blocksForHost, blocksForHost));
    }
    return 0;
}
Also used : VolumeManager(org.apache.accumulo.server.fs.VolumeManager) Connector(org.apache.accumulo.core.client.Connector) Scanner(org.apache.accumulo.core.client.Scanner) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ClientOpts(org.apache.accumulo.server.cli.ClientOpts) Value(org.apache.accumulo.core.data.Value) Key(org.apache.accumulo.core.data.Key)

Example 2 with ClientOpts

use of org.apache.accumulo.server.cli.ClientOpts in project accumulo by apache.

the class FindOfflineTablets method main.

public static void main(String[] args) throws Exception {
    ClientOpts opts = new ClientOpts();
    opts.parseArgs(FindOfflineTablets.class.getName(), args);
    Instance instance = opts.getInstance();
    AccumuloServerContext context = new AccumuloServerContext(instance, new ServerConfigurationFactory(opts.getInstance()));
    findOffline(context, null);
}
Also used : AccumuloServerContext(org.apache.accumulo.server.AccumuloServerContext) Instance(org.apache.accumulo.core.client.Instance) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) ServerConfigurationFactory(org.apache.accumulo.server.conf.ServerConfigurationFactory) ClientOpts(org.apache.accumulo.server.cli.ClientOpts)

Example 3 with ClientOpts

use of org.apache.accumulo.server.cli.ClientOpts in project accumulo by apache.

the class MergeStats method main.

public static void main(String[] args) throws Exception {
    ClientOpts opts = new ClientOpts();
    opts.parseArgs(MergeStats.class.getName(), args);
    Connector conn = opts.getConnector();
    Map<String, String> tableIdMap = conn.tableOperations().tableIdMap();
    for (Entry<String, String> entry : tableIdMap.entrySet()) {
        final String table = entry.getKey(), tableId = entry.getValue();
        String path = ZooUtil.getRoot(conn.getInstance().getInstanceID()) + Constants.ZTABLES + "/" + tableId + "/merge";
        MergeInfo info = new MergeInfo();
        if (ZooReaderWriter.getInstance().exists(path)) {
            byte[] data = ZooReaderWriter.getInstance().getData(path, new Stat());
            DataInputBuffer in = new DataInputBuffer();
            in.reset(data, data.length);
            info.readFields(in);
        }
        System.out.println(String.format("%25s  %10s %10s %s", table, info.getState(), info.getOperation(), info.getExtent()));
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) MergeInfo(org.apache.accumulo.server.master.state.MergeInfo) Stat(org.apache.zookeeper.data.Stat) DataInputBuffer(org.apache.hadoop.io.DataInputBuffer) ClientOpts(org.apache.accumulo.server.cli.ClientOpts)

Example 4 with ClientOpts

use of org.apache.accumulo.server.cli.ClientOpts in project accumulo by apache.

the class CheckForMetadataProblems method main.

public static void main(String[] args) throws Exception {
    ClientOpts opts = new ClientOpts();
    opts.parseArgs(CheckForMetadataProblems.class.getName(), args);
    VolumeManager fs = VolumeManagerImpl.get();
    checkMetadataAndRootTableEntries(RootTable.NAME, opts, fs);
    checkMetadataAndRootTableEntries(MetadataTable.NAME, opts, fs);
    opts.stopTracing();
    if (sawProblems)
        throw new RuntimeException();
}
Also used : VolumeManager(org.apache.accumulo.server.fs.VolumeManager) ClientOpts(org.apache.accumulo.server.cli.ClientOpts)

Example 5 with ClientOpts

use of org.apache.accumulo.server.cli.ClientOpts in project accumulo by apache.

the class ListTables method main.

public static void main(String[] args) throws Exception {
    ClientOpts opts = new ClientOpts();
    opts.parseArgs(ListTables.class.getName(), args);
    for (Entry<String, Table.ID> table : Tables.getNameToIdMap(opts.getInstance()).entrySet()) System.out.println(table.getKey() + " => " + table.getValue());
}
Also used : ClientOpts(org.apache.accumulo.server.cli.ClientOpts)

Aggregations

ClientOpts (org.apache.accumulo.server.cli.ClientOpts)5 Connector (org.apache.accumulo.core.client.Connector)2 VolumeManager (org.apache.accumulo.server.fs.VolumeManager)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Instance (org.apache.accumulo.core.client.Instance)1 Scanner (org.apache.accumulo.core.client.Scanner)1 Key (org.apache.accumulo.core.data.Key)1 Value (org.apache.accumulo.core.data.Value)1 AccumuloServerContext (org.apache.accumulo.server.AccumuloServerContext)1 ServerConfigurationFactory (org.apache.accumulo.server.conf.ServerConfigurationFactory)1 MergeInfo (org.apache.accumulo.server.master.state.MergeInfo)1 TServerInstance (org.apache.accumulo.server.master.state.TServerInstance)1 DataInputBuffer (org.apache.hadoop.io.DataInputBuffer)1 Stat (org.apache.zookeeper.data.Stat)1