5e878e02f8e1e4b6035d2c6958870ff82c6d456a
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / PceConstraints.java
1 /*
2  * Copyright © 2017 AT&T, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.transportpce.pce;
9
10 import java.util.ArrayList;
11 import java.util.List;
12 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.RoutingConstraintsSp;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
15
16 // internal type after parsing
17 public class PceConstraints {
18     /* Logging. */
19     private static final Logger LOG = LoggerFactory.getLogger(PceCalculation.class);
20
21     // TODO. for now metrics are set into hard structure
22     private RoutingConstraintsSp.PceMetric pceMetrics = RoutingConstraintsSp.PceMetric.HopCount;
23     private Long maxLatency = (long) -1;
24
25     private List<String> nodesToExclude = new ArrayList<String>();
26     private List<String> srlgToExclude = new ArrayList<String>();
27     private List<String> nodesToInclude = new ArrayList<String>();
28     private List<PceNode> pceNodesToInclude = new ArrayList<PceNode>();
29     public static final Long CONST_OSNR = 1L;
30     private double maxOSNR = (CONST_OSNR / (Math.pow(10, (24 / 10.0))));
31
32
33     public RoutingConstraintsSp.PceMetric getPceMetrics() {
34         return pceMetrics;
35     }
36
37     public void setPceMetrics(RoutingConstraintsSp.PceMetric pceMetrics) {
38         this.pceMetrics = pceMetrics;
39     }
40
41     // Latency of path is used by Graph to validate path
42     // if -1 , latency is not applicable (not mentioned in constraints)
43     public Long getMaxLatency() {
44         LOG.debug("in Pceconstraints getMaxLatency = {}", maxLatency);
45         return maxLatency;
46     }
47
48     public void setMaxLatency(Long maxLatency) {
49         LOG.debug("in Pceconstraints setMaxLatency = {}", maxLatency);
50         this.maxLatency = maxLatency;
51     }
52
53     // Exclude nodes / SRLD /
54     public List<String> getExcludeNodes() {
55         LOG.debug("in Pceconstraints getExcludeNodes size = {}", nodesToExclude.size());
56         return nodesToExclude;
57     }
58
59     public void setExcludeNodes(List<String> nodes) {
60         LOG.debug("in Pceconstraints setExcludeNodes size = {}", nodes.size());
61         nodesToExclude.addAll(nodes);
62     }
63
64     public List<String> getExcludeSRLG() {
65         LOG.debug("in Pceconstraints getExcludeSRLG size = {}", srlgToExclude.size());
66         return srlgToExclude;
67     }
68
69     public void setExcludeSRLG(List<String> srlg) {
70         LOG.debug("in Pceconstraints setExcludeSRLG size = {}", srlg.size());
71         srlgToExclude.addAll(srlg);
72     }
73
74
75     // Include nodes
76     public List<String> getIncludeNodes() {
77         LOG.debug("in Pceconstraints getIncludeNodes size = {}", nodesToInclude.size());
78         return nodesToInclude;
79     }
80
81     public void setIncludeNodes(List<String> nodes) {
82         LOG.debug("in Pceconstraints setIncludeNodes size = {}", nodes.size());
83         nodesToInclude.addAll(nodes);
84     }
85
86     public List<PceNode> getIncludePceNodes() {
87         LOG.debug("in Pceconstraints getIncludePceNodes size = {}", pceNodesToInclude.size());
88         return pceNodesToInclude;
89     }
90
91     public void setIncludePceNode(PceNode node) {
92         LOG.info("in Pceconstraints setIncludePceNode new node = {}", node.toString());
93         this.pceNodesToInclude.add(node);
94     }
95
96     public Double getMaxOSNR() {
97         LOG.debug("in Pceconstraints getMaxOSNR = {}", maxOSNR);
98         return maxOSNR;
99     }
100
101
102 }