use of org.apache.accumulo.core.clientImpl.AccumuloServerException 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 = 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.isEmpty()) {
// 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, tserver);
} catch (AccumuloServerException e) {
log.trace("lookupTablets failed server={}", tserver, e);
throw e;
}
return MetadataLocationObtainer.getMetadataLocationEntries(results).getLocations();
}
use of org.apache.accumulo.core.clientImpl.AccumuloServerException in project accumulo by apache.
the class MetadataLocationObtainer method lookupTablet.
@Override
public TabletLocations lookupTablet(ClientContext context, TabletLocation src, Text row, Text stopRow, TabletLocator parent) throws AccumuloSecurityException, AccumuloException {
try {
OpTimer timer = null;
if (log.isTraceEnabled()) {
log.trace("tid={} Looking up in {} row={} extent={} tserver={}", Thread.currentThread().getId(), src.tablet_extent.tableId(), TextUtil.truncate(row), src.tablet_extent, src.tablet_location);
timer = new OpTimer().start();
}
Range range = new Range(row, true, stopRow, true);
TreeMap<Key, Value> encodedResults = new TreeMap<>();
TreeMap<Key, Value> results = new TreeMap<>();
// Use the whole row iterator so that a partial mutations is not read. The code that extracts
// locations for tablets does a sanity check to ensure there is
// only one location. Reading a partial mutation could make it appear there are multiple
// locations when there are not.
List<IterInfo> serverSideIteratorList = new ArrayList<>();
serverSideIteratorList.add(new IterInfo(10000, WholeRowIterator.class.getName(), "WRI"));
Map<String, Map<String, String>> serverSideIteratorOptions = Collections.emptyMap();
boolean more = ThriftScanner.getBatchFromServer(context, range, src.tablet_extent, src.tablet_location, encodedResults, locCols, serverSideIteratorList, serverSideIteratorOptions, Constants.SCAN_BATCH_SIZE, Authorizations.EMPTY, 0L, null);
decodeRows(encodedResults, results);
if (more && results.size() == 1) {
range = new Range(results.lastKey().followingKey(PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME), true, new Key(stopRow).followingKey(PartialKey.ROW), false);
encodedResults.clear();
more = ThriftScanner.getBatchFromServer(context, range, src.tablet_extent, src.tablet_location, encodedResults, locCols, serverSideIteratorList, serverSideIteratorOptions, Constants.SCAN_BATCH_SIZE, Authorizations.EMPTY, 0L, null);
decodeRows(encodedResults, results);
}
if (timer != null) {
timer.stop();
log.trace("tid={} Got {} results from {} in {}", Thread.currentThread().getId(), results.size(), src.tablet_extent, String.format("%.3f secs", timer.scale(SECONDS)));
}
return MetadataLocationObtainer.getMetadataLocationEntries(results);
} catch (AccumuloServerException ase) {
if (log.isTraceEnabled())
log.trace("{} lookup failed, {} server side exception", src.tablet_extent.tableId(), src.tablet_location);
throw ase;
} catch (AccumuloException e) {
if (log.isTraceEnabled())
log.trace("{} lookup failed", src.tablet_extent.tableId(), e);
parent.invalidateCache(context, src.tablet_location);
}
return null;
}
Aggregations