Search in sources :

Example 66 with ReadFailedException

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());
    }
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) UnsubscribeDtclOutput(org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeDtclOutput) DOMDataReadOnlyTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction) RpcError(org.opendaylight.yangtools.yang.common.RpcError) ExecutionException(java.util.concurrent.ExecutionException) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) UnsubscribeDtclOutputBuilder(org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeDtclOutputBuilder) TimeoutException(java.util.concurrent.TimeoutException)

Example 67 with ReadFailedException

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());
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) DOMStoreReadTransaction(org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) DOMStoreReadWriteTransaction(org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) DOMStoreThreePhaseCommitCohort(org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort) Test(org.junit.Test)

Example 68 with ReadFailedException

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());
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) DOMStoreReadTransaction(org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction) DOMStoreReadWriteTransaction(org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction) Test(org.junit.Test)

Example 69 with ReadFailedException

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());
    }
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) Link(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link)

Example 70 with ReadFailedException

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());
    }
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) RemoveLspInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.RemoveLspInputBuilder) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) Link(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link)

Aggregations

ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)129 Optional (com.google.common.base.Optional)44 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)30 ArrayList (java.util.ArrayList)25 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)25 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)23 ExecutionException (java.util.concurrent.ExecutionException)17 Test (org.junit.Test)16 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)10 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)10 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)9 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)9 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)8 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)8 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)7 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)7 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)6 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)6 SingleTransactionDataBroker (org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker)6 VpnInstance (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance)6