use of org.apache.accumulo.core.spi.scan.ScanInfo 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);
}
}
use of org.apache.accumulo.core.spi.scan.ScanInfo in project accumulo by apache.
the class TabletServerResourceManager method createPriorityExecutor.
private ThreadPoolExecutor createPriorityExecutor(ScanExecutorConfig sec, Map<String, Queue<Runnable>> scanExecQueues) {
BlockingQueue<Runnable> queue;
if (sec.prioritizerClass.orElse("").isEmpty()) {
queue = new LinkedBlockingQueue<>();
} else {
ScanPrioritizer factory = null;
try {
factory = ConfigurationTypeHelper.getClassInstance(null, sec.prioritizerClass.get(), ScanPrioritizer.class);
} catch (Exception e) {
throw new RuntimeException(e);
}
if (factory == null) {
queue = new LinkedBlockingQueue<>();
} else {
Comparator<ScanInfo> comparator = factory.createComparator(new ScanPrioritizer.CreateParameters() {
private final ServiceEnvironment senv = new ServiceEnvironmentImpl(context);
@Override
public Map<String, String> getOptions() {
return sec.prioritizerOpts;
}
@Override
public ServiceEnvironment getServiceEnv() {
return senv;
}
});
// function to extract scan session from runnable
Function<Runnable, ScanInfo> extractor = r -> ((ScanSession.ScanMeasurer) TraceUtil.unwrap(r)).getScanInfo();
queue = new PriorityBlockingQueue<>(sec.maxThreads, Comparator.comparing(extractor, comparator));
}
}
scanExecQueues.put(sec.name, queue);
ThreadPoolExecutor es = ThreadPools.createThreadPool(sec.getCurrentMaxThreads(), sec.getCurrentMaxThreads(), 0L, TimeUnit.MILLISECONDS, "scan-" + sec.name, queue, sec.priority, true);
modifyThreadPoolSizesAtRuntime(sec::getCurrentMaxThreads, "scan-" + sec.name, es);
return es;
}
Aggregations