PCE update to support constraints
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / networkanalyzer / PceResult.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
9 package org.opendaylight.transportpce.pce.networkanalyzer;
10
11 import org.opendaylight.transportpce.common.ResponseCodes;
12 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.AToZDirection;
13 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.ZToADirection;
14
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
17
18 public class PceResult {
19     private static final Logger LOG = LoggerFactory.getLogger(PceResult.class);
20     private String calcMessage = "503 Calculator Unavailable";
21     private boolean calcStatus = false;
22     private String responseCode = ResponseCodes.RESPONSE_FAILED;
23     private long resultWavelength = -1;
24     // for now it is constant returned as received from A-end
25     private long rate = -1;
26
27     public enum LocalCause {
28         NONE, TOO_HIGH_LATENCY, NO_PATH_EXISTS, INT_PROBLEM;
29     }
30
31     private LocalCause localCause = LocalCause.NONE;
32
33     private AToZDirection atozdirection = null;
34     private ZToADirection ztoadirection = null;
35
36     public PceResult() {
37     }
38
39     public void setRC(String rc) {
40         switch (rc) {
41             case ResponseCodes.RESPONSE_OK :
42                 calcMessage = "Path is calculated";
43                 calcStatus = true;
44                 responseCode = ResponseCodes.RESPONSE_OK;
45                 break;
46             case ResponseCodes.RESPONSE_FAILED :
47                 responseCode = ResponseCodes.RESPONSE_FAILED;
48                 calcStatus = false;
49                 calcMessage = "No path available";
50                 break;
51             default:
52                 LOG.error("setRC: RespondeCodes unknown");
53         }
54     }
55
56     public String toString() {
57         return ("[" + calcMessage + "] code:[" + responseCode + "] wavelength="
58                 + resultWavelength + " localCause=" + localCause + " rate="
59                 + rate);
60     }
61
62     public boolean getStatus() {
63         return calcStatus;
64     }
65
66     public String getMessage() {
67         return calcMessage;
68     }
69
70     public String getResponseCode() {
71         return responseCode;
72     }
73
74     public long getResultWavelength() {
75         return resultWavelength;
76     }
77
78     public void setResultWavelength(long resultWavelength) {
79         this.resultWavelength = resultWavelength;
80     }
81
82     public AToZDirection getAtoZDirection() {
83         return atozdirection;
84     }
85
86     public ZToADirection getZtoADirection() {
87         return ztoadirection;
88     }
89
90     public void setAtoZDirection(AToZDirection atozDirection) {
91         this.atozdirection = atozDirection;
92     }
93
94     public void setZtoADirection(ZToADirection ztoaDirection) {
95         this.ztoadirection = ztoaDirection;
96     }
97
98     public long getRate() {
99         return rate;
100     }
101
102     public void setRate(long rate) {
103         this.rate = rate;
104     }
105
106     public LocalCause getLocalCause() {
107         return localCause;
108     }
109
110     public void setLocalCause(LocalCause lc) {
111         // For now keep the very first fatal problem
112         // TODO. Later this value might become history of algo if all
113         // significant problems are added here as to List
114         if (localCause == LocalCause.NONE) {
115             this.localCause = lc;
116         }
117     }
118
119     public void setCalcMessage(String calcMessage) {
120         this.calcMessage = calcMessage;
121     }
122
123 }