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.graph;
13 import org.jgrapht.GraphPath;
14 import org.opendaylight.transportpce.common.ResponseCodes;
15 import org.opendaylight.transportpce.pce.networkanalyzer.PceNode;
16 import org.opendaylight.transportpce.pce.networkanalyzer.PceResult;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
21 public class PostAlgoPathValidator {
23 private static final Logger LOG = LoggerFactory.getLogger(PceGraph.class);
26 private static final int MAX_WAWELENGTH = 96;
28 public PceResult checkPath(GraphPath<String, PceGraphEdge> path,
29 Map<NodeId, PceNode> allPceNodes, PceResult pceResult) {
31 if (path.getEdgeList().size() == 0) {
32 pceResult.setRC(ResponseCodes.RESPONSE_FAILED);
36 // choose wavelength available in all nodes of the path
37 pceResult.setRC(ResponseCodes.RESPONSE_FAILED);
38 Long waveL = chooseWavelength(path, allPceNodes);
40 pceResult.setResultWavelength(waveL);
41 pceResult.setRC(ResponseCodes.RESPONSE_OK);
42 LOG.info("In PostAlgoPathValidator: chooseWavelength WL found {} {}", waveL, path.toString());
45 // TODO here other post algo validations can be added
46 // more data can be sent to PceGraph module via PceResult structure if
53 private Long chooseWavelength(GraphPath<String, PceGraphEdge> path, Map<NodeId, PceNode> allPceNodes) {
54 Long wavelength = -1L;
56 for (long i = 1; i <= MAX_WAWELENGTH; i++) {
57 boolean completed = true;
58 LOG.debug("In chooseWavelength: {} {}", path.getLength(), path.toString());
59 for (PceGraphEdge edge : path.getEdgeList()) {
60 LOG.debug("In chooseWavelength: source {} ", edge.link().getSourceId().toString());
61 PceNode pceNode = allPceNodes.get(edge.link().getSourceId());
62 if (!pceNode.checkWL(i)) {
75 private boolean stubCheckOSNR(GraphPath<String, PceGraphEdge> path) {
76 double localOsnr = 0L;
77 for (PceGraphEdge edge : path.getEdgeList()) {
78 localOsnr = localOsnr + edge.link().getosnr();
80 LOG.info("In OSNR Stub: {}", localOsnr);