Search in sources :

Example 21 with ExecutionService

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

the class MetadataRaftGroupManager method createRaftNodeAsync.

private void createRaftNodeAsync(CPGroupInfo group) {
    ExecutionService executionService = nodeEngine.getExecutionService();
    executionService.execute(CP_SUBSYSTEM_EXECUTOR, () -> raftService.createRaftNode(group.id(), group.members()));
}
Also used : ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService)

Example 22 with ExecutionService

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

the class ExecutorServiceTest method testMultiPreregisteredExecutionCallbackCompletableFuture.

@Test
public void testMultiPreregisteredExecutionCallbackCompletableFuture() {
    ExecutionService es = getExecutionService(createHazelcastInstance(smallInstanceConfig()));
    CountDownLatch callableLatch = new CountDownLatch(1);
    CountDownLatch callbackLatch = new CountDownLatch(2);
    ExecutorService executorService = Executors.newSingleThreadExecutor();
    try {
        Future<String> future = executorService.submit(new CountDownLatchAwaitingCallable(callableLatch));
        CountingDownExecutionCallback<String> callback1 = new CountingDownExecutionCallback<>(callbackLatch);
        CountingDownExecutionCallback<String> callback2 = new CountingDownExecutionCallback<>(callbackLatch);
        CompletableFuture<String> completableFuture = es.asCompletableFuture(future);
        completableFuture.whenCompleteAsync(callback1);
        completableFuture.whenCompleteAsync(callback2);
        callableLatch.countDown();
        assertOpenEventually(callbackLatch);
        assertEquals(CountDownLatchAwaitingCallable.RESULT, callback1.getResult());
        assertEquals(CountDownLatchAwaitingCallable.RESULT, callback2.getResult());
    } finally {
        executorService.shutdown();
    }
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) IExecutorService(com.hazelcast.core.IExecutorService) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService) CountDownLatch(java.util.concurrent.CountDownLatch) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 23 with ExecutionService

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

the class MetricsServiceTest method testNoCollectionIfMetricsEnabledAndMcJmxDisabled.

@Test
public void testNoCollectionIfMetricsEnabledAndMcJmxDisabled() {
    config.getMetricsConfig().setEnabled(true);
    config.getMetricsConfig().getManagementCenterConfig().setEnabled(false);
    config.getMetricsConfig().getJmxConfig().setEnabled(false);
    ExecutionService executionServiceMock = mock(ExecutionService.class);
    when(nodeEngineMock.getExecutionService()).thenReturn(executionServiceMock);
    prepareMetricsService();
    verifyNoMoreInteractions(executionServiceMock);
}
Also used : ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 24 with ExecutionService

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

the class MetricsServiceTest method testNoCollectionIfMetricsDisabled.

@Test
public void testNoCollectionIfMetricsDisabled() {
    config.getMetricsConfig().setEnabled(false);
    ExecutionService executionServiceMock = mock(ExecutionService.class);
    when(nodeEngineMock.getExecutionService()).thenReturn(executionServiceMock);
    prepareMetricsService();
    verifyNoMoreInteractions(executionServiceMock);
}
Also used : ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 25 with ExecutionService

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

the class RepairingTaskTest method newRepairingTask.

private static RepairingTask newRepairingTask(Config config) {
    HazelcastProperties hazelcastProperties = new HazelcastProperties(config);
    InvalidationMetaDataFetcher invalidationMetaDataFetcher = mock(InvalidationMetaDataFetcher.class);
    ExecutionService executionService = mock(ExecutionService.class);
    SerializationService serializationService = mock(SerializationService.class);
    MinimalPartitionService minimalPartitionService = mock(MinimalPartitionService.class);
    UUID uuid = UuidUtil.newUnsecureUUID();
    ILogger logger = Logger.getLogger(RepairingTask.class);
    return new RepairingTask(hazelcastProperties, invalidationMetaDataFetcher, executionService.getGlobalTaskScheduler(), serializationService, minimalPartitionService, uuid, logger);
}
Also used : HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) SerializationService(com.hazelcast.internal.serialization.SerializationService) ILogger(com.hazelcast.logging.ILogger) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService) UUID(java.util.UUID)

Aggregations

ExecutionService (com.hazelcast.spi.impl.executionservice.ExecutionService)46 ILogger (com.hazelcast.logging.ILogger)10 ManagementCenterService (com.hazelcast.internal.management.ManagementCenterService)7 CALLER_RUNS (com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS)7 ExceptionUtil.peel (com.hazelcast.internal.util.ExceptionUtil.peel)7 ExceptionUtil.withTryCatch (com.hazelcast.internal.util.ExceptionUtil.withTryCatch)7 HazelcastProperties (com.hazelcast.spi.properties.HazelcastProperties)7 Future (java.util.concurrent.Future)7 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)6 QuickTest (com.hazelcast.test.annotation.QuickTest)6 Test (org.junit.Test)6 CountDownLatch (java.util.concurrent.CountDownLatch)5 IExecutorService (com.hazelcast.core.IExecutorService)4 AbstractLocalOperation (com.hazelcast.spi.impl.operationservice.AbstractLocalOperation)4 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 Node (com.hazelcast.instance.impl.Node)3 NodeEngine (com.hazelcast.spi.impl.NodeEngine)3 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)3 ExecutorService (java.util.concurrent.ExecutorService)3 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)2