X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=pcep%2Ftopology-provider%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fbgpcep%2Fpcep%2Ftopology%2Fprovider%2FAbstractTopologySessionListener.java;h=c3cdc667a2fe9abc5dd2697eac8d8b67cf7ac277;hb=5d8642f75fcaaf0dfa86277813989837c539e2c8;hp=6281d4151a9ff8623146a130a62a48ee402eedea;hpb=e0af77dd6423e18a37e628e27b52b5dd98fc9af0;p=bgpcep.git diff --git a/pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/AbstractTopologySessionListener.java b/pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/AbstractTopologySessionListener.java index 6281d4151a..c3cdc667a2 100644 --- a/pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/AbstractTopologySessionListener.java +++ b/pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/AbstractTopologySessionListener.java @@ -42,6 +42,7 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology. import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey; import org.opendaylight.yangtools.yang.binding.DataContainer; +import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -71,13 +72,11 @@ public abstract class AbstractTopologySessionListener implements }; private static final Logger LOG = LoggerFactory.getLogger(AbstractTopologySessionListener.class); - // FIXME: make this private - protected final ServerSessionManager serverSessionManager; - private final Map waitingRequests = new HashMap<>(); private final Map sendingRequests = new HashMap<>(); private final Map lspData = new HashMap<>(); private final Map lsps = new HashMap<>(); + private final ServerSessionManager serverSessionManager; private InstanceIdentifier topologyNode; private InstanceIdentifier topologyAugment; private PathComputationClientBuilder pccBuilder; @@ -102,7 +101,7 @@ public abstract class AbstractTopologySessionListener implements for (final Node n : topo.getNode()) { LOG.debug("Matching topology node {} to id {}", n, pccId); if (n.getNodeId().getValue().equals(pccId)) { - this.topologyNode = InstanceIdentifier.builder(this.serverSessionManager.getTopology()).child(Node.class, n.getKey()).toInstance(); + this.topologyNode = this.serverSessionManager.getTopology().child(Node.class, n.getKey()); LOG.debug("Reusing topology node {} for id {} at {}", n, pccId, this.topologyNode); return n; } @@ -114,7 +113,7 @@ public abstract class AbstractTopologySessionListener implements */ final NodeId id = new NodeId(pccId); final NodeKey nk = new NodeKey(id); - final InstanceIdentifier nti = InstanceIdentifier.builder(this.serverSessionManager.getTopology()).child(Node.class, nk).toInstance(); + final InstanceIdentifier nti = this.serverSessionManager.getTopology().child(Node.class, nk); final Node ret = new NodeBuilder().setKey(nk).setNodeId(id).build(); @@ -147,7 +146,7 @@ public abstract class AbstractTopologySessionListener implements onSessionUp(session, this.pccBuilder); this.topologyAugmentBuilder = new Node1Builder().setPathComputationClient(this.pccBuilder.build()); - this.topologyAugment = InstanceIdentifier.builder(this.topologyNode).augmentation(Node1.class).toInstance(); + this.topologyAugment = this.topologyNode.augmentation(Node1.class); final Node1 ta = this.topologyAugmentBuilder.build(); trans.putOperationalData(this.topologyAugment, ta); @@ -243,7 +242,7 @@ public abstract class AbstractTopologySessionListener implements this.topologyAugmentBuilder.setPathComputationClient(this.pccBuilder.build()); final Node1 ta = this.topologyAugmentBuilder.build(); - //trans.removeOperationalData(this.topologyAugment); + trans.removeOperationalData(this.topologyAugment); trans.putOperationalData(this.topologyAugment, ta); LOG.debug("Peer data {} set to {}", this.topologyAugment, ta); dirty = false; @@ -273,7 +272,7 @@ public abstract class AbstractTopologySessionListener implements } protected InstanceIdentifierBuilder pccIdentifier() { - return InstanceIdentifier.builder(this.topologyAugment).child(PathComputationClient.class); + return this.topologyAugment.builder().child(PathComputationClient.class); } protected final synchronized PCEPRequest removeRequest(final SRPID id) { @@ -308,15 +307,20 @@ public abstract class AbstractTopologySessionListener implements return req.getFuture(); } - protected final synchronized void updateLsp(final DataModificationTransaction trans, final PLSPID id, String name, + protected final synchronized void updateLsp(final DataModificationTransaction trans, final PLSPID id, final String lspName, final ReportedLspBuilder rlb, final boolean solicited) { - if (name == null) { + + final String name; + if (lspName == null) { name = this.lsps.get(id); if (name == null) { LOG.error("PLSPID {} seen for the first time, not reporting the LSP", id); return; } + } else { + name = lspName; } + LOG.debug("Saved LSP {} with name {}", id, name); this.lsps.put(id, name); @@ -363,12 +367,16 @@ public abstract class AbstractTopologySessionListener implements lspData.remove(name); } - abstract protected void onSessionUp(PCEPSession session, PathComputationClientBuilder pccBuilder); + protected abstract void onSessionUp(PCEPSession session, PathComputationClientBuilder pccBuilder); - abstract protected boolean onMessage(DataModificationTransaction trans, Message message); + protected abstract boolean onMessage(DataModificationTransaction trans, Message message); protected String lookupLspName(final PLSPID id) { Preconditions.checkNotNull(id, "ID parameter null."); return this.lsps.get(id); } + + protected final T readOperationalData(final InstanceIdentifier id) { + return serverSessionManager.readOperationalData(id); + } }