X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=pce%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fpce%2Fnetworkanalyzer%2FPceOtnNode.java;fp=pce%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fpce%2Fnetworkanalyzer%2FPceOtnNode.java;h=65132ce352e015ceafbef72abd47b39af6226a60;hb=c08e9285f82239f472821108732c5b0919a6f37a;hp=d31c51ff95a72201d1346f37f150bdc1b2e50762;hpb=dd578c571d0581f3be3c4a9348b518c8c7bdc13f;p=transportpce.git 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 d31c51ff9..65132ce35 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 @@ -211,74 +211,68 @@ public class PceOtnNode implements PceNode { } this.valid = SERVICE_TYPE_ODU_LIST.contains(this.otnServiceType) || SERVICE_TYPE_ETH_CLASS_MAP.containsKey(this.otnServiceType) - && isAzOrIntermediateAvl(availableXpdrClientTps, availableXpdrNWTps, - StringConstants.SERVICE_TYPE_100GE_S.equals(this.otnServiceType) - ? availableXpdrClientTps - : null); - //TODO check whether it makes sense to pass twice availableXpdrClientTps tp isAzOrIntermediateAvl - // and to differentiate SERVICE_TYPE_100GE_S case - // better pass otnServiceType -> this should probably be refactored + && checkSwPool(availableXpdrNWTps, availableXpdrClientTps); } - private boolean isAzOrIntermediateAvl(List clientTps, List netwTps, List clientTps0) { - switch (modeType) { - case "intermediate": - return checkSwPool(clientTps0, netwTps, 0, 2); - - case "AZ": - return checkSwPool(clientTps, netwTps, 1, 1); - - default: - LOG.error("unknown mode type {}", modeType); - return false; - } - } + private boolean checkSwPool(List netwTps, List clientTps) { - private boolean checkSwPool(List clientTps, List netwTps, int nbClient, int nbNetw) { if (netwTps == null) { return false; } - if (clientTps != null && nbClient == 1 && nbNetw == 1) { - clientTps.sort(Comparator.comparing(TpId::getValue)); - netwTps.sort(Comparator.comparing(TpId::getValue)); - for (TpId nwTp : netwTps) { - for (TpId clTp : clientTps) { - for (NonBlockingList nbl : new ArrayList<>(node.augmentation(Node1.class).getSwitchingPools() - .nonnullOduSwitchingPools().values().stream().findFirst().get() - .getNonBlockingList().values())) { - if (nbl.getTpList().contains(clTp) && nbl.getTpList().contains(nwTp)) { - usableXpdrClientTps.add(clTp); + Node1 node1 = node.augmentation(Node1.class); + if (node1 == null) { + return false; + } + List nblList = new ArrayList<>( + node1.getSwitchingPools().nonnullOduSwitchingPools() + .values().stream().findFirst().get() + .getNonBlockingList().values()); + if (nblList == null) { + return false; + } + netwTps.sort(Comparator.comparing(TpId::getValue)); + + switch (modeType) { + + case "intermediate": + for (NonBlockingList nbl: nblList) { + for (TpId nwTp : netwTps) { + if (nbl.getTpList().contains(nwTp)) { usableXpdrNWTps.add(nwTp); } - if (usableXpdrClientTps.size() >= 1 && usableXpdrNWTps.size() >= 1 - //since nbClient == 1 && nbNetw == 1... - && (this.clientPort == null || this.clientPort.equals(clTp.getValue()))) { - clientPerNwTp.put(nwTp.getValue(), clTp.getValue()); + if (usableXpdrNWTps.size() >= 2) { return true; } } } - } - } - if (nbClient == 0 && nbNetw == 2) { - netwTps.sort(Comparator.comparing(TpId::getValue)); - //TODO compared to above, nested loops are inverted below - does it make really sense ? - // there is room to rationalize things here - for (NonBlockingList nbl : new ArrayList<>(node.augmentation(Node1.class).getSwitchingPools() - .nonnullOduSwitchingPools().values().stream().findFirst().get() - .getNonBlockingList().values())) { - for (TpId nwTp : netwTps) { - if (nbl.getTpList().contains(nwTp)) { - usableXpdrNWTps.add(nwTp); - } - if (usableXpdrNWTps.size() >= 2) { - //since nbClient == 0 && nbNetw == 2... - return true; + return false; + + case "AZ": + if (clientTps == null) { + return false; + } + clientTps.sort(Comparator.comparing(TpId::getValue)); + for (NonBlockingList nbl: nblList) { + for (TpId nwTp : netwTps) { + for (TpId clTp : clientTps) { + if (nbl.getTpList().contains(clTp) && nbl.getTpList().contains(nwTp)) { + usableXpdrClientTps.add(clTp); + usableXpdrNWTps.add(nwTp); + } + if (usableXpdrClientTps.size() >= 1 && usableXpdrNWTps.size() >= 1 + && (this.clientPort == null || this.clientPort.equals(clTp.getValue()))) { + clientPerNwTp.put(nwTp.getValue(), clTp.getValue()); + return true; + } + } } } - } + return false; + + default: + LOG.error("Unsupported mode type {}", modeType); + return false; } - return false; } private boolean checkTpForOdtuTermination(TerminationPoint1 ontTp1) {