2 * Copyright © 2017 AT&T, Inc. and others. All rights reserved.
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
9 package org.opendaylight.transportpce.pce;
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 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
17 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 private long rate = -1; // for now it is constant returned as received from A-end
26 public enum LocalCause {
27 NONE, TOO_HIGH_LATENCY, NO_PATH_EXISTS, INT_PROBLEM;
30 private LocalCause localCause = LocalCause.NONE;
32 private AToZDirection atozdirection = null;
33 private ZToADirection ztoadirection = null;
38 public void setRC(String rc) {
40 case ResponseCodes.RESPONSE_OK:
41 this.calcMessage = "Path is calculated";
42 this.calcStatus = true;
43 this.responseCode = ResponseCodes.RESPONSE_OK;
45 case ResponseCodes.RESPONSE_FAILED:
46 this.responseCode = ResponseCodes.RESPONSE_FAILED;
47 this.calcStatus = false;
48 this.calcMessage = "No path available";
51 LOG.error("setRC: RespondeCodes unknown");//requires sl4j but not imported
56 public String toString() {
57 return ("[" + this.calcMessage + "] code:[" + this.responseCode + "] wavelength=" + this.resultWavelength
58 + " localCause=" + this.localCause + " rate=" + this.rate);
61 public boolean getStatus() {
62 return this.calcStatus;
65 public String getMessage() {
66 return this.calcMessage;
69 public String getResponseCode() {
70 return this.responseCode;
73 public long getResultWavelength() {
74 return this.resultWavelength;
77 public void setResultWavelength(long resultWavelength) {
78 this.resultWavelength = resultWavelength;
81 public AToZDirection getAtoZDirection() {
82 return this.atozdirection;
85 public ZToADirection getZtoADirection() {
86 return this.ztoadirection;
89 public void setAtoZDirection(AToZDirection atozdir) {
90 this.atozdirection = atozdir;
93 public void setZtoADirection(ZToADirection ztoadir) {
94 this.ztoadirection = ztoadir;
97 public long getRate() {
101 public void setRate(long rate) {
105 public LocalCause getLocalCause() {
106 return this.localCause;
109 public void setLocalCause(LocalCause lc) {
110 // For now keep the very first fatal problem
111 // TODO. Later this value might become history of algo if all significant problems are added here as to List
112 if (this.localCause == LocalCause.NONE) {
113 this.localCause = lc;
118 public void setCalcMessage(String calcMessage) {
119 this.calcMessage = calcMessage;