Span locateSpan = Trace.start("scan:locateTablet");
try {
loc = TabletLocator.getInstance(instance, scanState.tableName).locateTablet(scanState.startRow, scanState.skipStartRow, false, credentials);
if (loc == null) {
if (!Tables.exists(instance, scanState.tableName.toString()))
throw new TableDeletedException(scanState.tableName.toString());
else if (Tables.getTableState(instance, scanState.tableName.toString()) == TableState.OFFLINE)
throw new TableOfflineException(instance, scanState.tableName.toString());
error = "Failed to locate tablet for table : " + scanState.tableName + " row : " + scanState.startRow;
if (!error.equals(lastError))
log.debug(error);
else if (log.isTraceEnabled())
log.trace(error);
lastError = error;
UtilWaitThread.sleep(100);
} else {
// when a tablet splits we do want to continue scanning the low child
// of the split if we are already passed it
Range dataRange = loc.tablet_extent.toDataRange();
if (scanState.range.getStartKey() != null && dataRange.afterEndKey(scanState.range.getStartKey())) {
// go to the next tablet
scanState.startRow = loc.tablet_extent.getEndRow();
scanState.skipStartRow = true;
loc = null;
} else if (scanState.range.getEndKey() != null && dataRange.beforeStartKey(scanState.range.getEndKey())) {
// should not happen
throw new RuntimeException("Unexpected tablet, extent : " + loc.tablet_extent + " range : " + scanState.range + " startRow : "
+ scanState.startRow);
}
}
} catch (AccumuloServerException e) {
log.debug("Scan failed, server side exception : " + e.getMessage());
throw e;
} catch (AccumuloException e) {
error = "exception from tablet loc " + e.getMessage();
if (!error.equals(lastError))
log.debug(error);
else if (log.isTraceEnabled())
log.trace(error);
lastError = error;
UtilWaitThread.sleep(100);
} finally {
locateSpan.stop();
}
}
Span scanLocation = Trace.start("scan:location");
scanLocation.data("tserver", loc.tablet_location);
try {
results = scan(loc, scanState, conf);
} catch (AccumuloSecurityException e) {
Tables.clearCache(instance);
if (!Tables.exists(instance, scanState.tableName.toString()))
throw new TableDeletedException(scanState.tableName.toString());
throw e;
} catch (TApplicationException tae) {
throw new AccumuloServerException(loc.tablet_location, tae);
} catch (NotServingTabletException e) {
error = "Scan failed, not serving tablet " + loc;