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;
13 import org.opendaylight.transportpce.pce.networkanalyzer.PceNode;
14 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.RoutingConstraintsSp;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
18 // internal type after parsing
19 public class PceConstraints {
21 private static final Logger LOG = LoggerFactory.getLogger(PceConstraints.class);
23 // TODO. for now metrics are set into hard structure
24 private RoutingConstraintsSp.PceMetric pceMetrics = RoutingConstraintsSp.PceMetric.HopCount;
25 private Long maxLatency = (long) -1;
27 // Structure related to EXCLUDE constraints
28 // Nodes/CLLI/SRLG lists might consist of two types of elements : (1)from diversity constraints (2)from exclude list
29 // e.g.: nodesToExclude - topo-level nodes IDs - comes from diversity constraints
30 // : supNodesToExclude - supporting nodes IDs - comes from exclude list
31 // "mapConstraints" class converts diversity elements into correct names
32 private List<String> nodesToExclude = new ArrayList<String>();
33 private List<String> supNodesToExclude = new ArrayList<String>();
35 private List<Long> srlgToExclude = new ArrayList<Long>();
36 private List<String> srlgLinksToExclude = new ArrayList<String>();
38 private List<String> clliToExclude = new ArrayList<String>();
39 private List<String> clliNodesToExclude = new ArrayList<String>();
41 ///Structures related to INCLUDE constraints
42 private List<String> nodesToInclude = new ArrayList<String>();
43 private List<PceNode> pceNodesToInclude = new ArrayList<PceNode>();
44 private List<ResourcePair> listToInclude = new ArrayList<ResourcePair>();
46 private List<String> srlgNames = new ArrayList<String>();
48 public enum ResourceType {
49 NONE, NODE, SRLG, CLLI;
52 public RoutingConstraintsSp.PceMetric getPceMetrics() {
56 public void setPceMetrics(RoutingConstraintsSp.PceMetric pceMetrics) {
57 this.pceMetrics = pceMetrics;
60 // Latency of path is used by Graph to validate path
61 // if -1 , latency is not applicable (not mentioned in constraints)
62 public Long getMaxLatency() {
63 LOG.debug("in Pceconstraints getMaxLatency = {}", maxLatency);
67 public void setMaxLatency(Long maxLatency) {
68 LOG.debug("in Pceconstraints setMaxLatency = {}", maxLatency);
69 this.maxLatency = maxLatency;
72 // Exclude nodes / SRLD / CLLI
74 public List<String> getExcludeSupNodes() {
75 LOG.debug("in Pceconstraints getExcludeSupNodes size = {}", supNodesToExclude.size());
76 return supNodesToExclude;
79 public void setExcludeSupNodes(List<String> supNodes) {
80 LOG.debug("in Pceconstraints setExcludeSupNodes size = {}", supNodes.size());
81 supNodesToExclude.addAll(supNodes);
84 public List<Long> getExcludeSRLG() {
85 LOG.debug("in Pceconstraints getExcludeSRLG size = {}", srlgToExclude.size());
89 public void setExcludeSRLG(List<Long> srlg) {
90 LOG.info("in Pceconstraints setExcludeSRLG size = {}", srlg.size());
91 srlgToExclude.addAll(srlg);
94 public List<String> getExcludeCLLI() {
95 LOG.debug("in Pceconstraints getExcludeCLLI size = {}", clliToExclude.size());
99 public void setExcludeCLLI(List<String> clli) {
100 LOG.debug("in Pceconstraints setExcludeCLLI size = {}", clli.size());
101 clliToExclude.addAll(clli);
104 // CLLI nodes are defined as result of 'diversity 'node'' constraints
105 // clliNodesToExclude are saved as nodes, during NW analysis the relevant
106 // CLLI IDs are added to clliToExclude
107 public List<String> getExcludeClliNodes() {
108 LOG.info("in Pceconstraints getExcludeClliNodes size = {}", clliNodesToExclude.size());
109 return clliNodesToExclude;
112 public void setExcludeClliNodes(List<String> clli) {
113 LOG.debug("in Pceconstraints setExcludeCLLI size = {}", clli.size());
114 clliNodesToExclude.addAll(clli);
117 public List<String> getExcludeSrlgLinks() {
118 LOG.info("in Pceconstraints getExcludeSrlgNodes size = {}", srlgLinksToExclude.size());
119 return srlgLinksToExclude;
122 public void setExcludeSrlgLinks(List<String> srlg) {
123 LOG.debug("in Pceconstraints setExcludeSRLG size = {}", srlg.size());
124 srlgLinksToExclude.addAll(srlg);
127 public List<String> getExcludeNodes() {
128 LOG.info("in Pceconstraints getExcludeNodes size = {}", nodesToExclude.size());
129 return nodesToExclude;
132 public void setExcludeNodes(List<String> nodes) {
133 LOG.debug("in Pceconstraints setExcludeNodes size = {}", nodes.size());
134 nodesToExclude.addAll(nodes);
138 public List<String> getIncludeNodes() {
139 LOG.debug("in Pceconstraints getIncludeNodes size = {}", nodesToInclude.size());
140 return nodesToInclude;
143 public void setIncludeNodes(List<String> nodes) {
144 LOG.debug("in Pceconstraints setIncludeNodes size = {}", nodes.size());
145 nodesToInclude.addAll(nodes);
148 public List<PceNode> getIncludePceNodes() {
149 LOG.debug("in Pceconstraints getIncludePceNodes size = {}", pceNodesToInclude.size());
150 return pceNodesToInclude;
153 public void setIncludePceNode(PceNode node) {
154 LOG.info("in Pceconstraints setIncludePceNode new node = {}", node.toString());
155 this.pceNodesToInclude.add(node);
158 public class ResourcePair {
159 public ResourcePair(ResourceType type, String name) {
165 private ResourceType type = ResourceType.NODE;
167 private String name = "";
169 public ResourceType getType() {
173 public String getName() {
179 public List<ResourcePair> getListToInclude() {
180 return listToInclude;
183 public void setListToInclude(ResourcePair elementToInclude) {
184 this.listToInclude.add(elementToInclude);
185 switch (elementToInclude.type) {
187 srlgNames.add(elementToInclude.name);
194 public List<String> getSRLGnames() {