X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=vpnservice%2Felanmanager%2Felanmanager-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetvirt%2Felan%2Fl2gw%2Futils%2FElanL2GatewayUtils.java;h=c7f96bd9f949e81ff3f08719d2e3adffddd9783f;hb=87bfb5f23ad64ebf02e4e75d33ff6cfa9332ee8f;hp=42a7b8ae3515dd33946cecbd25691cc13038aa76;hpb=5727251ffa914bfd002a44da276daba577da3c43;p=netvirt.git diff --git a/vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/utils/ElanL2GatewayUtils.java b/vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/utils/ElanL2GatewayUtils.java index 42a7b8ae35..c7f96bd9f9 100644 --- a/vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/utils/ElanL2GatewayUtils.java +++ b/vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/utils/ElanL2GatewayUtils.java @@ -38,6 +38,7 @@ import org.opendaylight.genius.utils.SystemPropertyReader; import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundConstants; import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils; import org.opendaylight.genius.utils.hwvtep.HwvtepUtils; +import org.opendaylight.netvirt.elan.ElanException; import org.opendaylight.netvirt.elan.l2gw.jobs.DeleteL2GwDeviceMacsFromElanJob; import org.opendaylight.netvirt.elan.l2gw.jobs.DeleteLogicalSwitchJob; import org.opendaylight.netvirt.elan.l2gw.listeners.HwvtepTerminationPointListener; @@ -106,7 +107,7 @@ public class ElanL2GatewayUtils { private final DataStoreJobCoordinator dataStoreJobCoordinator = DataStoreJobCoordinator.getInstance(); private static Timer LogicalSwitchDeleteJobTimer = new Timer(); - private static final int LOGICAL_SWITCH_DELETE_DELAY = 120000; + private static final int LOGICAL_SWITCH_DELETE_DELAY = 20000; private final ConcurrentMap, TimerTask> logicalSwitchDeletedTasks = new ConcurrentHashMap<>(); public ElanL2GatewayUtils(DataBroker broker, ItmRpcService itmRpcService, ElanUtils elanUtils, @@ -305,9 +306,10 @@ public class ElanL2GatewayUtils { * the elan * @param interfaceName * the interface name + * @throws ElanException in case of issues creating the flow objects */ public void installL2gwDeviceMacsInDpn(BigInteger dpnId, NodeId l2gwDeviceNodeId, ElanInstance elan, - String interfaceName) { + String interfaceName) throws ElanException { L2GatewayDevice l2gwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elan.getElanInstanceName(), l2gwDeviceNodeId.getValue()); if (l2gwDevice == null) { @@ -329,9 +331,10 @@ public class ElanL2GatewayUtils { * the elan * @param interfaceName * the interface name + * @throws ElanException in case of issues creating the flow objects */ public void installDmacFlowsOnDpn(BigInteger dpnId, L2GatewayDevice l2gwDevice, ElanInstance elan, - String interfaceName) { + String interfaceName) throws ElanException { String elanName = elan.getElanInstanceName(); List l2gwDeviceLocalMacs = l2gwDevice.getUcastLocalMacs(); @@ -355,8 +358,10 @@ public class ElanL2GatewayUtils { * the elan * @param interfaceName * the interface name + * @throws ElanException in case of issues creating the flow objects */ - public void installElanL2gwDevicesLocalMacsInDpn(BigInteger dpnId, ElanInstance elan, String interfaceName) { + public void installElanL2gwDevicesLocalMacsInDpn(BigInteger dpnId, ElanInstance elan, String interfaceName) + throws ElanException { ConcurrentMap elanL2GwDevicesFromCache = ElanL2GwCacheUtils .getInvolvedL2GwDevices(elan.getElanInstanceName()); if (elanL2GwDevicesFromCache != null) { @@ -455,9 +460,8 @@ public class ElanL2GatewayUtils { * @return true, if successful */ private static boolean doesLocalUcastMacExistsInCache(L2GatewayDevice elanL2GwDevice, String macAddress) { - java.util.Optional macExistsInCache = elanL2GwDevice.getUcastLocalMacs().stream() - .filter(mac -> mac.getMacEntryKey().getValue().equalsIgnoreCase(macAddress)).findFirst(); - return macExistsInCache.isPresent(); + return elanL2GwDevice.getUcastLocalMacs().stream() + .anyMatch(mac -> mac.getMacEntryKey().getValue().equalsIgnoreCase(macAddress)); } /** @@ -605,7 +609,7 @@ public class ElanL2GatewayUtils { }); if (LOG.isDebugEnabled()) { - List elanMacs = lstElanMacs.stream().map(mac -> mac.getValue()).collect(Collectors.toList()); + List elanMacs = lstElanMacs.stream().map(MacAddress::getValue).collect(Collectors.toList()); LOG.debug("Deleting elan [{}] macs from node [{}]. Deleted macs = {}", elanName, hwvtepNodeId, elanMacs); } return future; @@ -863,8 +867,7 @@ public class ElanL2GatewayUtils { WriteTransaction transaction = broker.newWriteOnlyTransaction(); for (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712 - .l2gateway.attributes.devices.Interfaces deviceInterface : hwVtepDevice - .getInterfaces()) { + .l2gateway.attributes.devices.Interfaces deviceInterface : hwVtepDevice.getInterfaces()) { NodeId physicalSwitchNodeId = HwvtepSouthboundUtils.createManagedNodeId(nodeId, hwVtepDevice.getDeviceName()); TerminationPoint portTerminationPoint = HwvtepUtils.getPhysicalPortTerminationPoint(broker, @@ -937,7 +940,7 @@ public class ElanL2GatewayUtils { WriteTransaction transaction = broker.newWriteOnlyTransaction(); for (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712 - .l2gateway.attributes.devices.Interfaces deviceInterface : hwVtepDevice.getInterfaces()) { + .l2gateway.attributes.devices.Interfaces deviceInterface : hwVtepDevice.getInterfaces()) { String phyPortName = deviceInterface.getInterfaceName(); if (deviceInterface.getSegmentationIds() != null && !deviceInterface.getSegmentationIds().isEmpty()) { for (Integer vlanId : deviceInterface.getSegmentationIds()) { @@ -1003,13 +1006,7 @@ public class ElanL2GatewayUtils { public static Interface getInterfaceFromConfigDS(InterfaceKey interfaceKey, DataBroker dataBroker) { InstanceIdentifier interfaceId = getInterfaceIdentifier(interfaceKey); - Optional interfaceOptional = IfmUtil.read(LogicalDatastoreType.CONFIGURATION, interfaceId, - dataBroker); - if (!interfaceOptional.isPresent()) { - return null; - } - - return interfaceOptional.get(); + return IfmUtil.read(LogicalDatastoreType.CONFIGURATION, interfaceId, dataBroker).orNull(); } /**