use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project controller by opendaylight.
the class MdsalLowLevelTestProvider method unsubscribeDtcl.
@Override
public Future<RpcResult<UnsubscribeDtclOutput>> unsubscribeDtcl() {
LOG.debug("Received unsubscribe-dtcl");
if (idIntsListener == null || dtclReg == null) {
final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Dtcl missing.", "No DataTreeChangeListener registered.");
return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed().withRpcError(error).build());
}
try {
idIntsListener.tryFinishProcessing().get(120, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "resource-denied-transport", "Unable to finish notification processing in 120 seconds.", "clustering-it", "clustering-it", e);
return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed().withRpcError(error).build());
}
dtclReg.close();
dtclReg = null;
if (!idIntsListener.hasTriggered()) {
final RpcError error = RpcResultBuilder.newError(ErrorType.APPLICATION, "No notification received.", "id-ints listener has not received" + "any notifications.");
return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed().withRpcError(error).build());
}
final DOMDataReadOnlyTransaction rTx = domDataBroker.newReadOnlyTransaction();
try {
final Optional<NormalizedNode<?, ?>> readResult = rTx.read(CONTROLLER_CONFIG, WriteTransactionsHandler.ID_INT_YID).checkedGet();
if (!readResult.isPresent()) {
final RpcError error = RpcResultBuilder.newError(ErrorType.APPLICATION, "Final read empty.", "No data read from id-ints list.");
return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed().withRpcError(error).build());
}
return Futures.immediateFuture(RpcResultBuilder.success(new UnsubscribeDtclOutputBuilder().setCopyMatches(idIntsListener.checkEqual(readResult.get()))).build());
} catch (final ReadFailedException e) {
final RpcError error = RpcResultBuilder.newError(ErrorType.APPLICATION, "Read failed.", "Final read from id-ints failed.");
return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed().withRpcError(error).build());
}
}
use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project controller by opendaylight.
the class InMemoryDataStoreTest method testExistsForExistingData.
@Test
public void testExistsForExistingData() throws Exception {
DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
assertNotNull(writeTx);
ContainerNode containerNode = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).addChild(ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)).build()).build();
writeTx.merge(TestModel.TEST_PATH, containerNode);
CheckedFuture<Boolean, ReadFailedException> exists = writeTx.exists(TestModel.TEST_PATH);
assertEquals(true, exists.checkedGet());
DOMStoreThreePhaseCommitCohort ready = writeTx.ready();
ready.preCommit().get();
ready.commit().get();
DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction();
assertNotNull(readTx);
exists = readTx.exists(TestModel.TEST_PATH);
assertEquals(true, exists.checkedGet());
}
use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project controller by opendaylight.
the class InMemoryDataStoreTest method testExistsForNonExistingData.
@Test
public void testExistsForNonExistingData() throws Exception {
DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
assertNotNull(writeTx);
CheckedFuture<Boolean, ReadFailedException> exists = writeTx.exists(TestModel.TEST_PATH);
assertEquals(false, exists.checkedGet());
DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction();
assertNotNull(readTx);
exists = readTx.exists(TestModel.TEST_PATH);
assertEquals(false, exists.checkedGet());
}
use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project bgpcep by opendaylight.
the class UpdateTunnelInstructionExecutor method invokeOperation.
@Override
protected ListenableFuture<OperationResult> invokeOperation() {
final InstanceIdentifier<Topology> tii = TopologyProgrammingUtil.topologyForInput(this.updateTunnelInput);
final InstanceIdentifier<Link> lii = TunnelProgrammingUtil.linkIdentifier(tii, this.updateTunnelInput);
try (ReadOnlyTransaction t = this.dataProvider.newReadOnlyTransaction()) {
final Link link;
final Node node;
try {
// The link has to exist
link = t.read(LogicalDatastoreType.OPERATIONAL, lii).checkedGet().get();
// The source node has to exist
node = TunelProgrammingUtil.sourceNode(t, tii, link).get();
} catch (IllegalStateException | ReadFailedException e) {
LOG.debug("Link or node does not exist.", e);
return TunelProgrammingUtil.RESULT;
}
return Futures.transform((ListenableFuture<RpcResult<UpdateLspOutput>>) this.topologyService.updateLsp(buildUpdateInput(link, node)), RpcResult::getResult, MoreExecutors.directExecutor());
}
}
use of org.opendaylight.controller.md.sal.common.api.data.ReadFailedException in project bgpcep by opendaylight.
the class DestroyTunnelInstructionExecutor method invokeOperation.
@Override
protected ListenableFuture<OperationResult> invokeOperation() {
final InstanceIdentifier<Topology> tii = TopologyProgrammingUtil.topologyForInput(this.pcepDestroyTunnelInput);
final InstanceIdentifier<Link> lii = TunnelProgrammingUtil.linkIdentifier(tii, this.pcepDestroyTunnelInput);
try (ReadOnlyTransaction t = this.dataProvider.newReadOnlyTransaction()) {
final Node node;
final Link link;
try {
// The link has to exist
link = t.read(LogicalDatastoreType.OPERATIONAL, lii).checkedGet().get();
// The source node has to exist
node = TunelProgrammingUtil.sourceNode(t, tii, link).get();
} catch (IllegalStateException | ReadFailedException e) {
LOG.debug("Link or node does not exist.", e);
return TunelProgrammingUtil.RESULT;
}
final RemoveLspInputBuilder ab = new RemoveLspInputBuilder();
ab.setName(link.getAugmentation(Link1.class).getSymbolicPathName());
ab.setNode(node.getSupportingNode().get(0).getKey().getNodeRef());
return Futures.transform((ListenableFuture<RpcResult<RemoveLspOutput>>) this.topologyService.removeLsp(ab.build()), RpcResult::getResult, MoreExecutors.directExecutor());
}
}
Aggregations