use of org.apache.accumulo.core.spi.scan.ScanDispatch in project accumulo by apache.
the class TabletServerResourceManager method executeReadAhead.
public void executeReadAhead(KeyExtent tablet, ScanDispatcher dispatcher, ScanSession scanInfo, Runnable task) {
task = ScanSession.wrap(scanInfo, task);
if (tablet.isRootTablet()) {
// TODO make meta dispatch??
scanInfo.scanParams.setScanDispatch(ScanDispatch.builder().build());
task.run();
} else if (tablet.isMeta()) {
// TODO make meta dispatch??
scanInfo.scanParams.setScanDispatch(ScanDispatch.builder().build());
scanExecutors.get("meta").execute(task);
} else {
DispatchParameters params = new DispatchParamsImpl() {
// in scan critical path so only create ServiceEnv if needed
private final Supplier<ServiceEnvironment> senvSupplier = Suppliers.memoize(() -> new ServiceEnvironmentImpl(context));
@Override
public ScanInfo getScanInfo() {
return scanInfo;
}
@Override
public Map<String, ScanExecutor> getScanExecutors() {
return scanExecutorChoices;
}
@Override
public ServiceEnvironment getServiceEnv() {
return senvSupplier.get();
}
};
ScanDispatch prefs = dispatcher.dispatch(params);
scanInfo.scanParams.setScanDispatch(prefs);
ThreadPoolExecutor executor = scanExecutors.get(prefs.getExecutorName());
if (executor == null) {
log.warn("For table id {}, {} dispatched to non-existent executor {} Using default executor.", tablet.tableId(), dispatcher.getClass().getName(), prefs.getExecutorName());
executor = scanExecutors.get(SimpleScanDispatcher.DEFAULT_SCAN_EXECUTOR_NAME);
} else if ("meta".equals(prefs.getExecutorName())) {
log.warn("For table id {}, {} dispatched to meta executor. Using default executor.", tablet.tableId(), dispatcher.getClass().getName());
executor = scanExecutors.get(SimpleScanDispatcher.DEFAULT_SCAN_EXECUTOR_NAME);
}
executor.execute(task);
}
}
Aggregations