package org.opendaylight.transportpce.pce.networkanalyzer;
-import com.google.common.base.Optional;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ExecutionException;
+import java.util.stream.Collectors;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.transportpce.common.NetworkUtils;
import org.opendaylight.transportpce.common.ResponseCodes;
import org.opendaylight.transportpce.common.network.NetworkTransactionService;
import org.opendaylight.transportpce.pce.constraints.PceConstraints;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev190624.PathComputationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.Node1;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Node1;
import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmLinkType;
import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmNodeType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
private String znodeId = "";
private PceConstraints pceHardConstraints;
-// private PceConstraints pceSoftConstraints;
///////////// Intermediate data/////////////////
private List<PceLink> addLinks = new ArrayList<PceLink>();
// this List serves graph calculation
private Map<NodeId, PceNode> allPceNodes = new HashMap<NodeId, PceNode>();
- // this List serves calculation of ZtoA path descritopn
+ // this List serves calculation of ZtoA path description
// TODO maybe better solution is possible
private Map<LinkId, PceLink> allPceLinks = new HashMap<LinkId, PceLink>();
private Set<LinkId> linksToExclude = new HashSet<LinkId>();
this.returnStructure = rc;
this.pceHardConstraints = pceHardConstraints;
-// this.pceSoftConstraints = pceSoftConstraints;
parseInput();
}
returnStructure.setRC(ResponseCodes.RESPONSE_FAILED);
return;
}
-
printNodesInfo(allPceNodes);
- // printLinksInfo(allPceLinks);
returnStructure.setRC(ResponseCodes.RESPONSE_OK);
return;
LOG.error("readMdSal: network is null: {}", nwInstanceIdentifier);
return false;
}
- allNodes = nw.getNode();
+ allNodes = nw.getNode().stream().sorted((n1, n2) -> n1.getNodeId().getValue().compareTo(n2.getNodeId()
+ .getValue())).collect(Collectors.toList());
Network1 nw1 = nw.augmentation(Network1.class);
- allLinks = nw1.getLink();
+ allLinks = nw1.getLink().stream().sorted((l1, l2) -> l1.getSource().getSourceTp().toString().compareTo(l2
+ .getSource().getSourceTp().toString())).collect(Collectors.toList());
if (allNodes == null || allNodes.isEmpty()) {
LOG.error("readMdSal: no nodes ");
return false;
LOG.debug("validateLink: DROP-LINK saved {}", pcelink.toString());
break;
case XPONDERINPUT :
- azSrgs.add(sourceId); // store separately all SRG links directly
+ // store separately all SRG links directly
+ azSrgs.add(sourceId);
// connected to A/Z
if (!dest.checkTP(pcelink.getDestTP().toString())) {
LOG.debug("validateLink: XPONDER-INPUT is rejected as NW port is busy - {} ", pcelink.toString());
source.addOutgoingLink(pcelink);
LOG.debug("validateLink: XPONDER-INPUT link added to allPceLinks {}", pcelink.toString());
break;
- case XPONDEROUTPUT : // does it mean XPONDER==>>SRG ?
- azSrgs.add(destId); // store separately all SRG links directly
+ // does it mean XPONDER==>>SRG ?
+ case XPONDEROUTPUT :
+ // store separately all SRG links directly
+ azSrgs.add(destId);
// connected to A/Z
if (!source.checkTP(pcelink.getSourceTP().toString())) {
LOG.debug("validateLink: XPONDER-OUTPUT is rejected as NW port is busy - {} ", pcelink.toString());
break;
}
- if (pceNode.getSupNodeIdPceNode().equals(anodeId)) {
- if (endPceNode(nodeType,pceNode.getNodeId(), pceNode)) {
+ if (pceNode.getSupNodeIdPceNode().equals(this.anodeId)) {
+ if (this.aendPceNode != null) {
+ LOG.debug("aendPceNode already gets: {}", this.aendPceNode);
+ } else if (endPceNode(nodeType,pceNode.getNodeId(), pceNode)) {
this.aendPceNode = pceNode;
}
+ // returning false otherwise would break E2E test
}
- if (pceNode.getSupNodeIdPceNode().equals(znodeId)) {
- if (endPceNode(nodeType,pceNode.getNodeId(), pceNode)) {
+ if (pceNode.getSupNodeIdPceNode().equals(this.znodeId)) {
+ if (this.zendPceNode != null) {
+ LOG.debug("zendPceNode already gets: {}", this.zendPceNode);
+ } else if (endPceNode(nodeType,pceNode.getNodeId(), pceNode)) {
this.zendPceNode = pceNode;
}
+ // returning false otherwise would break E2E test
}
allPceNodes.put(pceNode.getNodeId(), pceNode);
private ConstraintTypes validateNodeConstraints(PceNode pcenode) {
- if (pceHardConstraints.getExcludeSupNodes().isEmpty() && pceHardConstraints.getExcludeCLLI().isEmpty()) {
+ if (pceHardConstraints.getExcludeSupNodes().isEmpty() && pceHardConstraints.getExcludeCLLI().isEmpty()) {
return ConstraintTypes.NONE;
}
}
private Boolean endPceNode(OpenroadmNodeType openroadmNodeType, NodeId nodeId, PceNode pceNode) {
- Boolean add = true;
switch (openroadmNodeType) {
case SRG :
pceNode.initSrgTps();
pceNode.initXndrTps();
break;
default:
- add = false;
LOG.warn("endPceNode: Node {} is not SRG or XPONDER !", nodeId);
- break;
+ return false;
+ }
+
+ if (!pceNode.isValid()) {
+ LOG.error("validateNode : there are no availaible wavelengths in node {}", pceNode.getNodeId().getValue());
+ return false;
}
- return add;
+ return true;
}
public PceNode getaendPceNode() {
}
}
- private static void printLinksInfo(Map<LinkId, PceLink> allpcelinks) {
+ /*private static void printLinksInfo(Map<LinkId, PceLink> allpcelinks) {
Iterator<Map.Entry<LinkId, PceLink>> links = allpcelinks.entrySet().iterator();
while (links.hasNext()) {
LOG.info("In printLinksInfo link {} : ", links.next().getValue().toString());
}
- }
+ }*/
}