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
8 package org.opendaylight.transportpce.pce.constraints;
10 import java.util.ArrayList;
11 import java.util.List;
12 import org.opendaylight.transportpce.pce.networkanalyzer.PceOpticalNode;
13 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.RoutingConstraintsSp;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
17 // internal type after parsing
18 public class PceConstraints {
20 private static final Logger LOG = LoggerFactory.getLogger(PceConstraints.class);
22 // TODO. for now metrics are set into hard structure
23 private RoutingConstraintsSp.PceMetric pceMetrics = RoutingConstraintsSp.PceMetric.HopCount;
24 private Long maxLatency = -1L;
26 // Structure related to EXCLUDE constraints
27 // Nodes/CLLI/SRLG lists might consist of two types of elements : (1)from diversity constraints (2)from exclude list
28 // e.g.: nodesToExclude - topo-level nodes IDs - comes from diversity constraints
29 // : supNodesToExclude - supporting nodes IDs - comes from exclude list
30 // "mapConstraints" class converts diversity elements into correct names
31 private List<String> nodesToExclude = new ArrayList<>();
32 private List<String> supNodesToExclude = new ArrayList<>();
34 private List<Long> srlgToExclude = new ArrayList<>();
35 private List<String> srlgLinksToExclude = new ArrayList<>();
37 private List<String> clliToExclude = new ArrayList<>();
38 private List<String> clliNodesToExclude = new ArrayList<>();
40 ///Structures related to INCLUDE constraints
41 private List<String> nodesToInclude = new ArrayList<>();
42 private List<PceOpticalNode> pceNodesToInclude = new ArrayList<>();
43 private List<ResourcePair> listToInclude = new ArrayList<>();
45 private List<String> srlgNames = new ArrayList<>();
47 public enum ResourceType {
48 NONE, NODE, SRLG, CLLI;
51 public RoutingConstraintsSp.PceMetric getPceMetrics() {
55 public void setPceMetrics(RoutingConstraintsSp.PceMetric pceMetrics) {
56 this.pceMetrics = pceMetrics;
59 // Latency of path is used by Graph to validate path
60 // if -1 , latency is not applicable (not mentioned in constraints)
61 public Long getMaxLatency() {
62 LOG.debug("in Pceconstraints getMaxLatency = {}", maxLatency);
66 public void setMaxLatency(Long maxLatency) {
67 LOG.debug("in Pceconstraints setMaxLatency = {}", maxLatency);
68 this.maxLatency = maxLatency;
71 // Exclude nodes / SRLD / CLLI
73 public List<String> getExcludeSupNodes() {
74 LOG.debug("in Pceconstraints getExcludeSupNodes size = {}", supNodesToExclude.size());
75 return supNodesToExclude;
78 public void setExcludeSupNodes(List<String> supNodes) {
79 LOG.debug("in Pceconstraints setExcludeSupNodes size = {}", supNodes.size());
80 supNodesToExclude.addAll(supNodes);
83 public List<Long> getExcludeSRLG() {
84 LOG.debug("in Pceconstraints getExcludeSRLG size = {}", srlgToExclude.size());
88 public void setExcludeSRLG(List<Long> srlg) {
89 LOG.info("in Pceconstraints setExcludeSRLG size = {}", srlg.size());
90 srlgToExclude.addAll(srlg);
93 public List<String> getExcludeCLLI() {
94 LOG.debug("in Pceconstraints getExcludeCLLI size = {}", clliToExclude.size());
98 public void setExcludeCLLI(List<String> clli) {
99 LOG.debug("in Pceconstraints setExcludeCLLI size = {}", clli.size());
100 clliToExclude.addAll(clli);
103 // CLLI nodes are defined as result of 'diversity 'node'' constraints
104 // clliNodesToExclude are saved as nodes, during NW analysis the relevant
105 // CLLI IDs are added to clliToExclude
106 public List<String> getExcludeClliNodes() {
107 LOG.info("in Pceconstraints getExcludeClliNodes size = {}", clliNodesToExclude.size());
108 return clliNodesToExclude;
111 public void setExcludeClliNodes(List<String> clli) {
112 LOG.debug("in Pceconstraints setExcludeCLLI size = {}", clli.size());
113 clliNodesToExclude.addAll(clli);
116 public List<String> getExcludeSrlgLinks() {
117 LOG.info("in Pceconstraints getExcludeSrlgNodes size = {}", srlgLinksToExclude.size());
118 return srlgLinksToExclude;
121 public void setExcludeSrlgLinks(List<String> srlg) {
122 LOG.debug("in Pceconstraints setExcludeSRLG size = {}", srlg.size());
123 srlgLinksToExclude.addAll(srlg);
126 public List<String> getExcludeNodes() {
127 LOG.info("in Pceconstraints getExcludeNodes size = {}", nodesToExclude.size());
128 return nodesToExclude;
131 public void setExcludeNodes(List<String> nodes) {
132 LOG.debug("in Pceconstraints setExcludeNodes size = {}", nodes.size());
133 nodesToExclude.addAll(nodes);
137 public List<String> getIncludeNodes() {
138 LOG.debug("in Pceconstraints getIncludeNodes size = {}", nodesToInclude.size());
139 return nodesToInclude;
142 public void setIncludeNodes(List<String> nodes) {
143 LOG.debug("in Pceconstraints setIncludeNodes size = {}", nodes.size());
144 nodesToInclude.addAll(nodes);
147 public List<PceOpticalNode> getIncludePceNodes() {
148 LOG.debug("in Pceconstraints getIncludePceNodes size = {}", pceNodesToInclude.size());
149 return pceNodesToInclude;
152 public void setIncludePceNode(PceOpticalNode node) {
153 LOG.info("in Pceconstraints setIncludePceNode new node = {}", node);
154 this.pceNodesToInclude.add(node);
157 public static class ResourcePair {
159 public ResourcePair(ResourceType type, String name) {
165 private ResourceType type = ResourceType.NODE;
166 private String name = "";
168 public ResourceType getType() {
172 public String getName() {
178 public List<ResourcePair> getListToInclude() {
179 return listToInclude;
182 public void setListToInclude(ResourcePair elementToInclude) {
183 this.listToInclude.add(elementToInclude);
184 switch (elementToInclude.type) {
186 srlgNames.add(elementToInclude.name);
193 public List<String> getSRLGnames() {