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