private static final Logger LOG = LoggerFactory.getLogger(PcePathDescription.class);
private List<PceLink> pathAtoZ = null;
- private List<PceLink> pathZtoA = null;
private PceResult rc;
private Map<LinkId, PceLink> allPceLinks = null;
public PceResult buildDescriptions() {
LOG.info("In buildDescriptions: AtoZ = {}", pathAtoZ);
- Map<AToZKey,AToZ> atozList = new HashMap<>();
+ Map<AToZKey,AToZ> atozMap = new HashMap<>();
if (pathAtoZ == null) {
rc.setRC(ResponseCodes.RESPONSE_FAILED);
LOG.error("In buildDescriptions: there is empty AtoZ path");
return rc;
}
- buildAtoZ(atozList, pathAtoZ);
+ buildAtoZ(atozMap, pathAtoZ);
+ rc.setAtoZDirection(buildAtoZDirection(atozMap).build());
+ List<PceLink> pathZtoA = ImmutableList.copyOf(pathAtoZ).reverse();
+ LOG.info("In buildDescriptions: ZtoA {}", pathZtoA);
+
+ Map<ZToAKey,ZToA> ztoaMap = new HashMap<>();
+ if (pathZtoA == null) {
+ rc.setRC(ResponseCodes.RESPONSE_FAILED);
+ LOG.error("In buildDescriptions: there is empty ZtoA path");
+ return rc;
+ }
+ buildZtoA(ztoaMap, pathZtoA);
+ rc.setZtoADirection(buildZtoADirection(ztoaMap).build());
+
+ return rc;
+ }
+
+ /**
+ * Create a builder for AtoZDirection object.
+ * @param atozMap Map of AToZ object
+ * @return a builder for AtoZDirection object
+ */
+ private AToZDirectionBuilder buildAtoZDirection(Map<AToZKey, AToZ> atozMap) {
AToZDirectionBuilder atoZDirectionBldr = new AToZDirectionBuilder()
.setRate(Uint32.valueOf(rc.getRate()))
- .setAToZ(atozList);
+ .setAToZ(atozMap);
if ("100GE".equals(rc.getServiceType()) || "OTU4".equals(rc.getServiceType())) {
atoZDirectionBldr.setAToZWavelengthNumber(Uint32.valueOf(rc.getResultWavelength()));
} else if ("10GE".equals(rc.getServiceType()) || "1GE".equals(rc.getServiceType())
|| "ODU4".equals(rc.getServiceType())) {
if (rc.getResultTribSlot() != null && rc.getResultTribPort() != null) {
+ @SuppressWarnings("unchecked")
List<Uint16> tribSlotList = (List<Uint16>) rc.getResultTribSlot().values().toArray()[0];
atoZDirectionBldr.setAToZWavelengthNumber(Uint32.valueOf(0))
.setTribPortNumber(Uint16.valueOf(rc.getResultTribPort().values().toArray()[0].toString()))
atoZDirectionBldr.setTribSlotNumber(Uint16.valueOf(0)).setTribPortNumber(Uint16.valueOf(0));
}
}
- rc.setAtoZDirection(atoZDirectionBldr.build());
- pathZtoA = ImmutableList.copyOf(pathAtoZ).reverse();
- LOG.info("In buildDescriptions: ZtoA {}", pathZtoA);
+ return atoZDirectionBldr;
+ }
- Map<ZToAKey,ZToA> ztoaList = new HashMap<>();
- if (pathZtoA == null) {
- rc.setRC(ResponseCodes.RESPONSE_FAILED);
- LOG.error("In buildDescriptions: there is empty ZtoA path");
- return rc;
- }
- buildZtoA(ztoaList, pathZtoA);
+ /**
+ * Create a builder for ZtoADirection object.
+ * @param ztoaMap Map of ZToA object
+ * @return a builder for ZtoADirection object
+ */
+ private ZToADirectionBuilder buildZtoADirection(Map<ZToAKey, ZToA> ztoaMap) {
ZToADirectionBuilder ztoADirectionBldr = new ZToADirectionBuilder()
.setRate(Uint32.valueOf(rc.getRate()))
- .setZToA(ztoaList);
+ .setZToA(ztoaMap);
if ("100GE".equals(rc.getServiceType()) || "OTU4".equals(rc.getServiceType())) {
ztoADirectionBldr.setZToAWavelengthNumber(Uint32.valueOf(rc.getResultWavelength()));
} else if ("10GE".equals(rc.getServiceType()) || "1GE".equals(rc.getServiceType())
|| "ODU4".equals(rc.getServiceType())) {
if (rc.getResultTribSlot() != null && rc.getResultTribPort() != null) {
+ @SuppressWarnings("unchecked")
List<Uint16> tribSlotList = (List<Uint16>) rc.getResultTribSlot().values().toArray()[0];
ztoADirectionBldr.setZToAWavelengthNumber(Uint32.valueOf(0))
.setTribPortNumber(Uint16.valueOf(rc.getResultTribPort().values().toArray()[0].toString()))
ztoADirectionBldr.setTribSlotNumber(Uint16.valueOf(0)).setTribPortNumber(Uint16.valueOf(0));
}
}
- rc.setZtoADirection(ztoADirectionBldr.build());
-
- return rc;
+ return ztoADirectionBldr;
}
- private void buildAtoZ(Map<AToZKey, AToZ> atozList, List<PceLink> path) {
+ @SuppressWarnings("java:S138")
+ //sonar issue This method has 77 lines, which is greater than the 75 lines authorized. Split it into smaller
+ //ignore as it's not relevant to split it from functional point
+ private void buildAtoZ(Map<AToZKey, AToZ> atozMap, List<PceLink> path) {
Integer index = 0;
PceLink lastLink = null;
AToZ lastResource = null;
AToZKey clientKey = new AToZKey(index.toString());
Resource clientResource = new ResourceBuilder().setResource(stp).build();
AToZ firstResource = new AToZBuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build();
- atozList.put(firstResource.key(),firstResource);
+ atozMap.put(firstResource.key(),firstResource);
index += 1;
for (PceLink pcelink : path) {
String srcName = pcelink.getSourceId().getValue();
Resource nodeResource1 = new ResourceBuilder().setResource(sourceNode).build();
AToZ srcResource = new AToZBuilder().setId(srcName).withKey(sourceKey).setResource(nodeResource1).build();
index += 1;
- atozList.put(srcResource.key(),srcResource);
+ atozMap.put(srcResource.key(),srcResource);
// source TP
tpName = pcelink.getSourceTP().toString();
Resource tpResource1 = new ResourceBuilder().setResource(stp).build();
AToZ stpResource = new AToZBuilder().setId(tpName).withKey(srcTPKey).setResource(tpResource1).build();
index += 1;
- atozList.put(stpResource.key(),stpResource);
+ atozMap.put(stpResource.key(),stpResource);
String linkName = pcelink.getLinkId().getValue();
// Link
Resource nodeResource2 = new ResourceBuilder().setResource(atozLink).build();
AToZ linkResource = new AToZBuilder().setId(linkName).withKey(linkKey).setResource(nodeResource2).build();
index += 1;
- atozList.put(linkResource.key(),linkResource);
+ atozMap.put(linkResource.key(),linkResource);
String destName = pcelink.getDestId().getValue();
// target TP
Resource tpResource2 = new ResourceBuilder().setResource(dtp).build();
AToZ ttpResource = new AToZBuilder().setId(tpName).withKey(destTPKey).setResource(tpResource2).build();
index += 1;
- atozList.put(ttpResource.key(),ttpResource);
+ atozMap.put(ttpResource.key(),ttpResource);
org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev200629.pce
.resource.resource.resource.Node targetNode = new NodeBuilder()
}
if (lastResource != null) {
- atozList.put(lastResource.key(),lastResource);
+ atozMap.put(lastResource.key(),lastResource);
}
// build Z side Client TP
clientKey = new AToZKey(index.toString());
clientResource = new ResourceBuilder().setResource(stp).build();
lastResource = new AToZBuilder().setId(tpName).withKey(clientKey).setResource(clientResource).build();
- atozList.put(lastResource.key(),lastResource);
+ atozMap.put(lastResource.key(),lastResource);
}
}
private boolean gnpyToCheckFeasiblity(AToZDirection atoz, ZToADirection ztoa, GnpyUtilitiesImpl gnpy)
- throws GnpyException, Exception {
+ throws GnpyException {
//Call GNPy for path verification
if (gnpy.verifyComputationByGnpy(atoz, ztoa, pceHardConstraints)) {
return false;
}
- private void callGnpyToComputeNewPath(GnpyUtilitiesImpl gnpy) throws GnpyException, Exception {
+ private void callGnpyToComputeNewPath(GnpyUtilitiesImpl gnpy) throws GnpyException {
//Call GNPy in the case of non feasibility
LOG.info("In pceSendingPceRPC: the path is not feasible according to Gnpy");
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
+import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices;
}
}
}
- Include include = new IncludeBuilder().setOrderedHops(orderedHopsList).build();
+ Include include = new IncludeBuilder()
+ .setOrderedHops(orderedHopsList.stream()
+ .collect(Collectors.toMap(OrderedHops::key, orderedHops -> orderedHops)))
+ .build();
General general = new GeneralBuilder().setInclude(include).build();
hardConstraints = new HardConstraintsBuilder().setCoRoutingOrGeneral(general).build();
return hardConstraints;
import java.util.ArrayList;
import java.util.List;
+import java.util.stream.Collectors;
import org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices;
import org.opendaylight.transportpce.common.network.NetworkTransactionService;
import org.opendaylight.transportpce.pce.constraints.PceConstraints;
public class GnpyUtilitiesImpl {
private static final Logger LOG = LoggerFactory.getLogger(GnpyUtilitiesImpl.class);
- private NetworkTransactionService networkTransaction;
private PathComputationRequestInput input;
private GnpyTopoImpl gnpyTopo = null;
private GnpyResult gnpyAtoZ;
public GnpyUtilitiesImpl(NetworkTransactionService networkTransaction, PathComputationRequestInput input,
BindingDOMCodecServices bindingDOMCodecServices)
throws GnpyException {
-
- this.networkTransaction = networkTransaction;
this.gnpyTopo = new GnpyTopoImpl(networkTransaction);
this.input = input;
this.gnpyAtoZ = null;
}
public boolean verifyComputationByGnpy(AToZDirection atoz, ZToADirection ztoa, PceConstraints pceHardConstraints)
- throws GnpyException, Exception {
+ throws GnpyException {
if (atoz == null || atoz.getAToZ() == null || ztoa == null || ztoa.getZToA() == null) {
throw new GnpyException("In GnpyUtilities: the path transmitted to Gnpy is null");
return isPcePathFeasible;
}
- public GnpyResult gnpyResponseOneDirection(GnpyServiceImpl gnpySvc) throws GnpyException, Exception {
+ @SuppressWarnings("checkstyle:illegalcatch")
+ public GnpyResult gnpyResponseOneDirection(GnpyServiceImpl gnpySvc) throws GnpyException {
requestId = Uint32.valueOf((requestId.toJava()) + 1);
List<PathRequest> pathRequestList = new ArrayList<>(gnpySvc.getPathRequest().values());
List<Synchronization> synchronizationList = gnpySvc.getSynchronization();
// Send the computed path to GNPY tool
List<Elements> elementsList = new ArrayList<>(gnpyTopo.getElements().values());
List<Connections> connectionsList = gnpyTopo.getConnections();
- String gnpyResponse = getGnpyResponse(elementsList, connectionsList, pathRequestList,
- synchronizationList);
+ String gnpyResponse;
+ try {
+ gnpyResponse = getGnpyResponse(elementsList, connectionsList, pathRequestList,
+ synchronizationList);
+ } catch (Exception e) {
+ throw new GnpyException("Something went wrong", e);
+ }
// Analyze the response
if (gnpyResponse == null) {
throw new GnpyException("In GnpyUtilities: no response from GNPy server");
}
public HardConstraints askNewPathFromGnpy(PceConstraints pceHardConstraints)
- throws GnpyException, Exception {
+ throws GnpyException {
AToZDirection atoztmp = new AToZDirectionBuilder()
.setRate(input.getServiceAEnd().getServiceRate())
public String getGnpyResponse(List<Elements> elementsList, List<Connections> connectionsList,
List<PathRequest> pathRequestList, List<Synchronization> synchronizationList)
- throws GnpyException, Exception {
+ throws GnpyException {
GnpyApi gnpyApi = new GnpyApiBuilder()
.setTopologyFile(
- new TopologyFileBuilder().setElements(elementsList).setConnections(connectionsList).build())
+ new TopologyFileBuilder()
+ .setElements(elementsList.stream().collect(Collectors.toMap(Elements::key, element -> element)))
+ .setConnections(connectionsList).build())
.setServiceFile(
- new ServiceFileBuilder().setPathRequest(pathRequestList).build())
+ new ServiceFileBuilder()
+ .setPathRequest(pathRequestList.stream()
+ .collect(Collectors.toMap(PathRequest::key, pathRequest -> pathRequest)))
+ .build())
.build();
InstanceIdentifier<GnpyApi> idGnpyApi = InstanceIdentifier.builder(GnpyApi.class).build();
String gnpyJson;
public class InAlgoPathValidator implements PathValidator<String, PceGraphEdge> {
/* Logging. */
private static final Logger LOG = LoggerFactory.getLogger(InAlgoPathValidator.class);
+ private static final String IN_CHECK_PATH_DROPPED_MSG = "in checkPath dropped {} {} ";
public InAlgoPathValidator() {
super();
return (checkTurn(partialPath.getEdgeList().get(size - 1).link().getlinkType(), edge.link().getlinkType()));
}
+ @SuppressWarnings("java:S1541")
+ //sonar issue The Cyclomatic Complexity of this method "checkTurn" is 13 which is greater than 10 authorized.
+ //here we have clear conditional, so for the moment no need to manage this issue
private boolean checkTurn(OpenroadmLinkType prevType, OpenroadmLinkType nextType) {
if (nextType == OpenroadmLinkType.ADDLINK && prevType != OpenroadmLinkType.XPONDEROUTPUT) {
- LOG.debug("in checkPath dropped {} {} ", prevType, nextType);
+ LOG.debug(IN_CHECK_PATH_DROPPED_MSG, prevType, nextType);
return false;
}
if (nextType == OpenroadmLinkType.EXPRESSLINK && prevType != OpenroadmLinkType.ROADMTOROADM) {
- LOG.debug("in checkPath dropped {} {} ", prevType, nextType);
+ LOG.debug(IN_CHECK_PATH_DROPPED_MSG, prevType, nextType);
return false;
}
if (nextType == OpenroadmLinkType.DROPLINK && prevType != OpenroadmLinkType.ROADMTOROADM) {
- LOG.debug("in checkPath dropped {} {} ", prevType, nextType);
+ LOG.debug(IN_CHECK_PATH_DROPPED_MSG, prevType, nextType);
return false;
}
if (nextType == OpenroadmLinkType.XPONDERINPUT && prevType != OpenroadmLinkType.DROPLINK) {
- LOG.debug("in checkPath dropped {} {} ", prevType, nextType);
+ LOG.debug(IN_CHECK_PATH_DROPPED_MSG, prevType, nextType);
return false;
}
if (prevType == OpenroadmLinkType.EXPRESSLINK && nextType != OpenroadmLinkType.ROADMTOROADM) {
- LOG.debug("in checkPath dropped {} {} ", prevType, nextType);
+ LOG.debug(IN_CHECK_PATH_DROPPED_MSG, prevType, nextType);
return false;
}
if (prevType == OpenroadmLinkType.ADDLINK && nextType != OpenroadmLinkType.ROADMTOROADM) {
- LOG.debug("in checkPath dropped {} {} ", prevType, nextType);
+ LOG.debug(IN_CHECK_PATH_DROPPED_MSG, prevType, nextType);
return false;
}
import org.jgrapht.graph.DefaultWeightedEdge;
import org.opendaylight.transportpce.pce.networkanalyzer.PceLink;
+@SuppressWarnings("serial")
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
value = "SE_NO_SERIALVERSIONID",
justification = "https://github.com/rzwitserloot/lombok/wiki/WHY-NOT:-serialVersionUID")
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.SortedMap;
import java.util.TreeMap;
import org.opendaylight.transportpce.common.NetworkUtils;
import org.opendaylight.transportpce.pce.constraints.PceConstraints;
import org.slf4j.LoggerFactory;
public final class MapUtils {
+ private static final String MAP_UTILS_NO_LINK_AUGMENTATION_AVAILABLE_MSG =
+ "MapUtils: No Link augmentation available. {}";
/* Logging. */
private static final Logger LOG = LoggerFactory.getLogger(MapUtils.class);
}
public static List<Long> getSRLG(Link link) {
+ Span omsAttributesSpan = getOmsAttributesSpan(link);
+ if (omsAttributesSpan == null) {
+ LOG.debug("No concatenation for this link");
+ return new ArrayList<>();
+ }
List<Long> srlgList = new ArrayList<>();
- try {
- Map<LinkConcatenationKey, LinkConcatenation> linkList = getOmsAttributesSpan(link).getLinkConcatenation();
- for (LinkConcatenation lc : linkList.values()) {
+ Map<LinkConcatenationKey, LinkConcatenation> linkList = omsAttributesSpan.nonnullLinkConcatenation();
+ for (LinkConcatenation lc : linkList.values()) {
+ if (lc != null && lc.getSRLGId() != null) {
srlgList.add(lc.getSRLGId().toJava());
}
- } catch (NullPointerException e) {
- LOG.debug("No concatenation for this link");
}
return srlgList;
}
public static List<Long> getSRLGfromLink(Link link) {
- List<Long> srlgList = new ArrayList<>();
- org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1 linkC =
- link.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class);
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1 linkC = link
+ .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.Link1.class);
if (linkC == null) {
- LOG.error("MapUtils: No Link augmentation available. {}", link.getLinkId().getValue());
-
- } else {
- try {
- for (org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130.networks.network.link
- .LinkConcatenation lc : linkC.nonnullLinkConcatenation().values()) {
- srlgList.add(lc.getSRLGId().toJava());
- }
- } catch (NullPointerException e) {
- LOG.debug("No concatenation for this link");
+ LOG.error(MAP_UTILS_NO_LINK_AUGMENTATION_AVAILABLE_MSG, link.getLinkId().getValue());
+ return new ArrayList<>();
+ }
+ List<Long> srlgList = new ArrayList<>();
+ for (org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev181130
+ .networks.network.link.LinkConcatenation lc : linkC.nonnullLinkConcatenation().values()) {
+ if (lc != null && lc.getSRLGId() != null) {
+ srlgList.add(lc.getSRLGId().toJava());
+ } else {
+ LOG.debug("No concatenation or SLRG id for this link");
}
}
return srlgList;
return null;
}
- public static TreeMap<String, String> getAllSupNode(Node node) {
+ public static SortedMap<String, String> getAllSupNode(Node node) {
TreeMap<String, String> allSupNodes = new TreeMap<>();
for (SupportingNode supnode : node.nonnullSupportingNode().values()) {
allSupNodes.put(supnode.getNetworkRef().getValue(),
// ID and type
link1 = link.augmentation(Link1.class);
if (link1 == null) {
- LOG.error("MapUtils: No Link augmentation available. {}", link.getLinkId().getValue());
+ LOG.error(MAP_UTILS_NO_LINK_AUGMENTATION_AVAILABLE_MSG, link.getLinkId().getValue());
return null;
}
public static Span getOmsAttributesSpan(Link link) {
org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.Link1 link1 = null;
- Span tempSpan = null;
link1 =
link.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.Link1.class);
if (link1 == null) {
- LOG.error("MapUtils: No Link augmentation available. {}", link.getLinkId().getValue());
- }
- try {
- tempSpan = link1.getOMSAttributes().getSpan();
+ LOG.error(MAP_UTILS_NO_LINK_AUGMENTATION_AVAILABLE_MSG, link.getLinkId().getValue());
+ return null;
}
- catch (NullPointerException e) {
+ if (link1.getOMSAttributes() == null) {
LOG.error("MapUtils: No Link getOMSAttributes available. {}", link.getLinkId().getValue());
+ return null;
}
-
- return tempSpan;
+ return link1.getOMSAttributes().getSpan();
}
public static LinkId extractOppositeLink(Link link) {
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.eclipse.jdt.annotation.NonNull;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@SuppressWarnings("serial")
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
value = "SE_NO_SERIALVERSIONID",
justification = "https://github.com/rzwitserloot/lombok/wiki/WHY-NOT:-serialVersionUID")
*/
double weight = 0;
private boolean isValid = true;
- private boolean isOtnValid = true;
// this member is for XPONDER INPUT/OUTPUT links.
// it keeps name of client corresponding to NETWORK TP
private final List<Long> srlgList;
private final double osnr;
private final transient Span omsAttributesSpan;
- private static final double CELERITY = 2.99792458 * 1e5; //meter per ms
+ //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;
this.omsAttributesSpan = null;
this.srlgList = null;
this.latency = 0L;
- this.osnr = 100L; //infinite OSNR in DB
+ //infinite OSNR in DB
+ this.osnr = 100L;
this.availableBandwidth = 0L;
this.usedBandwidth = 0L;
}
//Compute the link latency : if the latency is not defined, the latency is computed from the omsAttributesSpan
private Long calcLatency(Link link) {
- Link1 link1 = null;
- Long tmplatency;
- link1 = link.augmentation(Link1.class);
+ Link1 link1 = link.augmentation(Link1.class);
if (link1.getLinkLatency() != null) {
- tmplatency = link1.getLinkLatency().toJava();
- return tmplatency;
+ return link1.getLinkLatency().toJava();
}
-
- try {
- double tmp = 0;
- @NonNull
- Map<LinkConcatenationKey, LinkConcatenation> linkConcatenationMap =
- this.omsAttributesSpan.nonnullLinkConcatenation();
- for (Map.Entry<LinkConcatenationKey, LinkConcatenation> entry : linkConcatenationMap.entrySet()) {
- //Length is expressed in meter and latency is expressed in ms according to OpenROADM MSA
- tmp += entry.getValue().getSRLGLength().toJava() / CELERITY;
- LOG.info("In PceLink: The latency of link {} == {}",link.getLinkId(),tmp);
+ if (this.omsAttributesSpan == null) {
+ return 1L;
+ }
+ double tmp = 0;
+ Map<LinkConcatenationKey, LinkConcatenation> linkConcatenationMap = this.omsAttributesSpan
+ .nonnullLinkConcatenation();
+ for (Map.Entry<LinkConcatenationKey, LinkConcatenation> 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;
}
- tmplatency = (long) Math.ceil(tmp);
- } catch (NullPointerException e) {
- LOG.debug("In PceLink: cannot compute the latency for the link {}",link.getLinkId().getValue());
- tmplatency = 1L;
+ tmp += entry.getValue().getSRLGLength().toJava() / CELERITY;
+ LOG.info("In PceLink: The latency of link {} == {}", link.getLinkId(), tmp);
}
- return tmplatency;
+ return (long) Math.ceil(tmp);
}
//Compute the OSNR of a span
double pout = retrievePower(linkConcatenationiterator.next().getFiberType());
// span loss (dB)
double spanLoss = this.omsAttributesSpan.getSpanlossCurrent().getValue().doubleValue();
- double pin = pout - spanLoss; // power on the input of the current ROADM (dBm)
+ // 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;
isValid = false;
LOG.error("PceLink: No Link type or opposite link is available. Link is ignored {}", linkId);
}
- if ((this.sourceId == null) || (this.destId == null) || (this.sourceTP == null) || (this.destTP == null)) {
- isValid = false;
- LOG.error("PceLink: No Link source or destination is available. Link is ignored {}", linkId);
- }
- if ((this.sourceNetworkSupNodeId.equals("")) || (this.destNetworkSupNodeId.equals(""))) {
- isValid = false;
- LOG.error("PceLink: No Link source SuppNodeID or destination SuppNodeID is available. Link is ignored {}",
- linkId);
- }
- if ((this.sourceCLLI.equals("")) || (this.destCLLI.equals(""))) {
- isValid = false;
- LOG.error("PceLink: No Link source CLLI or destination CLLI 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);
linkId, serviceType);
}
+ return checkParams();
+ }
+
+ private boolean checkParams() {
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;
this.node.augmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
.ietf.network.topology.rev180226.Node1.class);
List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
- .node.TerminationPoint> allTps = new ArrayList(nodeTp.getTerminationPoint().values());
- if (allTps == null) {
+ .node.TerminationPoint> allTps = new ArrayList<>(nodeTp.nonnullTerminationPoint().values());
+ if (allTps.isEmpty()) {
LOG.error("initSrgTpList: ROADM TerminationPoint list is empty for node {}", this);
this.valid = false;
return;
LOG.info("initSrgTpList: SRG-PP tp = {} found", tp.getTpId().getValue());
try {
List<UsedWavelength> usedWavelengths =
- new ArrayList(nttp1.getPpAttributes().getUsedWavelength().values());
+ new ArrayList<>(nttp1.getPpAttributes().getUsedWavelength().values());
if (usedWavelengths.isEmpty()) {
used = false;
}
case SRG :
List<org.opendaylight.yang.gen.v1.http.org.openroadm.srg.rev181130.srg.node.attributes
.AvailableWavelengths> srgAvailableWL =
- new ArrayList(node1.getSrgAttributes().getAvailableWavelengths().values());
- if (srgAvailableWL == null) {
+ new ArrayList<>(node1.getSrgAttributes().nonnullAvailableWavelengths().values());
+ if (srgAvailableWL.isEmpty()) {
this.valid = false;
LOG.error("initWLlist: SRG AvailableWavelengths is empty for node {}", this);
return;
case DEGREE :
List<org.opendaylight.yang.gen.v1.http.org.openroadm.degree.rev181130.degree.node.attributes
.AvailableWavelengths> degAvailableWL =
- new ArrayList(node1.getDegreeAttributes().getAvailableWavelengths().values());
- if (degAvailableWL == null) {
+ new ArrayList<>(node1.getDegreeAttributes().nonnullAvailableWavelengths().values());
+ if (degAvailableWL.isEmpty()) {
this.valid = false;
LOG.error("initWLlist: DEG AvailableWavelengths is empty for node {}", this);
return;
this.node.augmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
.ietf.network.topology.rev180226.Node1.class);
List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
- .node.TerminationPoint> allTps = new ArrayList(nodeTp.getTerminationPoint().values());
- if (allTps == null) {
+ .node.TerminationPoint> allTps = new ArrayList<>(nodeTp.nonnullTerminationPoint().values());
+ if (allTps.isEmpty()) {
this.valid = false;
LOG.error("initXndrTps: XPONDER TerminationPoint list is empty for node {}", this);
return;
= this.node.augmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
.ietf.network.topology.rev180226.Node1.class);
List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
- .node.TerminationPoint> allTps = new ArrayList(nodeTp.getTerminationPoint().values());
+ .node.TerminationPoint> allTps = new ArrayList<>(nodeTp.nonnullTerminationPoint().values());
this.valid = false;
- if (allTps == null) {
+ if (allTps.isEmpty()) {
LOG.error("PceOtnNode: initXndrTps: XPONDER TerminationPoint list is empty for node {}", this);
return;
}
for (TpId nwTp : netwTps) {
for (TpId clTp : clientTps) {
@Nullable
- List<NonBlockingList> nblList = new ArrayList(node.augmentation(Node1.class).getSwitchingPools()
- .getOduSwitchingPools().values().stream().findFirst().get().getNonBlockingList().values());
+ List<NonBlockingList> nblList = new ArrayList<>(node.augmentation(Node1.class).getSwitchingPools()
+ .nonnullOduSwitchingPools().values().stream().findFirst().get().getNonBlockingList().values());
for (NonBlockingList nbl : nblList) {
if (nbl.getTpList().contains(clTp) && nbl.getTpList().contains(nwTp)) {
usableXpdrClientTps.add(clTp);
if (clientTps == null && netwTps != null && nbClient == 0 && nbNetw == 2) {
netwTps.sort(Comparator.comparing(TpId::getValue));
@Nullable
- List<NonBlockingList> nblList = new ArrayList(node.augmentation(Node1.class).getSwitchingPools()
- .getOduSwitchingPools().values().stream().findFirst().get().getNonBlockingList().values());
+ List<NonBlockingList> nblList = new ArrayList<>(node.augmentation(Node1.class).getSwitchingPools()
+ .nonnullOduSwitchingPools().values().stream().findFirst().get().getNonBlockingList().values());
for (NonBlockingList nbl : nblList) {
for (TpId nwTp : netwTps) {
if (nbl.getTpList().contains(nwTp)) {
node.augmentation(
org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev181130.Node1.class);
SwitchingPools sp = node1.getSwitchingPools();
- List<OduSwitchingPools> osp = new ArrayList(sp.getOduSwitchingPools().values());
+ List<OduSwitchingPools> osp = new ArrayList<>(sp.nonnullOduSwitchingPools().values());
for (OduSwitchingPools ospx : osp) {
- List<NonBlockingList> nbl = new ArrayList(ospx.getNonBlockingList().values());
+ List<NonBlockingList> nbl = new ArrayList<>(ospx.nonnullNonBlockingList().values());
for (NonBlockingList nbll : nbl) {
if (nbll.getAvailableInterconnectBandwidth().toJava() >= neededBW && nbll.getTpList() != null
&& nbll.getTpList().contains(tp1.getTpId()) && nbll.getTpList().contains(tp2.getTpId())) {
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
import org.opendaylight.mdsal.binding.api.NotificationPublishService;
import org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices;
import org.opendaylight.transportpce.common.network.NetworkTransactionService;
GnpyResponse respZtoA = generateGnpyResponse(gnpyZtoA.getResponse(),"Z-to-A");
listResponse.add(respZtoA);
}
- output.setGnpyResponse(listResponse);
+ output.setGnpyResponse(listResponse.stream()
+ .collect(Collectors.toMap(GnpyResponse::key, gnpyResponse -> gnpyResponse)));
if (Boolean.FALSE.equals(sendingPCE.getSuccess()) || (path == null)) {
configurationResponseCommon.setAckFinalIndicator("Yes")
.setAccumulativeValue(pathMetricGnpy.getAccumulativeValue()).build();
gnpyPathMetricList.add(pathMetric);
}
- PathProperties pathProperties = new PathPropertiesBuilder().setPathMetric(gnpyPathMetricList).build();
+ PathProperties pathProperties = new PathPropertiesBuilder()
+ .setPathMetric(gnpyPathMetricList.stream()
+ .collect(Collectors.toMap(PathMetric::key, pathMetric -> pathMetric)))
+ .build();
PathCase gnpyPathCase = new PathCaseBuilder().setPathProperties(pathProperties).build();
respType = gnpyPathCase;
feasible = true;
package org.opendaylight.transportpce.pce.impl;
-import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.ArgumentMatchers.eq;
import org.eclipse.jdt.annotation.NonNull;
}
};
-
-
Mockito
.when(rpcService
- .registerRpcImplementation(eq(TransportpcePceService.class), anyObject()))
+ .registerRpcImplementation(eq(TransportpcePceService.class), Mockito.any()))
.thenReturn(rpcRegistration);
pceProvider.init();
pceProvider.close();
self.assertEqual(res['output']['configuration-response-common'][
'response-message'],
'Path is calculated by PCE')
- self.assertEqual(res['output']['gnpy-response'][0]['path-dir'],
- 'A-to-Z')
- self.assertEqual(res['output']['gnpy-response'][0]['feasibility'], True)
self.assertEqual(res['output']['gnpy-response'][1]['path-dir'],
- 'Z-to-A')
+ 'A-to-Z')
self.assertEqual(res['output']['gnpy-response'][1]['feasibility'], True)
+ self.assertEqual(res['output']['gnpy-response'][0]['path-dir'],
+ 'Z-to-A')
+ self.assertEqual(res['output']['gnpy-response'][0]['feasibility'], True)
time.sleep(5)
# Path computed by PCE is not feasible by GNPy and GNPy cannot find
self.assertEqual(res['output']['configuration-response-common'][
'response-message'],
'No path available by PCE and GNPy ')
- self.assertEqual(res['output']['gnpy-response'][0]['path-dir'],
+ self.assertEqual(res['output']['gnpy-response'][1]['path-dir'],
'A-to-Z')
- self.assertEqual(res['output']['gnpy-response'][0]['feasibility'],
+ self.assertEqual(res['output']['gnpy-response'][1]['feasibility'],
False)
- self.assertEqual(res['output']['gnpy-response'][1]['path-dir'],
+ self.assertEqual(res['output']['gnpy-response'][0]['path-dir'],
'Z-to-A')
- self.assertEqual(res['output']['gnpy-response'][1]['feasibility'],
+ self.assertEqual(res['output']['gnpy-response'][0]['feasibility'],
False)
time.sleep(5)
self.assertEqual(res['output']['configuration-response-common'][
'response-message'],
'Path is calculated by GNPy')
- self.assertEqual(res['output']['gnpy-response'][0]['path-dir'],
- 'A-to-Z')
- self.assertEqual(res['output']['gnpy-response'][0]['feasibility'], True)
self.assertEqual(res['output']['gnpy-response'][1]['path-dir'],
- 'Z-to-A')
+ 'A-to-Z')
self.assertEqual(res['output']['gnpy-response'][1]['feasibility'], True)
+ self.assertEqual(res['output']['gnpy-response'][0]['path-dir'],
+ 'Z-to-A')
+ self.assertEqual(res['output']['gnpy-response'][0]['feasibility'], True)
time.sleep(5)
# Not found path by PCE and GNPy cannot find another one