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 java.util.ArrayList;
12 import java.util.HashMap;
13 import java.util.List;
15 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev170929.Node1;
16 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev170929.TerminationPoint1;
17 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev170929.OpenroadmNodeType;
18 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev170929.OpenroadmTpType;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev150608.NodeId;
20 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev150608.network.Node;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
24 public class PceNode {
27 private static final Logger LOG = LoggerFactory.getLogger(PceCalculation.class);
29 ////////////////////////// NODES ///////////////////////////
33 private boolean valid = true;
35 private final Node node;
36 private final NodeId nodeId;
37 private final OpenroadmNodeType nodeType;
39 // wavelength calculation per node type
40 private List<Long> availableWLindex = new ArrayList<Long>();
41 private List<String> usedXpndrNWTps = new ArrayList<String>();
43 private List<PceLink> outgoingLinks = new ArrayList<PceLink>();
45 private Map<String, String> clientPerNwTp = new HashMap<String, String>();
47 public PceNode(Node node, OpenroadmNodeType nodeType, NodeId nodeId) {
50 this.nodeType = nodeType;
52 if ((node == null) || (nodeId == null) || (nodeType == null)) {
53 LOG.error("PceNode: one of parameters is not populated : nodeId, node type");
58 public void initWLlist() {
60 this.availableWLindex.clear();
66 Node1 node1 = this.node.augmentation(Node1.class);
68 switch (this.nodeType) {
70 List<org.opendaylight.yang.gen.v1.http.org.openroadm.srg.rev170929.srg.node.attributes
71 .AvailableWavelengths> srgAvailableWL = node1.getSrgAttributes().getAvailableWavelengths();
73 if (srgAvailableWL == null) {
75 LOG.error("initWLlist: SRG AvailableWavelengths is empty for node {}", this.toString());
79 for (org.opendaylight.yang.gen.v1.http.org.openroadm.srg.rev170929.srg.node.attributes
80 .AvailableWavelengths awl : srgAvailableWL) {
81 this.availableWLindex.add(awl.getIndex());
82 LOG.debug("initWLlist: SRG next = {} in {}" , awl.getIndex() , this.toString());
88 List<org.opendaylight.yang.gen.v1.http.org.openroadm.degree.rev170929.degree.node.attributes
89 .AvailableWavelengths> degAvailableWL = node1.getDegreeAttributes().getAvailableWavelengths();
91 if (degAvailableWL == null) {
93 LOG.error("initWLlist: DEG AvailableWavelengths is empty for node {}", this.toString());
97 for (org.opendaylight.yang.gen.v1.http.org.openroadm.degree.rev170929.degree.node.attributes
98 .AvailableWavelengths awl : degAvailableWL) {
99 this.availableWLindex.add(awl.getIndex());
100 LOG.debug("initWLlist: DEGREE next = {} in {}", awl.getIndex(), this.toString());
108 for (long i = 1; i <= 96; i++) {
109 this.availableWLindex.add(i);
115 LOG.error("initWLlist: unsupported node type {} in node {}" , this.nodeType, this.toString());
119 if (this.availableWLindex.size() == 0) {
120 LOG.debug("initWLlist: There are no available wavelengths in node {}", this.toString());
123 LOG.debug("initWLlist: availableWLindex size = {} in {}" , this.availableWLindex.size(), this.toString());
128 public void initXndrTps() {
134 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev150608.Node1 nodeTp =
135 this.node.augmentation(
136 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev150608.Node1.class);
138 List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev150608.network.node
139 .TerminationPoint> allTps = nodeTp.getTerminationPoint();
141 if (allTps == null) {
143 LOG.error("initXndrTps: XPONDER TerminationPoint list is empty for node {}", this.toString());
149 for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev150608.network.node
150 .TerminationPoint tp : allTps) {
152 TerminationPoint1 tp1 = tp.augmentation(TerminationPoint1.class);
154 if (tp1.getTpType() == OpenroadmTpType.XPONDERNETWORK) {
156 if (tp1.getXpdrNetworkAttributes().getWavelength() != null) {
157 this.usedXpndrNWTps.add(tp.getTpId().getValue());
158 LOG.debug("initWLlist: XPONDER tp = {} is used", tp.getTpId().getValue());
163 // find Client of this network TP
164 String client = tp1.getXpdrNetworkAttributes().getTailEquipmentId();
165 if ((client.equals("")) || (client == null)) {
166 LOG.error("initXndrTps: XPONDER {} NW TP doesn't have defined Client {}",
167 this.toString(),tp.getTpId().getValue());
170 this.clientPerNwTp.put(tp.getTpId().getValue(), client);
175 LOG.error("initXndrTps: XPONDER doesn't have available wavelengths for node {}", this.toString());
182 public boolean checkTP(String tp) {
183 if (this.usedXpndrNWTps.contains(tp)) {
189 public boolean checkWL(long index) {
190 if (this.availableWLindex.contains(index)) {
196 public boolean isValid() {
200 public List<Long> getAvailableWLs() {
201 return this.availableWLindex;
204 public void addOutgoingLink(PceLink outLink) {
205 this.outgoingLinks.add(outLink);
208 public List<PceLink> getOutgoingLinks() {
209 return this.outgoingLinks;
212 public String getClient(String tp) {
213 return this.clientPerNwTp.get(tp);
217 public String toString() {
218 return "PceNode type=" + this.nodeType + " ID=" + this.nodeId.getValue();