Bug 7451 - Leftovers in dispatcher table when unbind and ietf-state
[genius.git] / interfacemanager / interfacemanager-impl / src / main / java / org / opendaylight / genius / interfacemanager / servicebindings / flowbased / utilities / FlowBasedServicesUtils.java
index 0fa737bd2b1ead5e77f360da5cacdfb2fd6b46ad..e561f7db82725294d73b0888f83147cb0e2dcca8 100644 (file)
@@ -13,6 +13,8 @@ import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 import org.apache.commons.lang3.StringUtils;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
@@ -80,6 +82,9 @@ public class FlowBasedServicesUtils {
         INGRESS, EGRESS
     }
 
+    private static ConcurrentMap<String, InterfaceBoundServicesState> boundServicesStateMap = new
+        ConcurrentHashMap<>();
+
     public static final ImmutableBiMap<ServiceMode, Class<? extends ServiceModeBase>>
         SERVICE_MODE_MAP = new ImmutableBiMap.Builder<ServiceMode, Class<? extends ServiceModeBase>>()
             .put(ServiceMode.EGRESS, ServiceModeEgress.class).put(ServiceMode.INGRESS, ServiceModeIngress.class)
@@ -646,6 +651,19 @@ public class FlowBasedServicesUtils {
         futures.add(inventoryConfigShardTransaction.submit());
     }
 
+    public static InterfaceBoundServicesState getBoundServicesStateFromCache(String interfaceName) {
+        return boundServicesStateMap.get(interfaceName);
+    }
+
+    public static void addBoundServicesStateToCache(String interfaceName, InterfaceBoundServicesState
+        interfaceBoundServicesState) {
+        boundServicesStateMap.put(interfaceName, interfaceBoundServicesState);
+    }
+
+    public static  InterfaceBoundServicesState removeBoundServicesStateFromCache(String interfaceName) {
+        return boundServicesStateMap.remove(interfaceName);
+    }
+
     private static boolean isExternal(Interface iface) {
         if (iface == null) {
             return false;