use of com.hazelcast.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.
the class CacheServiceTest method setup.
@Before
public void setup() {
// setup mocks
ExecutionService executionService = mock(ExecutionService.class);
ManagedExecutorService executorService = mock(ManagedExecutorService.class);
when(executionService.getExecutor(anyString())).thenReturn(executorService);
mockNodeEngine = Mockito.mock(NodeEngine.class);
when(mockNodeEngine.getLogger(any(Class.class))).thenReturn(Logger.getLogger(CacheServiceTest.class));
when(mockNodeEngine.getExecutionService()).thenReturn(executionService);
latch = new CountDownLatch(1);
}
use of com.hazelcast.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.
the class CacheProxySupport method createAndSubmitLoadAllTask.
@SuppressWarnings("unchecked")
protected void createAndSubmitLoadAllTask(Set<Data> keysData, boolean replaceExistingValues, CompletionListener completionListener) {
try {
CacheProxyLoadAllTask loadAllTask = new CacheProxyLoadAllTask(getNodeEngine(), operationProvider, keysData, replaceExistingValues, completionListener, getServiceName());
ExecutionService executionService = getNodeEngine().getExecutionService();
final CompletableFutureTask<Object> future = (CompletableFutureTask<Object>) executionService.submit("loadAll-" + nameWithPrefix, loadAllTask);
loadAllTasks.add(future);
future.whenCompleteAsync((response, t) -> {
loadAllTasks.remove(future);
if (t != null) {
logger.warning("Problem in loadAll task", t);
}
});
} catch (Exception e) {
if (completionListener != null) {
completionListener.onException(e);
}
throw new CacheException(e);
}
}
use of com.hazelcast.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.
the class ClientEngineImpl method newClientExecutor.
private Executor newClientExecutor() {
// if user code deployment is enabled, we need more thread per core since operations can do blocking tasks
// to load classes from other members
boolean userCodeDeploymentEnabled = nodeEngine.getConfig().getUserCodeDeploymentConfig().isEnabled();
int threadsPerCore = userCodeDeploymentEnabled ? BLOCKING_THREADS_PER_CORE : THREADS_PER_CORE;
final ExecutionService executionService = nodeEngine.getExecutionService();
int coreSize = RuntimeAvailableProcessors.get();
int threadCount = node.getProperties().getInteger(ClusterProperty.CLIENT_ENGINE_THREAD_COUNT);
if (threadCount <= 0) {
threadCount = coreSize * threadsPerCore;
}
logger.finest("Creating new client executor with threadCount=" + threadCount);
// to load classes from other members
if (userCodeDeploymentEnabled) {
return executionService.register(ExecutionService.CLIENT_EXECUTOR, threadCount, coreSize * EXECUTOR_QUEUE_CAPACITY_PER_CORE, ExecutorType.CONCRETE);
}
String name = ExecutionService.CLIENT_EXECUTOR;
ClassLoader classLoader = nodeEngine.getConfigClassLoader();
String hzName = nodeEngine.getHazelcastInstance().getName();
String internalName = name.substring("hz:".length());
String threadNamePrefix = createThreadPoolName(hzName, internalName);
UnblockablePoolExecutorThreadFactory factory = new UnblockablePoolExecutorThreadFactory(threadNamePrefix, classLoader);
return executionService.register(ExecutionService.CLIENT_EXECUTOR, threadCount, coreSize * EXECUTOR_QUEUE_CAPACITY_PER_CORE, factory);
}
use of com.hazelcast.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.
the class AbstractBlockingService method init.
@Override
public final void init(NodeEngine nodeEngine, Properties properties) {
this.raftService = nodeEngine.getService(RaftService.SERVICE_NAME);
ExecutionService executionService = nodeEngine.getExecutionService();
executionService.scheduleWithRepetition(new ExpireWaitKeysPeriodicTask(), WAIT_TIMEOUT_TASK_PERIOD_MILLIS, WAIT_TIMEOUT_TASK_PERIOD_MILLIS, MILLISECONDS);
initImpl();
}
use of com.hazelcast.spi.impl.executionservice.ExecutionService in project hazelcast by hazelcast.
the class MetadataRaftGroupManager method scheduleDiscoverInitialCPMembersTask.
private void scheduleDiscoverInitialCPMembersTask(boolean terminateOnDiscoveryFailure) {
DiscoverInitialCPMembersTask task = new DiscoverInitialCPMembersTask(terminateOnDiscoveryFailure);
currentDiscoveryTask = task;
ExecutionService executionService = nodeEngine.getExecutionService();
executionService.schedule(CP_SUBSYSTEM_MANAGEMENT_EXECUTOR, task, DISCOVER_INITIAL_CP_MEMBERS_TASK_DELAY_MILLIS, MILLISECONDS);
}
Aggregations