Search in sources :

Example 16 with InternalCompletableFuture

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

the class MapKeyLoader method sendBatch.

private List<Future> sendBatch(Map<Integer, List<Data>> batch, boolean replaceExistingValues) {
    Set<Entry<Integer, List<Data>>> entries = batch.entrySet();
    List<Future> futures = new ArrayList<Future>(entries.size());
    for (Entry<Integer, List<Data>> e : entries) {
        int partitionId = e.getKey();
        List<Data> keys = e.getValue();
        MapOperation op = operationProvider.createLoadAllOperation(mapName, keys, replaceExistingValues);
        InternalCompletableFuture<Object> future = opService.invokeOnPartition(SERVICE_NAME, op, partitionId);
        futures.add(future);
    }
    return futures;
}
Also used : ArrayList(java.util.ArrayList) Data(com.hazelcast.nio.serialization.Data) MapOperation(com.hazelcast.map.impl.operation.MapOperation) Entry(java.util.Map.Entry) InternalCompletableFuture(com.hazelcast.spi.InternalCompletableFuture) Future(java.util.concurrent.Future) AbstractCompletableFuture(com.hazelcast.spi.impl.AbstractCompletableFuture) ArrayList(java.util.ArrayList) List(java.util.List)

Example 17 with InternalCompletableFuture

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

the class RingbufferAbstractTest method destroy_whenBlockedThreads_thenDistributedObjectDestroyedException.

@Test(expected = DistributedObjectDestroyedException.class)
public void destroy_whenBlockedThreads_thenDistributedObjectDestroyedException() throws Exception {
    spawn(new Runnable() {

        @Override
        public void run() {
            sleepSeconds(2);
            ringbuffer.destroy();
        }
    });
    InternalCompletableFuture f = (InternalCompletableFuture) ringbuffer.readManyAsync(0, 1, 1, null);
    f.join();
}
Also used : InternalCompletableFuture(com.hazelcast.spi.InternalCompletableFuture) Test(org.junit.Test)

Aggregations

InternalCompletableFuture (com.hazelcast.spi.InternalCompletableFuture)17 Operation (com.hazelcast.spi.Operation)6 Data (com.hazelcast.nio.serialization.Data)5 ArrayList (java.util.ArrayList)5 ExecutionException (java.util.concurrent.ExecutionException)5 TimeoutException (java.util.concurrent.TimeoutException)5 Member (com.hazelcast.core.Member)4 Address (com.hazelcast.nio.Address)3 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)2 ClientInvocation (com.hazelcast.client.spi.impl.ClientInvocation)2 InvocationBuilder (com.hazelcast.spi.InvocationBuilder)2 OperationService (com.hazelcast.spi.OperationService)2 CacheCreateConfigOperation (com.hazelcast.cache.impl.operation.CacheCreateConfigOperation)1 AwaitOperation (com.hazelcast.concurrent.countdownlatch.operations.AwaitOperation)1 CountDownOperation (com.hazelcast.concurrent.countdownlatch.operations.CountDownOperation)1 GetCountOperation (com.hazelcast.concurrent.countdownlatch.operations.GetCountOperation)1 SetCountOperation (com.hazelcast.concurrent.countdownlatch.operations.SetCountOperation)1 BeforeAwaitOperation (com.hazelcast.concurrent.lock.operations.BeforeAwaitOperation)1 SignalOperation (com.hazelcast.concurrent.lock.operations.SignalOperation)1 AcquireOperation (com.hazelcast.concurrent.semaphore.operations.AcquireOperation)1