Search in sources :

Example 11 with ExecutionService

use of com.hazelcast.spi.ExecutionService in project hazelcast by hazelcast.

the class BasicCompletableFutureTest method basicCompletableFuture.

private static <V> BasicCompletableFuture<V> basicCompletableFuture(Future<V> future) {
    NodeEngine engine = mock(NodeEngine.class);
    when(engine.getLogger(BasicCompletableFuture.class)).thenReturn(mock(ILogger.class));
    ExecutionService executionService = mock(ExecutionService.class);
    when(engine.getExecutionService()).thenReturn(executionService);
    when(executionService.getExecutor(anyString())).thenReturn(new TestCurrentThreadExecutor());
    return new BasicCompletableFuture<V>(future, engine);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) ILogger(com.hazelcast.logging.ILogger) ExecutionService(com.hazelcast.spi.ExecutionService)

Example 12 with ExecutionService

use of com.hazelcast.spi.ExecutionService in project hazelcast by hazelcast.

the class CachedExecutorServiceDelegateTest method setup.

@Before
public void setup() {
    cachedExecutorService = new NamedThreadPoolExecutor("test", 0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), Executors.defaultThreadFactory());
    ExecutionService executionService = mock(ExecutionService.class);
    when(executionService.getExecutor(ExecutionService.ASYNC_EXECUTOR)).thenReturn(cachedExecutorService);
    nodeEngine = mock(NodeEngine.class);
    when(nodeEngine.getExecutionService()).thenReturn(executionService);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) SynchronousQueue(java.util.concurrent.SynchronousQueue) ExecutionService(com.hazelcast.spi.ExecutionService) Before(org.junit.Before)

Example 13 with ExecutionService

use of com.hazelcast.spi.ExecutionService in project hazelcast by hazelcast.

the class AbstractAddressMessageTask method execute.

@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);
    }
}
Also used : Executor(java.util.concurrent.Executor) ExecutionService(com.hazelcast.spi.ExecutionService)

Example 14 with ExecutionService

use of com.hazelcast.spi.ExecutionService in project hazelcast by hazelcast.

the class AbstractPartitionMessageTask method execute.

@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);
    }
}
Also used : Executor(java.util.concurrent.Executor) ExecutionService(com.hazelcast.spi.ExecutionService)

Example 15 with ExecutionService

use of com.hazelcast.spi.ExecutionService in project hazelcast by hazelcast.

the class ClientEngineImpl method newClientQueryExecutor.

private Executor newClientQueryExecutor() {
    final ExecutionService executionService = nodeEngine.getExecutionService();
    int coreSize = Runtime.getRuntime().availableProcessors();
    int threadCount = node.getProperties().getInteger(GroupProperty.CLIENT_ENGINE_QUERY_THREAD_COUNT);
    if (threadCount <= 0) {
        threadCount = coreSize * QUERY_THREADS_PER_CORE;
    }
    logger.finest("Creating new client query executor with threadCount=" + threadCount);
    return executionService.register(ExecutionService.CLIENT_QUERY_EXECUTOR, threadCount, coreSize * EXECUTOR_QUEUE_CAPACITY_PER_CORE, ExecutorType.CONCRETE);
}
Also used : ExecutionService(com.hazelcast.spi.ExecutionService) ClientEndpoint(com.hazelcast.client.ClientEndpoint)

Aggregations

ExecutionService (com.hazelcast.spi.ExecutionService)22 NodeEngine (com.hazelcast.spi.NodeEngine)5 IExecutorService (com.hazelcast.core.IExecutorService)4 HazelcastProperties (com.hazelcast.spi.properties.HazelcastProperties)4 ParallelTest (com.hazelcast.test.annotation.ParallelTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 ExecutorService (java.util.concurrent.ExecutorService)4 Test (org.junit.Test)4 ILogger (com.hazelcast.logging.ILogger)3 ClientEndpoint (com.hazelcast.client.ClientEndpoint)2 OperationService (com.hazelcast.spi.OperationService)2 ManagedExecutorService (com.hazelcast.util.executor.ManagedExecutorService)2 Executor (java.util.concurrent.Executor)2 MapConfig (com.hazelcast.config.MapConfig)1 ExecutionCallback (com.hazelcast.core.ExecutionCallback)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 LifecycleService (com.hazelcast.core.LifecycleService)1 PrefixedDistributedObject (com.hazelcast.core.PrefixedDistributedObject)1 ClusterService (com.hazelcast.internal.cluster.ClusterService)1