- force PCE to calculate ZToA path on unidir ports.
- solve PCE calculation error with SRG-CP Bidirectionel with
SRG-PP unidir.
- solve NullPointerException cause by getting oppositeLink
for UNIDIR link, not present in topology.
JIRA: TRNSPRTPCE-70
Change-Id: I728cc081c7a40838349eef6481f82b6bf1349029
Signed-off-by: Martial COULIBALY <martial.coulibaly@gfi.fr>
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.transportpce.common.NetworkUtils;
import org.opendaylight.transportpce.common.ResponseCodes;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestInput;
import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev170929.Node1;
import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev170929.OpenroadmNodeType;
/* Logging. */
private static final Logger LOG = LoggerFactory.getLogger(PceCalculation.class);
private DataBroker dataBroker = null;
+ private PortMapping portMapping = null;
///////////// data parsed from Input/////////////////
private PathComputationRequestInput input;
private String anodeId = "";
// private static final String NETWORK_ID = "Transport Overlay";
public PceCalculation(PathComputationRequestInput input, DataBroker dataBroker, PceConstraints pceHardConstraints,
- PceConstraints pceSoftConstraints, PceResult rc) {
+ PceConstraints pceSoftConstraints, PceResult rc, PortMapping portMapping) {
this.input = input;
this.dataBroker = dataBroker;
+ this.portMapping = portMapping;
this.returnStructure = rc;
this.pceHardConstraints = pceHardConstraints;
this.pceSoftConstraints = pceSoftConstraints;
default:
break;
}
- PceNode pceNode = new PceNode(node, nodeType, nodeId);
+ PceNode pceNode = new PceNode(node, nodeType, nodeId, portMapping);
if (!pceNode.isValid()) {
LOG.error(" validateNode: Node is ignored due errors in network data ");
return false;
import java.util.Map;
import java.util.Optional;
import java.util.TreeMap;
+import java.util.stream.Collectors;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev170228.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.Direction;
import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev170929.Node1;
import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev170929.TerminationPoint1;
import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev170929.network.node.termination.point.pp.attributes.UsedWavelength;
private List<String> usedXpndrNWTps = new ArrayList<String>();
private List<PceLink> outgoingLinks = new ArrayList<PceLink>();
private Map<String, String> clientPerNwTp = new HashMap<String, String>();
+ private PortMapping portMapping;
+ private boolean isUnidir;
- public PceNode(Node node, OpenroadmNodeType nodeType, NodeId nodeId) {
+ public PceNode(Node node, OpenroadmNodeType nodeType, NodeId nodeId, PortMapping portMapping) {
this.node = node;
this.nodeId = nodeId;
this.nodeType = nodeType;
LOG.error("PceNode: one of parameters is not populated : nodeId, node type");
this.valid = false;
}
+ this.portMapping = portMapping;
+ this.isUnidir = false;
}
public void initSrgTps() {
}
LOG.info("initSrgTpList: availableSrgPp size = {} && availableSrgCp size = {} in {}", this.availableSrgPp
.size(), this.availableSrgCp.size(), this.toString());
+ this.isUnidir();
return;
}
LOG.error("initXndrTps: XPONDER doesn't have available wavelengths for node {}", this.toString());
return;
}
+ this.isUnidir();
+ }
+
+ private void isUnidir() {
+ LOG.info("isUnidir: getting port direction...");
+ switch (nodeType) {
+ case XPONDER:
+ LOG.info("isUnidir: getting port direction on XPONDER-NETWORK port ...");
+ Optional<String> tp = this.clientPerNwTp.keySet().stream().findFirst();
+ Mapping mapping = this.portMapping.getMapping(node.getSupportingNode().get(0).getNodeRef().getValue(),
+ tp.get());
+ if (mapping != null) {
+ if (mapping.getPortDirection().compareTo(Direction.Bidirectional) != 0) {
+ this.isUnidir = true;
+ LOG.warn("isUnidir: XPONDER NETWORK have UNIDIR port...");
+ }
+ } else {
+ LOG.error("isUnidir: Cannot get mapping for tp '{}'", tp.get());
+ }
+ break;
+ case SRG:
+ LOG.info("isUnidir: getting port direction on ROADM SRG-PP port ...");
+ List<OpenroadmTpType> resultTx = this.availableSrgPp.values().stream()
+ .filter(pp -> pp == OpenroadmTpType.SRGTXPP).collect(Collectors.toList());
+ List<OpenroadmTpType> resultRx = this.availableSrgPp.values().stream()
+ .filter(pp -> pp == OpenroadmTpType.SRGRXPP).collect(Collectors.toList());
+ if (!resultTx.isEmpty() && !resultRx.isEmpty()) {
+ this.isUnidir = true;
+ LOG.warn("isUnidir: SRG node have UNIDIR port...");
+ }
+ break;
+ default:
+ this.isUnidir = false;
+ break;
+ }
}
public String getRdmSrgClient(String tp, Boolean aend) {
}
switch (cpType) {
case SRGTXRXCP:
- LOG.info("getRdmSrgClient: Getting BI Directional PP port ...");
- srgType = OpenroadmTpType.SRGTXRXPP;
+ LOG.info("getRdmSrgClient: Getting BI or UNI Directional PP port ...");
+ if (this.isUnidir) {
+ LOG.info("getRdmSrgClient: Getting UNI PP Port");
+ if (aend) {
+ LOG.info("getRdmSrgClient: Getting UNI Rx PP port ...");
+ srgType = OpenroadmTpType.SRGRXPP;
+ } else {
+ LOG.info("getRdmSrgClient: Getting UNI Tx PP port ...");
+ srgType = OpenroadmTpType.SRGTXPP;
+ }
+ } else {
+ LOG.info("getRdmSrgClient: Getting BI PP Port");
+ srgType = OpenroadmTpType.SRGTXRXPP;
+ }
break;
case SRGTXCP:
LOG.info("getRdmSrgClient: Getting UNI Rx PP port ...");
return this.clientPerNwTp.get(tp);
}
+ public OpenroadmNodeType getPceNodeType() {
+ return this.nodeType;
+ }
+
+ public boolean getUnidir() {
+ return this.isUnidir;
+ }
+
@Override
public String toString() {
return "PceNode type=" + this.nodeType + " ID=" + this.nodeId.getValue();
package org.opendaylight.transportpce.pce;
import com.google.common.collect.ImmutableList;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+
import org.opendaylight.transportpce.common.ResponseCodes;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.AToZDirectionBuilder;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.ZToADirectionBuilder;
Integer index = 0;
PceLink lastLink = null;
ZToA lastResource = null;
+ LinkId oppositeLinkId;
// build Z size Client TP
- PceLink pcelink = this.allPceLinks.get(path.get(0).getOppositeLink());
- String tpName = pcelink.getClient();
- String xname = pcelink.getSourceId().getValue();
- TerminationPoint stp = new TerminationPointBuilder()
- .setTpNodeId(xname).setTpId(tpName)
- .build();
-
- ZToAKey clientKey = new ZToAKey(index.toString());
- Resource clientResource = new ResourceBuilder().setResource(stp).build();
- ZToA firstResource = new ZToABuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build();
- etoelist.add(firstResource);
- index++;
-
- for (PceLink pcelinkAtoZ : path) {
-
- pcelink = this.allPceLinks.get(pcelinkAtoZ.getOppositeLink());
- LOG.debug("link to oppsite: {} to {}", pcelinkAtoZ.toString(), pcelink.toString());
-
- String srcName = pcelink.getSourceId().getValue();
-
-
- // Nodes
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
- .resource.resource.resource.Node sourceNode = new NodeBuilder()
- .setNodeId(srcName).build();
-
-
- // Source Resource
- ZToAKey sourceKey = new ZToAKey(index.toString());
- Resource nodeResource1 = new ResourceBuilder().setResource(sourceNode).build();
- ZToA srcResource = new ZToABuilder().setId(srcName).withKey(sourceKey).setResource(nodeResource1).build();
- index++;
- etoelist.add(srcResource);
-
- // source TP
- tpName = pcelink.getSourceTP().toString();
- stp = new TerminationPointBuilder()
- .setTpNodeId(srcName).setTpId(tpName)
+ try {
+ oppositeLinkId = path.get(0).getOppositeLink();
+ } catch (NullPointerException e) {
+ LOG.warn("buildZtoA : OppositeLink for link '{}' is null, maybe UNIDIR Link ...", path.get(0));
+ return;
+ }
+ PceLink pcelink = this.allPceLinks.get(oppositeLinkId);
+ if (pcelink != null) {
+ String tpName = pcelink.getClient();
+ String xname = pcelink.getSourceId().getValue();
+ TerminationPoint stp = new TerminationPointBuilder()
+ .setTpNodeId(xname).setTpId(tpName)
.build();
-
- // Resource
- ZToAKey srcTPKey = new ZToAKey(index.toString());
- Resource tpResource1 = new ResourceBuilder().setResource(stp).build();
- ZToA stpResource = new ZToABuilder().setId(tpName).withKey(srcTPKey).setResource(tpResource1).build();
+ ZToAKey clientKey = new ZToAKey(index.toString());
+ Resource clientResource = new ResourceBuilder().setResource(stp).build();
+ ZToA firstResource = new ZToABuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build();
+ etoelist.add(firstResource);
index++;
- etoelist.add(stpResource);
-
- String linkName = pcelink.getLinkId().getValue();
- // Link
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
- .resource.resource.resource.Link ztoaLink = new LinkBuilder()
- .setLinkId(linkName).build();
-
- // Link Resource
- ZToAKey linkKey = new ZToAKey(index.toString());
- Resource nodeResource2 = new ResourceBuilder().setResource(ztoaLink).build();
- ZToA linkResource = new ZToABuilder().setId(linkName).withKey(linkKey).setResource(nodeResource2).build();
- index++;
- etoelist.add(linkResource);
-
- String destName = pcelink.getDestId().getValue();
- // target TP
- tpName = pcelink.getDestTP().toString();
- TerminationPoint ttp = new TerminationPointBuilder()
- .setTpNodeId(destName).setTpId(tpName).build();
+ for (PceLink pcelinkAtoZ : path) {
+ pcelink = this.allPceLinks.get(pcelinkAtoZ.getOppositeLink());
+ LOG.debug("link to oppsite: {} to {}", pcelinkAtoZ.toString(), pcelink.toString());
+ String srcName = pcelink.getSourceId().getValue();
+ // Nodes
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
+ .resource.resource.resource.Node sourceNode = new NodeBuilder()
+ .setNodeId(srcName).build();
+
+ // Source Resource
+ ZToAKey sourceKey = new ZToAKey(index.toString());
+ Resource nodeResource1 = new ResourceBuilder().setResource(sourceNode).build();
+ ZToA srcResource = new ZToABuilder().setId(srcName).withKey(sourceKey).setResource(nodeResource1)
+ .build();
+ index++;
+ etoelist.add(srcResource);
+
+ // source TP
+ tpName = pcelink.getSourceTP().toString();
+ stp = new TerminationPointBuilder()
+ .setTpNodeId(srcName).setTpId(tpName)
+ .build();
+
+ // Resource
+ ZToAKey srcTPKey = new ZToAKey(index.toString());
+ Resource tpResource1 = new ResourceBuilder().setResource(stp).build();
+ ZToA stpResource = new ZToABuilder().setId(tpName).withKey(srcTPKey).setResource(tpResource1).build();
+ index++;
+ etoelist.add(stpResource);
+
+ String linkName = pcelink.getLinkId().getValue();
+ // Link
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
+ .resource.resource.resource.Link ztoaLink = new LinkBuilder()
+ .setLinkId(linkName).build();
+
+ // Link Resource
+ ZToAKey linkKey = new ZToAKey(index.toString());
+ Resource nodeResource2 = new ResourceBuilder().setResource(ztoaLink).build();
+ ZToA linkResource = new ZToABuilder().setId(linkName).withKey(linkKey).setResource(nodeResource2)
+ .build();
+ index++;
+ etoelist.add(linkResource);
+
+ String destName = pcelink.getDestId().getValue();
+ // target TP
+ tpName = pcelink.getDestTP().toString();
+ TerminationPoint ttp = new TerminationPointBuilder()
+ .setTpNodeId(destName).setTpId(tpName).build();
+
+ // Resource
+ ZToAKey destTPKey = new ZToAKey(index.toString());
+ Resource tpResource2 = new ResourceBuilder().setResource(ttp).build();
+ ZToA ttpResource = new ZToABuilder().setId(tpName).withKey(destTPKey).setResource(tpResource2).build();
+ index++;
+ etoelist.add(ttpResource);
+
+ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
+ .resource.resource.resource.Node targetNode = new NodeBuilder()
+ .setNodeId(destName).build();
+ // Target Resource
+ ZToAKey targetKey = new ZToAKey(index.toString());
+ Resource nodeResource3 = new ResourceBuilder().setResource(targetNode).build();
+ lastResource = new ZToABuilder().setId(destName).withKey(targetKey).setResource(nodeResource3).build();
+
+ lastLink = pcelink;
+ }
+ etoelist.add(lastResource);
+
+ // build Z side Client TP
+ tpName = lastLink.getClient();
+ xname = lastLink.getDestId().getValue();
+ stp = new TerminationPointBuilder()
+ .setTpNodeId(xname).setTpId(tpName).build();
- // Resource
- ZToAKey destTPKey = new ZToAKey(index.toString());
- Resource tpResource2 = new ResourceBuilder().setResource(ttp).build();
- ZToA ttpResource = new ZToABuilder().setId(tpName).withKey(destTPKey).setResource(tpResource2).build();
index++;
- etoelist.add(ttpResource);
-
-
- org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.pce
- .resource.resource.resource.Node targetNode = new NodeBuilder()
- .setNodeId(destName).build();
- // Target Resource
- ZToAKey targetKey = new ZToAKey(index.toString());
- Resource nodeResource3 = new ResourceBuilder().setResource(targetNode).build();
- lastResource = new ZToABuilder().setId(destName).withKey(targetKey).setResource(nodeResource3).build();
-
- lastLink = pcelink;
+ clientKey = new ZToAKey(index.toString());
+ clientResource = new ResourceBuilder().setResource(stp).build();
+ lastResource = new ZToABuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build();
+ etoelist.add(lastResource);
+ } else {
+ LOG.warn("buildZtoA : OppositeLink for link '{}' is null, maybe UNIDIR Link ...", path.get(0));
}
- etoelist.add(lastResource);
-
- // build Z side Client TP
- tpName = lastLink.getClient();
- xname = lastLink.getDestId().getValue();
- stp = new TerminationPointBuilder()
- .setTpNodeId(xname).setTpId(tpName).build();
-
-
- index++;
- clientKey = new ZToAKey(index.toString());
- clientResource = new ResourceBuilder().setResource(stp).build();
- lastResource = new ZToABuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build();
- etoelist.add(lastResource);
}
package org.opendaylight.transportpce.pce;
+import java.util.ArrayList;
+import java.util.List;
+
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
import org.opendaylight.transportpce.pce.PceResult.LocalCause;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestInput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.PathComputationRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.path.computation.request.input.ServiceAEnd;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.path.computation.request.input.ServiceAEndBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.path.computation.request.input.ServiceZEnd;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.path.computation.request.input.ServiceZEndBuilder;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev171017.service.path.rpc.result.PathDescriptionBuilder;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.AToZDirection;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.ZToADirection;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.ZToADirectionBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.atoz.direction.AToZ;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.ztoa.direction.ZToA;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev171017.path.description.ztoa.direction.ZToABuilder;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.RoutingConstraintsSp.PceMetric;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory.getLogger(PceSendingPceRPCs.class);
/* define procedure success (or not ). */
private PceResult rc = new PceResult();
+ private PceResult reverseRc = new PceResult();
/*
* define type of request<br> <code>true</code> pathcomputation <br>
private PathDescriptionBuilder pathDescription;
private PathComputationRequestInput input;
+ private PathComputationRequestInput reverseInput;
private DataBroker dataBroker;
+ private PortMapping portMapping;
private PceConstraints pceHardConstraints = new PceConstraints();
private PceConstraints pceSoftConstraints = new PceConstraints();
setPathDescription(null);
this.input = null;
+ this.reverseInput = null;
this.dataBroker = null;
}
- public PceSendingPceRPCs(PathComputationRequestInput input, DataBroker dataBroker) {
+ public PceSendingPceRPCs(PathComputationRequestInput input, DataBroker dataBroker, PortMapping portMapping) {
setPathDescription(null);
// TODO compliance check to check that input is not empty
this.input = input;
+ this.reverseInput = null;
this.dataBroker = dataBroker;
+ this.portMapping = portMapping;
}
public void cancelResourceReserve() {
LOG.info("cancelResourceReserve ...");
}
+ private void reverseInput() {
+ LOG.info("reverseInput: reversing input endNode ...");
+ ServiceAEnd serviceAEnd = new ServiceAEndBuilder(this.input.getServiceZEnd()).build();
+ ServiceZEnd serviceZEnd = new ServiceZEndBuilder(this.input.getServiceAEnd()).build();
+ this.reverseInput = new PathComputationRequestInputBuilder(this.input)
+ .setServiceAEnd(serviceAEnd)
+ .setServiceZEnd(serviceZEnd)
+ .build();
+ }
+
public void pathComputation() {
LOG.info("PathComputation ...");
pceHardConstraints = constraints.getPceHardConstraints();
pceSoftConstraints = constraints.getPceSoftConstraints();
-
LOG.info("nwAnalizer ...");
PceCalculation nwAnalizer = new PceCalculation(input, dataBroker,
- pceHardConstraints, pceSoftConstraints, rc);
+ pceHardConstraints, pceSoftConstraints, rc, portMapping);
nwAnalizer.calcPath();
rc = nwAnalizer.getReturnStructure();
if (!rc.getStatus()) {
LOG.error("In pathComputation nwAnalizer: result = {}", rc.toString());
return;
}
+ if (nwAnalizer.getaPceNode().getUnidir() || nwAnalizer.getzPceNode().getUnidir()) {
+ LOG.warn("PathComputation: PceNodes contains unidir ports ...");
+ reverseInput();
+ }
LOG.info("PceGraph ...");
LOG.warn("PathComputation: aPceNode '{}' - zPceNode '{}'", nwAnalizer.getaPceNode(), nwAnalizer.getzPceNode());
.setAToZDirection(atoz)
.setZToADirection(ztoa));
LOG.info("In pathComputation Graph is Found");
+ if (reverseInput != null) {
+ reversePathComputation();
+ }
+ }
+
+ public void reversePathComputation() {
+ LOG.info("reversePathComputation ...");
+
+ PceConstraintsCalc constraints = new PceConstraintsCalc(reverseInput, dataBroker);
+ pceHardConstraints = constraints.getPceHardConstraints();
+ pceSoftConstraints = constraints.getPceSoftConstraints();
+
+ LOG.info("nwAnalizer ...");
+ PceCalculation nwAnalizer = new PceCalculation(reverseInput, dataBroker,
+ pceHardConstraints, pceSoftConstraints, rc, portMapping);
+ nwAnalizer.calcPath();
+ rc = nwAnalizer.getReturnStructure();
+ if (!rc.getStatus()) {
+ LOG.error("In reversePathComputation nwAnalizer: result = {}", rc.toString());
+ return;
+ }
+
+ LOG.info("PceGraph ...");
+ LOG.warn("reversePathComputation: aPceNode '{}' - zPceNode '{}'", nwAnalizer.getaPceNode(),
+ nwAnalizer.getzPceNode());
+ PceGraph graph = new PceGraph(
+ nwAnalizer.getaPceNode(),
+ nwAnalizer.getzPceNode(),
+ nwAnalizer.getAllPceNodes(),
+ pceHardConstraints, pceSoftConstraints, rc);
+ graph.calcPath();
+ rc = graph.getReturnStructure();
+ if (!rc.getStatus()) {
+ LOG.warn("In reversePathComputation : Graph return without Path ");
+ // TODO fix. This is quick workaround for algorithm problem
+ if ((rc.getLocalCause() == LocalCause.TOO_HIGH_LATENCY)
+ && (pceHardConstraints.getPceMetrics() == PceMetric.HopCount)
+ && (pceHardConstraints.getMaxLatency() != -1)) {
+ pceHardConstraints.setPceMetrics(PceMetric.PropagationDelay);
+ graph = patchRerunGraph(graph);
+ }
+
+ if (!rc.getStatus()) {
+ LOG.error("In reversePathComputation graph.calcPath: result = {}", rc.toString());
+ return;
+ }
+ }
+
+ LOG.info("PcePathDescription ...");
+ PcePathDescription description = new PcePathDescription(
+ graph.getPathAtoZ(),
+ nwAnalizer.getAllPceLinks(), rc);
+ description.buildDescriptions();
+ rc = description.getReturnStructure();
+ if (!rc.getStatus()) {
+ LOG.error("In pathComputation description: result = {}", rc.toString());
+ return;
+ }
+
+ LOG.info("setPathDescription ...");
+ AToZDirection atoz = rc.getAtoZDirection();
+ ZToADirection ztoa = rc.getZtoADirection();
+ if ((atoz == null) || (atoz.getAToZ() == null)) {
+ rc.setRC("400");
+ LOG.error("In reversePathComputation empty atoz path after description: result = {}", rc.toString());
+ return;
+ }
+ if ((ztoa == null) || (ztoa.getZToA() == null)) {
+ rc.setRC("400");
+ LOG.error("In reversePathComputation empty ztoa path after description: result = {}", rc.toString());
+ return;
+ }
+ setPathDescription(this.pathDescription
+ .setZToADirection(convertDirection(atoz)));
+ LOG.info("In reversePathComputation Graph is Found");
+ }
+
+ private ZToADirection convertDirection(AToZDirection atozDir) {
+ LOG.info("convertDirection : converting Direction ...");
+ ZToADirectionBuilder result = new ZToADirectionBuilder();
+ List<ZToA> ztoaList = new ArrayList<ZToA>();
+ for (AToZ atoz : atozDir.getAToZ()) {
+ ZToA ztoa = new ZToABuilder().setId(atoz.getId()).setResource(atoz.getResource()).build();
+ ztoaList.add(ztoa);
+ }
+ result.setZToA(ztoaList).setModulationFormat(atozDir.getModulationFormat()).setRate(atozDir.getRate())
+ .setZToAWavelengthNumber(atozDir.getAToZWavelengthNumber());
+ return result.build();
}
private PceGraph patchRerunGraph(PceGraph graph) {
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.transportpce.common.mapping.PortMapping;
import org.opendaylight.transportpce.pce.PceComplianceCheck;
import org.opendaylight.transportpce.pce.PceComplianceCheckResult;
import org.opendaylight.transportpce.pce.PceSendingPceRPCs;
private final NotificationPublishService notificationPublishService;
private final DataBroker dataBroker;
+ private final PortMapping portMapping;
- public PathComputationServiceImpl(DataBroker dataBroker,
- NotificationPublishService notificationPublishService) {
+ public PathComputationServiceImpl(DataBroker dataBroker, NotificationPublishService notificationPublishService,
+ PortMapping portMapping) {
this.notificationPublishService = notificationPublishService;
this.dataBroker = dataBroker;
+ this.portMapping = portMapping;
}
public void init() {
String message = "";
String responseCode = "";
- PceSendingPceRPCs sendingPCE = new PceSendingPceRPCs(input, dataBroker);
+ PceSendingPceRPCs sendingPCE = new PceSendingPceRPCs(input, dataBroker, portMapping);
sendingPCE.pathComputation();
message = sendingPCE.getMessage();
responseCode = sendingPCE.getResponseCode();
interface="org.opendaylight.controller.md.sal.binding.api.NotificationPublishService"\r
odl:type="default" />\r
\r
+ <reference id="portMapping" interface="org.opendaylight.transportpce.common.mapping.PortMapping" />\r
+\r
<bean id="pceServiceImpl"\r
class="org.opendaylight.transportpce.pce.service.PathComputationServiceImpl"\r
init-method="init" destroy-method="close">\r
<argument ref="dataBroker"/>\r
<argument ref="notificationPublishService" />\r
+ <argument ref="portMapping" />\r
</bean>\r
\r
<bean id="provider"\r
LOG.info("testPathCalculations");
PathComputationService pathComputationService =
- new PathComputationServiceImpl(getDataBroker(), notificationPublishService);
+ new PathComputationServiceImpl(getDataBroker(), notificationPublishService, null);
PathComputationRequestOutput output = pathComputationService.pathComputationRequest(input);
PceTestUtils.checkConfigurationResponse(output, expectedOutput);
PceTestUtils.writeTopologyIntoDataStore(getDataBroker(), getDataStoreContextUtil(), this.topologyDataPath);
PathComputationService pathComputationService =
- new PathComputationServiceImpl(getDataBroker(), this.notificationPublishService);
+ new PathComputationServiceImpl(getDataBroker(), this.notificationPublishService, null);
PathComputationRequestOutput output = pathComputationService.pathComputationRequest(this.input);
PceTestUtils.checkConfigurationResponse(output, this.expectedOutput);
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
+
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
public ModelMappingUtilsTest() {
NotificationPublishService notificationPublishService = new NotificationPublishServiceMock();
PathComputationService pathComputationService = new PathComputationServiceImpl(getDataBroker(),
- notificationPublishService);
+ notificationPublishService, null);
pceServiceWrapper = new PCEServiceWrapper(pathComputationService);
this.pathComputationRequestOutput = pceServiceWrapper.performPCE(ServiceDataUtils.buildServiceCreateInput(),
true);
public ServiceHandlerImplTest() throws Exception {
NotificationPublishService notificationPublishService = new NotificationPublishServiceMock();
- this.pathComputationService = new PathComputationServiceImpl(getDataBroker(), notificationPublishService);
+ this.pathComputationService = new PathComputationServiceImpl(getDataBroker(), notificationPublishService, null);
PceTestUtils.writeTopologyIntoDataStore(getDataBroker(), getDataStoreContextUtil(),
"topologyData/NW-simple-topology.xml");
this.rendererServiceOperations =
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
public PCEServiceWrapperTest() {
NotificationPublishService notificationPublishService = new NotificationPublishServiceMock();
- this.pathComputationService = new PathComputationServiceImpl(getDataBroker(), notificationPublishService);
+ this.pathComputationService = new PathComputationServiceImpl(getDataBroker(), notificationPublishService, null);
}
@Before
public ServiceDataStoreOperationsImplTest() {
NotificationPublishService notificationPublishService = new NotificationPublishServiceMock();
PathComputationService pathComputationService = new PathComputationServiceImpl(getDataBroker(),
- notificationPublishService);
+ notificationPublishService, null);
this.pceServiceWrapper = new PCEServiceWrapper(pathComputationService);
this.rendererServiceOperations =
new StubRendererServiceOperations(this.networkModelWavelengthService, getDataBroker());