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));
});
}
Aggregations