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 // for now it is constant returned as received from A-end
25 private long rate = -1;
27 public enum LocalCause {
28 NONE, TOO_HIGH_LATENCY, NO_PATH_EXISTS, INT_PROBLEM;
31 private LocalCause localCause = LocalCause.NONE;
33 private AToZDirection atozdirection = null;
34 private ZToADirection ztoadirection = null;
39 public void setRC(String rc) {
41 case ResponseCodes.RESPONSE_OK:
42 this.calcMessage = "Path is calculated";
43 this.calcStatus = true;
44 this.responseCode = ResponseCodes.RESPONSE_OK;
46 case ResponseCodes.RESPONSE_FAILED:
47 this.responseCode = ResponseCodes.RESPONSE_FAILED;
48 this.calcStatus = false;
49 this.calcMessage = "No path available";
52 LOG.error("setRC: RespondeCodes unknown");
57 public String toString() {
58 return ("[" + this.calcMessage + "] code:[" + this.responseCode + "] wavelength=" + this.resultWavelength
59 + " localCause=" + this.localCause + " rate=" + this.rate);
62 public boolean getStatus() {
63 return this.calcStatus;
66 public String getMessage() {
67 return this.calcMessage;
70 public String getResponseCode() {
71 return this.responseCode;
74 public long getResultWavelength() {
75 return this.resultWavelength;
78 public void setResultWavelength(long resultWavelength) {
79 this.resultWavelength = resultWavelength;
82 public AToZDirection getAtoZDirection() {
83 return this.atozdirection;
86 public ZToADirection getZtoADirection() {
87 return this.ztoadirection;
90 public void setAtoZDirection(AToZDirection atozdirectionIn) {
91 this.atozdirection = atozdirectionIn;
94 public void setZtoADirection(ZToADirection ztoadirectionIn) {
95 this.ztoadirection = ztoadirectionIn;
98 public long getRate() {
102 public void setRate(long rate) {
106 public LocalCause getLocalCause() {
107 return this.localCause;
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 significant problems are added here as to List
113 if (this.localCause == LocalCause.NONE) {
114 this.localCause = lc;
119 public void setCalcMessage(String calcMessage) {
120 this.calcMessage = calcMessage;