Remove GENIUS UTIL references in Elanmanager Module
[netvirt.git] / elanmanager / impl / src / main / java / org / opendaylight / netvirt / elan / internal / ElanLearntVpnVipToPortListener.java
index a8522c0490f9a42ade60857d85259c6104b3d0bc..df8ba7ed34d07e9e5b0b8e4b90fc53bb753f6a15 100644 (file)
@@ -5,37 +5,40 @@
  * 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.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;
@@ -50,7 +53,7 @@ import org.slf4j.LoggerFactory;
 
 @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;
@@ -63,7 +66,9 @@ public class ElanLearntVpnVipToPortListener extends
     @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;
@@ -73,21 +78,16 @@ public class ElanLearntVpnVipToPortListener extends
         this.elanInterfaceCache = elanInterfaceCache;
     }
 
-    @Override
-    @PostConstruct
     public void init() {
-        /* ELAN will learn the MAC by itself using ElanPacketInHandler class.
-        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);
@@ -96,12 +96,12 @@ public class ElanLearntVpnVipToPortListener extends
     }
 
     @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);
@@ -109,12 +109,7 @@ public class ElanLearntVpnVipToPortListener extends
                 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;
 
@@ -153,13 +148,13 @@ public class ElanLearntVpnVipToPortListener extends
             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;
 
@@ -192,7 +187,7 @@ public class ElanLearntVpnVipToPortListener extends
             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(
@@ -207,3 +202,4 @@ public class ElanLearntVpnVipToPortListener extends
 
 
 }
+*/