use of org.apache.accumulo.core.client.impl.ScannerOptions in project accumulo by apache.
the class MetadataLocationObtainer method lookupTablets.
@Override
public List<TabletLocation> lookupTablets(ClientContext context, String tserver, Map<KeyExtent, List<Range>> tabletsRanges, TabletLocator parent) throws AccumuloSecurityException, AccumuloException {
final TreeMap<Key, Value> results = new TreeMap<>();
ResultReceiver rr = new ResultReceiver() {
@Override
public void receive(List<Entry<Key, Value>> entries) {
for (Entry<Key, Value> entry : entries) {
try {
results.putAll(WholeRowIterator.decodeRow(entry.getKey(), entry.getValue()));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
};
ScannerOptions opts = null;
try (SettableScannerOptions unsetOpts = new SettableScannerOptions()) {
opts = unsetOpts.setColumns(locCols);
}
Map<KeyExtent, List<Range>> unscanned = new HashMap<>();
Map<KeyExtent, List<Range>> failures = new HashMap<>();
try {
TabletServerBatchReaderIterator.doLookup(context, tserver, tabletsRanges, failures, unscanned, rr, columns, opts, Authorizations.EMPTY);
if (failures.size() > 0) {
// invalidate extents in parents cache
if (log.isTraceEnabled())
log.trace("lookupTablets failed for {} extents", failures.size());
parent.invalidateCache(failures.keySet());
}
} catch (IOException e) {
log.trace("lookupTablets failed server={}", tserver, e);
parent.invalidateCache(context.getInstance(), tserver);
} catch (AccumuloServerException e) {
log.trace("lookupTablets failed server={}", tserver, e);
throw e;
}
return MetadataLocationObtainer.getMetadataLocationEntries(results).getLocations();
}
use of org.apache.accumulo.core.client.impl.ScannerOptions in project vertexium by visallo.
the class AccumuloGraphLogger method logStartIterator.
public void logStartIterator(ScannerBase scanner) {
if (!queryLogger.isTraceEnabled()) {
return;
}
SortedSet<Column> fetchedColumns = null;
if (scanner instanceof ScannerOptions) {
fetchedColumns = ((ScannerOptions) scanner).getFetchedColumns();
}
String table = null;
try {
Field tableField = scanner.getClass().getDeclaredField("table");
tableField.setAccessible(true);
Object tableObj = tableField.get(scanner);
if (tableObj instanceof String) {
table = (String) tableObj;
} else {
table = tableObj.toString();
}
} catch (Exception e) {
queryLogger.trace("Could not get table name from scanner", e);
}
if (scanner instanceof BatchScanner) {
try {
Field rangesField = scanner.getClass().getDeclaredField("ranges");
rangesField.setAccessible(true);
ArrayList<Range> ranges = (ArrayList<Range>) rangesField.get(scanner);
if (ranges.size() == 0) {
logStartIterator(table, (Range) null, fetchedColumns);
} else if (ranges.size() == 1) {
logStartIterator(table, ranges.iterator().next(), fetchedColumns);
} else {
logStartIterator(table, ranges, fetchedColumns);
}
} catch (Exception e) {
queryLogger.trace("Could not get ranges from BatchScanner", e);
}
} else if (scanner instanceof Scanner) {
Range range = ((Scanner) scanner).getRange();
logStartIterator(table, range, fetchedColumns);
} else {
queryLogger.trace("begin accumulo iterator: %s", scanner.getClass().getName());
}
}
Aggregations