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();
}
}
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();
}
}
}
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();
}
}
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);
}
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);
}
}
Aggregations