* 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.internal;
-import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
-import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
+import static org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION;
+import static org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL;
-import com.google.common.base.Optional;
import com.google.common.util.concurrent.ListenableFuture;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Optional;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
-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.infra.Datastore.Configuration;
-import org.opendaylight.genius.infra.Datastore.Operational;
-import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
-import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
-import org.opendaylight.genius.infra.TypedReadWriteTransaction;
-import org.opendaylight.genius.infra.TypedWriteTransaction;
+import org.opendaylight.mdsal.binding.util.Datastore.Configuration;
+import org.opendaylight.mdsal.binding.util.Datastore.Operational;
+import org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner;
+import org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl;
+import org.opendaylight.mdsal.binding.util.TypedReadWriteTransaction;
+import org.opendaylight.mdsal.binding.util.TypedWriteTransaction;
import org.opendaylight.genius.interfacemanager.globals.InterfaceInfo;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
+import org.opendaylight.infrautils.utils.concurrent.Executors;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.cache.ElanInterfaceCache;
import org.opendaylight.netvirt.elan.utils.ElanConstants;
import org.opendaylight.netvirt.elan.utils.ElanUtils;
+import org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener;
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;
@Singleton
public class ElanLearntVpnVipToPortListener extends
- AsyncDataTreeChangeListenerBase<LearntVpnVipToPort, ElanLearntVpnVipToPortListener> {
+ AbstractAsyncDataTreeChangeListener<LearntVpnVipToPort> {
private static final Logger LOG = LoggerFactory.getLogger(ElanLearntVpnVipToPortListener.class);
private final DataBroker broker;
private final ManagedNewTransactionRunner txRunner;
@Inject
public ElanLearntVpnVipToPortListener(DataBroker broker, IInterfaceManager interfaceManager, ElanUtils elanUtils,
JobCoordinator jobCoordinator, ElanInstanceCache elanInstanceCache, ElanInterfaceCache elanInterfaceCache) {
- super(LearntVpnVipToPort.class, ElanLearntVpnVipToPortListener.class);
+ super(broker, LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(LearntVpnVipToPortData.class)
+ .child(LearntVpnVipToPort.class),
+ Executors.newListeningSingleThreadExecutor("ElanLearntVpnVipToPortListener", LOG));
this.broker = broker;
this.txRunner = new ManagedNewTransactionRunnerImpl(broker);
this.interfaceManager = interfaceManager;
this.elanInterfaceCache = elanInterfaceCache;
}
- @Override
- @PostConstruct
public void init() {
- registerListener(LogicalDatastoreType.OPERATIONAL, broker);
- }
+ LOG.info("{} registered", getClass().getSimpleName());
+
+ // ELAN will learn the MAC by itself using ElanPacketInHandler class.
+ //registerListener(LogicalDatastoreType.OPERATIONAL, broker);
- @Override
- protected InstanceIdentifier<LearntVpnVipToPort> getWildCardPath() {
- return InstanceIdentifier.create(LearntVpnVipToPortData.class).child(LearntVpnVipToPort.class);
}
@Override
- protected void remove(InstanceIdentifier<LearntVpnVipToPort> key, LearntVpnVipToPort dataObjectModification) {
+ public void remove(InstanceIdentifier<LearntVpnVipToPort> key, LearntVpnVipToPort dataObjectModification) {
String macAddress = dataObjectModification.getMacAddress();
String interfaceName = dataObjectModification.getPortName();
LOG.trace("Removing mac address {} from interface {} ", macAddress, interfaceName);
}
@Override
- protected void update(InstanceIdentifier<LearntVpnVipToPort> key, LearntVpnVipToPort dataObjectModificationBefore,
+ public void update(InstanceIdentifier<LearntVpnVipToPort> key, LearntVpnVipToPort dataObjectModificationBefore,
LearntVpnVipToPort dataObjectModificationAfter) {
}
@Override
- protected void add(InstanceIdentifier<LearntVpnVipToPort> key, LearntVpnVipToPort dataObjectModification) {
+ public void add(InstanceIdentifier<LearntVpnVipToPort> key, LearntVpnVipToPort dataObjectModification) {
String macAddress = dataObjectModification.getMacAddress();
String interfaceName = dataObjectModification.getPortName();
LOG.trace("Adding mac address {} to interface {} ", macAddress, interfaceName);
new StaticMacAddWorker(macAddress, interfaceName));
}
- @Override
- protected ElanLearntVpnVipToPortListener getDataTreeChangeListener() {
- return this;
- }
-
- private class StaticMacAddWorker implements Callable<List<ListenableFuture<Void>>> {
+ private class StaticMacAddWorker implements Callable<List<? extends ListenableFuture<?>>> {
String macAddress;
String interfaceName;
InstanceIdentifier<MacEntry> elanMacEntryId =
ElanUtils.getMacEntryOperationalDataPath(elanName, physAddress);
interfaceTx.put(elanMacEntryId, macEntry);
- ElanInstance elanInstance = elanInstanceCache.get(elanName).orNull();
+ ElanInstance elanInstance = elanInstanceCache.get(elanName).orElse(null);
elanUtils.setupMacFlows(elanInstance, interfaceManager.getInterfaceInfo(interfaceName), macTimeOut,
macAddress, true, flowTx);
}
}
- private class StaticMacRemoveWorker implements Callable<List<ListenableFuture<Void>>> {
+ private class StaticMacRemoveWorker implements Callable<List<? extends ListenableFuture<?>>> {
String macAddress;
String interfaceName;
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);
+ elanUtils.deleteMacFlows(elanInstanceCache.get(elanName).orElse(null), interfaceInfo, macEntry, flowTx);
interfaceTx.delete(
ElanUtils.getInterfaceMacEntriesIdentifierOperationalDataPath(interfaceName, physAddress));
interfaceTx.delete(
}
+*/