Search in sources :

Example 1 with NotifyProducerRemoved

use of org.opendaylight.controller.cluster.sharding.messages.NotifyProducerRemoved in project controller by opendaylight.

the class ShardedDataTreeActor method onProducerRemoved.

private void onProducerRemoved(final ProducerRemoved message) {
    LOG.debug("Received ProducerRemoved: {}", message);
    final List<CompletableFuture<Object>> futures = new ArrayList<>();
    for (final String address : resolver.getShardingServicePeerActorAddresses()) {
        final ActorSelection selection = actorSystem.actorSelection(address);
        futures.add(FutureConverters.toJava(actorContext.executeOperationAsync(selection, new NotifyProducerRemoved(message.getSubtrees()))).toCompletableFuture());
    }
    final CompletableFuture<Void> combinedFuture = CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()]));
    final ActorRef respondTo = getSender();
    combinedFuture.thenRun(() -> respondTo.tell(new Status.Success(null), self())).exceptionally(e -> {
        respondTo.tell(new Status.Failure(null), self());
        return null;
    });
}
Also used : Status(akka.actor.Status) CompletableFuture(java.util.concurrent.CompletableFuture) ActorSelection(akka.actor.ActorSelection) ActorRef(akka.actor.ActorRef) ArrayList(java.util.ArrayList) NotifyProducerRemoved(org.opendaylight.controller.cluster.sharding.messages.NotifyProducerRemoved) Success(akka.actor.Status.Success)

Aggregations

ActorRef (akka.actor.ActorRef)1 ActorSelection (akka.actor.ActorSelection)1 Status (akka.actor.Status)1 Success (akka.actor.Status.Success)1 ArrayList (java.util.ArrayList)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 NotifyProducerRemoved (org.opendaylight.controller.cluster.sharding.messages.NotifyProducerRemoved)1