X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=pce%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fpce%2Fnetworkanalyzer%2FPceLink.java;h=eb94fa6bd67d2413f5f0d75c9cc4ab4c037e4708;hb=HEAD;hp=a38682dec36aa124ea4c6a6ea1dbf28374f15b75;hpb=ae67bdaafc371d7937f75dde8db77dadf037aa5b;p=transportpce.git diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceLink.java b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceLink.java index a38682dec..eafec5115 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceLink.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceLink.java @@ -8,29 +8,26 @@ package org.opendaylight.transportpce.pce.networkanalyzer; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.Serializable; -import java.util.Collection; -import java.util.Iterator; import java.util.List; import java.util.Map; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1; -import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.span.attributes.LinkConcatenation; -import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.span.attributes.LinkConcatenation.FiberType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.span.attributes.LinkConcatenationKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.networks.network.link.oms.attributes.Span; -import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmLinkType; -import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.OtnLinkType; +import org.opendaylight.transportpce.common.NetworkUtils; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.OtnLinkType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Link1; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State; +import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.networks.network.link.oms.attributes.Span; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmLinkType; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.LinkId; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @SuppressWarnings("serial") -@edu.umd.cs.findbugs.annotations.SuppressFBWarnings( +@SuppressFBWarnings( value = "SE_NO_SERIALVERSIONID", justification = "https://github.com/rzwitserloot/lombok/wiki/WHY-NOT:-serialVersionUID") public class PceLink implements Serializable { @@ -46,33 +43,34 @@ public class PceLink implements Serializable { // this member is for XPONDER INPUT/OUTPUT links. // it keeps name of client corresponding to NETWORK TP - private String client = ""; + private String clientA = ""; + private String clientZ = ""; private final LinkId linkId; private final OpenroadmLinkType linkType; private final NodeId sourceId; private final NodeId destId; - private transient Object sourceTP; - private transient Object destTP; + private final TpId sourceTP; + private final TpId destTP; private final String sourceNetworkSupNodeId; private final String destNetworkSupNodeId; private final String sourceCLLI; private final String destCLLI; private final LinkId oppositeLink; + private final AdminStates adminStates; + private final State state; private final Long latency; private final Long availableBandwidth; private final Long usedBandwidth; private final List srlgList; - private final double osnr; + private final Double length; + private final Double cd; + private final Double pmd2; + private final Double spanLoss; + private final Double powerCorrection; private final transient Span omsAttributesSpan; - //meter per ms - private static final double CELERITY = 2.99792458 * 1e5; - private static final double NOISE_MASK_A = 0.571429; - private static final double NOISE_MASK_B = 39.285714; - private static final double UPPER_BOUND_OSNR = 33; - private static final double LOWER_BOUND_OSNR = 0.1; public PceLink(Link link, PceNode source, PceNode dest) { - LOG.info("PceLink: : PceLink start "); + LOG.debug("PceLink: : PceLink start "); this.linkId = link.getLinkId(); @@ -92,28 +90,47 @@ public class PceLink implements Serializable { this.oppositeLink = calcOpposite(link); - if (this.linkType == OpenroadmLinkType.ROADMTOROADM) { - this.omsAttributesSpan = MapUtils.getOmsAttributesSpan(link); - this.srlgList = MapUtils.getSRLG(link); - this.latency = calcLatency(link); - this.osnr = calcSpanOSNR(); - this.availableBandwidth = 0L; - this.usedBandwidth = 0L; - } else if (this.linkType == OpenroadmLinkType.OTNLINK) { - this.availableBandwidth = MapUtils.getAvailableBandwidth(link); - this.usedBandwidth = MapUtils.getUsedBandwidth(link); - this.srlgList = MapUtils.getSRLGfromLink(link); - this.osnr = 0.0; - this.latency = 0L; - this.omsAttributesSpan = null; - } else { - this.omsAttributesSpan = null; - this.srlgList = null; - this.latency = 0L; - //infinite OSNR in DB - this.osnr = 100L; - this.availableBandwidth = 0L; - this.usedBandwidth = 0L; + this.adminStates = link.augmentation(Link1.class).getAdministrativeState(); + this.state = link.augmentation(Link1.class).getOperationalState(); + switch (this.linkType) { + case ROADMTOROADM: + this.omsAttributesSpan = MapUtils.getOmsAttributesSpan(link); + this.length = NetworkUtils.calcLength(link); + this.srlgList = MapUtils.getSRLG(link); + this.latency = NetworkUtils.calcLatency(link); + this.availableBandwidth = 0L; + this.usedBandwidth = 0L; + Map spanLossMap = NetworkUtils.calcSpanLoss(link); + this.spanLoss = spanLossMap.get("SpanLoss"); + this.powerCorrection = spanLossMap.get("PoutCorrection"); + Map cdAndPmdMap = NetworkUtils.calcCDandPMD(link); + this.cd = cdAndPmdMap.get("CD"); + this.pmd2 = cdAndPmdMap.get("PMD2"); + break; + case OTNLINK: + this.availableBandwidth = MapUtils.getAvailableBandwidth(link); + this.usedBandwidth = MapUtils.getUsedBandwidth(link); + this.srlgList = MapUtils.getSRLGfromLink(link); + this.latency = 0L; + this.length = 0.0; + this.omsAttributesSpan = null; + this.spanLoss = 0.0; + this.powerCorrection = 0.0; + this.cd = 0.0; + this.pmd2 = 0.0; + break; + default: + this.omsAttributesSpan = null; + this.srlgList = null; + this.latency = 0L; + this.length = 0.0; + this.availableBandwidth = 0L; + this.usedBandwidth = 0L; + this.spanLoss = 0.0; + this.powerCorrection = 0.0; + this.cd = 0.0; + this.pmd2 = 0.0; + break; } LOG.debug("PceLink: created PceLink {}", linkId); } @@ -128,93 +145,23 @@ public class PceLink implements Serializable { return tmpoppositeLink; } - //Compute the link latency : if the latency is not defined, the latency is computed from the omsAttributesSpan - private Long calcLatency(Link link) { - Link1 link1 = link.augmentation(Link1.class); - if (link1.getLinkLatency() != null) { - return link1.getLinkLatency().toJava(); - } - if (this.omsAttributesSpan == null) { - return 1L; - } - double tmp = 0; - Map linkConcatenationMap = this.omsAttributesSpan - .nonnullLinkConcatenation(); - for (Map.Entry entry : linkConcatenationMap.entrySet()) { - // Length is expressed in meter and latency is expressed in ms according to OpenROADM MSA - if (entry == null || entry.getValue() == null || entry.getValue().getSRLGLength() == null) { - LOG.debug("In PceLink: cannot compute the latency for the link {}", link.getLinkId().getValue()); - return 1L; - } - tmp += entry.getValue().getSRLGLength().toJava() / CELERITY; - LOG.info("In PceLink: The latency of link {} == {}", link.getLinkId(), tmp); - } - return (long) Math.ceil(tmp); + public LinkId getOppositeLink() { + return oppositeLink; } - //Compute the OSNR of a span - public double calcSpanOSNR() { - if (this.omsAttributesSpan == null) { - return 0L; - } - Collection linkConcatenationList = - this.omsAttributesSpan.nonnullLinkConcatenation().values(); - if (linkConcatenationList == null) { - LOG.error("in PceLink : Null field in the OmsAttrubtesSpan"); - return 0L; - } - Iterator linkConcatenationiterator = linkConcatenationList.iterator(); - if (!linkConcatenationiterator.hasNext()) { - return 0L; - } - // power on the output of the previous ROADM (dBm) - double pout = retrievePower(linkConcatenationiterator.next().getFiberType()); - // span loss (dB) - double spanLoss = this.omsAttributesSpan.getSpanlossCurrent().getValue().doubleValue(); - // power on the input of the current ROADM (dBm) - double pin = pout - spanLoss; - double spanOsnrDb = NOISE_MASK_A * pin + NOISE_MASK_B; - if (spanOsnrDb > UPPER_BOUND_OSNR) { - spanOsnrDb = UPPER_BOUND_OSNR; - } else if (spanOsnrDb < LOWER_BOUND_OSNR) { - spanOsnrDb = LOWER_BOUND_OSNR; - } - return spanOsnrDb; + public AdminStates getAdminStates() { + return adminStates; } - private double retrievePower(FiberType fiberType) { - double power; - switch (fiberType) { - case Smf: - power = 2; - break; - case Eleaf: - power = 1; - break; - case Truewavec: - power = -1; - break; - case Oleaf: - case Dsf: - case Truewave: - case NzDsf: - case Ull: - default: - power = 0; - break; - } - return power; - } - - public LinkId getOppositeLink() { - return oppositeLink; + public State getState() { + return state; } - public Object getSourceTP() { + public TpId getSourceTP() { return sourceTP; } - public Object getDestTP() { + public TpId getDestTP() { return destTP; } @@ -234,12 +181,24 @@ public class PceLink implements Serializable { return destId; } - public String getClient() { - return client; + public String getClientA() { + return clientA; + } + + public Double getLength() { + return length; + } + + public void setClientA(String client) { + this.clientA = client; + } + + public String getClientZ() { + return clientZ; } - public void setClient(String client) { - this.client = client; + public void setClientZ(String client) { + this.clientZ = client; } // Double for transformer of JUNG graph @@ -267,10 +226,6 @@ public class PceLink implements Serializable { return srlgList; } - public double getosnr() { - return osnr; - } - public String getsourceCLLI() { return sourceCLLI; } @@ -279,17 +234,40 @@ public class PceLink implements Serializable { return destCLLI; } + public Double getspanLoss() { + return spanLoss; + } + + public Double getcd() { + return cd; + } + + public Double getpmd2() { + return pmd2; + } + + public Double getpowerCorrection() { + return powerCorrection; + } + public boolean isValid() { - if ((this.linkId == null) || (this.linkType == null) || (this.oppositeLink == null)) { + if (this.linkId == null || this.linkType == null || this.oppositeLink == null) { isValid = false; LOG.error("PceLink: No Link type or opposite link is available. Link is ignored {}", linkId); } isValid = checkParams(); - if ((this.omsAttributesSpan == null) && (this.linkType == OpenroadmLinkType.ROADMTOROADM)) { - isValid = false; - LOG.error("PceLink: Error reading Span for OMS link. Link is ignored {}", linkId); + if (this.linkType == OpenroadmLinkType.ROADMTOROADM && (this.length == null || this.length == 0.0)) { + if (this.omsAttributesSpan == null) { + isValid = false; + LOG.error("PceLink: Error reading Span for OMS link, and no available generic link information." + + " Link is ignored {}", linkId); + } else if (this.omsAttributesSpan.getSpanlossCurrent() == null) { + isValid = false; + LOG.error("PceLink: Error reading Span for OMS link, and no available generic link information." + + " Link is ignored {}", linkId); + } } - if ((this.srlgList != null) && (this.srlgList.isEmpty())) { + if (this.srlgList != null && this.srlgList.isEmpty()) { isValid = false; LOG.error("PceLink: Empty srlgList for OMS link. Link is ignored {}", linkId); } @@ -303,9 +281,6 @@ public class PceLink implements Serializable { return false; } - OtnLinkType otnLinkType = link - .augmentation(org.opendaylight.yang.gen.v1.http.transportpce.topology.rev200129.Link1.class) - .getOtnLinkType(); if (this.availableBandwidth == 0L) { LOG.error("PceLink: No bandwidth available for OTN Link, link {} is ignored ", linkId); return false; @@ -314,8 +289,31 @@ public class PceLink implements Serializable { long neededBW; OtnLinkType neededType = null; switch (serviceType) { - + case "ODUC2": + if (this.usedBandwidth != 0L) { + return false; + } + neededBW = 200000L; + // Add intermediate rate otn-link-type + neededType = OtnLinkType.OTUC2; + break; + case "ODUC3": + if (this.usedBandwidth != 0L) { + return false; + } + neededBW = 300000L; + // change otn-link-type + neededType = OtnLinkType.OTUC3; + break; + case "ODUC4": + if (this.usedBandwidth != 0L) { + return false; + } + neededBW = 400000L; + neededType = OtnLinkType.OTUC4; + break; case "ODU4": + case "100GEs": if (this.usedBandwidth != 0L) { return false; } @@ -332,6 +330,11 @@ public class PceLink implements Serializable { case "ODU1": neededBW = 2500L; break; + case "100GEm": + neededBW = 100000L; + // TODO: Here link type needs to be changed, based on the line-rate + neededType = OtnLinkType.ODUC4; + break; case "10GE": neededBW = 10000L; neededType = OtnLinkType.ODTU4; @@ -344,31 +347,38 @@ public class PceLink implements Serializable { LOG.error("PceLink: isOtnValid Link {} unsupported serviceType {} ", linkId, serviceType); return false; } - - if ((this.availableBandwidth >= neededBW) - && ((neededType == null) || (neededType.equals(otnLinkType)))) { - LOG.info("PceLink: Selected Link {} has available bandwidth and is eligible for {} creation ", + if (this.availableBandwidth >= neededBW + && (neededType == null + || neededType.equals( + link.augmentation( + org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630 + .Link1.class) + .getOtnLinkType()))) { + LOG.debug("PceLink: Selected Link {} has available bandwidth and is eligible for {} creation ", linkId, serviceType); } - return checkParams(); } private boolean checkParams() { - if ((this.linkId == null) || (this.linkType == null) || (this.oppositeLink == null)) { + if (this.linkId == null || this.linkType == null || this.oppositeLink == null) { LOG.error("PceLink: No Link type or opposite link is available. Link is ignored {}", linkId); return false; } - if ((this.sourceId == null) || (this.destId == null) || (this.sourceTP == null) || (this.destTP == null)) { + if (this.adminStates == null || this.state == null) { + LOG.error("PceLink: Link is not available. Link is ignored {}", linkId); + return false; + } + if (this.sourceId == null || this.destId == null || this.sourceTP == null || this.destTP == null) { LOG.error("PceLink: No Link source or destination is available. Link is ignored {}", linkId); return false; } - if ((this.sourceNetworkSupNodeId.equals("")) || (this.destNetworkSupNodeId.equals(""))) { + if (this.sourceNetworkSupNodeId.equals("") || this.destNetworkSupNodeId.equals("")) { LOG.error("PceLink: No Link source SuppNodeID or destination SuppNodeID is available. Link is ignored {}", linkId); return false; } - if ((this.sourceCLLI.equals("")) || (this.destCLLI.equals(""))) { + if (this.sourceCLLI.equals("") || this.destCLLI.equals("")) { LOG.error("PceLink: No Link source CLLI or destination CLLI is available. Link is ignored {}", linkId); return false; } @@ -380,16 +390,4 @@ public class PceLink implements Serializable { public String toString() { return "PceLink type=" + linkType + " ID=" + linkId.getValue() + " latency=" + latency; } - - private void writeObject(ObjectOutputStream out) throws IOException { - out.defaultWriteObject(); - out.writeObject(this.sourceTP); - out.writeObject(this.destTP); - } - - private void readObject(ObjectInputStream in) throws IOException,ClassNotFoundException { - in.defaultReadObject(); - this.sourceTP = in.readObject(); - this.destTP = in.readObject(); - } }