From 767266b4daf54646e022f17d7f9674e929081583 Mon Sep 17 00:00:00 2001 From: "guillaume.lambert" Date: Wed, 29 Apr 2020 16:49:38 +0200 Subject: [PATCH] fix PCE SpotBugs issues - add a SuppressFBwarning decorator on classes with false positives - remove uncalled private methods - enforce SpotBugs at build time in PCE pom.xml JIRA: TRNSPRTPCE-244 Signed-off-by: guillaume.lambert Change-Id: I1c2f7e8ec1b8cd9994641d31a004733e5d77c272 --- pce/pom.xml | 6 -- .../pce/graph/PostAlgoPathValidator.java | 59 ++---------------- .../pce/networkanalyzer/PceOtnNode.java | 61 ------------------- .../service/PathComputationServiceImpl.java | 4 ++ 4 files changed, 8 insertions(+), 122 deletions(-) diff --git a/pce/pom.xml b/pce/pom.xml index 67ec610bf..c39133d30 100644 --- a/pce/pom.xml +++ b/pce/pom.xml @@ -104,10 +104,4 @@ Author: Martial Coulibaly on behalf of Orange - - - - false - - diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PostAlgoPathValidator.java b/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PostAlgoPathValidator.java index bd4052d79..245be1b6a 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PostAlgoPathValidator.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/graph/PostAlgoPathValidator.java @@ -8,6 +8,7 @@ package org.opendaylight.transportpce.pce.graph; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -36,6 +37,9 @@ public class PostAlgoPathValidator { public static final Long CONST_OSNR = 1L; public static final double SYS_MARGIN = 0; + @SuppressFBWarnings( + value = "SF_SWITCH_FALLTHROUGH", + justification = "intentional fallthrough") public PceResult checkPath(GraphPath path, Map allPceNodes, PceResult pceResult, PceConstraints pceHardConstraints, String serviceType) { @@ -344,61 +348,6 @@ public class PostAlgoPathValidator { return tribSlotMap; } - private List> chooseTribSlot3(GraphPath path, - Map allPceNodes) { - List> tribSlot = new ArrayList<>(); - boolean statusOK = true; - boolean check = false; - Object nodeClass = allPceNodes.getClass(); - if (nodeClass.getClass().isInstance(PceNode.class)) { - LOG.debug("In choosetribSlot: AllPceNodes contains PceNode instance, no trib port search"); - return tribSlot; - } else if (nodeClass.getClass().isInstance(PceNode.class)) { - LOG.debug("In choosetribPort: {} {}", path.getLength(), path); - } - for (PceGraphEdge edge : path.getEdgeList()) { - LOG.debug("In chooseTribSlot: source {} ", edge.link().getSourceId()); - PceNode pceNode = allPceNodes.get(edge.link().getSourceId()); - Object tps = allPceNodes.get(edge.link().getSourceTP()); - Object tpd = allPceNodes.get(edge.link().getDestTP()); - if ((pceNode.getAvailableTribSlots().containsKey(tps.toString())) - && (pceNode.getAvailableTribSlots().containsKey(tpd.toString()))) { - List tribSlotEdgeSourceN = pceNode.getAvailableTribSlots().get(tps.toString()); - List tribSlotEdgeDestN = pceNode.getAvailableTribSlots().get(tps.toString()); - check = false; - for (int i = 0; i <= 79; i++) { - if (tribSlotEdgeSourceN.get(i) == null) { - break; - } - // TODO This will need to be modified as soon as the trib-slots allocation per - // trib-port - // policy applied by the different manufacturer is known - if (tribSlotEdgeSourceN.get(i).equals(tribSlotEdgeDestN.get(i))) { - check = true; - } else { - check = false; - LOG.debug("In chooseTribSlot: Misalignement of trib slots between source {} and dest {}", - edge.link().getSourceId(), edge.link().getDestId()); - break; - } - } - if (check) { - tribSlot.add(tribSlotEdgeSourceN); - } - } else { - LOG.debug("In chooseTribSlot: source {} does not have provisonned hosting HO interface ", - edge.link().getSourceId()); - statusOK = false; - } - } - if (statusOK && check) { - return tribSlot; - } else { - tribSlot.clear(); - return tribSlot; - } - } - // Check the path OSNR private boolean checkOSNR(GraphPath path) { double linkOsnrDb; diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOtnNode.java b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOtnNode.java index 47f3b7008..bda495cfa 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOtnNode.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceOtnNode.java @@ -271,67 +271,6 @@ public class PceOtnNode implements PceNode { return false; } - private Boolean findClientCompliantInterface(List sic) { - boolean compliant = false; - for (SupportedInterfaceCapability sit : sic) { - String interfacetype = sit.getIfCapType().getName(); - switch (interfacetype) { - case "If1GEODU0": - case "If1GE": - if ("1GE".equals(this.otnServiceType)) { - compliant = true; - } - break; - case "If10GEODU2e": - case "If10GE": - if ("10GE".equals(this.otnServiceType)) { - compliant = true; - } - break; - case "If100GEODU4": - case "If100GE": - if ("100GE".equals(this.otnServiceType)) { - compliant = true; - } - break; - case "IfOTU4ODU4": - case "IfOCHOTU4ODU4": - if ("OTU4".equals(this.otnServiceType) || "ODU4".equals(this.otnServiceType)) { - compliant = true; - } - break; - default: - compliant = false; - break; - } - } - return compliant; - } - - private Boolean findNetworkCompliantInterface(List sic) { - boolean compliant = false; - for (SupportedInterfaceCapability sit : sic) { - String interfacetype = sit.getIfCapType().toString(); - switch (interfacetype) { - case "IfOTU4ODU4": - case "IfOCHOTU4ODU4": - compliant = true; - break; - case "IfOTU2ODU2": - case "IfOCHOTU2ODU2": - if (("1GE".equals(this.otnServiceType)) || ("10GE".equals(this.otnServiceType))) { - compliant = true; - } - break; - // add all use case with higher rate interfaces when it shows up - default: - compliant = false; - break; - } - } - return compliant; - } - public void validateXponder(String anodeId, String znodeId) { if (!isValid()) { return; diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImpl.java b/pce/src/main/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImpl.java index 9d860f8a3..85ccde2b1 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImpl.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/service/PathComputationServiceImpl.java @@ -10,6 +10,7 @@ package org.opendaylight.transportpce.pce.service; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.ArrayList; import java.util.List; import java.util.concurrent.Callable; @@ -74,6 +75,9 @@ public class PathComputationServiceImpl implements PathComputationService { LOG.info("close."); } + @SuppressFBWarnings( + value = "UPM_UNCALLED_PRIVATE_METHOD", + justification = "false positive, this method is used by public method cancelResourceReserve") private void sendNotifications(ServicePathNotificationTypes servicePathNotificationTypes, String serviceName, RpcStatusEx rpcStatusEx, String message, PathDescription pathDescription) { ServicePathRpcResultBuilder servicePathRpcResultBuilder = -- 2.36.6