Search in sources :

Example 6 with ExecutionService

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

the class JobSupervisor method checkFullyProcessed.

public void checkFullyProcessed(JobProcessInformation processInformation) {
    if (isOwnerNode()) {
        JobPartitionState[] partitionStates = processInformation.getPartitionStates();
        for (JobPartitionState partitionState : partitionStates) {
            if (partitionState == null || partitionState.getState() != JobPartitionState.State.PROCESSED) {
                return;
            }
        }
        final String name = configuration.getName();
        final String jobId = configuration.getJobId();
        final NodeEngine nodeEngine = configuration.getNodeEngine();
        final GetResultOperationFactory operationFactory = new GetResultOperationFactory(name, jobId);
        // Get the initial future object to eventually set the result and cleanup
        final TrackableJobFuture future = jobTracker.unregisterTrackableJob(jobId);
        if (future == null) {
            // If already handled just return
            return;
        }
        final JobSupervisor jobSupervisor = this;
        Runnable runnable = new GetResultsRunnable(nodeEngine, operationFactory, jobId, jobSupervisor, future);
        ExecutionService executionService = nodeEngine.getExecutionService();
        ManagedExecutorService executor = executionService.getExecutor(ExecutionService.ASYNC_EXECUTOR);
        executor.submit(runnable);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) ManagedExecutorService(com.hazelcast.util.executor.ManagedExecutorService) JobPartitionState(com.hazelcast.mapreduce.JobPartitionState) GetResultOperationFactory(com.hazelcast.mapreduce.impl.operation.GetResultOperationFactory) ExecutionService(com.hazelcast.spi.ExecutionService)

Example 7 with ExecutionService

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

the class PostJoinProxyOperation method run.

@Override
public void run() throws Exception {
    if (proxies == null || proxies.size() <= 0) {
        return;
    }
    NodeEngine nodeEngine = getNodeEngine();
    ProxyServiceImpl proxyService = getService();
    ExecutionService executionService = nodeEngine.getExecutionService();
    for (final ProxyInfo proxy : proxies) {
        final ProxyRegistry registry = proxyService.getOrCreateRegistry(proxy.getServiceName());
        try {
            executionService.execute(ExecutionService.SYSTEM_EXECUTOR, new Runnable() {

                @Override
                public void run() {
                    registry.createProxy(proxy.getObjectName(), false, true);
                }
            });
        } catch (Throwable t) {
            getLogger().warning("Cannot create proxy [" + proxy.getServiceName() + ":" + proxy.getObjectName() + "]!", t);
        }
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) ProxyInfo(com.hazelcast.spi.impl.proxyservice.impl.ProxyInfo) ProxyRegistry(com.hazelcast.spi.impl.proxyservice.impl.ProxyRegistry) ProxyServiceImpl(com.hazelcast.spi.impl.proxyservice.impl.ProxyServiceImpl) ExecutionService(com.hazelcast.spi.ExecutionService)

Example 8 with ExecutionService

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

the class ExecutorServiceTest method testMultiPreregisteredExecutionCallbackCompletableFuture.

@Test
public void testMultiPreregisteredExecutionCallbackCompletableFuture() {
    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));
        CountingDownExecutionCallback<String> callback1 = new CountingDownExecutionCallback<String>(callbackLatch);
        CountingDownExecutionCallback<String> callback2 = new CountingDownExecutionCallback<String>(callbackLatch);
        ICompletableFuture<String> completableFuture = es.asCompletableFuture(future);
        completableFuture.andThen(callback1);
        completableFuture.andThen(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.ExecutionService) CountDownLatch(java.util.concurrent.CountDownLatch) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 9 with ExecutionService

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

the class ClientEngineImpl method newClientExecutor.

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

Example 10 with ExecutionService

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

the class RepairingTaskTest method newRepairingTask.

private RepairingTask newRepairingTask(Config config) {
    MetaDataFetcher metaDataFetcher = mock(MetaDataFetcher.class);
    ExecutionService executionService = mock(ExecutionService.class);
    MinimalPartitionService minimalPartitionService = mock(MinimalPartitionService.class);
    String uuid = UuidUtil.newUnsecureUUID().toString();
    ILogger logger = Logger.getLogger(RepairingTask.class);
    HazelcastProperties hazelcastProperties = new HazelcastProperties(config);
    return new RepairingTask(metaDataFetcher, executionService.getGlobalTaskScheduler(), minimalPartitionService, hazelcastProperties, uuid, logger);
}
Also used : HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) ILogger(com.hazelcast.logging.ILogger) ExecutionService(com.hazelcast.spi.ExecutionService)

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