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;
11 import org.jgrapht.GraphPath;
12 import org.jgrapht.alg.shortestpath.PathValidator;
13 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmLinkType;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
17 public class InAlgoPathValidator implements PathValidator<String, PceGraphEdge> {
19 private static final Logger LOG = LoggerFactory.getLogger(InAlgoPathValidator.class);
21 public InAlgoPathValidator() {
26 public boolean isValidPath(GraphPath<String, PceGraphEdge> partialPath, PceGraphEdge edge) {
27 int size = partialPath.getEdgeList().size();
31 LOG.debug("InAlgoPathValidator: partialPath size: {} prev edge {} new edge {}",
32 size, edge.link().getlinkType(), partialPath.getEdgeList().get(size - 1).link().getlinkType());
34 return (checkTurn(partialPath.getEdgeList().get(size - 1).link().getlinkType(), edge.link().getlinkType()));
37 private boolean checkTurn(OpenroadmLinkType prevType, OpenroadmLinkType nextType) {
39 if (nextType == OpenroadmLinkType.ADDLINK && prevType != OpenroadmLinkType.XPONDEROUTPUT) {
40 LOG.debug("in checkPath dropped {} {} ", prevType, nextType);
44 if (nextType == OpenroadmLinkType.EXPRESSLINK && prevType != OpenroadmLinkType.ROADMTOROADM) {
45 LOG.debug("in checkPath dropped {} {} ", prevType, nextType);
49 if (nextType == OpenroadmLinkType.DROPLINK && prevType != OpenroadmLinkType.ROADMTOROADM) {
50 LOG.debug("in checkPath dropped {} {} ", prevType, nextType);
54 if (nextType == OpenroadmLinkType.XPONDERINPUT && prevType != OpenroadmLinkType.DROPLINK) {
55 LOG.debug("in checkPath dropped {} {} ", prevType, nextType);
59 if (prevType == OpenroadmLinkType.EXPRESSLINK && nextType != OpenroadmLinkType.ROADMTOROADM) {
60 LOG.debug("in checkPath dropped {} {} ", prevType, nextType);
64 if (prevType == OpenroadmLinkType.ADDLINK && nextType != OpenroadmLinkType.ROADMTOROADM) {
65 LOG.debug("in checkPath dropped {} {} ", prevType, nextType);