Search in sources :

Example 21 with ExecutionService

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

the class PartitionContainer method createRecordStore.

private RecordStore createRecordStore(String name) {
    MapServiceContext serviceContext = mapService.getMapServiceContext();
    MapContainer mapContainer = serviceContext.getMapContainer(name);
    MapConfig mapConfig = mapContainer.getMapConfig();
    NodeEngine nodeEngine = serviceContext.getNodeEngine();
    IPartitionService ps = nodeEngine.getPartitionService();
    OperationService opService = nodeEngine.getOperationService();
    ExecutionService execService = nodeEngine.getExecutionService();
    HazelcastProperties hazelcastProperties = nodeEngine.getProperties();
    MapKeyLoader keyLoader = new MapKeyLoader(name, opService, ps, nodeEngine.getClusterService(), execService, mapContainer.toData());
    keyLoader.setMaxBatch(hazelcastProperties.getInteger(GroupProperty.MAP_LOAD_CHUNK_SIZE));
    keyLoader.setMaxSize(getMaxSizePerNode(mapConfig.getMaxSizeConfig()));
    keyLoader.setHasBackup(mapConfig.getTotalBackupCount() > 0);
    keyLoader.setMapOperationProvider(serviceContext.getMapOperationProvider(name));
    RecordStore recordStore = serviceContext.createRecordStore(mapContainer, partitionId, keyLoader);
    recordStore.init();
    return recordStore;
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) IPartitionService(com.hazelcast.spi.partition.IPartitionService) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) MapConfig(com.hazelcast.config.MapConfig) OperationService(com.hazelcast.spi.OperationService) ExecutionService(com.hazelcast.spi.ExecutionService)

Example 22 with ExecutionService

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

the class ExecutorServiceTest method testMultiPostRegisteredExecutionCallbackCompletableFuture.

@Test
public void testMultiPostRegisteredExecutionCallbackCompletableFuture() throws Exception {
    ExecutionService es = getExecutionService(createHazelcastInstance());
    CountDownLatch callableLatch = new CountDownLatch(1);
    CountDownLatch callbackLatch = new CountDownLatch(2);
    ExecutorService executorService = Executors.newSingleThreadExecutor();
    try {
        Future<String> future = executorService.submit(new CountDownLatchAwaitingCallable(callableLatch));
        ICompletableFuture<String> completableFuture = es.asCompletableFuture(future);
        callableLatch.countDown();
        future.get();
        CountingDownExecutionCallback<String> callback1 = new CountingDownExecutionCallback<String>(callbackLatch);
        completableFuture.andThen(callback1);
        CountingDownExecutionCallback<String> callback2 = new CountingDownExecutionCallback<String>(callbackLatch);
        completableFuture.andThen(callback2);
        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.ExecutionService) CountDownLatch(java.util.concurrent.CountDownLatch) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

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