Adapt PCE code for OTN services
[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 java.util.List;
12 import java.util.Map;
13
14 import org.opendaylight.transportpce.common.ResponseCodes;
15 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev190531.ServiceFormat;
16 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.AToZDirection;
17 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.ZToADirection;
18
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 public class PceResult {
23     private static final Logger LOG = LoggerFactory.getLogger(PceResult.class);
24     private String calcMessage = "503 Calculator Unavailable";
25     private boolean calcStatus = false;
26     private String responseCode = ResponseCodes.RESPONSE_FAILED;
27     private long resultWavelength = -1;
28     private Map<String, Integer> resultTribPort;
29     private Map<String, List<Integer>> resultTribSlot;
30     private Integer resultTribSlotNb = -1;
31     private String serviceType = "";
32
33     // for now it is constant returned as received from A-end
34     private long rate = -1;
35     private  ServiceFormat serviceFormat = ServiceFormat.OC;
36
37     public enum LocalCause {
38         NONE, TOO_HIGH_LATENCY, OUT_OF_SPEC_OSNR, NO_PATH_EXISTS, INT_PROBLEM, HD_NODE_INCLUDE;
39     }
40
41     private LocalCause localCause = LocalCause.NONE;
42
43     private AToZDirection atozdirection = null;
44     private ZToADirection ztoadirection = null;
45
46     public PceResult() {
47     }
48
49     public void setRC(String rc) {
50         switch (rc) {
51             case ResponseCodes.RESPONSE_OK :
52                 calcMessage = "Path is calculated by PCE";
53                 calcStatus = true;
54                 responseCode = ResponseCodes.RESPONSE_OK;
55                 break;
56             case ResponseCodes.RESPONSE_FAILED :
57                 responseCode = ResponseCodes.RESPONSE_FAILED;
58                 calcStatus = false;
59                 calcMessage = "No path available by PCE";
60                 break;
61             default:
62                 LOG.error("setRC: RespondeCodes unknown");
63         }
64     }
65
66     public String toString() {
67         return ("[" + calcMessage + "] code:[" + responseCode + "] wavelength=" + resultWavelength + " localCause="
68                 + localCause + " rate=" + rate + " serviceType = " + serviceType);
69     }
70
71     public boolean getStatus() {
72         return calcStatus;
73     }
74
75     public String getMessage() {
76         return calcMessage;
77     }
78
79     public String getResponseCode() {
80         return responseCode;
81     }
82
83     public long getResultWavelength() {
84         return resultWavelength;
85     }
86
87     public void setResultWavelength(long resultWavelength) {
88         this.resultWavelength = resultWavelength;
89     }
90
91     public AToZDirection getAtoZDirection() {
92         return atozdirection;
93     }
94
95     public ZToADirection getZtoADirection() {
96         return ztoadirection;
97     }
98
99     public void setAtoZDirection(AToZDirection atozDirection) {
100         this.atozdirection = atozDirection;
101     }
102
103     public void setZtoADirection(ZToADirection ztoaDirection) {
104         this.ztoadirection = ztoaDirection;
105     }
106
107     public long getRate() {
108         return rate;
109     }
110
111     public void setRate(long rate) {
112         this.rate = rate;
113     }
114
115     public ServiceFormat getServiceFormat() {
116         return serviceFormat;
117     }
118
119     public void setServiceFormat(ServiceFormat serviceFormat) {
120         this.serviceFormat = serviceFormat;
121     }
122
123     public LocalCause getLocalCause() {
124         return localCause;
125     }
126
127     public void setLocalCause(LocalCause lc) {
128         // For now keep the very first fatal problem
129         // TODO. Later this value might become history of algo if all
130         // significant problems are added here as to List
131         if (localCause == LocalCause.NONE) {
132             this.localCause = lc;
133         }
134     }
135
136     public void setCalcMessage(String calcMessage) {
137         this.calcMessage = calcMessage;
138     }
139
140     public Map<String, Integer> getResultTribPort() {
141         return resultTribPort;
142     }
143
144     public void setResultTribPort(Map<String, Integer> resultTribPort) {
145         this.resultTribPort = resultTribPort;
146     }
147
148     public Map<String, List<Integer>> getResultTribSlot() {
149         return resultTribSlot;
150     }
151
152     public void setResultTribSlot(Map<String, List<Integer>> resultTribSlot) {
153         this.resultTribSlot = resultTribSlot;
154     }
155
156     public int getResultTribSlotNb() {
157         return resultTribSlotNb;
158     }
159
160     public void setResultTribSlotNb(int resultTribSlotNb) {
161         this.resultTribSlotNb = resultTribSlotNb;
162     }
163
164     public String getServiceType() {
165         return serviceType;
166     }
167
168     public void setServiceType(String serviceType) {
169         this.serviceType = serviceType;
170     }
171
172 }