Search in sources :

Example 6 with InvocationFuture

use of com.hazelcast.spi.impl.operationservice.impl.InvocationFuture in project hazelcast by hazelcast.

the class MemberSchemaService method searchClusterAsync.

private CompletableFuture<Schema> searchClusterAsync(long schemaId, Iterator<Member> iterator, OperationService operationService) {
    if (!iterator.hasNext()) {
        return CompletableFuture.completedFuture(null);
    }
    Address address = iterator.next().getAddress();
    FetchSchemaOperation op = new FetchSchemaOperation(schemaId);
    InvocationFuture<Schema> future = operationService.invokeOnTarget(SERVICE_NAME, op, address);
    return future.handle((data, throwable) -> {
        // handle the exception and carry it to next `thenCompose` method
        if (throwable != null) {
            return throwable;
        }
        return data;
    }).thenCompose(o -> {
        if (o instanceof Throwable || o == null) {
            return searchClusterAsync(schemaId, iterator, operationService);
        }
        Schema retrievedSchema = (Schema) o;
        putLocal(retrievedSchema);
        return CompletableFuture.completedFuture(getLocal(schemaId));
    });
}
Also used : InvocationUtil.invokeOnStableClusterSerial(com.hazelcast.internal.util.InvocationUtil.invokeOnStableClusterSerial) Address(com.hazelcast.cluster.Address) InvocationFuture(com.hazelcast.spi.impl.operationservice.impl.InvocationFuture) NodeEngine(com.hazelcast.spi.impl.NodeEngine) Properties(java.util.Properties) Iterator(java.util.Iterator) Member(com.hazelcast.cluster.Member) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) CompletableFuture(java.util.concurrent.CompletableFuture) ManagedService(com.hazelcast.internal.services.ManagedService) Schema(com.hazelcast.internal.serialization.impl.compact.Schema) ArrayList(java.util.ArrayList) ClusterService(com.hazelcast.internal.cluster.ClusterService) List(java.util.List) ILogger(com.hazelcast.logging.ILogger) Operation(com.hazelcast.spi.impl.operationservice.Operation) SchemaService(com.hazelcast.internal.serialization.impl.compact.SchemaService) Map(java.util.Map) PreJoinAwareService(com.hazelcast.internal.services.PreJoinAwareService) Versions(com.hazelcast.internal.cluster.Versions) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Nonnull(javax.annotation.Nonnull) Address(com.hazelcast.cluster.Address) Schema(com.hazelcast.internal.serialization.impl.compact.Schema)

Aggregations

Operation (com.hazelcast.spi.impl.operationservice.Operation)5 InvocationFuture (com.hazelcast.spi.impl.operationservice.impl.InvocationFuture)5 Address (com.hazelcast.cluster.Address)4 Member (com.hazelcast.cluster.Member)4 ILogger (com.hazelcast.logging.ILogger)3 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)2 MemberLeftException (com.hazelcast.core.MemberLeftException)2 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)2 Probe (com.hazelcast.internal.metrics.Probe)2 NodeEngine (com.hazelcast.spi.impl.NodeEngine)2 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 UUID (java.util.UUID)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Nonnull (javax.annotation.Nonnull)2