BUG-542 - adding overall statictics
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / session / SessionManagerOFImpl.java
index 0af916d6dcb45c06465816c1fbdaafbe735dd600..24ba19a676d1247cfec53b3a26197dd808f42024 100644 (file)
@@ -14,7 +14,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutorService;
 
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
@@ -22,14 +21,18 @@ import org.opendaylight.openflowplugin.openflow.md.core.ConnectionConductor;
 import org.opendaylight.openflowplugin.openflow.md.core.IMDMessageTranslator;
 import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
 import org.opendaylight.openflowplugin.openflow.md.core.TranslatorKey;
+import org.opendaylight.openflowplugin.openflow.md.queue.MessageSpy;
 import org.opendaylight.openflowplugin.openflow.md.queue.PopListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.concepts.util.ListenerRegistry;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.util.concurrent.ListeningExecutorService;
+
 /**
  * @author mirehak
  */
@@ -37,15 +40,16 @@ public class SessionManagerOFImpl implements SessionManager {
 
     protected static final Logger LOG = LoggerFactory.getLogger(SessionManagerOFImpl.class);
     private static SessionManagerOFImpl instance;
-    private ConcurrentHashMap<SwitchConnectionDistinguisher, SessionContext> sessionLot;
+    private ConcurrentHashMap<SwitchSessionKeyOF, SessionContext> sessionLot;
     private Map<TranslatorKey, Collection<IMDMessageTranslator<OfHeader, List<DataObject>>>> translatorMapping;
     private Map<Class<? extends DataObject>, Collection<PopListener<DataObject>>> popListenerMapping;
 
-
     protected ListenerRegistry<SessionListener> sessionListeners;
     private NotificationProviderService notificationProviderService;
 
     private DataProviderService dataProviderService;
+    private ListeningExecutorService rpcPool;
+    
 
     /**
      * @return singleton instance
@@ -72,12 +76,12 @@ public class SessionManagerOFImpl implements SessionManager {
     }
 
     @Override
-    public SessionContext getSessionContext(SwitchConnectionDistinguisher sessionKey) {
+    public SessionContext getSessionContext(SwitchSessionKeyOF sessionKey) {
         return sessionLot.get(sessionKey);
     }
 
     @Override
-    public void invalidateSessionContext(SwitchConnectionDistinguisher sessionKey) {
+    public void invalidateSessionContext(SwitchSessionKeyOF sessionKey) {
         SessionContext context = getSessionContext(sessionKey);
         if (context == null) {
             LOG.warn("context for invalidation not found");
@@ -115,7 +119,7 @@ public class SessionManagerOFImpl implements SessionManager {
     }
 
     @Override
-    public void addSessionContext(SwitchConnectionDistinguisher sessionKey, SessionContext context) {
+    public void addSessionContext(SwitchSessionKeyOF sessionKey, SessionContext context) {
         sessionLot.put(sessionKey, context);
 
         sessionNotifier.onSessionAdded(sessionKey, context);
@@ -123,7 +127,7 @@ public class SessionManagerOFImpl implements SessionManager {
     }
 
     @Override
-    public void invalidateAuxiliary(SwitchConnectionDistinguisher sessionKey,
+    public void invalidateAuxiliary(SwitchSessionKeyOF sessionKey,
             SwitchConnectionDistinguisher connectionCookie) {
         SessionContext context = getSessionContext(sessionKey);
         invalidateAuxiliary(context, connectionCookie, true);
@@ -175,7 +179,7 @@ public class SessionManagerOFImpl implements SessionManager {
     private final SessionListener sessionNotifier = new SessionListener() {
 
         @Override
-        public void onSessionAdded(SwitchConnectionDistinguisher sessionKey, SessionContext context) {
+        public void onSessionAdded(SwitchSessionKeyOF sessionKey, SessionContext context) {
             for (ListenerRegistration<SessionListener> listener : sessionListeners) {
                 try {
                     listener.getInstance().onSessionAdded(sessionKey, context);
@@ -196,8 +200,8 @@ public class SessionManagerOFImpl implements SessionManager {
             }
         }
     };
-    private ExecutorService rpcPool;
-
+    private MessageSpy<DataContainer> messageSpy;
+    
 
     @Override
     public Map<TranslatorKey, Collection<IMDMessageTranslator<OfHeader, List<DataObject>>>> getTranslatorMapping() {
@@ -252,12 +256,22 @@ public class SessionManagerOFImpl implements SessionManager {
     }
 
     @Override
-    public void setRpcPool(ExecutorService rpcPool) {
+    public void setRpcPool(ListeningExecutorService rpcPool) {
         this.rpcPool = rpcPool;
     }
     
     @Override
-    public ExecutorService getRpcPool() {
+    public ListeningExecutorService getRpcPool() {
         return rpcPool;
     }
+    
+    @Override
+    public void setMessageSpy(MessageSpy<DataContainer> messageSpy) {
+        this.messageSpy = messageSpy;
+    }
+    
+    @Override
+    public MessageSpy<DataContainer> getMessageSpy() {
+        return messageSpy;
+    }
 }