From 87536a0284548945b494de09b4c554541d41739e Mon Sep 17 00:00:00 2001 From: Karthikeyan Krishnan Date: Fri, 5 Jun 2020 11:36:53 +0530 Subject: [PATCH] Exception during netvirt CSIT Issue: ====== 2020-06-04T06:17:55,547 | ERROR | jobcoordinator-main-task-138 | VpnSubnetRouteHandler | 364 - org.opendaylight.netvirt.vpnmanager-impl - 0.11.0.SNAPSHOT | SUBNETROUTE: onInterfaceUp: Unable to handle interface up event for port 015fb82e-c78a-40bd-85a0-88091273a7dd in subnet 9a942efe-ef93-483a-a3e6-b8c5cb01b218 java.lang.IllegalArgumentException: Multiple entries with same key: VpnInterfacesKey{_interfaceName=015fb82e-c78a-40bd-85a0-88091273a7dd} =VpnInterfaces{_interfaceName=015fb82e-c78a-40bd-85a0-88091273a7dd, augmentation=[]} and VpnInterfacesKey{_interfaceName=015fb82e-c78a-40bd-85a0-88091273a7dd} =VpnInterfaces{getInterfaceName=015fb82e-c78a-40bd-85a0-88091273a7dd, augmentation=[]}. To index multiple values under a key, use Multimaps.index. at com.google.common.collect.Maps.uniqueIndex(Maps.java:1338) ~[bundleFile:?] at com.google.common.collect.Maps.uniqueIndex(Maps.java:1293) ~[bundleFile:?] at org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet .op.data.subnet.op.data.entry.SubnetToDpnBuilder.setVpnInterfaces(SubnetToDpnBuilder.java:148) ~[bundleFile:?] at org.opendaylight.netvirt.vpnmanager.SubnetOpDpnManager.addInterfaceToDpn(SubnetOpDpnManager.java:137) ~[bundleFile:?] at org.opendaylight.netvirt.vpnmanager.VpnSubnetRouteHandler.onInterfaceUp(VpnSubnetRouteHandler.java:613) [bundleFile:?] Solution: ========= Have handled the proper fix for processing map data Signed-off-by: Karthikeyan Krishnan Change-Id: I744f8ceadeaa65c82ea3f963bc323699caa06f13 --- .../vpnmanager/SubnetOpDpnManager.java | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/SubnetOpDpnManager.java b/vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/SubnetOpDpnManager.java index a82765c710..906e61ce8f 100644 --- a/vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/SubnetOpDpnManager.java +++ b/vpnmanager/impl/src/main/java/org/opendaylight/netvirt/vpnmanager/SubnetOpDpnManager.java @@ -8,7 +8,9 @@ package org.opendaylight.netvirt.vpnmanager; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.concurrent.ExecutionException; import javax.inject.Inject; @@ -64,8 +66,8 @@ public class SubnetOpDpnManager { return null; } SubnetToDpnBuilder subDpnBuilder = new SubnetToDpnBuilder().withKey(new SubnetToDpnKey(dpnId)); - List vpnIntfList = new ArrayList<>(); - subDpnBuilder.setVpnInterfaces(vpnIntfList); + Map vpnInterfaceMap = new HashMap<>(); + subDpnBuilder.setVpnInterfaces(vpnInterfaceMap); SubnetToDpn subDpn = subDpnBuilder.build(); SingleTransactionDataBroker.syncWrite(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId, subDpn, VpnUtil.SINGLE_TRANSACTION_BROKER_NO_RETRY); @@ -127,14 +129,13 @@ public class SubnetOpDpnManager { subDpn = optionalSubDpn.get(); } SubnetToDpnBuilder subDpnBuilder = new SubnetToDpnBuilder(subDpn); - List vpnIntfList = new ArrayList<>(); - vpnIntfList = subDpnBuilder.getVpnInterfaces() != null - ? new ArrayList<>(subDpnBuilder.getVpnInterfaces().values()) : vpnIntfList; - + Map vpnInterfaceMap = new HashMap<>(); + vpnInterfaceMap = subDpnBuilder.getVpnInterfaces() != null + ? new HashMap<>(subDpnBuilder.getVpnInterfaces()) : vpnInterfaceMap; VpnInterfaces vpnIntfs = new VpnInterfacesBuilder().withKey(new VpnInterfacesKey(intfName)).setInterfaceName(intfName).build(); - vpnIntfList.add(vpnIntfs); - subDpnBuilder.setVpnInterfaces(vpnIntfList); + vpnInterfaceMap.put(vpnIntfs.key(), vpnIntfs); + subDpnBuilder.setVpnInterfaces(vpnInterfaceMap); subDpn = subDpnBuilder.build(); SingleTransactionDataBroker.syncWrite(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId, subDpn, VpnUtil.SINGLE_TRANSACTION_BROKER_NO_RETRY); @@ -215,18 +216,19 @@ public class SubnetOpDpnManager { } SubnetToDpnBuilder subDpnBuilder = new SubnetToDpnBuilder(optionalSubDpn.get()); - List vpnIntfList = new ArrayList<>(); - vpnIntfList = (subDpnBuilder.getVpnInterfaces() != null && !subDpnBuilder.getVpnInterfaces().isEmpty()) - ? new ArrayList<>(subDpnBuilder.getVpnInterfaces().values()) : vpnIntfList; + Map vpnInterfaceMap = new HashMap<>(); + + vpnInterfaceMap = (subDpnBuilder.getVpnInterfaces() != null && !subDpnBuilder.getVpnInterfaces().isEmpty()) + ? new HashMap<>(subDpnBuilder.getVpnInterfaces()) : vpnInterfaceMap; VpnInterfaces vpnIntfs = new VpnInterfacesBuilder().withKey(new VpnInterfacesKey(intfName)).setInterfaceName(intfName).build(); - vpnIntfList.remove(vpnIntfs); - if (vpnIntfList.isEmpty()) { + vpnInterfaceMap.remove(vpnIntfs.key()); + if (vpnInterfaceMap.isEmpty()) { // Remove the DPN as well removeDpnFromSubnet(subnetId, dpnId); dpnRemoved = true; } else { - subDpnBuilder.setVpnInterfaces(vpnIntfList); + subDpnBuilder.setVpnInterfaces(vpnInterfaceMap); SingleTransactionDataBroker.syncWrite(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId, subDpnBuilder.build(), VpnUtil.SINGLE_TRANSACTION_BROKER_NO_RETRY); } -- 2.36.6