Search in sources :

Example 1 with CompletableFutureTask

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

the class CacheProxySupport method createAndSubmitLoadAllTask.

@SuppressWarnings("unchecked")
protected void createAndSubmitLoadAllTask(Set<Data> keysData, boolean replaceExistingValues, CompletionListener completionListener) {
    try {
        CacheProxyLoadAllTask loadAllTask = new CacheProxyLoadAllTask(getNodeEngine(), operationProvider, keysData, replaceExistingValues, completionListener, getServiceName());
        ExecutionService executionService = getNodeEngine().getExecutionService();
        final CompletableFutureTask<Object> future = (CompletableFutureTask<Object>) executionService.submit("loadAll-" + nameWithPrefix, loadAllTask);
        loadAllTasks.add(future);
        future.whenCompleteAsync((response, t) -> {
            loadAllTasks.remove(future);
            if (t != null) {
                logger.warning("Problem in loadAll task", t);
            }
        });
    } catch (Exception e) {
        if (completionListener != null) {
            completionListener.onException(e);
        }
        throw new CacheException(e);
    }
}
Also used : CompletableFutureTask(com.hazelcast.internal.util.executor.CompletableFutureTask) CacheException(javax.cache.CacheException) AbstractDistributedObject(com.hazelcast.spi.impl.AbstractDistributedObject) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService) EntryProcessorException(javax.cache.processor.EntryProcessorException) CacheException(javax.cache.CacheException)

Aggregations

CompletableFutureTask (com.hazelcast.internal.util.executor.CompletableFutureTask)1 AbstractDistributedObject (com.hazelcast.spi.impl.AbstractDistributedObject)1 ExecutionService (com.hazelcast.spi.impl.executionservice.ExecutionService)1 CacheException (javax.cache.CacheException)1 EntryProcessorException (javax.cache.processor.EntryProcessorException)1