use of org.opendaylight.controller.cluster.datastore.DataTreeCohortActor.Success in project controller by opendaylight.
the class DataTreeCohortActorTest method askAndAwait.
private static void askAndAwait(ActorRef actor, CommitProtocolCommand<?> message) throws Exception {
Timeout timeout = new Timeout(5, TimeUnit.SECONDS);
Object result = Await.result(Patterns.ask(actor, message, timeout), timeout.duration());
assertTrue("Expected Success but was " + result, result instanceof Success);
assertEquals("Success", message.getTxId(), ((Success) result).getTxId());
}
use of org.opendaylight.controller.cluster.datastore.DataTreeCohortActor.Success in project controller by opendaylight.
the class CompositeDataTreeCohort method sendMessageToSuccessful.
private List<Entry<ActorRef, Future<Object>>> sendMessageToSuccessful(final Object message) {
LOG.debug("{}: sendMesageToSuccessful: {}", txId, message);
final List<Entry<ActorRef, Future<Object>>> ret = new ArrayList<>(successfulFromPrevious.size());
for (Success s : successfulFromPrevious) {
final ActorRef actor = s.getCohort();
ret.add(new SimpleImmutableEntry<>(actor, Patterns.ask(actor, message, timeout)));
}
return ret;
}
use of org.opendaylight.controller.cluster.datastore.DataTreeCohortActor.Success in project controller by opendaylight.
the class CompositeDataTreeCohort method abort.
Optional<CompletionStage<?>> abort() {
LOG.debug("{}: abort - successfulFromPrevious: {}", txId, successfulFromPrevious);
state = State.ABORTED;
if (successfulFromPrevious.isEmpty()) {
return Optional.empty();
}
final DataTreeCohortActor.Abort message = new DataTreeCohortActor.Abort(txId);
final List<Future<Object>> futures = new ArrayList<>(successfulFromPrevious.size());
for (Success s : successfulFromPrevious) {
futures.add(Patterns.ask(s.getCohort(), message, timeout));
}
return Optional.of(FutureConverters.toJava(Futures.sequence(futures, ExecutionContexts.global())));
}
Aggregations