Search in sources :

Example 1 with ManagedExecutorService

use of com.hazelcast.internal.util.executor.ManagedExecutorService in project hazelcast by hazelcast.

the class RaftSessionService method getAllSessions.

@Override
public InternalCompletableFuture<Collection<CPSession>> getAllSessions(String groupName) {
    checkTrue(!METADATA_CP_GROUP_NAME.equals(groupName), "Cannot query CP sessions on the METADATA CP group!");
    ManagedExecutorService executor = nodeEngine.getExecutionService().getExecutor(SYSTEM_EXECUTOR);
    InternalCompletableFuture<Collection<CPSession>> future = InternalCompletableFuture.withExecutor(executor);
    raftService.getCPGroup(groupName).whenCompleteAsync((group, t) -> {
        if (t == null) {
            if (group != null) {
                getAllSessions(group.id()).whenCompleteAsync(completingCallback(future));
            } else {
                future.completeExceptionally(new IllegalArgumentException());
            }
        } else {
            future.completeExceptionally(t);
        }
    });
    return future;
}
Also used : ManagedExecutorService(com.hazelcast.internal.util.executor.ManagedExecutorService) Collections.unmodifiableCollection(java.util.Collections.unmodifiableCollection) Collection(java.util.Collection)

Example 2 with ManagedExecutorService

use of com.hazelcast.internal.util.executor.ManagedExecutorService in project hazelcast by hazelcast.

the class RaftSessionService method forceCloseSession.

@Override
public InternalCompletableFuture<Boolean> forceCloseSession(String groupName, final long sessionId) {
    ManagedExecutorService executor = nodeEngine.getExecutionService().getExecutor(SYSTEM_EXECUTOR);
    InternalCompletableFuture<Boolean> future = InternalCompletableFuture.withExecutor(executor);
    raftService.getCPGroup(groupName).whenCompleteAsync((group, t) -> {
        if (t == null) {
            if (group != null) {
                raftService.getInvocationManager().<Boolean>invoke(group.id(), new CloseSessionOp(sessionId)).whenCompleteAsync(completingCallback(future));
            } else {
                future.complete(false);
            }
        } else {
            future.completeExceptionally(t);
        }
    });
    return future;
}
Also used : ManagedExecutorService(com.hazelcast.internal.util.executor.ManagedExecutorService) CloseSessionOp(com.hazelcast.cp.internal.session.operation.CloseSessionOp)

Example 3 with ManagedExecutorService

use of com.hazelcast.internal.util.executor.ManagedExecutorService in project hazelcast by hazelcast.

the class MapServiceContextImpl method createMapQueryRunner.

protected QueryRunner createMapQueryRunner(NodeEngine nodeEngine, QueryOptimizer queryOptimizer, ResultProcessorRegistry resultProcessorRegistry, PartitionScanRunner partitionScanRunner) {
    boolean parallelEvaluation = nodeEngine.getProperties().getBoolean(QUERY_PREDICATE_PARALLEL_EVALUATION);
    PartitionScanExecutor partitionScanExecutor;
    if (parallelEvaluation) {
        int opTimeoutInMillis = nodeEngine.getProperties().getInteger(OPERATION_CALL_TIMEOUT_MILLIS);
        ManagedExecutorService queryExecutorService = nodeEngine.getExecutionService().getExecutor(QUERY_EXECUTOR);
        partitionScanExecutor = new ParallelPartitionScanExecutor(partitionScanRunner, queryExecutorService, opTimeoutInMillis);
    } else {
        partitionScanExecutor = new CallerRunsPartitionScanExecutor(partitionScanRunner);
    }
    return new QueryRunner(this, queryOptimizer, partitionScanExecutor, resultProcessorRegistry);
}
Also used : ManagedExecutorService(com.hazelcast.internal.util.executor.ManagedExecutorService) CallerRunsPartitionScanExecutor(com.hazelcast.map.impl.query.CallerRunsPartitionScanExecutor) ParallelPartitionScanExecutor(com.hazelcast.map.impl.query.ParallelPartitionScanExecutor) PartitionScanExecutor(com.hazelcast.map.impl.query.PartitionScanExecutor) ParallelPartitionScanExecutor(com.hazelcast.map.impl.query.ParallelPartitionScanExecutor) CallerRunsPartitionScanExecutor(com.hazelcast.map.impl.query.CallerRunsPartitionScanExecutor) QueryRunner(com.hazelcast.map.impl.query.QueryRunner)

Example 4 with ManagedExecutorService

use of com.hazelcast.internal.util.executor.ManagedExecutorService in project hazelcast by hazelcast.

the class MapServiceContextImpl method createAggregationResultProcessor.

private AggregationResultProcessor createAggregationResultProcessor(SerializationService ss) {
    boolean parallelAccumulation = nodeEngine.getProperties().getBoolean(AGGREGATION_ACCUMULATION_PARALLEL_EVALUATION);
    int opTimeoutInMillis = nodeEngine.getProperties().getInteger(OPERATION_CALL_TIMEOUT_MILLIS);
    AccumulationExecutor accumulationExecutor;
    if (parallelAccumulation) {
        ManagedExecutorService queryExecutorService = nodeEngine.getExecutionService().getExecutor(QUERY_EXECUTOR);
        accumulationExecutor = new ParallelAccumulationExecutor(queryExecutorService, ss, opTimeoutInMillis);
    } else {
        accumulationExecutor = new CallerRunsAccumulationExecutor(ss);
    }
    return new AggregationResultProcessor(accumulationExecutor, serializationService);
}
Also used : ManagedExecutorService(com.hazelcast.internal.util.executor.ManagedExecutorService) ParallelAccumulationExecutor(com.hazelcast.map.impl.query.ParallelAccumulationExecutor) CallerRunsAccumulationExecutor(com.hazelcast.map.impl.query.CallerRunsAccumulationExecutor) AccumulationExecutor(com.hazelcast.map.impl.query.AccumulationExecutor) CallerRunsAccumulationExecutor(com.hazelcast.map.impl.query.CallerRunsAccumulationExecutor) ParallelAccumulationExecutor(com.hazelcast.map.impl.query.ParallelAccumulationExecutor) AggregationResultProcessor(com.hazelcast.map.impl.query.AggregationResultProcessor)

Example 5 with ManagedExecutorService

use of com.hazelcast.internal.util.executor.ManagedExecutorService 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);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) ManagedExecutorService(com.hazelcast.internal.util.executor.ManagedExecutorService) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService) CountDownLatch(java.util.concurrent.CountDownLatch) Before(org.junit.Before)

Aggregations

ManagedExecutorService (com.hazelcast.internal.util.executor.ManagedExecutorService)8 Config (com.hazelcast.config.Config)2 ScheduledExecutorConfig (com.hazelcast.config.ScheduledExecutorConfig)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)2 ExecutionService (com.hazelcast.spi.impl.executionservice.ExecutionService)2 DurableExecutorConfig (com.hazelcast.config.DurableExecutorConfig)1 ExecutorConfig (com.hazelcast.config.ExecutorConfig)1 CloseSessionOp (com.hazelcast.cp.internal.session.operation.CloseSessionOp)1 Node (com.hazelcast.instance.impl.Node)1 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)1 MetricsRegistry (com.hazelcast.internal.metrics.MetricsRegistry)1 AccumulationExecutor (com.hazelcast.map.impl.query.AccumulationExecutor)1 AggregationResultProcessor (com.hazelcast.map.impl.query.AggregationResultProcessor)1 CallerRunsAccumulationExecutor (com.hazelcast.map.impl.query.CallerRunsAccumulationExecutor)1 CallerRunsPartitionScanExecutor (com.hazelcast.map.impl.query.CallerRunsPartitionScanExecutor)1 ParallelAccumulationExecutor (com.hazelcast.map.impl.query.ParallelAccumulationExecutor)1 ParallelPartitionScanExecutor (com.hazelcast.map.impl.query.ParallelPartitionScanExecutor)1 PartitionScanExecutor (com.hazelcast.map.impl.query.PartitionScanExecutor)1 QueryRunner (com.hazelcast.map.impl.query.QueryRunner)1