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 /////////////// EXCLUDE ///////////////////
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>();
40 private List<String> nodesToInclude = new ArrayList<String>();
41 private List<PceNode> pceNodesToInclude = new ArrayList<PceNode>();
43 public static final Long CONST_OSNR = 1L;
44 private double maxOSNR = (CONST_OSNR / (Math.pow(10, (24 / 10.0))));
47 * /////////////// INCLUDE CONSTRAINTS.///////////////////
49 private List<ResourcePair> listToInclude = new ArrayList<ResourcePair>();
50 private List<String> srlgNames = new ArrayList<String>();
52 public enum ResourceType {
53 NONE, NODE, SRLG, CLLI;
56 public RoutingConstraintsSp.PceMetric getPceMetrics() {
60 public void setPceMetrics(RoutingConstraintsSp.PceMetric pceMetrics) {
61 this.pceMetrics = pceMetrics;
64 // Latency of path is used by Graph to validate path
65 // if -1 , latency is not applicable (not mentioned in constraints)
66 public Long getMaxLatency() {
67 LOG.debug("in Pceconstraints getMaxLatency = {}", maxLatency);
71 public void setMaxLatency(Long maxLatency) {
72 LOG.debug("in Pceconstraints setMaxLatency = {}", maxLatency);
73 this.maxLatency = maxLatency;
76 // Exclude nodes / SRLD / CLLI
78 public List<String> getExcludeSupNodes() {
79 LOG.debug("in Pceconstraints getExcludeSupNodes size = {}", supNodesToExclude.size());
80 return supNodesToExclude;
83 public void setExcludeSupNodes(List<String> supNodes) {
84 LOG.debug("in Pceconstraints setExcludeSupNodes size = {}", supNodes.size());
85 supNodesToExclude.addAll(supNodes);
88 public List<Long> getExcludeSRLG() {
89 LOG.debug("in Pceconstraints getExcludeSRLG size = {}", srlgToExclude.size());
93 public void setExcludeSRLG(List<Long> srlg) {
94 LOG.info("in Pceconstraints setExcludeSRLG size = {}", srlg.size());
95 srlgToExclude.addAll(srlg);
98 public List<String> getExcludeCLLI() {
99 LOG.debug("in Pceconstraints getExcludeCLLI size = {}", clliToExclude.size());
100 return clliToExclude;
103 public void setExcludeCLLI(List<String> clli) {
104 LOG.debug("in Pceconstraints setExcludeCLLI size = {}", clli.size());
105 clliToExclude.addAll(clli);
108 // CLLI nodes are defined as result of 'diversity 'node'' constraints
109 // clliNodesToExclude are saved as nodes, during NW analysis the relevant
110 // CLLI IDs are added to clliToExclude
111 public List<String> getExcludeClliNodes() {
112 LOG.info("in Pceconstraints getExcludeClliNodes size = {}", clliNodesToExclude.size());
113 return clliNodesToExclude;
116 public void setExcludeClliNodes(List<String> clli) {
117 LOG.debug("in Pceconstraints setExcludeCLLI size = {}", clli.size());
118 clliNodesToExclude.addAll(clli);
121 public List<String> getExcludeSrlgLinks() {
122 LOG.info("in Pceconstraints getExcludeSrlgNodes size = {}", srlgLinksToExclude.size());
123 return srlgLinksToExclude;
126 public void setExcludeSrlgLinks(List<String> srlg) {
127 LOG.debug("in Pceconstraints setExcludeSRLG size = {}", srlg.size());
128 srlgLinksToExclude.addAll(srlg);
131 public List<String> getExcludeNodes() {
132 LOG.info("in Pceconstraints getExcludeNodes size = {}", nodesToExclude.size());
133 return nodesToExclude;
136 public void setExcludeNodes(List<String> nodes) {
137 LOG.debug("in Pceconstraints setExcludeNodes size = {}", nodes.size());
138 nodesToExclude.addAll(nodes);
142 public List<String> getIncludeNodes() {
143 LOG.debug("in Pceconstraints getIncludeNodes size = {}", nodesToInclude.size());
144 return nodesToInclude;
147 public void setIncludeNodes(List<String> nodes) {
148 LOG.debug("in Pceconstraints setIncludeNodes size = {}", nodes.size());
149 nodesToInclude.addAll(nodes);
152 public List<PceNode> getIncludePceNodes() {
153 LOG.debug("in Pceconstraints getIncludePceNodes size = {}", pceNodesToInclude.size());
154 return pceNodesToInclude;
157 public void setIncludePceNode(PceNode node) {
158 LOG.info("in Pceconstraints setIncludePceNode new node = {}", node.toString());
159 this.pceNodesToInclude.add(node);
162 public Double getMaxOSNR() {
163 LOG.debug("in Pceconstraints getMaxOSNR = {}", maxOSNR);
167 public class ResourcePair {
168 public ResourcePair(ResourceType type, String name) {
174 private ResourceType type = ResourceType.NODE;
176 private String name = "";
178 public ResourceType getType() {
182 public String getName() {
188 public List<ResourcePair> getListToInclude() {
189 return listToInclude;
192 public void setListToInclude(ResourcePair elementToInclude) {
193 this.listToInclude.add(elementToInclude);
194 switch (elementToInclude.type) {
196 srlgNames.add(elementToInclude.name);
203 public List<String> getSRLGnames() {