Search in sources :

Example 1 with DataTreeListenerInfo

use of org.opendaylight.controller.cluster.datastore.messages.DataTreeListenerInfo in project controller by opendaylight.

the class ShardDataTreeListenerInfoMXBeanImpl method getListenerActorsInfo.

@SuppressWarnings("checkstyle:IllegalCatch")
private List<DataTreeListenerInfo> getListenerActorsInfo(Collection<ActorSelection> actors) {
    final Timeout timeout = new Timeout(20, TimeUnit.SECONDS);
    final List<Future<Object>> futureList = new ArrayList<>(actors.size());
    for (ActorSelection actor : actors) {
        futureList.add(Patterns.ask(actor, GetInfo.INSTANCE, timeout));
    }
    try {
        final List<DataTreeListenerInfo> listenerInfoList = new ArrayList<>();
        Await.result(Futures.sequence(futureList, ExecutionContext.Implicits$.MODULE$.global()), timeout.duration()).forEach(obj -> listenerInfoList.add((DataTreeListenerInfo) obj));
        return listenerInfoList;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : DataTreeListenerInfo(org.opendaylight.controller.cluster.datastore.messages.DataTreeListenerInfo) ActorSelection(akka.actor.ActorSelection) Timeout(akka.util.Timeout) ArrayList(java.util.ArrayList) Future(scala.concurrent.Future)

Aggregations

ActorSelection (akka.actor.ActorSelection)1 Timeout (akka.util.Timeout)1 ArrayList (java.util.ArrayList)1 DataTreeListenerInfo (org.opendaylight.controller.cluster.datastore.messages.DataTreeListenerInfo)1 Future (scala.concurrent.Future)1