NETVIRT-1030 Unbinding elan service during interface state change
[netvirt.git] / vpnservice / elanmanager / elanmanager-impl / src / main / java / org / opendaylight / netvirt / elan / internal / InterfaceRemoveWorkerOnElan.java
index 6e97452c5840d5f1604e8f9652fc009b2c217433..3a50196fc5c8925951562e3cb8bba3018afec33d 100644 (file)
@@ -11,8 +11,9 @@ import com.google.common.util.concurrent.ListenableFuture;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.Callable;
+
 import org.opendaylight.genius.interfacemanager.globals.InterfaceInfo;
-import org.opendaylight.netvirt.elan.ElanException;
+import org.opendaylight.netvirt.elan.utils.ElanUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -21,21 +22,18 @@ public class InterfaceRemoveWorkerOnElan implements Callable<List<ListenableFutu
 
     private static final Logger LOG = LoggerFactory.getLogger(InterfaceRemoveWorkerOnElan.class);
 
-    private String key;
-    private ElanInstance elanInfo;
-    private String interfaceName;
-    private InterfaceInfo interfaceInfo;
-    private boolean isInterfaceStateRemoved;
-    private ElanInterfaceManager dataChangeListener;
+    private final String key;
+    private final ElanInstance elanInfo;
+    private final String interfaceName;
+    private final InterfaceInfo interfaceInfo;
+    private final ElanInterfaceManager dataChangeListener;
 
     public InterfaceRemoveWorkerOnElan(String key, ElanInstance elanInfo, String interfaceName,
-            InterfaceInfo interfaceInfo, boolean isInterfaceStateRemoved, ElanInterfaceManager dataChangeListener) {
-        super();
+            InterfaceInfo interfaceInfo, ElanInterfaceManager dataChangeListener) {
         this.key = key;
         this.elanInfo = elanInfo;
         this.interfaceName = interfaceName;
         this.interfaceInfo = interfaceInfo;
-        this.isInterfaceStateRemoved = isInterfaceStateRemoved;
         this.dataChangeListener = dataChangeListener;
     }
 
@@ -51,10 +49,11 @@ public class InterfaceRemoveWorkerOnElan implements Callable<List<ListenableFutu
     public List<ListenableFuture<Void>> call() throws Exception {
         List<ListenableFuture<Void>> futures = new ArrayList<>();
         try {
-            dataChangeListener.removeElanInterface(futures, elanInfo, interfaceName, interfaceInfo,
-                    isInterfaceStateRemoved);
+            futures.addAll(dataChangeListener.removeElanInterface(elanInfo, interfaceName, interfaceInfo));
         } catch (RuntimeException e) {
-            throw new ElanException("Error while processing " + key + " for " + interfaceName, e);
+            LOG.error("Error while processing key {} for elan interface {} and elan {}",
+                    key, interfaceName, elanInfo, e);
+            ElanUtils.addToListenableFutureIfTxException(e, futures);
         }
         return futures;
     }