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;
};
private static final Logger LOG = LoggerFactory.getLogger(AbstractTopologySessionListener.class);
- // FIXME: make this private
- protected final ServerSessionManager serverSessionManager;
-
private final Map<SRPID, PCEPRequest> waitingRequests = new HashMap<>();
private final Map<SRPID, PCEPRequest> sendingRequests = new HashMap<>();
private final Map<String, ReportedLsp> lspData = new HashMap<>();
private final Map<PLSPID, String> lsps = new HashMap<>();
+ private final ServerSessionManager serverSessionManager;
private InstanceIdentifier<Node> topologyNode;
private InstanceIdentifier<Node1> topologyAugment;
private PathComputationClientBuilder pccBuilder;
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;
}
*/
final NodeId id = new NodeId(pccId);
final NodeKey nk = new NodeKey(id);
- final InstanceIdentifier<Node> nti = InstanceIdentifier.builder(this.serverSessionManager.getTopology()).child(Node.class, nk).toInstance();
+ final InstanceIdentifier<Node> nti = this.serverSessionManager.getTopology().child(Node.class, nk);
final Node ret = new NodeBuilder().setKey(nk).setNodeId(id).build();
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);
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;
}
protected InstanceIdentifierBuilder<PathComputationClient> pccIdentifier() {
- return InstanceIdentifier.builder(this.topologyAugment).child(PathComputationClient.class);
+ return this.topologyAugment.builder().child(PathComputationClient.class);
}
protected final synchronized PCEPRequest removeRequest(final SRPID id) {
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);
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 extends DataObject> T readOperationalData(final InstanceIdentifier<T> id) {
+ return serverSessionManager.readOperationalData(id);
+ }
}