@Override public void execute(Runnable command) { if (Thread.currentThread().getClass() == PartitionOperationThread.class) { // instead of offloading it to another thread, we run on the partition thread. This will speed up throughput. command.run(); } else { ExecutionService executionService = nodeEngine.getExecutionService(); Executor executor = executionService.getExecutor(ExecutionService.ASYNC_EXECUTOR); executor.execute(command); } }
@SuppressWarnings("unchecked") private void executeReadOnlyEntryProcessor(final Object oldValue, String executorName) { executionService.execute(executorName, new Runnable() { @Override public void run() { try { Data result = operator(EntryOperation.this, entryProcessor) .operateOnKeyValue(dataKey, oldValue).getResult(); sendResponse(result); } catch (Throwable t) { sendResponse(t); } } }); }
public NodeQueryCacheScheduler(MapServiceContext mapServiceContext) { executionService = getExecutionService(mapServiceContext); executorName = EXECUTOR_NAME_PREFIX + UuidUtil.newUnsecureUuidString(); executionService.register(executorName, 1, EXECUTOR_DEFAULT_QUEUE_CAPACITY, ExecutorType.CACHED); taskScheduler = executionService.getTaskScheduler(executorName); }
private void scheduleNewExecution(long now) { future = executionService.schedule(runnable, delay, TimeUnit.MILLISECONDS); hardLimit = now + maxDelay; } }
private EntryTaskScheduler<Data, Integer> createScheduler(ObjectNamespace namespace) { NodeEngine nodeEngine = lockService.getNodeEngine(); LockEvictionProcessor entryProcessor = new LockEvictionProcessor(nodeEngine, namespace); TaskScheduler globalScheduler = nodeEngine.getExecutionService().getGlobalTaskScheduler(); return EntryTaskSchedulerFactory.newScheduler(globalScheduler, entryProcessor, ScheduleType.FOR_EACH); }
public void start() { executionService.scheduleWithRepetition(this, HEART_BEAT_CHECK_INTERVAL_SECONDS, HEART_BEAT_CHECK_INTERVAL_SECONDS, SECONDS); }
@Override public void shutdown() { executionService.shutdownExecutor(executorName); } }
@Override public void init(NodeEngine nodeEngine, Properties properties) { long mergeFirstRunDelayMs = node.getProperties().getPositiveMillisOrDefault(GroupProperty.MERGE_FIRST_RUN_DELAY_SECONDS, DEFAULT_MERGE_RUN_DELAY_MILLIS); ExecutionService executionService = nodeEngine.getExecutionService(); executionService.register(EXECUTOR_NAME, 2, CLUSTER_EXECUTOR_QUEUE_CAPACITY, ExecutorType.CACHED); long mergeNextRunDelayMs = node.getProperties().getPositiveMillisOrDefault(GroupProperty.MERGE_NEXT_RUN_DELAY_SECONDS, DEFAULT_MERGE_RUN_DELAY_MILLIS); executionService.scheduleWithRepetition(EXECUTOR_NAME, new SplitBrainHandler(node), mergeFirstRunDelayMs, mergeNextRunDelayMs, TimeUnit.MILLISECONDS); membershipManager.init(); clusterHeartbeatManager.init(); }
/** * Triggers key loading if there is no ongoing key loading task, otherwise * does nothing. The actual loading is done on the * {@link ExecutionService#MAP_LOAD_ALL_KEYS_EXECUTOR} executor. * The loaded keys will be dispatched to partition owners for value loading. * * @param mapStoreContext the map store context for this map * @param replaceExistingValues if the existing entries for the loaded keys should be replaced * @return a future representing pending completion of the key loading task * @see MapLoader#loadAllKeys() * @see #sendKeysInBatches(MapStoreContext, boolean) */ private Future<?> sendKeys(final MapStoreContext mapStoreContext, final boolean replaceExistingValues) { if (keyLoadFinished.isDone()) { keyLoadFinished = new LoadFinishedFuture(); Future<Boolean> sent = execService.submit(MAP_LOAD_ALL_KEYS_EXECUTOR, new Callable<Boolean>() { @Override public Boolean call() throws Exception { sendKeysInBatches(mapStoreContext, replaceExistingValues); return false; } }); execService.asCompletableFuture(sent).andThen(keyLoadFinished); } return keyLoadFinished; }
private Executor newBlockingExecutor() { final ExecutionService executionService = nodeEngine.getExecutionService(); int coreSize = Runtime.getRuntime().availableProcessors(); int threadCount = node.getProperties().getInteger(GroupProperty.CLIENT_ENGINE_BLOCKING_THREAD_COUNT); if (threadCount <= 0) { threadCount = coreSize * BLOCKING_THREADS_PER_CORE; } logger.finest("Creating new client executor for blocking tasks with threadCount=" + threadCount); return executionService.register(ExecutionService.CLIENT_BLOCKING_EXECUTOR, threadCount, coreSize * EXECUTOR_QUEUE_CAPACITY_PER_CORE, ExecutorType.CONCRETE); }
private Future<?> executeTask(String executorName, Callable task) { return getExecutionService().submit(executorName, task); }
private void scheduleNewExecution(long now) { future = executionService.schedule(runnable, delay, TimeUnit.MILLISECONDS); hardLimit = now + maxDelay; } }
private EntryTaskScheduler<Data, Integer> createScheduler(ObjectNamespace namespace) { NodeEngine nodeEngine = lockService.getNodeEngine(); LockEvictionProcessor entryProcessor = new LockEvictionProcessor(nodeEngine, namespace); TaskScheduler globalScheduler = nodeEngine.getExecutionService().getGlobalTaskScheduler(); return EntryTaskSchedulerFactory.newScheduler(globalScheduler, entryProcessor, ScheduleType.FOR_EACH); }
public void start() { executionService.scheduleWithRepetition(this, HEART_BEAT_CHECK_INTERVAL_SECONDS, HEART_BEAT_CHECK_INTERVAL_SECONDS, SECONDS); }
@Override public void shutdown() { executionService.shutdownExecutor(executorName); } }
@Override public void init(NodeEngine nodeEngine, Properties properties) { long mergeFirstRunDelayMs = node.getProperties().getPositiveMillisOrDefault(GroupProperty.MERGE_FIRST_RUN_DELAY_SECONDS, DEFAULT_MERGE_RUN_DELAY_MILLIS); ExecutionService executionService = nodeEngine.getExecutionService(); executionService.register(EXECUTOR_NAME, 2, CLUSTER_EXECUTOR_QUEUE_CAPACITY, ExecutorType.CACHED); long mergeNextRunDelayMs = node.getProperties().getPositiveMillisOrDefault(GroupProperty.MERGE_NEXT_RUN_DELAY_SECONDS, DEFAULT_MERGE_RUN_DELAY_MILLIS); executionService.scheduleWithRepetition(EXECUTOR_NAME, new SplitBrainHandler(node), mergeFirstRunDelayMs, mergeNextRunDelayMs, TimeUnit.MILLISECONDS); membershipManager.init(); clusterHeartbeatManager.init(); }
/** * Triggers key loading if there is no ongoing key loading task, otherwise * does nothing. The actual loading is done on the * {@link ExecutionService#MAP_LOAD_ALL_KEYS_EXECUTOR} executor. * The loaded keys will be dispatched to partition owners for value loading. * * @param mapStoreContext the map store context for this map * @param replaceExistingValues if the existing entries for the loaded keys should be replaced * @return a future representing pending completion of the key loading task * @see MapLoader#loadAllKeys() * @see #sendKeysInBatches(MapStoreContext, boolean) */ private Future<?> sendKeys(final MapStoreContext mapStoreContext, final boolean replaceExistingValues) { if (keyLoadFinished.isDone()) { keyLoadFinished = new LoadFinishedFuture(); Future<Boolean> sent = execService.submit(MAP_LOAD_ALL_KEYS_EXECUTOR, new Callable<Boolean>() { @Override public Boolean call() throws Exception { sendKeysInBatches(mapStoreContext, replaceExistingValues); return false; } }); execService.asCompletableFuture(sent).andThen(keyLoadFinished); } return keyLoadFinished; }
private Executor newClientExecutor() { final ExecutionService executionService = nodeEngine.getExecutionService(); int coreSize = RuntimeAvailableProcessors.get(); int threadCount = node.getProperties().getInteger(GroupProperty.CLIENT_ENGINE_THREAD_COUNT); if (threadCount <= 0) { threadCount = coreSize * THREADS_PER_CORE; } logger.finest("Creating new client executor with threadCount=" + threadCount); return executionService.register(ExecutionService.CLIENT_EXECUTOR, threadCount, coreSize * EXECUTOR_QUEUE_CAPACITY_PER_CORE, ExecutorType.CONCRETE); }
private Future<?> executeTask(String executorName, Callable task) { return getExecutionService().submit(executorName, task); }
@Override public void execute(Runnable command) { if (Thread.currentThread().getClass() == PartitionOperationThread.class) { // instead of offloading it to another thread, we run on the partition thread. This will speed up throughput. command.run(); } else { ExecutionService executionService = nodeEngine.getExecutionService(); Executor executor = executionService.getExecutor(ExecutionService.ASYNC_EXECUTOR); executor.execute(command); } }