use of org.opendaylight.netconf.topology.singleton.messages.transactions.SubmitRequest in project netconf by opendaylight.
the class WriteTransactionActorTestAdapter method testSubmit.
@Test
public void testSubmit() {
doReturn(emptyFluentFuture()).when(mockWriteTx).commit();
actorRef.tell(new SubmitRequest(), probe.ref());
verify(mockWriteTx).commit();
probe.expectMsgClass(Success.class);
}
use of org.opendaylight.netconf.topology.singleton.messages.transactions.SubmitRequest in project netconf by opendaylight.
the class WriteTransactionActorTestAdapter method testSubmitFail.
@Test
public void testSubmitFail() {
final RpcError rpcError = RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, "fail", "fail");
final TransactionCommitFailedException cause = new TransactionCommitFailedException("fail", rpcError);
when(mockWriteTx.commit()).thenReturn(FluentFutures.immediateFailedFluentFuture(cause));
actorRef.tell(new SubmitRequest(), probe.ref());
verify(mockWriteTx).commit();
final Failure response = probe.expectMsgClass(Failure.class);
assertEquals(cause, response.cause());
}
use of org.opendaylight.netconf.topology.singleton.messages.transactions.SubmitRequest in project netconf by opendaylight.
the class ActorProxyTransactionFacade method commit.
@Override
public FluentFuture<? extends CommitInfo> commit() {
LOG.debug("{}: Commit via actor {}", id, masterTxActor);
final Future<Object> future = Patterns.ask(masterTxActor, new SubmitRequest(), askTimeout);
final SettableFuture<CommitInfo> settableFuture = SettableFuture.create();
future.onComplete(new OnComplete<>() {
@Override
public void onComplete(final Throwable failure, final Object response) {
if (failure != null) {
LOG.debug("{}: Commit failed", id, failure);
settableFuture.setException(newTransactionCommitFailedException(processFailure(failure)));
return;
}
LOG.debug("{}: Commit succeeded", id);
settableFuture.set(CommitInfo.empty());
}
private TransactionCommitFailedException newTransactionCommitFailedException(final Throwable failure) {
return new TransactionCommitFailedException(String.format("%s: Commit of transaction failed", getIdentifier()), failure);
}
}, executionContext);
return FluentFuture.from(settableFuture);
}
use of org.opendaylight.netconf.topology.singleton.messages.transactions.SubmitRequest in project netconf by opendaylight.
the class WriteAdapter method handle.
@SuppressWarnings("checkstyle:IllegalCatch")
public void handle(final Object message, final ActorRef sender, final ActorContext context, final ActorRef self) {
// TODO Maybe we should store it and fail the submit immediately?.
try {
if (message instanceof MergeRequest) {
final MergeRequest mergeRequest = (MergeRequest) message;
final NormalizedNodeMessage data = mergeRequest.getNormalizedNodeMessage();
tx.merge(mergeRequest.getStore(), data.getIdentifier(), data.getNode());
} else if (message instanceof PutRequest) {
final PutRequest putRequest = (PutRequest) message;
final NormalizedNodeMessage data = putRequest.getNormalizedNodeMessage();
tx.put(putRequest.getStore(), data.getIdentifier(), data.getNode());
} else if (message instanceof DeleteRequest) {
final DeleteRequest deleteRequest = (DeleteRequest) message;
tx.delete(deleteRequest.getStore(), deleteRequest.getPath());
} else if (message instanceof CancelRequest) {
cancel(context, sender, self);
} else if (message instanceof SubmitRequest) {
submit(sender, self, context);
}
} catch (final RuntimeException exception) {
LOG.error("Write command has failed.", exception);
}
}
Aggregations