Search in sources :

Example 1 with ScanDispatch

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);
    }
}
Also used : ServiceEnvironment(org.apache.accumulo.core.spi.common.ServiceEnvironment) ServiceEnvironmentImpl(org.apache.accumulo.server.ServiceEnvironmentImpl) DispatchParameters(org.apache.accumulo.core.spi.scan.ScanDispatcher.DispatchParameters) ScanInfo(org.apache.accumulo.core.spi.scan.ScanInfo) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Collectors.toUnmodifiableMap(java.util.stream.Collectors.toUnmodifiableMap) ScanDispatch(org.apache.accumulo.core.spi.scan.ScanDispatch)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 Collectors.toUnmodifiableMap (java.util.stream.Collectors.toUnmodifiableMap)1 ServiceEnvironment (org.apache.accumulo.core.spi.common.ServiceEnvironment)1 ScanDispatch (org.apache.accumulo.core.spi.scan.ScanDispatch)1 DispatchParameters (org.apache.accumulo.core.spi.scan.ScanDispatcher.DispatchParameters)1 ScanInfo (org.apache.accumulo.core.spi.scan.ScanInfo)1 ServiceEnvironmentImpl (org.apache.accumulo.server.ServiceEnvironmentImpl)1