Search in sources :

Example 81 with AccumuloClient

use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.

the class RandomWriter method main.

public static void main(String[] args) throws Exception {
    Opts opts = new Opts();
    opts.principal = "root";
    opts.parseArgs(RandomWriter.class.getName(), args);
    Span span = TraceUtil.startSpan(RandomWriter.class, "main");
    try (Scope scope = span.makeCurrent()) {
        long start = System.currentTimeMillis();
        Properties clientProps = opts.getClientProps();
        String principal = ClientProperty.AUTH_PRINCIPAL.getValue(clientProps);
        log.info("starting at {} for user {}", start, principal);
        try (AccumuloClient accumuloClient = Accumulo.newClient().from(clientProps).build();
            BatchWriter bw = accumuloClient.createBatchWriter(opts.tableName)) {
            log.info("Writing {} mutations...", opts.count);
            bw.addMutations(new RandomMutationGenerator(opts.count));
        } catch (Exception e) {
            log.error("{}", e.getMessage(), e);
            throw e;
        }
        long stop = System.currentTimeMillis();
        log.info("stopping at {}", stop);
        log.info("elapsed: {}", (((double) stop - (double) start) / 1000.0));
    } finally {
        span.end();
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) Scope(io.opentelemetry.context.Scope) ClientOpts(org.apache.accumulo.core.cli.ClientOpts) BatchWriter(org.apache.accumulo.core.client.BatchWriter) Properties(java.util.Properties) Span(io.opentelemetry.api.trace.Span)

Example 82 with AccumuloClient

use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.

the class TableDiskUsage method main.

public static void main(String[] args) throws Exception {
    Opts opts = new Opts();
    opts.parseArgs(TableDiskUsage.class.getName(), args);
    Span span = TraceUtil.startSpan(TableDiskUsage.class, "main");
    try (Scope scope = span.makeCurrent()) {
        try (AccumuloClient client = Accumulo.newClient().from(opts.getClientProps()).build()) {
            VolumeManager fs = opts.getServerContext().getVolumeManager();
            org.apache.accumulo.server.util.TableDiskUsage.printDiskUsage(opts.tables, fs, client, false);
        } finally {
            span.end();
        }
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) VolumeManager(org.apache.accumulo.server.fs.VolumeManager) Scope(io.opentelemetry.context.Scope) ServerUtilOpts(org.apache.accumulo.server.cli.ServerUtilOpts) Span(io.opentelemetry.api.trace.Span)

Example 83 with AccumuloClient

use of org.apache.accumulo.core.client.AccumuloClient 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 84 with AccumuloClient

use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.

the class Upgrader9to10 method upgradeRelativePaths.

/**
 * Remove all file entries containing relative paths and replace them with absolute URI paths.
 * Absolute paths are resolved by prefixing relative paths with a volume configured by the user in
 * the instance.volumes.upgrade.relative property, which is only used during an upgrade. If any
 * relative paths are found and this property is not configured, or if any resolved absolute path
 * does not correspond to a file that actually exists, the upgrade step fails and aborts without
 * making changes. See the property {@link Property#INSTANCE_VOLUMES_UPGRADE_RELATIVE} and the
 * pull request <a href="https://github.com/apache/accumulo/pull/1461">#1461</a>.
 */
public static void upgradeRelativePaths(ServerContext context, Ample.DataLevel level) {
    String tableName = level.metaTable();
    AccumuloClient c = context;
    VolumeManager fs = context.getVolumeManager();
    String upgradeProp = context.getConfiguration().get(Property.INSTANCE_VOLUMES_UPGRADE_RELATIVE);
    // constructed from the upgrade property + relative path
    if (checkForRelativePaths(c, fs, tableName, upgradeProp)) {
        log.info("Relative Tablet File paths exist in {}, replacing with absolute using {}", tableName, upgradeProp);
    } else {
        log.info("No relative paths found in {} during upgrade.", tableName);
        return;
    }
    // second pass, create atomic mutations to replace the relative path
    replaceRelativePaths(c, fs, tableName, upgradeProp);
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) VolumeManager(org.apache.accumulo.server.fs.VolumeManager)

Example 85 with AccumuloClient

use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.

the class Upgrader9to10 method upgradeFileDeletes.

/**
 * Improve how Delete markers are stored. For more information see:
 * <a href="https://github.com/apache/accumulo/issues/1043">#1043</a>
 * <a href="https://github.com/apache/accumulo/pull/1366">#1366</a>
 */
public void upgradeFileDeletes(ServerContext context, Ample.DataLevel level) {
    String tableName = level.metaTable();
    AccumuloClient c = context;
    Ample ample = context.getAmple();
    // find all deletes
    try (BatchWriter writer = c.createBatchWriter(tableName)) {
        log.info("looking for candidates in table {}", tableName);
        Iterator<String> oldCandidates = getOldCandidates(context, tableName);
        String upgradeProp = context.getConfiguration().get(Property.INSTANCE_VOLUMES_UPGRADE_RELATIVE);
        while (oldCandidates.hasNext()) {
            List<String> deletes = readCandidatesInBatch(oldCandidates);
            log.info("found {} deletes to upgrade", deletes.size());
            for (String olddelete : deletes) {
                // create new formatted delete
                log.trace("upgrading delete entry for {}", olddelete);
                Path absolutePath = resolveRelativeDelete(olddelete, upgradeProp);
                String updatedDel = switchToAllVolumes(absolutePath);
                writer.addMutation(ample.createDeleteMutation(updatedDel));
            }
            writer.flush();
            // if nothing thrown then we're good so mark all deleted
            log.info("upgrade processing completed so delete old entries");
            for (String olddelete : deletes) {
                log.trace("deleting old entry for {}", olddelete);
                writer.addMutation(deleteOldDeleteMutation(olddelete));
            }
            writer.flush();
        }
    } catch (TableNotFoundException | MutationsRejectedException e) {
        throw new RuntimeException(e);
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) Path(org.apache.hadoop.fs.Path) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) Ample(org.apache.accumulo.core.metadata.schema.Ample) BatchWriter(org.apache.accumulo.core.client.BatchWriter) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException)

Aggregations

AccumuloClient (org.apache.accumulo.core.client.AccumuloClient)500 Test (org.junit.Test)411 BatchWriter (org.apache.accumulo.core.client.BatchWriter)149 Text (org.apache.hadoop.io.Text)143 Mutation (org.apache.accumulo.core.data.Mutation)138 Scanner (org.apache.accumulo.core.client.Scanner)122 Value (org.apache.accumulo.core.data.Value)118 Key (org.apache.accumulo.core.data.Key)108 NewTableConfiguration (org.apache.accumulo.core.client.admin.NewTableConfiguration)91 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)64 HashMap (java.util.HashMap)61 Range (org.apache.accumulo.core.data.Range)51 TreeSet (java.util.TreeSet)50 ArrayList (java.util.ArrayList)47 Entry (java.util.Map.Entry)41 Path (org.apache.hadoop.fs.Path)39 CompactionConfig (org.apache.accumulo.core.client.admin.CompactionConfig)34 Authorizations (org.apache.accumulo.core.security.Authorizations)34 BatchScanner (org.apache.accumulo.core.client.BatchScanner)32 HashSet (java.util.HashSet)31