<version>${infrautils.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.infrautils</groupId>
+ <artifactId>caches-test</artifactId>
+ <version>${infrautils.version}</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.opendaylight.genius</groupId>
<artifactId>mdsalutil-testutils</artifactId>
--- /dev/null
+/*
+ * Copyright (c) 2017 Inocybe Technologies and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.netvirt.elan.cache;
+
+import com.google.common.base.Optional;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.genius.mdsalutil.cache.DataObjectCache;
+import org.opendaylight.infrautils.caches.CacheProvider;
+import org.opendaylight.netvirt.elanmanager.api.ElanHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Caches ElanInstances.
+ *
+ * @author Thomas Pantelis
+ */
+@Singleton
+public class ElanInstanceCache extends DataObjectCache<ElanInstance> {
+ private static final Logger LOG = LoggerFactory.getLogger(ElanInstanceCache.class);
+
+ @Inject
+ public ElanInstanceCache(DataBroker dataBroker, CacheProvider cacheProvider) {
+ super(ElanInstance.class, dataBroker, LogicalDatastoreType.CONFIGURATION,
+ InstanceIdentifier.create(ElanInstances.class).child(ElanInstance.class), cacheProvider);
+ }
+
+ public Optional<ElanInstance> get(String elanInstanceName) {
+ try {
+ return get(ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName));
+ } catch (ReadFailedException e) {
+ LOG.warn("Error reading ElanInstance {}", elanInstanceName, e);
+ return Optional.absent();
+ }
+ }
+}
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
+import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.evpn.utils.EvpnUtils;
-import org.opendaylight.netvirt.elan.utils.ElanUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanForwardingTables;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.forwarding.tables.MacTable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
private static final Logger LOG = LoggerFactory.getLogger(ElanMacEntryListener.class);
private final DataBroker broker;
private final EvpnUtils evpnUtils;
+ private final ElanInstanceCache elanInstanceCache;
@Inject
- public ElanMacEntryListener(final DataBroker broker, final EvpnUtils evpnUtils) {
+ public ElanMacEntryListener(final DataBroker broker, final EvpnUtils evpnUtils,
+ final ElanInstanceCache elanInstanceCache) {
this.broker = broker;
this.evpnUtils = evpnUtils;
+ this.elanInstanceCache = elanInstanceCache;
}
@Override
protected void add(InstanceIdentifier<MacEntry> instanceIdentifier, MacEntry macEntry) {
LOG.info("ElanMacEntryListener : ADD macEntry {} ", instanceIdentifier);
String elanName = instanceIdentifier.firstKeyOf(MacTable.class).getElanInstanceName();
- ElanInstance elanInfo = ElanUtils.getElanInstanceByName(broker, elanName);
+ ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
if (EvpnUtils.getEvpnNameFromElan(elanInfo) == null) {
LOG.trace("ElanMacEntryListener : Add evpnName is null for elan {} ", elanInfo);
return;
protected void remove(InstanceIdentifier<MacEntry> instanceIdentifier, MacEntry macEntry) {
LOG.info("ElanMacEntryListener : remove macEntry {} ", instanceIdentifier);
String elanName = instanceIdentifier.firstKeyOf(MacTable.class).getElanInstanceName();
- ElanInstance elanInfo = ElanUtils.getElanInstanceByName(broker, elanName);
+ ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
if (EvpnUtils.getEvpnNameFromElan(elanInfo) == null) {
LOG.trace("ElanMacEntryListener : Remove evpnName is null for elan {} ", elanInfo);
return;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
-
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.netvirt.elan.evpn.utils.EvpnMacVrfUtils;
import org.opendaylight.netvirt.elan.evpn.utils.EvpnUtils;
-import org.opendaylight.netvirt.elan.utils.ElanUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.EvpnAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
protected void update(InstanceIdentifier<ElanInstance> instanceIdentifier, ElanInstance original,
ElanInstance update) {
String elanName = update.getElanInstanceName();
- ElanUtils.addElanInstanceIntoCache(elanName, update);
if (evpnUtils.isWithdrawEvpnRT2Routes(original, update)) {
evpnUtils.withdrawEvpnRT2Routes(original.getAugmentation(EvpnAugmentation.class), elanName);
evpnMacVrfUtils.updateEvpnDmacFlows(original, false);
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
+import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
+import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.utils.ElanConstants;
import org.opendaylight.netvirt.elan.utils.ElanUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
private final EvpnUtils evpnUtils;
private final JobCoordinator jobCoordinator;
private final ElanUtils elanUtils;
+ private final ElanInstanceCache elanInstanceCache;
@Inject
public EvpnMacVrfUtils(final DataBroker dataBroker, final IdManagerService idManager,
final ElanEvpnFlowUtils elanEvpnFlowUtils, final IMdsalApiManager mdsalManager, final EvpnUtils evpnUtils,
- final JobCoordinator jobCoordinator, final ElanUtils elanUtils) {
+ final JobCoordinator jobCoordinator, final ElanUtils elanUtils, final ElanInstanceCache elanInstanceCache) {
this.dataBroker = dataBroker;
this.idManager = idManager;
this.elanEvpnFlowUtils = elanEvpnFlowUtils;
this.evpnUtils = evpnUtils;
this.jobCoordinator = jobCoordinator;
this.elanUtils = elanUtils;
+ this.elanInstanceCache = elanInstanceCache;
}
- public Long getElanTagByMacvrfiid(InstanceIdentifier<MacVrfEntry> macVrfEntryIid) {
+ @Nullable
+ private Long getElanTagByMacvrfiid(InstanceIdentifier<MacVrfEntry> macVrfEntryIid) {
String elanName = getElanNameByMacvrfiid(macVrfEntryIid);
if (elanName == null) {
LOG.error("getElanTag: elanName is NULL for iid = {}", macVrfEntryIid);
}
- ElanInstance elanInstance = ElanUtils.getElanInstanceByName(dataBroker, elanName);
+ ElanInstance elanInstance = elanInstanceCache.get(elanName).orNull();
+ if (elanInstance == null) {
+ return null;
+ }
+
Long elanTag = elanInstance.getElanTag();
if (elanTag == null || elanTag == 0L) {
elanTag = ElanUtils.retrieveNewElanTag(idManager, elanName);
}
public boolean checkEvpnAttachedToNet(String elanName) {
- ElanInstance elanInfo = ElanUtils.getElanInstanceByName(dataBroker, elanName);
+ ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
String evpnName = EvpnUtils.getEvpnNameFromElan(elanInfo);
if (evpnName == null) {
LOG.error("Error : evpnName is null for elanName {}", elanName);
String nexthopIP = macVrfEntry.getRoutePaths().get(0).getNexthopAddress();
IpAddress ipAddress = new IpAddress(new Ipv4Address(nexthopIP));
Long elanTag = getElanTagByMacvrfiid(instanceIdentifier);
+ if (elanTag == null) {
+ return;
+ }
+
String dstMacAddress = macVrfEntry.getMac();
long vni = macVrfEntry.getL2vni();
jobCoordinator.enqueueJob(dstMacAddress, () -> {
String nexthopIP = macVrfEntry.getRoutePaths().get(0).getNexthopAddress();
IpAddress ipAddress = new IpAddress(new Ipv4Address(nexthopIP));
Long elanTag = getElanTagByMacvrfiid(instanceIdentifier);
+ if (elanTag == null) {
+ return;
+ }
+
String macToRemove = macVrfEntry.getMac();
jobCoordinator.enqueueJob(macToRemove, () -> {
List<ListenableFuture<Void>> futures = new ArrayList<>();
import org.opendaylight.genius.utils.ServiceIndex;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
import org.opendaylight.netvirt.bgpmanager.api.IBgpManager;
+import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.l2gw.utils.SettableFutureCallback;
import org.opendaylight.netvirt.elan.utils.ElanConstants;
import org.opendaylight.netvirt.elan.utils.ElanUtils;
private final JobCoordinator jobCoordinator;
private final IBgpManager bgpManager;
private final IVpnManager vpnManager;
+ private final ElanInstanceCache elanInstanceCache;
@Inject
public EvpnUtils(DataBroker broker, IInterfaceManager interfaceManager, ElanUtils elanUtils,
ItmRpcService itmRpcService, IVpnManager vpnManager, IBgpManager bgpManager,
- JobCoordinator jobCoordinator) {
+ JobCoordinator jobCoordinator, ElanInstanceCache elanInstanceCache) {
this.broker = broker;
this.interfaceManager = interfaceManager;
this.elanUtils = elanUtils;
this.vpnManager = vpnManager;
this.bgpManager = bgpManager;
this.jobCoordinator = jobCoordinator;
+ this.elanInstanceCache = elanInstanceCache;
}
public boolean isWithdrawEvpnRT2Routes(ElanInstance original, ElanInstance update) {
return;
}
String rd = vpnManager.getVpnRd(broker, evpnName);
- ElanInstance elanInfo = ElanUtils.getElanInstanceByName(broker, elanName);
+ ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
macEntries.stream().filter(isIpv4PrefixAvailable).forEach(macEntry -> {
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(macEntry.getInterface());
if (interfaceInfo == null) {
public void programEvpnL2vniDemuxTable(String elanName, final BiConsumer<String, String> serviceHandler,
BiConsumer<BigInteger, FlowEntity> flowHandler) {
- ElanInstance elanInfo = ElanUtils.getElanInstanceByName(broker, elanName);
+ ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
List<String> tunnelInterfaceNameList = getDcGatewayTunnelInterfaceNameList();
if (tunnelInterfaceNameList.isEmpty()) {
LOG.info("No DC gateways tunnels while programming l2vni table for elan {}.", elanName);
import org.opendaylight.genius.utils.clustering.EntityOwnershipUtils;
import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundConstants;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
+import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayMulticastUtils;
import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayUtils;
import org.opendaylight.netvirt.elan.utils.ElanClusterUtils;
private final ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils;
private final ElanClusterUtils elanClusterUtils;
private final JobCoordinator jobCoordinator;
+ private final ElanInstanceCache elanInstanceCache;
@Inject
public ElanDpnInterfaceClusteredListener(DataBroker broker, EntityOwnershipUtils entityOwnershipUtils,
ElanL2GatewayUtils elanL2GatewayUtils,
ElanClusterUtils elanClusterUtils, JobCoordinator jobCoordinator,
- ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils) {
+ ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils,
+ ElanInstanceCache elanInstanceCache) {
this.broker = broker;
this.entityOwnershipUtils = entityOwnershipUtils;
this.elanL2GatewayUtils = elanL2GatewayUtils;
this.elanL2GatewayMulticastUtils = elanL2GatewayMulticastUtils;
this.elanClusterUtils = elanClusterUtils;
this.jobCoordinator = jobCoordinator;
+ this.elanInstanceCache = elanInstanceCache;
}
@PostConstruct
if (entityOwnershipUtils.isEntityOwner(HwvtepSouthboundConstants.ELAN_ENTITY_TYPE,
HwvtepSouthboundConstants.ELAN_ENTITY_NAME)) {
ElanUtils.addDPNInterfaceToElanInCache(getElanName(identifier), dpnInterfaces);
- ElanInstance elanInstance = ElanUtils.getElanInstanceByName(broker, elanName);
- elanL2GatewayUtils.installElanL2gwDevicesLocalMacsInDpn(
- dpnInterfaces.getDpId(), elanInstance, dpnInterfaces.getInterfaces().get(0));
-
- // updating remote mcast mac on l2gw devices
- elanL2GatewayMulticastUtils.updateRemoteMcastMacOnElanL2GwDevices(elanName);
+ ElanInstance elanInstance = elanInstanceCache.get(elanName).orNull();
+ if (elanInstance != null) {
+ elanL2GatewayUtils.installElanL2gwDevicesLocalMacsInDpn(
+ dpnInterfaces.getDpId(), elanInstance, dpnInterfaces.getInterfaces().get(0));
+
+ // updating remote mcast mac on l2gw devices
+ elanL2GatewayMulticastUtils.updateRemoteMcastMacOnElanL2GwDevices(elanName);
+ }
}
} finally {
ElanUtils.addDPNInterfaceToElanInCache(getElanName(identifier), dpnInterfaces);
import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
+import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.utils.ElanUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList;
private final IInterfaceManager interfaceManager;
private final ElanServiceProvider elanService;
private final JobCoordinator jobCoordinator;
+ private final ElanInstanceCache elanInstanceCache;
@Inject
public ElanDpnInterfacesListener(final DataBroker dataBroker, final IInterfaceManager interfaceManager,
- final ElanServiceProvider elanService, final JobCoordinator jobCoordinator) {
+ final ElanServiceProvider elanService, final JobCoordinator jobCoordinator,
+ final ElanInstanceCache elanInstanceCache) {
this.dataBroker = dataBroker;
this.interfaceManager = interfaceManager;
this.elanService = elanService;
this.jobCoordinator = jobCoordinator;
+ this.elanInstanceCache = elanInstanceCache;
}
@PostConstruct
LOG.debug("received Dpninterfaces update event for dpn {}", update.getDpId());
BigInteger dpnId = update.getDpId();
String elanInstanceName = identifier.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
- ElanInstance elanInstance = ElanUtils.getElanInstanceByName(dataBroker, elanInstanceName);
+ ElanInstance elanInstance = elanInstanceCache.get(elanInstanceName).orNull();
if (elanInstance != null && !elanInstance.isExternal() && ElanUtils.isVlan(elanInstance)) {
List<String> interfaces = update.getInterfaces();
LOG.debug("received Dpninterfaces add event for dpn {}", dpnInterfaces.getDpId());
BigInteger dpnId = dpnInterfaces.getDpId();
String elanInstanceName = identifier.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
- ElanInstance elanInstance = ElanUtils.getElanInstanceByName(dataBroker, elanInstanceName);
+ ElanInstance elanInstance = elanInstanceCache.get(elanInstanceName).orNull();
// trigger creation of vlan provider intf for the vlan provider network
// on br-int patch port for this DPN
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
+import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.utils.ElanUtils;
import org.opendaylight.netvirt.elan.utils.TransportZoneNotificationUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.config.rev150710.ElanConfig;
private final TransportZoneNotificationUtil transportZoneNotificationUtil;
private final DataBroker dbx;
private final Boolean useTransportZone;
+ private final ElanInstanceCache elanInstanceCache;
@Inject
public ElanDpnToTransportZoneListener(final DataBroker dbx, final IInterfaceManager interfaceManager,
- final ElanConfig elanConfig, final TransportZoneNotificationUtil tznu) {
+ final ElanConfig elanConfig, final TransportZoneNotificationUtil tznu,
+ final ElanInstanceCache elanInstanceCache) {
useTransportZone = elanConfig.isAutoConfigTransportZones();
transportZoneNotificationUtil = tznu;
this.dbx = dbx;
+ this.elanInstanceCache = elanInstanceCache;
}
@PostConstruct
BigInteger dpId = dataObjectModification.getDpId();
String elanInstanceName = key.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
- if (!ElanUtils.isVxlanNetwork(dbx, elanInstanceName)) {
+ if (!ElanUtils.isVxlan(elanInstanceCache.get(elanInstanceName).orNull())) {
LOG.debug("ElanInstance {} is not vxlan network, nothing to do", elanInstanceName);
return;
}
BigInteger dpId = dataObjectModification.getDpId();
String elanInstanceName = key.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
- if (!ElanUtils.isVxlanNetwork(dbx, elanInstanceName)) {
+ if (!ElanUtils.isVxlan(elanInstanceCache.get(elanInstanceName).orNull())) {
return;
}
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
+import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayMulticastUtils;
import org.opendaylight.netvirt.elan.utils.ElanConstants;
-import org.opendaylight.netvirt.elan.utils.ElanUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ExternalTeps;
private final DataBroker broker;
private final ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils;
private final JobCoordinator jobCoordinator;
+ private final ElanInstanceCache elanInstanceCache;
@Inject
public ElanExtnTepListener(DataBroker dataBroker, ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils,
- JobCoordinator jobCoordinator) {
+ JobCoordinator jobCoordinator, ElanInstanceCache elanInstanceCache) {
super(ExternalTeps.class, ElanExtnTepListener.class);
this.broker = dataBroker;
this.elanL2GatewayMulticastUtils = elanL2GatewayMulticastUtils;
this.jobCoordinator = jobCoordinator;
+ this.elanInstanceCache = elanInstanceCache;
}
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
private void updateElanRemoteBroadCastGroup(final InstanceIdentifier<ExternalTeps> iid) {
String elanName = iid.firstKeyOf(ElanInstance.class).getElanInstanceName();
- ElanInstance elanInfo = ElanUtils.getElanInstanceByName(broker, elanName);
+ ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
+ if (elanInfo == null) {
+ return;
+ }
jobCoordinator.enqueueJob(elanName, () -> {
SettableFuture<Void> ft = SettableFuture.create();
import org.opendaylight.genius.utils.ServiceIndex;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
import org.opendaylight.netvirt.elan.ElanException;
+import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayMulticastUtils;
import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayUtils;
import org.opendaylight.netvirt.elan.utils.ElanConstants;
private final ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils;
private final ElanUtils elanUtils;
private final JobCoordinator jobCoordinator;
+ private final ElanInstanceCache elanInstanceCache;
private final Map<String, ConcurrentLinkedQueue<ElanInterface>>
unProcessedElanInterfaces = new ConcurrentHashMap<>();
final INeutronVpnManager neutronVpnManager, final ElanItmUtils elanItmUtils,
final ElanEtreeUtils elanEtreeUtils, final ElanL2GatewayUtils elanL2GatewayUtils,
final ElanUtils elanUtils, final JobCoordinator jobCoordinator,
- final ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils) {
+ final ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils,
+ final ElanInstanceCache elanInstanceCache) {
super(ElanInterface.class, ElanInterfaceManager.class);
this.broker = dataBroker;
this.idManager = managerService;
this.elanUtils = elanUtils;
this.jobCoordinator = jobCoordinator;
this.elanL2GatewayMulticastUtils = elanL2GatewayMulticastUtils;
+ this.elanInstanceCache = elanInstanceCache;
}
@Override
@Override
protected void remove(InstanceIdentifier<ElanInterface> identifier, ElanInterface del) {
String interfaceName = del.getName();
- ElanInstance elanInfo = ElanUtils.getElanInstanceByName(broker, del.getElanInstanceName());
+ ElanInstance elanInfo = elanInstanceCache.get(del.getElanInstanceName()).orNull();
/*
* Handling in case the elan instance is deleted.If the Elan instance is
* deleted, there is no need to explicitly delete the elan interfaces
tx);
} else {
elanForwardingEntriesHandler.addElanInterfaceForwardingTableList(
- ElanUtils.getElanInstanceByName(broker, elanName), interfaceName, staticMacEntry, tx);
+ elanName, interfaceName, staticMacEntry, tx);
}
ElanUtils.waitForTransactionToComplete(tx);
}
LOG.info("Interface {} is removed from Interface Oper DS due to port down ", interfaceName);
return;
}
- ElanInstance elanInstance = ElanUtils.getElanInstanceByName(broker, elanInstanceName);
+ ElanInstance elanInstance = elanInstanceCache.get(elanInstanceName).orNull();
if (elanInstance == null) {
elanInstance = new ElanInstanceBuilder().setElanInstanceName(elanInstanceName)
existingMacEntry.get(), tx);
} else {
elanForwardingEntriesHandler
- .addElanInterfaceForwardingTableList(elanInstance, interfaceName, staticMacEntry, tx);
+ .addElanInterfaceForwardingTableList(elanInstanceName, interfaceName, staticMacEntry, tx);
}
if (isInterfaceOperational) {
.setKey(new MacEntryKey(physAddress)).build();
WriteTransaction tx = broker.newWriteOnlyTransaction();
elanForwardingEntriesHandler.deleteElanInterfaceForwardingEntries(
- ElanUtils.getElanInstanceByName(broker, elanInstanceName), interfaceInfo, macEntry, tx);
+ elanInstanceCache.get(elanInstanceName).orNull(), interfaceInfo, macEntry, tx);
ElanUtils.waitForTransactionToComplete(tx);
}
for (ElanDpnInterfacesList elanDpns : elanDpnIf) {
int cnt = 0;
String elanName = elanDpns.getElanInstanceName();
- ElanInstance elanInfo = ElanUtils.getElanInstanceByName(broker, elanName);
+ ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
if (elanInfo == null) {
LOG.warn("ELAN Info is null for elanName {} that does exist in elanDpnInterfaceList, "
+ "skipping this ELAN for tunnel handling", elanName);
List<ElanDpnInterfacesList> elanDpnIf = dpnInterfaceLists.getElanDpnInterfacesList();
for (ElanDpnInterfacesList elanDpns : elanDpnIf) {
String elanName = elanDpns.getElanInstanceName();
- ElanInstance elanInfo = ElanUtils.getElanInstanceByName(broker, elanName);
+ ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
DpnInterfaces dpnInterfaces = elanUtils.getElanInterfaceInfoByElanDpn(elanName, dpId);
- if (dpnInterfaces == null || dpnInterfaces.getInterfaces() == null
+ if (elanInfo == null || dpnInterfaces == null || dpnInterfaces.getInterfaces() == null
|| dpnInterfaces.getInterfaces().isEmpty()) {
continue;
}
import org.opendaylight.genius.interfacemanager.globals.InterfaceInfo;
import org.opendaylight.genius.mdsalutil.MDSALUtil;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
+import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.utils.ElanConstants;
import org.opendaylight.netvirt.elan.utils.ElanUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan;
private final DataBroker broker;
private final ElanInterfaceManager elanInterfaceManager;
private final JobCoordinator jobCoordinator;
+ private final ElanInstanceCache elanInstanceCache;
@Inject
public ElanInterfaceStateChangeListener(final DataBroker db, final ElanInterfaceManager ifManager,
- final JobCoordinator jobCoordinator) {
+ final JobCoordinator jobCoordinator, final ElanInstanceCache elanInstanceCache) {
super(Interface.class, ElanInterfaceStateChangeListener.class);
broker = db;
elanInterfaceManager = ifManager;
this.jobCoordinator = jobCoordinator;
+ this.elanInstanceCache = elanInstanceCache;
}
@Override
interfaceInfo.setInterfaceType(InterfaceInfo.InterfaceType.VLAN_INTERFACE);
interfaceInfo.setInterfaceTag(delIf.getIfIndex());
String elanInstanceName = elanInterface.getElanInstanceName();
- ElanInstance elanInstance = ElanUtils.getElanInstanceByName(broker, elanInstanceName);
+ ElanInstance elanInstance = elanInstanceCache.get(elanInstanceName).orNull();
if (elanInstance == null) {
LOG.debug("No Elan instance is available for the interface:{} ", interfaceName);
return;
package org.opendaylight.netvirt.elan.internal;
import com.google.common.util.concurrent.ListenableFuture;
+import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
+import org.opendaylight.genius.interfacemanager.globals.InterfaceInfo;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
+import org.opendaylight.netvirt.elan.ElanException;
+import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.utils.ElanConstants;
import org.opendaylight.netvirt.elan.utils.ElanUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.LearntVpnVipToPortData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
private final IInterfaceManager interfaceManager;
private final ElanUtils elanUtils;
private final JobCoordinator jobCoordinator;
+ private final ElanInstanceCache elanInstanceCache;
@Inject
public ElanLearntVpnVipToPortListener(DataBroker broker, IInterfaceManager interfaceManager, ElanUtils elanUtils,
- JobCoordinator jobCoordinator) {
+ JobCoordinator jobCoordinator, ElanInstanceCache elanInstanceCache) {
super(LearntVpnVipToPort.class, ElanLearntVpnVipToPortListener.class);
this.broker = broker;
this.interfaceManager = interfaceManager;
this.elanUtils = elanUtils;
this.jobCoordinator = jobCoordinator;
+ this.elanInstanceCache = elanInstanceCache;
}
@Override
}
WriteTransaction interfaceTx = broker.newWriteOnlyTransaction();
WriteTransaction flowTx = broker.newWriteOnlyTransaction();
- elanUtils.addMacEntryToDsAndSetupFlows(interfaceName, macAddress,
- elanInterface.getElanInstanceName(), interfaceTx, flowTx, ElanConstants.STATIC_MAC_TIMEOUT);
+ addMacEntryToDsAndSetupFlows(elanInterface.getElanInstanceName(), interfaceTx,
+ flowTx, ElanConstants.STATIC_MAC_TIMEOUT);
List<ListenableFuture<Void>> futures = new ArrayList<>();
futures.add(interfaceTx.submit());
futures.add(flowTx.submit());
return futures;
}
+
+ private void addMacEntryToDsAndSetupFlows(String elanName, WriteTransaction interfaceTx,
+ WriteTransaction flowTx, int macTimeOut) throws ElanException {
+ LOG.trace("Adding mac address {} and interface name {} to ElanInterfaceForwardingEntries and "
+ + "ElanForwardingTables DS", macAddress, interfaceName);
+ BigInteger timeStamp = new BigInteger(String.valueOf(System.currentTimeMillis()));
+ PhysAddress physAddress = new PhysAddress(macAddress);
+ MacEntry macEntry = new MacEntryBuilder().setInterface(interfaceName).setMacAddress(physAddress)
+ .setKey(new MacEntryKey(physAddress)).setControllerLearnedForwardingEntryTimestamp(timeStamp)
+ .setIsStaticAddress(false).build();
+ InstanceIdentifier<MacEntry> macEntryId = ElanUtils
+ .getInterfaceMacEntriesIdentifierOperationalDataPath(interfaceName, physAddress);
+ interfaceTx.put(LogicalDatastoreType.OPERATIONAL, macEntryId, macEntry);
+ InstanceIdentifier<MacEntry> elanMacEntryId =
+ ElanUtils.getMacEntryOperationalDataPath(elanName, physAddress);
+ interfaceTx.put(LogicalDatastoreType.OPERATIONAL, elanMacEntryId, macEntry);
+ ElanInstance elanInstance = elanInstanceCache.get(elanName).orNull();
+ elanUtils.setupMacFlows(elanInstance, interfaceManager.getInterfaceInfo(interfaceName), macTimeOut,
+ macAddress, true, flowTx);
+ }
}
private class StaticMacRemoveWorker implements Callable<List<ListenableFuture<Void>>> {
}
WriteTransaction interfaceTx = broker.newWriteOnlyTransaction();
WriteTransaction flowTx = broker.newWriteOnlyTransaction();
- elanUtils.deleteMacEntryFromDsAndRemoveFlows(interfaceName, macAddress,
- elanInterface.getElanInstanceName(), interfaceTx, flowTx);
+ deleteMacEntryFromDsAndRemoveFlows(elanInterface.getElanInstanceName(), interfaceTx,
+ flowTx);
List<ListenableFuture<Void>> futures = new ArrayList<>();
futures.add(interfaceTx.submit());
futures.add(flowTx.submit());
return futures;
}
+
+ private void deleteMacEntryFromDsAndRemoveFlows(String elanName, WriteTransaction interfaceTx,
+ WriteTransaction flowTx) {
+ LOG.trace("Deleting mac address {} and interface name {} from ElanInterfaceForwardingEntries "
+ + "and ElanForwardingTables DS", macAddress, interfaceName);
+ PhysAddress physAddress = new PhysAddress(macAddress);
+ MacEntry macEntry = elanUtils.getInterfaceMacEntriesOperationalDataPath(interfaceName, physAddress);
+ InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
+ if (macEntry != null && interfaceInfo != null) {
+ elanUtils.deleteMacFlows(elanInstanceCache.get(elanName).orNull(), interfaceInfo, macEntry, flowTx);
+ }
+ interfaceTx.delete(LogicalDatastoreType.OPERATIONAL,
+ ElanUtils.getInterfaceMacEntriesIdentifierOperationalDataPath(interfaceName, physAddress));
+ interfaceTx.delete(LogicalDatastoreType.OPERATIONAL,
+ ElanUtils.getMacEntryOperationalDataPath(elanName, physAddress));
+ }
}
private String buildJobKey(String mac, String interfaceName) {
import org.opendaylight.genius.mdsalutil.NwConstants;
import org.opendaylight.genius.mdsalutil.packet.Ethernet;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
+import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.evpn.utils.EvpnUtils;
import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayUtils;
import org.opendaylight.netvirt.elan.utils.ElanUtils;
private final ElanL2GatewayUtils elanL2GatewayUtils;
private final EvpnUtils evpnUtils;
private final JobCoordinator jobCoordinator;
+ private final ElanInstanceCache elanInstanceCache;
@Inject
public ElanPacketInHandler(DataBroker dataBroker, final IInterfaceManager interfaceManager, ElanUtils elanUtils,
- EvpnUtils evpnUtils, ElanL2GatewayUtils elanL2GatewayUtils, JobCoordinator jobCoordinator) {
+ EvpnUtils evpnUtils, ElanL2GatewayUtils elanL2GatewayUtils, JobCoordinator jobCoordinator,
+ ElanInstanceCache elanInstanceCache) {
broker = dataBroker;
this.interfaceManager = interfaceManager;
this.elanUtils = elanUtils;
this.elanL2GatewayUtils = elanL2GatewayUtils;
this.evpnUtils = evpnUtils;
this.jobCoordinator = jobCoordinator;
+ this.elanInstanceCache = elanInstanceCache;
}
@Override
if (srcIpAddress.isPresent()) {
String prefix = srcIpAddress.get().getIpv4Address().getValue();
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
- ElanInstance elanInstance = ElanUtils.getElanInstanceByName(broker, elanName);
+ ElanInstance elanInstance = elanInstanceCache.get(elanName).orNull();
evpnUtils.advertisePrefix(elanInstance, macAddress, prefix, interfaceName, interfaceInfo.getDpId());
}
enqueueJobForMacSpecificTasks(macAddress, elanTag, interfaceName, elanName, physAddress, oldMacEntry,
newMacEntry, isVlanOrFlatProviderIface);
- ElanInstance elanInstance = ElanUtils.getElanInstanceByName(broker, elanName);
+ ElanInstance elanInstance = elanInstanceCache.get(elanName).orNull();
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
if (interfaceInfo == null) {
LOG.trace("Interface:{} is not present under Config DS", interfaceName);
* Static MAC having been added on a wrong ELAN.
*/
private void tryAndRemoveInvalidMacEntry(String elanName, MacEntry macEntry) {
- ElanInstance elanInfo = ElanUtils.getElanInstanceByName(broker, elanName);
+ ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
if (elanInfo == null) {
LOG.warn("MAC {} is been added (either statically or dynamically) for an invalid Elan {}. "
+ "Manual cleanup may be necessary", macEntry.getMacAddress(), elanName);
import org.opendaylight.genius.mdsalutil.MatchInfoBase;
import org.opendaylight.genius.mdsalutil.MetaDataUtil;
import org.opendaylight.genius.mdsalutil.NwConstants;
+import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.genius.mdsalutil.nxmatches.NxMatchRegister;
import org.opendaylight.genius.utils.ServiceIndex;
import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundConstants;
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException;
import org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput;
+import org.opendaylight.netvirt.elan.arp.responder.ArpResponderUtil;
+import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.utils.ElanConstants;
import org.opendaylight.netvirt.elan.utils.ElanUtils;
import org.opendaylight.netvirt.elanmanager.api.ElanHelper;
private final DataBroker broker;
private final ElanUtils elanUtils;
private final SouthboundUtils southboundUtils;
+ private final IMdsalApiManager mdsalManager;
+ private final ElanInstanceCache elanInstanceCache;
private boolean isL2BeforeL3;
private final EntityOwnershipCandidateRegistration candidateRegistration;
ElanInterfaceManager elanInterfaceManager,
ElanUtils elanUtils,
EntityOwnershipService entityOwnershipService,
- SouthboundUtils southboundUtils) {
+ SouthboundUtils southboundUtils, ElanInstanceCache elanInstanceCache,
+ IMdsalApiManager mdsalManager) {
this.idManager = idManager;
this.interfaceManager = interfaceManager;
this.elanInstanceManager = elanInstanceManager;
this.broker = dataBroker;
this.elanUtils = elanUtils;
this.southboundUtils = southboundUtils;
+ this.elanInstanceCache = elanInstanceCache;
+ this.mdsalManager = mdsalManager;
candidateRegistration = registerCandidate(entityOwnershipService);
}
@Override
public ElanInstance getElanInstance(String elanName) {
- return ElanUtils.getElanInstanceByName(broker, elanName);
+ return elanInstanceCache.get(elanName).orNull();
}
@Override
LOG.trace("ELAN service is after L3VPN in the Netvirt pipeline skip known L3DMAC flows installation");
return;
}
- ElanInstance elanInstance = ElanUtils.getElanInstanceByName(broker, elanInstanceName);
+ ElanInstance elanInstance = elanInstanceCache.get(elanInstanceName).orNull();
if (elanInstance == null) {
LOG.warn("Null elan instance {}", elanInstanceName);
return;
LOG.trace("ELAN service is after L3VPN in the Netvirt pipeline skip known L3DMAC flows installation");
return;
}
- ElanInstance elanInstance = ElanUtils.getElanInstanceByName(broker, elanInstanceName);
+ ElanInstance elanInstance = elanInstanceCache.get(elanInstanceName).orNull();
if (elanInstance == null) {
LOG.warn("Null elan instance {}", elanInstanceName);
return;
@Override
public void addArpResponderFlow(ArpResponderInput arpResponderInput) {
- elanUtils.addArpResponderFlow(arpResponderInput.getDpId(), arpResponderInput.getInterfaceName(),
- arpResponderInput.getSpa(), arpResponderInput.getSha(), arpResponderInput.getLportTag(),
+ String ingressInterfaceName = arpResponderInput.getInterfaceName();
+ String macAddress = arpResponderInput.getSha();
+ String ipAddress = arpResponderInput.getSpa();
+ int lportTag = arpResponderInput.getLportTag();
+ BigInteger dpnId = arpResponderInput.getDpId();
+
+ LOG.info("Installing the ARP responder flow on DPN {} for Interface {} with MAC {} & IP {}", dpnId,
+ ingressInterfaceName, macAddress, ipAddress);
+ ElanInterface elanIface = ElanUtils.getElanInterfaceByElanInterfaceName(broker, ingressInterfaceName);
+ ElanInstance elanInstance = elanInstanceCache.get(elanIface.getElanInstanceName()).orNull();
+ if (elanInstance == null) {
+ LOG.debug("addArpResponderFlow: elanInstance is null, Failed to install arp responder flow for Interface {}"
+ + " with MAC {} & IP {}", dpnId,
+ ingressInterfaceName, macAddress, ipAddress);
+ return;
+ }
+ String flowId = ArpResponderUtil.getFlowId(lportTag, ipAddress);
+ ArpResponderUtil.installFlow(mdsalManager, dpnId, flowId, flowId, NwConstants.DEFAULT_ARP_FLOW_PRIORITY,
+ ArpResponderUtil.generateCookie(lportTag, ipAddress),
+ ArpResponderUtil.getMatchCriteria(lportTag, elanInstance, ipAddress),
arpResponderInput.getInstructions());
+ LOG.info("Installed the ARP Responder flow for Interface {}", ingressInterfaceName);
}
@Override
public void addExternalTunnelArpResponderFlow(ArpResponderInput arpResponderInput, String elanInstanceName) {
- elanUtils.addExternalTunnelArpResponderFlow(arpResponderInput.getDpId(), arpResponderInput.getSpa(),
- arpResponderInput.getSha(), arpResponderInput.getLportTag(),
- arpResponderInput.getInstructions(), elanInstanceName);
+ BigInteger dpnId = arpResponderInput.getDpId();
+ String ipAddress = arpResponderInput.getSpa();
+ String macAddress = arpResponderInput.getSha();
+
+ LOG.trace("Installing the ExternalTunnel ARP responder flow on DPN {} for ElanInstance {} with MAC {} & IP {}",
+ dpnId, elanInstanceName, macAddress, ipAddress);
+
+ ElanInstance elanInstance = elanInstanceCache.get(elanInstanceName).orNull();
+ if (elanInstance == null) {
+ LOG.warn("Null elan instance {}", elanInstanceName);
+ return;
+ }
+
+ int lportTag = arpResponderInput.getLportTag();
+ String flowId = ArpResponderUtil.getFlowId(lportTag, ipAddress);
+ ArpResponderUtil.installFlow(mdsalManager, dpnId, flowId, flowId, NwConstants.DEFAULT_ARP_FLOW_PRIORITY,
+ ArpResponderUtil.generateCookie(lportTag, ipAddress), ArpResponderUtil.getMatchCriteria(lportTag,
+ elanInstance, ipAddress), arpResponderInput.getInstructions());
+ LOG.trace("Installed the ExternalTunnel ARP Responder flow for ElanInstance {}", elanInstanceName);
}
@Override
import org.opendaylight.genius.mdsalutil.MetaDataUtil;
import org.opendaylight.genius.mdsalutil.NwConstants;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
+import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.utils.ElanConstants;
import org.opendaylight.netvirt.elan.utils.ElanUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
private final IInterfaceManager interfaceManager;
private final ElanUtils elanUtils;
private final JobCoordinator jobCoordinator;
+ private final ElanInstanceCache elanInstanceCache;
@Inject
public ElanSmacFlowEventListener(DataBroker broker, IInterfaceManager interfaceManager, ElanUtils elanUtils,
- JobCoordinator jobCoordinator) {
+ JobCoordinator jobCoordinator, ElanInstanceCache elanInstanceCache) {
this.broker = broker;
this.interfaceManager = interfaceManager;
this.elanUtils = elanUtils;
this.jobCoordinator = jobCoordinator;
+ this.elanInstanceCache = elanInstanceCache;
}
@Override
LOG.info("Deleting the Mac-Entry:{} present on ElanInstance:{}", macEntry, elanInstanceName);
if (macEntry != null && interfaceInfo != null) {
WriteTransaction deleteFlowTx = broker.newWriteOnlyTransaction();
- elanUtils.deleteMacFlows(ElanUtils.getElanInstanceByName(broker, elanInstanceName), interfaceInfo,
+ elanUtils.deleteMacFlows(elanInstanceCache.get(elanInstanceName).orNull(), interfaceInfo,
macEntry, deleteFlowTx);
ListenableFuture<Void> result = deleteFlowTx.submit();
elanFutures.add(result);
import java.math.BigInteger;
import java.util.List;
-import java.util.Set;
import java.util.concurrent.ConcurrentMap;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.datastoreutils.AsyncClusteredDataTreeChangeListenerBase;
+import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayMulticastUtils;
import org.opendaylight.netvirt.elan.utils.ElanClusterUtils;
import org.opendaylight.netvirt.elan.utils.ElanUtils;
private final ElanClusterUtils elanClusterUtils;
private final ElanUtils elanUtils;
private final ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils;
+ private final ElanInstanceCache elanInstanceCache;
@Inject
public ElanGroupListener(DataBroker db, ElanClusterUtils elanClusterUtils, ElanUtils elanUtils,
- ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils) {
+ ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils, ElanInstanceCache elanInstanceCache) {
super(Group.class, ElanGroupListener.class);
broker = db;
this.elanClusterUtils = elanClusterUtils;
this.elanUtils = elanUtils;
this.elanL2GatewayMulticastUtils = elanL2GatewayMulticastUtils;
+ this.elanInstanceCache = elanInstanceCache;
registerListener(LogicalDatastoreType.CONFIGURATION, broker);
LOG.trace("ElanGroupListener registered");
}
ElanInstance getElanInstanceFromGroupId(Group update) {
- Set<String> elanNames = ElanUtils.getAllElanNames();
- for (String elanName : elanNames) {
- ElanInstance elanInstance = ElanUtils.getElanInstanceByName(broker, elanName);
+ for (ElanInstance elanInstance : elanInstanceCache.getAllPresent()) {
if (elanInstance.getElanTag() != null) {
long elanTag = elanInstance.getElanTag();
long elanBCGroupId = ElanUtils.getElanRemoteBroadCastGroupID(elanTag);
import org.opendaylight.genius.datastoreutils.hwvtep.HwvtepClusteredDataTreeChangeListener;
import org.opendaylight.genius.utils.batching.ResourceBatchingManager;
import org.opendaylight.genius.utils.hwvtep.HwvtepUtils;
+import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayUtils;
-import org.opendaylight.netvirt.elan.utils.ElanUtils;
import org.opendaylight.netvirt.elanmanager.utils.ElanL2GwCacheUtils;
import org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
private final DataBroker broker;
private final ElanL2GatewayUtils elanL2GatewayUtils;
+ private final ElanInstanceCache elanInstanceCache;
- public HwvtepLocalUcastMacListener(DataBroker broker, ElanL2GatewayUtils elanL2GatewayUtils) {
+ public HwvtepLocalUcastMacListener(DataBroker broker, ElanL2GatewayUtils elanL2GatewayUtils,
+ ElanInstanceCache elanInstanceCache) {
super(LocalUcastMacs.class, HwvtepLocalUcastMacListener.class);
this.broker = broker;
this.elanL2GatewayUtils = elanL2GatewayUtils;
+ this.elanInstanceCache = elanInstanceCache;
ResourceBatchingManager.getInstance().registerDefaultBatchHandlers(this.broker);
}
elanL2GwDevice.removeUcastLocalMac(macRemoved);
elanL2GatewayUtils.unInstallL2GwUcastMacFromL2gwDevices(elanName, elanL2GwDevice,
Collections.singletonList(new MacAddress(macAddress.toLowerCase(Locale.getDefault()))));
- elanL2GatewayUtils.unInstallL2GwUcastMacFromElanDpns(ElanUtils.getElanInstanceByName(broker, elanName),
+ elanL2GatewayUtils.unInstallL2GwUcastMacFromElanDpns(elanInstanceCache.get(elanName).orNull(),
elanL2GwDevice, Collections.singletonList(new MacAddress(macAddress.toLowerCase(Locale.getDefault()))));
}
LOG.trace("LocalUcastMacs {} added to {}", macAddress, hwvtepNodeId);
String elanName = getElanName(macAdded);
- ElanInstance elan = ElanUtils.getElanInstanceByName(broker, elanName);
+ ElanInstance elan = elanInstanceCache.get(elanName).orNull();
if (elan == null) {
LOG.warn("Could not find ELAN for mac {} being added", macAddress);
return;
import org.opendaylight.genius.utils.hwvtep.HwvtepHACache;
import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
+import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
import org.opendaylight.netvirt.elan.l2gw.ha.listeners.HAOpClusteredListener;
import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayUtils;
-import org.opendaylight.netvirt.elan.utils.ElanUtils;
import org.opendaylight.netvirt.elanmanager.utils.ElanL2GwCacheUtils;
import org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
private final ElanL2GatewayUtils elanL2GatewayUtils;
private final HAOpClusteredListener haOpClusteredListener;
private final JobCoordinator jobCoordinator;
+ private final ElanInstanceCache elanInstanceCache;
@Inject
public LocalUcastMacListener(final DataBroker dataBroker,
final HAOpClusteredListener haOpClusteredListener,
final ElanL2GatewayUtils elanL2GatewayUtils,
- final JobCoordinator jobCoordinator) {
+ final JobCoordinator jobCoordinator,
+ final ElanInstanceCache elanInstanceCache) {
super(dataBroker, false);
this.elanL2GatewayUtils = elanL2GatewayUtils;
this.haOpClusteredListener = haOpClusteredListener;
this.jobCoordinator = jobCoordinator;
+ this.elanInstanceCache = elanInstanceCache;
}
@Override
}
elanL2GwDevice.removeUcastLocalMac(macRemoved);
- ElanInstance elanInstance = ElanUtils.getElanInstanceByName(dataBroker, elanName);
+ ElanInstance elanInstance = elanInstanceCache.get(elanName).orNull();
elanL2GatewayUtils.unInstallL2GwUcastMacFromL2gwDevices(elanName, elanL2GwDevice,
Collections.singletonList(new MacAddress(macAddress.toLowerCase(Locale.getDefault()))));
elanL2GatewayUtils.unInstallL2GwUcastMacFromElanDpns(elanInstance, elanL2GwDevice,
LOG.trace("LocalUcastMacs {} added to {}", macAddress, hwvtepNodeId);
- ElanInstance elan = ElanUtils.getElanInstanceByName(dataBroker, elanName);
+ ElanInstance elan = elanInstanceCache.get(elanName).orNull();
if (elan == null) {
LOG.warn("Could not find ELAN for mac {} being added", macAddress);
return;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
-
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.genius.utils.hwvtep.HwvtepUtils;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
import org.opendaylight.netvirt.elan.ElanException;
+import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.l2gw.jobs.DeleteL2GwDeviceMacsFromElanJob;
import org.opendaylight.netvirt.elan.l2gw.jobs.DeleteLogicalSwitchJob;
import org.opendaylight.netvirt.elan.utils.ElanClusterUtils;
private final OdlInterfaceRpcService interfaceManagerRpcService;
private final JobCoordinator jobCoordinator;
private final ElanUtils elanUtils;
+ private final ElanInstanceCache elanInstanceCache;
private final ConcurrentMap<Pair<NodeId, String>, ScheduledFuture> logicalSwitchDeletedTasks
= new ConcurrentHashMap<>();
public ElanL2GatewayUtils(DataBroker broker, ElanDmacUtils elanDmacUtils, ElanItmUtils elanItmUtils,
ElanClusterUtils elanClusterUtils, OdlInterfaceRpcService interfaceManagerRpcService,
JobCoordinator jobCoordinator, ElanUtils elanUtils,
- Scheduler scheduler, ElanConfig elanConfig) {
+ Scheduler scheduler, ElanConfig elanConfig, ElanInstanceCache elanInstanceCache) {
this.broker = broker;
this.elanDmacUtils = elanDmacUtils;
this.elanItmUtils = elanItmUtils;
this.elanUtils = elanUtils;
this.scheduler = scheduler;
this.elanConfig = elanConfig;
+ this.elanInstanceCache = elanInstanceCache;
}
@PreDestroy
if (ls != null) {
// Logical switch name is Elan name
String elanName = getElanFromLogicalSwitch(ls.getHwvtepNodeName().getValue());
- return ElanUtils.getElanInstanceByName(broker, elanName);
+ return elanInstanceCache.get(elanName).orNull();
} else {
String macAddress = localUcastMac.getMacEntryKey().getValue();
LOG.error("Could not find logical_switch for {} being added/deleted", macAddress);
LOG.trace("No L2 gateway devices in Elan [{}] cache.", elanName);
return;
}
- final ElanInstance elan = ElanUtils.getElanInstanceByName(broker, elanName);
+ final ElanInstance elan = elanInstanceCache.get(elanName).orNull();
if (elan == null) {
LOG.error("Could not find Elan by name: {}", elanName);
return;
LOG.info("Deleting L2GatewayDevice [{}] UcastLocalMacs from elan [{}]", l2GatewayDevice.getHwvtepNodeId(),
elanName);
- ElanInstance elan = ElanUtils.getElanInstanceByName(broker, elanName);
+ ElanInstance elan = elanInstanceCache.get(elanName).orNull();
if (elan == null) {
LOG.error("Could not find Elan by name: {}", elanName);
return;
import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils;
import org.opendaylight.genius.utils.hwvtep.HwvtepUtils;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
+import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.internal.ElanInstanceManager;
import org.opendaylight.netvirt.elan.l2gw.ha.listeners.HAOpClusteredListener;
import org.opendaylight.netvirt.elan.l2gw.jobs.AssociateHwvtepToElanJob;
private final ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils;
private final JobCoordinator jobCoordinator;
private final L2GatewayCache l2GatewayCache;
+ private final ElanInstanceCache elanInstanceCache;
private final List<AutoCloseable> closeables = new CopyOnWriteArrayList<>();
private final HAOpClusteredListener haOpClusteredListener;
public L2GatewayConnectionUtils(DataBroker dataBroker, ElanInstanceManager elanInstanceManager,
ElanClusterUtils elanClusterUtils, ElanL2GatewayUtils elanL2GatewayUtils,
JobCoordinator jobCoordinator, ElanL2GatewayMulticastUtils elanL2GatewayMulticastUtils,
- L2GatewayCache l2GatewayCache, HAOpClusteredListener haOpClusteredListener) {
+ L2GatewayCache l2GatewayCache, HAOpClusteredListener haOpClusteredListener,
+ ElanInstanceCache elanInstanceCache) {
this.broker = dataBroker;
this.elanInstanceManager = elanInstanceManager;
this.elanL2GatewayUtils = elanL2GatewayUtils;
this.jobCoordinator = jobCoordinator;
this.l2GatewayCache = l2GatewayCache;
this.haOpClusteredListener = haOpClusteredListener;
+ this.elanInstanceCache = elanInstanceCache;
}
@Override
public void onSuccess(@Nonnull Optional<Node> resultNode) {
LocalUcastMacListener localUcastMacListener =
new LocalUcastMacListener(broker, haOpClusteredListener,
- elanL2GatewayUtils, jobCoordinator);
+ elanL2GatewayUtils, jobCoordinator, elanInstanceCache);
settableFuture.set(resultNode);
Optional<Node> nodeOptional = resultNode;
if (nodeOptional.isPresent()) {
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import javax.inject.Inject;
import javax.inject.Singleton;
-
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.mdsalutil.MDSALUtil;
import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils;
import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
+import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.utils.ElanUtils;
import org.opendaylight.netvirt.elan.utils.Scheduler;
import org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayCache;
private final Scheduler scheduler;
private final ElanConfig elanConfig;
private final L2GatewayCache l2GatewayCache;
+ private final ElanInstanceCache elanInstanceCache;
private final Map<NodeId, ScheduledFuture> cleanupTasks = new ConcurrentHashMap<>();
@Inject
final ElanL2GatewayUtils elanL2GatewayUtils,
final Scheduler scheduler,
final ElanConfig elanConfig,
- final L2GatewayCache l2GatewayCache) {
+ final L2GatewayCache l2GatewayCache,
+ final ElanInstanceCache elanInstanceCache) {
this.broker = broker;
this.elanUtils = elanUtils;
this.elanL2GatewayUtils = elanL2GatewayUtils;
this.scheduler = scheduler;
this.elanConfig = elanConfig;
this.l2GatewayCache = l2GatewayCache;
+ this.elanInstanceCache = elanInstanceCache;
}
private long getCleanupDelay() {
List<String> validNetworks = connectionsOfDevice.stream()
.map((connection) -> connection.getNetworkId().getValue())
- .filter(elan -> elanUtils.getElanInstanceByName(broker, elan) != null)
+ .filter(elan -> elanInstanceCache.get(elan).isPresent())
.collect(Collectors.toList());
List<String> logicalSwitchesOnDevice = getLogicalSwitchesOnDevice(configNode);
+++ /dev/null
-/*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.netvirt.elan.utils;
-
-import java.util.Collection;
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Singleton
-public class CacheElanInstanceListener implements ClusteredDataTreeChangeListener<ElanInstance> {
-
- private static final Logger LOG = LoggerFactory.getLogger(CacheElanInstanceListener.class);
-
- private final DataBroker broker;
-
- private ListenerRegistration<CacheElanInstanceListener> registration;
-
- @Inject
- public CacheElanInstanceListener(DataBroker dataBroker) {
- this.broker = dataBroker;
- }
-
- @PostConstruct
- public void init() {
- registerListener();
- }
-
- private void registerListener() {
- final DataTreeIdentifier<ElanInstance> treeId =
- new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, getWildcardPath());
- LOG.trace("Registering on path: {}", treeId);
- registration = broker.registerDataTreeChangeListener(treeId, CacheElanInstanceListener.this);
- }
-
- protected InstanceIdentifier<ElanInstance> getWildcardPath() {
- return InstanceIdentifier.create(ElanInstances.class).child(ElanInstance.class);
- }
-
- @PreDestroy
- public void close() throws Exception {
- if (registration != null) {
- registration.close();
- }
- }
-
- @Override
- public void onDataTreeChanged(Collection<DataTreeModification<ElanInstance>> changes) {
- for (DataTreeModification<ElanInstance> change : changes) {
- DataObjectModification<ElanInstance> mod = change.getRootNode();
- switch (mod.getModificationType()) {
- case DELETE:
- ElanUtils.removeElanInstanceFromCache(mod.getDataBefore().getElanInstanceName());
- break;
- case SUBTREE_MODIFIED:
- case WRITE:
- ElanInstance elanInstance = mod.getDataAfter();
- ElanUtils.addElanInstanceIntoCache(elanInstance.getElanInstanceName(), elanInstance);
- break;
- default:
- throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
- }
- }
- }
-
-}
}
- public void addElanInterfaceForwardingTableList(ElanInstance elanInstance, String interfaceName,
+ public void addElanInterfaceForwardingTableList(String elanInstanceName, String interfaceName,
StaticMacEntries staticMacEntries, WriteTransaction tx) {
MacEntry macEntry = new MacEntryBuilder().setIsStaticAddress(true)
.setMacAddress(staticMacEntries.getMacAddress())
.setIpPrefix(staticMacEntries.getIpPrefix())
.setInterface(interfaceName).setKey(new MacEntryKey(staticMacEntries.getMacAddress())).build();
- createElanForwardingTablesList(elanInstance.getElanInstanceName(), macEntry, tx);
+ createElanForwardingTablesList(elanInstanceName, macEntry, tx);
createElanInterfaceForwardingTablesList(interfaceName, macEntry, tx);
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagNameBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagNameKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryKey;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
private static final Logger LOG = LoggerFactory.getLogger(ElanUtils.class);
- private static Map<String, ElanInstance> elanInstanceLocalCache = new ConcurrentHashMap<>();
private static Map<String, ElanInterface> elanInterfaceLocalCache = new ConcurrentHashMap<>();
private static Map<String, Set<DpnInterfaces>> elanInstancToDpnsCache = new ConcurrentHashMap<>();
private static Map<String, Set<String>> elanInstanceToInterfacesCache = new ConcurrentHashMap<>();
? elanConfig.isOpenstackVniSemanticsEnforced() : false;
}
- public static void addElanInstanceIntoCache(String elanInstanceName, ElanInstance elanInstance) {
- elanInstanceLocalCache.put(elanInstanceName, elanInstance);
- }
-
- public static void removeElanInstanceFromCache(String elanInstanceName) {
- elanInstanceLocalCache.remove(elanInstanceName);
- }
-
- public static ElanInstance getElanInstanceFromCache(String elanInstanceName) {
- return elanInstanceLocalCache.get(elanInstanceName);
- }
-
- public static Set<String> getAllElanNames() {
- return elanInstanceLocalCache.keySet();
- }
-
public static void addElanInterfaceIntoCache(String interfaceName, ElanInterface elanInterface) {
elanInterfaceLocalCache.put(interfaceName, elanInterface);
}
return InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class).build();
}
- // elan-instances config container
- @Nullable
- public static ElanInstance getElanInstanceByName(DataBroker broker, String elanInstanceName) {
- ElanInstance elanObj = getElanInstanceFromCache(elanInstanceName);
- if (elanObj != null) {
- return elanObj;
- }
- InstanceIdentifier<ElanInstance> elanIdentifierId =
- ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName);
- return MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, elanIdentifierId).orNull();
- }
-
// elan-interfaces Config Container
public static ElanInterface getElanInterfaceByElanInterfaceName(DataBroker broker, String elanInterfaceName) {
ElanInterface elanInterfaceObj = getElanInterfaceFromCache(elanInterfaceName);
return futures;
}
- public static boolean isVxlanNetwork(DataBroker broker, String elanInstanceName) {
- ElanInstance elanInstance = getElanInstanceByName(broker, elanInstanceName);
- return elanInstance != null && isVxlan(elanInstance);
- }
-
public static boolean isVxlan(ElanInstance elanInstance) {
return elanInstance != null && elanInstance.getSegmentType() != null
&& elanInstance.getSegmentType().isAssignableFrom(SegmentTypeVxlan.class)
return flow;
}
- /**
- * Add Mac Address to ElanInterfaceForwardingEntries and ElanForwardingTables
- * Install SMAC and DMAC flows.
- * @param interfaceName interface name
- * @param macAddress mac addresses
- * @param elanName elan Name
- * @param interfaceTx write transaction
- * @param flowTx flow write transaction
- * @param macTimeOut timeout value
- * @throws ElanException elan exception is thrown upon write failure
- */
- public void addMacEntryToDsAndSetupFlows(String interfaceName,
- String macAddress, String elanName, WriteTransaction interfaceTx, WriteTransaction flowTx, int macTimeOut)
- throws ElanException {
- LOG.trace("Adding mac address {} and interface name {} to ElanInterfaceForwardingEntries and "
- + "ElanForwardingTables DS", macAddress, interfaceName);
- BigInteger timeStamp = new BigInteger(String.valueOf(System.currentTimeMillis()));
- PhysAddress physAddress = new PhysAddress(macAddress);
- MacEntry macEntry = new MacEntryBuilder().setInterface(interfaceName).setMacAddress(physAddress)
- .setKey(new MacEntryKey(physAddress)).setControllerLearnedForwardingEntryTimestamp(timeStamp)
- .setIsStaticAddress(false).build();
- InstanceIdentifier<MacEntry> macEntryId = ElanUtils
- .getInterfaceMacEntriesIdentifierOperationalDataPath(interfaceName, physAddress);
- interfaceTx.put(LogicalDatastoreType.OPERATIONAL, macEntryId, macEntry);
- InstanceIdentifier<MacEntry> elanMacEntryId = ElanUtils.getMacEntryOperationalDataPath(elanName, physAddress);
- interfaceTx.put(LogicalDatastoreType.OPERATIONAL, elanMacEntryId, macEntry);
- ElanInstance elanInstance = ElanUtils.getElanInstanceByName(broker, elanName);
- setupMacFlows(elanInstance, interfaceManager.getInterfaceInfo(interfaceName), macTimeOut, macAddress, true,
- flowTx);
- }
-
- /**
- * Remove Mac Address from ElanInterfaceForwardingEntries and ElanForwardingTables
- * Remove SMAC and DMAC flows.
- * @param interfaceName interface name
- * @param macAddress mac addresses
- * @param elanName elan name
- * @param interfaceTx write transaction
- * @param flowTx flow write transaction
- */
- public void deleteMacEntryFromDsAndRemoveFlows(String interfaceName,
- String macAddress, String elanName, WriteTransaction interfaceTx, WriteTransaction flowTx) {
- LOG.trace("Deleting mac address {} and interface name {} from ElanInterfaceForwardingEntries "
- + "and ElanForwardingTables DS", macAddress, interfaceName);
- PhysAddress physAddress = new PhysAddress(macAddress);
- MacEntry macEntry = getInterfaceMacEntriesOperationalDataPath(interfaceName, physAddress);
- InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
- if (macEntry != null && interfaceInfo != null) {
- deleteMacFlows(ElanUtils.getElanInstanceByName(broker, elanName), interfaceInfo, macEntry, flowTx);
- }
- interfaceTx.delete(LogicalDatastoreType.OPERATIONAL,
- ElanUtils.getInterfaceMacEntriesIdentifierOperationalDataPath(interfaceName, physAddress));
- interfaceTx.delete(LogicalDatastoreType.OPERATIONAL,
- ElanUtils.getMacEntryOperationalDataPath(elanName, physAddress));
- }
-
public String getExternalElanInterface(String elanInstanceName, BigInteger dpnId) {
DpnInterfaces dpnInterfaces = getElanInterfaceInfoByElanDpn(elanInstanceName, dpnId);
if (dpnInterfaces == null || dpnInterfaces.getInterfaces() == null) {
return "elaninterface-" + interfaceName;
}
- public void addArpResponderFlow(BigInteger dpnId, String ingressInterfaceName, String ipAddress, String macAddress,
- int lportTag, List<Instruction> instructions) {
- LOG.info("Installing the ARP responder flow on DPN {} for Interface {} with MAC {} & IP {}", dpnId,
- ingressInterfaceName, macAddress, ipAddress);
- ElanInterface elanIface = getElanInterfaceByElanInterfaceName(broker, ingressInterfaceName);
- ElanInstance elanInstance = getElanInstanceByName(broker, elanIface.getElanInstanceName());
- if (elanInstance == null) {
- LOG.debug("addArpResponderFlow: elanInstance is null, Failed to install arp responder flow for Interface {}"
- + " with MAC {} & IP {}", dpnId,
- ingressInterfaceName, macAddress, ipAddress);
- return;
- }
- String flowId = ArpResponderUtil.getFlowId(lportTag, ipAddress);
- ArpResponderUtil.installFlow(mdsalManager, dpnId, flowId, flowId, NwConstants.DEFAULT_ARP_FLOW_PRIORITY,
- ArpResponderUtil.generateCookie(lportTag, ipAddress),
- ArpResponderUtil.getMatchCriteria(lportTag, elanInstance, ipAddress), instructions);
- LOG.info("Installed the ARP Responder flow for Interface {}", ingressInterfaceName);
- }
-
- public void addExternalTunnelArpResponderFlow(BigInteger dpnId, String ipAddress, String macAddress,
- int lportTag, List<Instruction> instructions, String elanInstanceName) {
- LOG.trace("Installing the ExternalTunnel ARP responder flow on DPN {} for ElanInstance {} with MAC {} & IP {}",
- dpnId, elanInstanceName, macAddress, ipAddress);
- ElanInstance elanInstance = getElanInstanceByName(broker, elanInstanceName);
- String flowId = ArpResponderUtil.getFlowId(lportTag, ipAddress);
- ArpResponderUtil.installFlow(mdsalManager, dpnId, flowId, flowId, NwConstants.DEFAULT_ARP_FLOW_PRIORITY,
- ArpResponderUtil.generateCookie(lportTag, ipAddress),
- ArpResponderUtil.getMatchCriteria(lportTag, elanInstance, ipAddress), instructions);
- LOG.trace("Installed the ExternalTunnel ARP Responder flow for ElanInstance {}", elanInstanceName);
- }
-
public void removeArpResponderFlow(BigInteger dpnId, String ingressInterfaceName, String ipAddress,
int lportTag) {
LOG.info("Removing the ARP responder flow on DPN {} of Interface {} with IP {}", dpnId, ingressInterfaceName,
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
+import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.internal.ElanBridgeManager;
import org.opendaylight.netvirt.elanmanager.api.IElanService;
import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
private final IElanService elanService;
private final ElanConfig elanConfig;
private final ElanBridgeManager elanBridgeManager;
+ private final ElanInstanceCache elanInstanceCache;
@Inject
public TransportZoneNotificationUtil(final DataBroker dbx, final IInterfaceManager interfaceManager,
- final IElanService elanService, final ElanConfig elanConfig, final ElanBridgeManager elanBridgeManager) {
+ final IElanService elanService, final ElanConfig elanConfig, final ElanBridgeManager elanBridgeManager,
+ final ElanInstanceCache elanInstanceCache) {
this.dataBroker = dbx;
this.mdsalUtils = new MdsalUtils(dbx);
this.elanService = elanService;
this.elanConfig = elanConfig;
this.elanBridgeManager = elanBridgeManager;
+ this.elanInstanceCache = elanInstanceCache;
southBoundUtils = new SouthboundUtils(mdsalUtils);
}
continue;
}
- if (ElanUtils.isVxlanNetwork(dataBroker, elanInt.getElanInstanceName())) {
+ if (ElanUtils.isVxlan(elanInstanceCache.get(elanInt.getElanInstanceName()).orNull())) {
return true;
} else {
LOG.debug("Non-VXLAN elanInstance: " + elanInt.getElanInstanceName());
interface="org.opendaylight.infrautils.jobcoordinator.JobCoordinator"/>
<reference id="l2GatewayCache"
interface="org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayCache"/>
+ <reference id="cacheProvider"
+ interface="org.opendaylight.infrautils.caches.CacheProvider"/>
<odl:rpc-service id="odlInterfaceRpcService"
interface="org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService" />
import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
import com.google.common.base.Optional;
-
import javax.inject.Inject;
import org.junit.Before;
import org.junit.Ignore;
import org.opendaylight.genius.mdsalutil.MDSALUtil;
import org.opendaylight.genius.mdsalutil.NwConstants;
import org.opendaylight.genius.testutils.interfacemanager.TunnelInterfaceDetails;
+import org.opendaylight.infrautils.caches.testutils.CacheModule;
import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
import org.opendaylight.infrautils.testutils.LogRule;
import org.opendaylight.mdsal.binding.testutils.AssertDataObjects;
// public @Rule RunUntilFailureRule repeater = new RunUntilFailureRule(classRepeater);
public @Rule LogRule logRule = new LogRule();
- public @Rule MethodRule guice = new GuiceRule(ElanServiceTestModule.class, JobCoordinatorTestModule.class);
+ public @Rule MethodRule guice = new GuiceRule(ElanServiceTestModule.class, JobCoordinatorTestModule.class,
+ CacheModule.class);
// TODO re-enable after we can await completion of listeners and DJC:
// Otherwise this too frequently causes spurious test failures, e.g. due to error
// logs Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: Operation was interrupted