X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=pcep%2Ftopology-provider%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fbgpcep%2Fpcep%2Ftopology%2Fprovider%2FPCEPStatefulPeerProposal.java;fp=pcep%2Ftopology-provider%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fbgpcep%2Fpcep%2Ftopology%2Fprovider%2FPCEPStatefulPeerProposal.java;h=dbcf4e588cf7710ceeb4956f48e5fff8aebea6a2;hb=d0032a5e38fa0860165031a19c1195036e4e9681;hp=75daaa46e8844912b521a7a101be272a8442a3ff;hpb=84155a9afeb5bd65b132b6df688d7fb012cb426a;p=bgpcep.git diff --git a/pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/PCEPStatefulPeerProposal.java b/pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/PCEPStatefulPeerProposal.java index 75daaa46e8..dbcf4e588c 100644 --- a/pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/PCEPStatefulPeerProposal.java +++ b/pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/PCEPStatefulPeerProposal.java @@ -14,6 +14,7 @@ import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.PathComputationClient1; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Stateful1; @@ -51,25 +52,28 @@ public final class PCEPStatefulPeerProposal { void setPeerProposal(final NodeId nodeId, final TlvsBuilder openTlvsBuilder) { if (isSynOptimizationEnabled(openTlvsBuilder)) { - final ListenableFuture> future = this.dataBroker.newReadOnlyTransaction().read( + try (final ReadOnlyTransaction rTx = this.dataBroker.newReadOnlyTransaction()) { + final ListenableFuture> future = rTx.read( LogicalDatastoreType.OPERATIONAL, this.topologyId.child(Node.class, new NodeKey(nodeId)).augmentation(Node1.class) - .child(PathComputationClient.class).augmentation(PathComputationClient1.class) - .child(LspDbVersion.class)); - Futures.addCallback(future, new FutureCallback>() { - @Override - public void onSuccess(final Optional result) { - if (result.isPresent()) { - openTlvsBuilder.addAugmentation(Tlvs3.class, new Tlvs3Builder().setLspDbVersion(result.get()) - .build()); + .child(PathComputationClient.class).augmentation(PathComputationClient1.class) + .child(LspDbVersion.class)); + Futures.addCallback(future, new FutureCallback>() { + @Override + public void onSuccess(final Optional result) { + if (result.isPresent()) { + openTlvsBuilder.addAugmentation(Tlvs3.class, + new Tlvs3Builder().setLspDbVersion(result.get()).build()); + } } - } - @Override - public void onFailure(final Throwable t) { - LOG.warn("Failed to read toplogy {}.", InstanceIdentifier.keyOf(PCEPStatefulPeerProposal.this.topologyId), t); - } - }); + @Override + public void onFailure(final Throwable t) { + LOG.warn("Failed to read toplogy {}.", InstanceIdentifier.keyOf( + PCEPStatefulPeerProposal.this.topologyId), t); + } + }); + } } }