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