2 * Copyright © 2017 AT&T, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.transportpce.pce.networkanalyzer;
11 import java.math.BigDecimal;
12 import java.util.ArrayList;
13 import java.util.HashMap;
14 import java.util.HashSet;
15 import java.util.List;
17 import java.util.Optional;
19 import java.util.concurrent.ExecutionException;
20 import java.util.stream.Collectors;
21 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
22 import org.opendaylight.transportpce.common.NetworkUtils;
23 import org.opendaylight.transportpce.common.ResponseCodes;
24 import org.opendaylight.transportpce.common.StringConstants;
25 import org.opendaylight.transportpce.common.fixedflex.GridConstant;
26 import org.opendaylight.transportpce.common.mapping.MappingUtils;
27 import org.opendaylight.transportpce.common.mapping.MappingUtilsImpl;
28 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
29 import org.opendaylight.transportpce.pce.constraints.PceConstraints;
30 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.PathComputationRequestInput;
31 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev201012.network.nodes.McCapabilities;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Link1;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.Node1;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmLinkType;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmNodeType;
37 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
38 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks;
39 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
40 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network;
41 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.NetworkKey;
42 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
43 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.LinkId;
44 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Network1;
45 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
46 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
47 import org.slf4j.Logger;
48 import org.slf4j.LoggerFactory;
50 public class PceCalculation {
52 private static final Logger LOG = LoggerFactory.getLogger(PceCalculation.class);
53 private NetworkTransactionService networkTransactionService = null;
55 ///////////// data parsed from Input/////////////////
56 private PathComputationRequestInput input;
57 private String anodeId = "";
58 private String znodeId = "";
59 private String serviceFormatA = "";
60 private String serviceFormatZ = "";
61 private String serviceType = "";
62 private Long serviceRate = 0L;
64 private PceConstraints pceHardConstraints;
66 ///////////// Intermediate data/////////////////
67 private List<PceLink> addLinks = new ArrayList<>();
68 private List<PceLink> dropLinks = new ArrayList<>();
69 private HashSet<NodeId> azSrgs = new HashSet<>();
71 private PceNode aendPceNode = null;
72 private PceNode zendPceNode = null;
74 private List<Link> allLinks = null;
75 private List<Node> allNodes = null;
77 // this List serves graph calculation
78 private Map<NodeId, PceNode> allPceNodes = new HashMap<>();
79 // this List serves calculation of ZtoA path description
80 // TODO maybe better solution is possible
81 private Map<LinkId, PceLink> allPceLinks = new HashMap<>();
82 private Set<LinkId> linksToExclude = new HashSet<>();
83 private PceResult returnStructure;
85 private enum ConstraintTypes {
86 NONE, HARD_EXCLUDE, HARD_INCLUDE, HARD_DIVERSITY, SOFT_EXCLUDE, SOFT_INCLUDE, SOFT_DIVERSITY;
89 private MappingUtils mappingUtils;
91 public PceCalculation(PathComputationRequestInput input, NetworkTransactionService networkTransactionService,
92 PceConstraints pceHardConstraints, PceConstraints pceSoftConstraints, PceResult rc) {
94 this.networkTransactionService = networkTransactionService;
95 this.returnStructure = rc;
97 this.pceHardConstraints = pceHardConstraints;
98 this.mappingUtils = new MappingUtilsImpl(networkTransactionService.getDataBroker());
102 public void retrievePceNetwork() {
104 LOG.info("In PceCalculation retrieveNetwork: ");
107 returnStructure.setRC(ResponseCodes.RESPONSE_FAILED);
110 MapUtils.mapDiversityConstraints(allNodes, allLinks, pceHardConstraints);
113 returnStructure.setRC(ResponseCodes.RESPONSE_FAILED);
116 printNodesInfo(allPceNodes);
118 returnStructure.setRC(ResponseCodes.RESPONSE_OK);
122 private boolean parseInput() {
123 if (input.getServiceAEnd().getServiceFormat() == null || input.getServiceZEnd().getServiceFormat() == null
124 || input.getServiceAEnd().getServiceRate() == null) {
125 LOG.error("Service Format and Service Rate are required for a path calculation");
128 serviceFormatA = input.getServiceAEnd().getServiceFormat().getName();
129 serviceFormatZ = input.getServiceZEnd().getServiceFormat().getName();
130 serviceRate = input.getServiceAEnd().getServiceRate().toJava();
132 LOG.info("parseInput: A and Z :[{}] and [{}]", anodeId, znodeId);
133 if (!(serviceFormatA.equals(serviceFormatZ))) {
134 LOG.info("parseInput: different service format for A and Z not handled, will use service format from Aend");
135 } else if (serviceRate == 100L) {
136 switch (serviceFormatA) {
139 serviceType = StringConstants.SERVICE_TYPE_100GE;
142 serviceType = StringConstants.SERVICE_TYPE_OTU4;
145 serviceType = StringConstants.SERVICE_TYPE_ODU4;
148 LOG.debug("parseInput: unsupported service type: Format {} Rate 100L", serviceFormatA);
151 //switch(serviceRate) may seem a better option at first glance.
152 //But switching on Long or long is not directly possible in Java.
153 //And casting to int bumps the limit here.
154 //Passing by ENUM or String are possible alternatives.
155 //Maybe HashMap and similar options should also be considered here.
156 } else if ("Ethernet".equals(serviceFormatA)) {
157 //only rate 100L is currently supported except in Ethernet
158 if (serviceRate == 10L) {
159 serviceType = StringConstants.SERVICE_TYPE_10GE;
160 } else if (serviceRate == 1L) {
161 serviceType = StringConstants.SERVICE_TYPE_1GE;
163 LOG.debug("parseInput: unsupported service type: Format Ethernet Rate {}", serviceRate);
166 LOG.debug("parseInput: unsupported service type: Format {} Rate {}",
167 serviceFormatA, serviceRate);
169 if (StringConstants.SERVICE_TYPE_ODU4.equals(serviceType)
170 || StringConstants.SERVICE_TYPE_10GE.equals(serviceType)
171 || StringConstants.SERVICE_TYPE_1GE.equals(serviceType)) {
172 anodeId = input.getServiceAEnd().getTxDirection().getPort().getPortDeviceName();
173 znodeId = input.getServiceZEnd().getTxDirection().getPort().getPortDeviceName();
175 anodeId = input.getServiceAEnd().getNodeId();
176 znodeId = input.getServiceZEnd().getNodeId();
179 returnStructure.setRate(input.getServiceAEnd().getServiceRate().toJava());
180 returnStructure.setServiceFormat(input.getServiceAEnd().getServiceFormat());
184 private boolean readMdSal() {
185 InstanceIdentifier<Network> nwInstanceIdentifier = null;
187 if (("OC".equals(serviceFormatA)) || ("OTU".equals(serviceFormatA)) || (("Ethernet".equals(serviceFormatA))
188 && (serviceRate == 100L))) {
190 LOG.info("readMdSal: network {}", NetworkUtils.OVERLAY_NETWORK_ID);
191 nwInstanceIdentifier = InstanceIdentifier.builder(Networks.class)
192 .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))).build();
193 } else if ("ODU".equals(serviceFormatA) || ("Ethernet".equals(serviceFormatA) && serviceRate == 10L)
194 || ("Ethernet".equals(serviceFormatA) && serviceRate == 1L)) {
195 LOG.info("readMdSal: network {}", NetworkUtils.OTN_NETWORK_ID);
196 nwInstanceIdentifier = InstanceIdentifier.builder(Networks.class)
197 .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OTN_NETWORK_ID))).build();
199 LOG.info("readMdSal: service-rate {} / service-format not handled {}", serviceRate, serviceFormatA);
204 Optional<Network> nwOptional =
205 networkTransactionService.read(LogicalDatastoreType.CONFIGURATION, nwInstanceIdentifier).get();
206 if (nwOptional.isPresent()) {
207 nw = nwOptional.get();
208 LOG.debug("readMdSal: network nodes: nwOptional.isPresent = true {}", nw);
210 } catch (InterruptedException | ExecutionException e) {
211 LOG.error("readMdSal: Error reading topology {}", nwInstanceIdentifier);
212 networkTransactionService.close();
213 returnStructure.setRC(ResponseCodes.RESPONSE_FAILED);
214 throw new RuntimeException(
215 "readMdSal: Error reading from operational store, topology : " + nwInstanceIdentifier + " :" + e);
217 networkTransactionService.close();
220 LOG.error("readMdSal: network is null: {}", nwInstanceIdentifier);
223 allNodes = nw.nonnullNode().values().stream().sorted((n1, n2)
224 -> n1.getNodeId().getValue().compareTo(n2.getNodeId().getValue())).collect(Collectors.toList());
225 Network1 nw1 = nw.augmentation(Network1.class);
227 allLinks = nw1.nonnullLink().values().stream().sorted((l1, l2)
228 -> l1.getSource().getSourceTp().toString().compareTo(l2.getSource().getSourceTp().toString()))
229 .collect(Collectors.toList());
231 LOG.warn("no otn links in otn-topology");
233 if (allNodes == null || allNodes.isEmpty()) {
234 LOG.error("readMdSal: no nodes ");
237 LOG.info("readMdSal: network nodes: {} nodes added", allNodes.size());
238 LOG.debug("readMdSal: network nodes: {} nodes added", allNodes);
240 if (allLinks == null || allLinks.isEmpty()) {
241 LOG.error("readMdSal: no links ");
244 LOG.info("readMdSal: network links: {} links added", allLinks.size());
245 LOG.debug("readMdSal: network links: {} links added", allLinks);
250 private boolean analyzeNw() {
252 LOG.debug("analyzeNw: allNodes size {}, allLinks size {}", allNodes.size(), allLinks.size());
254 if ((StringConstants.SERVICE_TYPE_100GE.equals(serviceType))
255 || (StringConstants.SERVICE_TYPE_OTU4.equals(serviceType))) {
256 // 100GE service and OTU4 service are handled at the openroadm-topology layer
257 for (Node node : allNodes) {
261 LOG.debug("analyzeNw: allPceNodes size {}", allPceNodes.size());
263 if (aendPceNode == null || zendPceNode == null) {
264 LOG.error("analyzeNw: Error in reading nodes: A or Z do not present in the network");
267 for (Link link : allLinks) {
271 LOG.debug("analyzeNw: addLinks size {}, dropLinks size {}", addLinks.size(), dropLinks.size());
273 LOG.debug("analyzeNw: azSrgs size = {}", azSrgs.size());
274 for (NodeId srg : azSrgs) {
275 LOG.debug("analyzeNw: A/Z Srgs SRG = {}", srg.getValue());
278 for (PceLink link : addLinks) {
279 filteraddLinks(link);
281 for (PceLink link : dropLinks) {
282 filterdropLinks(link);
286 // ODU4, 10GE/ODU2e or 1GE/ODU0 services are handled at openroadm-otn layer
288 for (Node node : allNodes) {
289 validateOtnNode(node);
292 LOG.info("analyzeNw: allPceNodes {}", allPceNodes);
294 if (aendPceNode == null || zendPceNode == null) {
295 LOG.error("analyzeNw: Error in reading nodes: A or Z do not present in the network");
298 for (Link link : allLinks) {
303 LOG.info("analyzeNw: allPceNodes size {}, allPceLinks size {}", allPceNodes.size(), allPceLinks.size());
305 if ((allPceNodes.size() == 0) || (allPceLinks.size() == 0)) {
309 LOG.debug("analyzeNw: allPceNodes {}", allPceNodes);
310 LOG.debug("analyzeNw: allPceLinks {}", allPceLinks);
315 private boolean filteraddLinks(PceLink pcelink) {
317 NodeId nodeId = pcelink.getSourceId();
319 if (azSrgs.contains(nodeId)) {
320 allPceLinks.put(pcelink.getLinkId(), pcelink);
321 allPceNodes.get(nodeId).addOutgoingLink(pcelink);
322 LOG.debug("analyzeNw: Add_LINK added to source and to allPceLinks {}", pcelink.getLinkId());
326 // remove the SRG from PceNodes, as it is not directly connected to A/Z
327 allPceNodes.remove(nodeId);
328 LOG.debug("analyzeNw: SRG removed {}", nodeId.getValue());
333 private boolean filterdropLinks(PceLink pcelink) {
335 NodeId nodeId = pcelink.getDestId();
337 if (azSrgs.contains(nodeId)) {
338 allPceLinks.put(pcelink.getLinkId(), pcelink);
339 allPceNodes.get(nodeId).addOutgoingLink(pcelink);
340 LOG.debug("analyzeNw: Drop_LINK added to dest and to allPceLinks {}", pcelink.getLinkId());
344 // remove the SRG from PceNodes, as it is not directly connected to A/Z
345 allPceNodes.remove(pcelink.getDestId());
346 LOG.debug("analyzeNw: SRG removed {}", nodeId.getValue());
351 private boolean validateLink(Link link) {
352 LOG.info("validateLink: link {} ", link);
354 NodeId sourceId = link.getSource().getSourceNode();
355 NodeId destId = link.getDestination().getDestNode();
356 PceNode source = allPceNodes.get(sourceId);
357 PceNode dest = allPceNodes.get(destId);
358 State state = link.augmentation(Link1.class).getOperationalState();
360 if (source == null) {
361 LOG.debug("validateLink: Link is ignored due source node is rejected by node validation - {}",
362 link.getSource().getSourceNode().getValue());
366 LOG.debug("validateLink: Link is ignored due dest node is rejected by node validation - {}",
367 link.getDestination().getDestNode().getValue());
371 if (State.OutOfService.equals(state)) {
372 LOG.debug("validateLink: Link is ignored due operational state - {}",
377 if ((StringConstants.SERVICE_TYPE_100GE.equals(serviceType))
378 || (StringConstants.SERVICE_TYPE_OTU4.equals(serviceType))) {
379 // 100GE or OTU4 services are handled at WDM Layer
380 PceLink pcelink = new PceLink(link, source, dest);
381 if (!pcelink.isValid()) {
382 dropOppositeLink(link);
383 LOG.error(" validateLink: Link is ignored due errors in network data or in opposite link");
386 LinkId linkId = pcelink.getLinkId();
387 if (validateLinkConstraints(pcelink).equals(ConstraintTypes.HARD_EXCLUDE)) {
388 dropOppositeLink(link);
389 LOG.debug("validateLink: constraints : link is ignored == {}", linkId.getValue());
392 switch (pcelink.getlinkType()) {
395 allPceLinks.put(linkId, pcelink);
396 source.addOutgoingLink(pcelink);
397 LOG.debug("validateLink: {}-LINK added to allPceLinks {}",
398 pcelink.getlinkType(), pcelink);
401 pcelink.setClient(source.getRdmSrgClient(pcelink.getSourceTP().toString()));
402 addLinks.add(pcelink);
403 LOG.debug("validateLink: ADD-LINK saved {}", pcelink);
406 pcelink.setClient(dest.getRdmSrgClient(pcelink.getDestTP().toString()));
407 dropLinks.add(pcelink);
408 LOG.debug("validateLink: DROP-LINK saved {}", pcelink);
411 // store separately all SRG links directly
412 azSrgs.add(sourceId);
414 if (!dest.checkTP(pcelink.getDestTP().toString())) {
416 "validateLink: XPONDER-INPUT is rejected as NW port is busy - {} ", pcelink);
419 if (dest.getXpdrClient(pcelink.getDestTP().toString()) != null) {
420 pcelink.setClient(dest.getXpdrClient(pcelink.getDestTP().toString()));
422 allPceLinks.put(linkId, pcelink);
423 source.addOutgoingLink(pcelink);
424 LOG.debug("validateLink: XPONDER-INPUT link added to allPceLinks {}", pcelink);
426 // does it mean XPONDER==>>SRG ?
428 // store separately all SRG links directly
431 if (!source.checkTP(pcelink.getSourceTP().toString())) {
433 "validateLink: XPONDER-OUTPUT is rejected as NW port is busy - {} ", pcelink);
436 if (source.getXpdrClient(pcelink.getSourceTP().toString()) != null) {
437 pcelink.setClient(source.getXpdrClient(pcelink.getSourceTP().toString()));
439 allPceLinks.put(linkId, pcelink);
440 source.addOutgoingLink(pcelink);
441 LOG.debug("validateLink: XPONDER-OUTPUT link added to allPceLinks {}", pcelink);
444 LOG.warn("validateLink: link type is not supported {}", pcelink);
448 } else if ((StringConstants.SERVICE_TYPE_ODU4.equals(serviceType))
449 || (StringConstants.SERVICE_TYPE_10GE.equals(serviceType))
450 || (StringConstants.SERVICE_TYPE_1GE.equals(serviceType))) {
451 // ODU4, 1GE and 10GE services relying on ODU2, ODU2e or ODU0 services are handled at OTN layer
452 PceLink pceOtnLink = new PceLink(link, source, dest);
454 if (!pceOtnLink.isOtnValid(link, serviceType)) {
455 dropOppositeLink(link);
456 LOG.error(" validateLink: Link is ignored due errors in network data or in opposite link");
460 LinkId linkId = pceOtnLink.getLinkId();
461 if (validateLinkConstraints(pceOtnLink).equals(ConstraintTypes.HARD_EXCLUDE)) {
462 dropOppositeLink(link);
463 LOG.debug("validateLink: constraints : link is ignored == {}", linkId.getValue());
467 switch (pceOtnLink.getlinkType()) {
469 if (dest.getXpdrClient(pceOtnLink.getDestTP().toString()) != null) {
470 pceOtnLink.setClient(dest.getXpdrClient(pceOtnLink.getDestTP().toString()));
473 allPceLinks.put(linkId, pceOtnLink);
474 source.addOutgoingLink(pceOtnLink);
475 LOG.info("validateLink: OTN-LINK added to allPceLinks {}", pceOtnLink);
478 LOG.warn("validateLink: link type is not supported {}", pceOtnLink);
483 LOG.error(" validateLink: Unmanaged service type {}", serviceType);
489 private boolean validateNode(Node node) {
490 LOG.debug("validateNode: node {} ", node);
491 // PceNode will be used in Graph algorithm
492 Node1 node1 = node.augmentation(Node1.class);
494 LOG.error("getNodeType: no Node1 (type) Augmentation for node: [{}]. Node is ignored", node.getNodeId());
497 if (State.OutOfService.equals(node1.getOperationalState())) {
498 LOG.error("getNodeType: node is ignored due to operational state - {}", node1.getOperationalState()
502 OpenroadmNodeType nodeType = node1.getNodeType();
503 String deviceNodeId = MapUtils.getSupNetworkNode(node);
504 // Should never happen but because of existing topology test files
505 // we have to manage this case
506 if (deviceNodeId == null || deviceNodeId.isBlank()) {
507 deviceNodeId = node.getNodeId().getValue();
509 LOG.info("Device node id {} for {}", deviceNodeId, node);
510 PceOpticalNode pceNode = new PceOpticalNode(node, nodeType, mappingUtils.getOpenRoadmVersion(deviceNodeId),
511 getSlotWidthGranularity(deviceNodeId, node.getNodeId()));
512 pceNode.validateAZxponder(anodeId, znodeId, input.getServiceAEnd().getServiceFormat());
513 pceNode.initFrequenciesBitSet();
515 if (!pceNode.isValid()) {
516 LOG.warn(" validateNode: Node is ignored");
519 if (validateNodeConstraints(pceNode).equals(ConstraintTypes.HARD_EXCLUDE)) {
522 if (endPceNode(nodeType, pceNode.getNodeId(), pceNode) && this.aendPceNode == null
523 && isAZendPceNode(this.serviceFormatA, pceNode, anodeId, "A")) {
524 this.aendPceNode = pceNode;
526 if (endPceNode(nodeType, pceNode.getNodeId(), pceNode) && this.zendPceNode == null
527 && isAZendPceNode(this.serviceFormatZ, pceNode, znodeId, "Z")) {
528 this.zendPceNode = pceNode;
531 allPceNodes.put(pceNode.getNodeId(), pceNode);
532 LOG.debug("validateNode: node is saved {}", pceNode.getNodeId().getValue());
536 private boolean isAZendPceNode(String serviceFormat, PceOpticalNode pceNode, String azNodeId, String azEndPoint) {
537 switch (serviceFormat) {
540 if (pceNode.getSupNetworkNodeId().equals(azNodeId)) {
545 if ("A".equals(azEndPoint) && pceNode.getNodeId().getValue()
546 .equals(this.input.getServiceAEnd().getRxDirection().getPort().getPortDeviceName())) {
549 if ("Z".equals(azEndPoint) && pceNode.getNodeId().getValue()
550 .equals(this.input.getServiceZEnd().getRxDirection().getPort().getPortDeviceName())) {
555 LOG.debug("Unsupported service Format {} for node {}", serviceFormat, pceNode.getNodeId().getValue());
560 private boolean validateOtnNode(Node node) {
561 LOG.info("validateOtnNode: {} ", node.getNodeId().getValue());
562 // PceOtnNode will be used in Graph algorithm
563 if (node.augmentation(Node1.class) != null) {
564 OpenroadmNodeType nodeType = node.augmentation(Node1.class).getNodeType();
566 PceOtnNode pceOtnNode = new PceOtnNode(node, nodeType, node.getNodeId(), "otn", serviceType);
567 pceOtnNode.validateXponder(anodeId, znodeId);
569 if (!pceOtnNode.isValid()) {
570 LOG.warn(" validateOtnNode: Node {} is ignored", node.getNodeId().getValue());
573 if (validateNodeConstraints(pceOtnNode).equals(ConstraintTypes.HARD_EXCLUDE)) {
576 if (pceOtnNode.getNodeId().getValue().equals(anodeId) && this.aendPceNode == null) {
577 this.aendPceNode = pceOtnNode;
579 if (pceOtnNode.getNodeId().getValue().equals(znodeId) && this.zendPceNode == null) {
580 this.zendPceNode = pceOtnNode;
582 allPceNodes.put(pceOtnNode.getNodeId(), pceOtnNode);
583 LOG.info("validateOtnNode: node {} is saved", node.getNodeId().getValue());
586 LOG.error("ValidateOtnNode: no node-type augmentation. Node {} is ignored", node.getNodeId().getValue());
591 private ConstraintTypes validateNodeConstraints(PceNode pcenode) {
592 if (pceHardConstraints.getExcludeSupNodes().isEmpty() && pceHardConstraints.getExcludeCLLI().isEmpty()) {
593 return ConstraintTypes.NONE;
595 if (pceHardConstraints.getExcludeSupNodes().contains(pcenode.getSupNetworkNodeId())) {
596 LOG.info("validateNodeConstraints: {}", pcenode.getNodeId().getValue());
597 return ConstraintTypes.HARD_EXCLUDE;
599 if (pceHardConstraints.getExcludeCLLI().contains(pcenode.getSupClliNodeId())) {
600 LOG.info("validateNodeConstraints: {}", pcenode.getNodeId().getValue());
601 return ConstraintTypes.HARD_EXCLUDE;
603 return ConstraintTypes.NONE;
606 private ConstraintTypes validateLinkConstraints(PceLink link) {
607 if (pceHardConstraints.getExcludeSRLG().isEmpty()) {
608 return ConstraintTypes.NONE;
611 // for now SRLG is the only constraint for link
612 if (link.getlinkType() != OpenroadmLinkType.ROADMTOROADM) {
613 return ConstraintTypes.NONE;
616 List<Long> constraints = new ArrayList<>(pceHardConstraints.getExcludeSRLG());
617 constraints.retainAll(link.getsrlgList());
618 if (!constraints.isEmpty()) {
619 LOG.info("validateLinkConstraints: {}", link.getLinkId().getValue());
620 return ConstraintTypes.HARD_EXCLUDE;
623 return ConstraintTypes.NONE;
626 private void dropOppositeLink(Link link) {
627 LinkId opplink = MapUtils.extractOppositeLink(link);
629 if (allPceLinks.containsKey(opplink)) {
630 allPceLinks.remove(opplink);
632 linksToExclude.add(opplink);
636 private Boolean endPceNode(OpenroadmNodeType openroadmNodeType, NodeId nodeId, PceOpticalNode pceNode) {
637 switch (openroadmNodeType) {
639 pceNode.initSrgTps();
640 this.azSrgs.add(nodeId);
643 pceNode.initXndrTps(input.getServiceAEnd().getServiceFormat());
646 LOG.warn("endPceNode: Node {} is not SRG or XPONDER !", nodeId);
650 if (!pceNode.isValid()) {
651 LOG.error("validateNode : there are no available frequencies in node {}", pceNode.getNodeId().getValue());
657 public PceNode getaendPceNode() {
661 public PceNode getzendPceNode() {
665 public Map<NodeId, PceNode> getAllPceNodes() {
666 return this.allPceNodes;
669 public Map<LinkId, PceLink> getAllPceLinks() {
670 return this.allPceLinks;
673 public String getServiceType() {
677 public PceResult getReturnStructure() {
678 return returnStructure;
681 private static void printNodesInfo(Map<NodeId, PceNode> allPceNodes) {
682 allPceNodes.forEach(((nodeId, pceNode) -> {
683 LOG.info("In printNodes in node {} : outgoing links {} ", pceNode.getNodeId().getValue(),
684 pceNode.getOutgoingLinks());
689 * Get mc capability slot width granularity for device.
690 * @param deviceNodeId String
691 * @param nodeId NodeId
692 * @return slot width granularity
694 private BigDecimal getSlotWidthGranularity(String deviceNodeId, NodeId nodeId) {
695 // nodeId: openroadm-topology level node
696 // deviceNodeId: openroadm-network level node
697 List<McCapabilities> mcCapabilities = mappingUtils.getMcCapabilitiesForNode(deviceNodeId);
698 String[] params = nodeId.getValue().split("-");
700 String rdmModuleName = params[params.length - 1];
701 for (McCapabilities mcCapabitility : mcCapabilities) {
702 if (mcCapabitility.getMcNodeName().contains(rdmModuleName)
703 && mcCapabitility.getSlotWidthGranularity() != null) {
704 return mcCapabitility.getSlotWidthGranularity().getValue();
707 return GridConstant.SLOT_WIDTH_50;