use of org.opendaylight.controller.cluster.sharding.messages.NotifyProducerCreated in project controller by opendaylight.
the class ShardedDataTreeActor method onProducerCreated.
private void onProducerCreated(final ProducerCreated message) {
LOG.debug("Received ProducerCreated: {}", message);
// fastpath if we have no peers
if (resolver.getShardingServicePeerActorAddresses().isEmpty()) {
getSender().tell(new Status.Success(null), noSender());
}
final ActorRef sender = getSender();
final Collection<DOMDataTreeIdentifier> subtrees = message.getSubtrees();
final List<CompletableFuture<Object>> futures = new ArrayList<>();
for (final String address : resolver.getShardingServicePeerActorAddresses()) {
final ActorSelection actorSelection = actorSystem.actorSelection(address);
futures.add(FutureConverters.toJava(actorContext.executeOperationAsync(actorSelection, new NotifyProducerCreated(subtrees), DEFAULT_ASK_TIMEOUT)).toCompletableFuture());
}
final CompletableFuture<Void> combinedFuture = CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()]));
combinedFuture.thenRun(() -> sender.tell(new Success(null), noSender())).exceptionally(throwable -> {
sender.tell(new Status.Failure(throwable), self());
return null;
});
}
Aggregations