package org.opendaylight.transportpce.stubpce.topology;
import com.google.common.collect.Lists;
-
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import java.util.SortedSet;
import java.util.TreeSet;
-
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.path.description.list.PathDescriptionsBuilder;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.AToZDirection;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.AToZDirectionBuilder;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ZToADirection;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.ResourceBuilder;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.resource.resource.Link;
import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.resource.resource.LinkBuilder;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.path.description.list.PathDescriptionsBuilder;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.resource.resource.link.LinkIdentifierBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
*/
private Boolean endNode(String end, List<String> supernodes) {
Boolean result = false;
- if (end != null && end.compareTo(" ") != 0) {
+ if ((end != null) && (end.compareTo(" ") != 0)) {
for (String node : supernodes) {
if (node.compareTo(end) == 0) {
result = true;
*/
public SuperNode getSuperNode(String nodeId) {
SuperNode result = null;
- if (network != null) {
- for (SuperNode tmp : network.getSuperNodes()) {
+ if (this.network != null) {
+ for (SuperNode tmp : this.network.getSuperNodes()) {
if (tmp.getSuperNodeId().compareTo(nodeId) == 0) {
result = tmp;
break;
for (String tmp : links) {
if (tmp.contains(aend)
&& tmp.contains(zend)) {
- LOG.info("direct path found for : " + aend + " / " + zend);
+ LOG.info("direct path found for : {} / {}", aend, zend);
if (tmp.startsWith(aend)) {
atozlink = tmp;
}
if (tmp.startsWith(zend)) {
ztoalink = tmp;
}
- if (atozlink != null && ztoalink != null) {
+ if ((atozlink != null) && (ztoalink != null)) {
result.add(atozlink.concat("/").concat(ztoalink));
atozlink = null;
ztoalink = null;
tmp = tmp.replace("Node", "ROADM");
if (tmp.compareTo(aend) != 0) {
if (link.contains(aend) && link.contains(tmp)) {
- LOG.info("hop : " + tmp);
+ LOG.info("hop : {}", tmp);
result = tmp;
}
}
*/
private List<String> getSuperNodeId() {
List<String> result = new ArrayList<String>();
- if (network.getSuperNodes().size() > 0) {
- for (SuperNode tmp : network.getSuperNodes()) {
+ if (this.network.getSuperNodes().size() > 0) {
+ for (SuperNode tmp : this.network.getSuperNodes()) {
result.add(tmp.getSuperNodeId());
}
}
*/
private List<String> getRoadmLinks() {
List<String> result = new ArrayList<String>();
- if (network.getRoadmToroadm().getLinks().size() > 0) {
- for (String tmp : network.getRoadmToroadm().getLinks()) {
+ if (this.network.getRoadmToroadm().getLinks().size() > 0) {
+ for (String tmp : this.network.getRoadmToroadm().getLinks()) {
result.add(tmp);
}
}
ztoa.add(split[1]);
}
}
- if (!atoz.isEmpty() && atoz.size() == ztoa.size()) {
+ if (!atoz.isEmpty() && (atoz.size() == ztoa.size())) {
NodeLinkNode node = new NodeLinkNode(aend, zend, atoz,ztoa,direct);
- paths.add(node);
+ this.paths.add(node);
}
} else {
- LOG.info(term + " links not found !");
+ LOG.info("{} links not found !", term);
}
}
* @param zend ending extremity path
*/
public void run(String aend, String zend) {
- if (network != null) {
+ if (this.network != null) {
List<String> supernodes = getSuperNodeId();
List<String> roadmLinks = getRoadmLinks();
- if (aend != null && zend != null) {
+ if ((aend != null) && (zend != null)) {
int size = supernodes.size();
String hop = null;
List<String> links = null;
hop = findHop(tmp, aend, supernodes);
if (hop != null) {
if (hop.compareTo(zend.replace("Node", "ROADM")) != 0) {
- LOG.info("next hop found : " + hop);
+ LOG.info("next hop found : {}", hop);
links.addAll(findLinks(aend,hop,roadmLinks,false));
links.addAll(findLinks(hop,zend,roadmLinks,false));
} else {
AToZ atoz = it.next();
org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription
.rev170426.pce.resource.resource.Resource res = atoz.getResource().getResource();
- int tmpkey = order + Integer.parseInt(atoz.getKey().getId());
+ int tmpkey = order + Integer.parseInt(atoz.key().getId());
AToZKey atozKey = new AToZKey(Integer.toString(tmpkey));
org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface
.pathdescription.rev170426.pce.resource.Resource resource = new ResourceBuilder()
.setResource(res).build();
- AToZ hop = new AToZBuilder().setId(atozKey.getId()).setKey(atozKey).setResource(resource).build();
+ AToZ hop = new AToZBuilder().setId(atozKey.getId()).withKey(atozKey).setResource(resource).build();
it.remove();
it.add(hop);
tmpkey++;
*/
public List<String> getDeg(String atozLink, String ztoaLink) {
List<String> result = new ArrayList<String>();
- if (atozLink != null && ztoaLink != null) {
+ if ((atozLink != null) && (ztoaLink != null)) {
String [] split = atozLink.split("-", 4);
if (split.length == 4) {
result = Lists.newArrayList(split[1],split[3]);
if (resLink != null) {
if (resLink instanceof Link) {
Link link = (Link) resLink;
- String newLinkId = reverseLinkId(link.getLinkId());
+ String newLinkId = reverseLinkId(link.getLinkIdentifier().getLinkId());
if (newLinkId != null) {
- resource = new ResourceBuilder().setResource(
- new LinkBuilder()
- .setLinkId(newLinkId)
- .build()
- ).build();
+ resource = new ResourceBuilder().setResource(new LinkBuilder()
+ .setLinkIdentifier(new LinkIdentifierBuilder()
+ .setLinkId(newLinkId)
+ .build())
+ .build())
+ .build();
}
} else {
}
if (resource != null) {
hop = new ZToABuilder()
- .setKey(ztoaKey)
+ .withKey(ztoaKey)
.setResource(resource)
.build();
ztoaList.add(hop);
PathDescriptionsBuilder pathDescr = new PathDescriptionsBuilder();
int size = atozDirection.size();
if (!atozDirection.isEmpty()) {
- LOG.info("result list AToZDirection size : " + atozDirection.size());
+ LOG.info("result list AToZDirection size : {}", atozDirection.size());
List<ZToADirection> ztoadirList = new ArrayList<ZToADirection>();
for (AToZDirection atozdir : atozDirection) {
ZToADirection ztodir = convertToZtoaDirection(atozdir);
ztoadirList.add(ztodir);
}
}
- if (!ztoadirList.isEmpty() && size == ztoadirList.size()) {
+ if (!ztoadirList.isEmpty() && (size == ztoadirList.size())) {
LOG.info("building PathDescriptions ...");
int index = 1;
String pathName = null;
for (int indexPath = 0 ; indexPath < size ; indexPath++) {
pathName = term.concat(Integer.toString(index));
- LOG.info("pathName : " + pathName);
+ LOG.info("pathName : {}", pathName);
pathDescr.setAToZDirection(atozDirection.get(indexPath))
.setZToADirection(ztoadirList.get(indexPath)).setPathName(pathName);
- LOG.info(pathDescr.build().toString());
+ LOG.info("pathdesciption : {}", pathDescr.build().toString());
result.add(new PathDescriptionsOrdered(pathDescr.build(),index));
index++;
}
if (split.length == 4) {
String aend = split[0].replaceAll("ROADM", "Node");
String zend = split[2].replaceAll("ROADM", "Node");
- if (aend != null && zend != null) {
- LOG.info("getting super node for : " + aend + " and " + zend);
+ if ((aend != null) && (zend != null)) {
+ LOG.info("getting super node for : {} and {}", aend, zend);
SuperNode aendSp = getSuperNode(aend);
SuperNode zendSp = getSuperNode(zend);
- if (aendSp != null && zendSp != null) {
+ if ((aendSp != null) && (zendSp != null)) {
result.add(aendSp);
result.add(zendSp);
}
*
* @param aend beginning extremity path
* @param zend ending extremity path
- * @param paths NodeLinkNode list paths
+ * @param nodeLinkNodes list paths
* @return PathDescriptionsOrdered List of direct paths
*/
- public SortedSet<PathDescriptionsOrdered> getDirectPathDesc(String aend, String zend,List<NodeLinkNode> paths) {
+ public SortedSet<PathDescriptionsOrdered> getDirectPathDesc(String aend, String zend,
+ List<NodeLinkNode> nodeLinkNodes) {
List<AToZDirection> atozdirectionPaths = new ArrayList<AToZDirection>();
SortedSet<PathDescriptionsOrdered> result = new TreeSet<PathDescriptionsOrdered>();
SuperNode aendSp = getSuperNode(aend);
SuperNode zendSp = getSuperNode(zend);
- if (!paths.isEmpty()) {
- for (NodeLinkNode tmp : paths) {
+ if (!nodeLinkNodes.isEmpty()) {
+ for (NodeLinkNode tmp : nodeLinkNodes) {
if (tmp.getDirect()) {
- LOG.info("Direct NodeLinkNode : " + tmp.toString());
+ LOG.info("Direct NodeLinkNode : {}", tmp.toString());
String atozLink = null;
String ztoaLink = null;
atozLink = tmp.getAtozLink().get(0);
ztoaLink = tmp.getZtoaLink().get(0);
- if (atozLink != null && ztoaLink != null) {
- LOG.info("atozlink : " + atozLink);
- LOG.info("ztoalink : " + ztoaLink);
+ if ((atozLink != null) && (ztoaLink != null)) {
+ LOG.info("atozlink : {}", atozLink);
+ LOG.info("ztoalink : {}", ztoaLink);
InterNodePath interAend = new InterNodePath(aendSp);
interAend.buildPath(zend);
InterNodePath interZend = new InterNodePath(zendSp);
interZend.buildPath(zend);
List<String> deg = getDeg(atozLink,ztoaLink);
- LOG.info("deg : " + deg.toString());
+ LOG.info("deg : {}", deg.toString());
if (deg.size() == 2) {
List<AToZDirection> cleanInterA =
interAend.replaceOrRemoveAToZDirectionEndLink(deg.get(0),"",atozLink,
LOG.info("List of direct path is empty !");
}
if (!atozdirectionPaths.isEmpty()) {
- LOG.info("result size : " + result.size());
+ LOG.info("result size : {}", result.size());
result = buildPathDescription(atozdirectionPaths,aend.concat("To").concat(zend).concat("_direct_"));
} else {
LOG.info("result is empty");
*
* @param aend beginning extremity path
* @param zend ending extremity path
- * @param paths NodeLinkNode list paths
+ * @param nodeLinkNodes list paths
* @return PathDescriptionsOrdered List of indirect paths
*/
- public SortedSet<PathDescriptionsOrdered> getIndirectPathDesc(String aend, String zend,List<NodeLinkNode> paths) {
+ public SortedSet<PathDescriptionsOrdered> getIndirectPathDesc(String aend, String zend,
+ List<NodeLinkNode> nodeLinkNodes) {
List<AToZDirection> atozdirectionPaths = new ArrayList<AToZDirection>();
SortedSet<PathDescriptionsOrdered> result = new TreeSet<PathDescriptionsOrdered>();
SuperNode aendSp = getSuperNode(aend);
SuperNode zendSp = getSuperNode(zend);
- if (!paths.isEmpty()) {
- for (NodeLinkNode tmp : paths) {
+ if (!nodeLinkNodes.isEmpty()) {
+ for (NodeLinkNode tmp : nodeLinkNodes) {
if (!tmp.getDirect()) {
- LOG.info("Indirect NodeLinkNode : " + tmp.toString());
+ LOG.info("Indirect NodeLinkNode : {}", tmp.toString());
int size = tmp.getAtozLink().size();
/** must be two for now just one hop. */
- LOG.info("number of links : " + size);
+ LOG.info("number of links : {}", size);
boolean first = true;
if (size == 2) {
List<String> atozLinks = tmp.getAtozLink();
List<String> ztoaLinks = tmp.getZtoaLink();
if (!atozLinks.isEmpty() && !ztoaLinks.isEmpty()) {
- LOG.info("atozlink : " + atozLinks.toString());
- LOG.info("ztoalink : " + ztoaLinks.toString());
+ LOG.info("atozlink : {}", atozLinks.toString());
+ LOG.info("ztoalink : {}", ztoaLinks.toString());
int loop = 0;
while (loop < 2) {
List<SuperNode> hop = getSuperNodeEndLink(atozLinks.get(loop));
- if (!hop.isEmpty() && hop.size() == 2) {
+ if (!hop.isEmpty() && (hop.size() == 2)) {
aendSp = hop.get(0);
zendSp = hop.get(1);
InterNodePath interAend = new InterNodePath(aendSp);
interAend.buildPath(zend);
- LOG.info("interAend : " + interAend.getAtoz().toString());
+ LOG.info("interAend : {}", interAend.getAtoz().toString());
InterNodePath interZend = new InterNodePath(zendSp);
interZend.buildPath(zend);
- LOG.info("interZend : " + interZend.getAtoz().toString());
+ LOG.info("interZend : {}", interZend.getAtoz().toString());
List<String> deg1 = getDeg(atozLinks.get(loop),ztoaLinks.get(loop));
- LOG.info("deg1 : " + deg1.toString());
- if (!deg1.isEmpty() && deg1.size() == 2) {
+ LOG.info("deg1 : {}", deg1.toString());
+ if (!deg1.isEmpty() && (deg1.size() == 2)) {
List<AToZDirection> cleanInterA = null;
List<AToZDirection> cleanInterZ = null;
if (zendSp.getSuperNodeId().compareTo(zend) == 0) {
LOG.info("List of indirect path is empty !");
}
if (!atozdirectionPaths.isEmpty()) {
- LOG.info("result size : " + result.size());
+ LOG.info("result size : {}", result.size());
result = buildPathDescription(atozdirectionPaths,aend.concat("To").concat(zend).concat("_indirect_"));
} else {
LOG.info("result is empty");
}
public List<NodeLinkNode> getPaths() {
- return paths;
+ return this.paths;
}
public void setPaths(List<NodeLinkNode> paths) {