Merge "Use generic-aware empty collections"
[controller.git] / opendaylight / sal / connection / implementation / src / main / java / org / opendaylight / controller / sal / connection / implementation / internal / ConnectionService.java
index ad4a5fba94e4b34f69bbb658421693305bd82888..5a637b79991fa26553e0b902571c2ecd311b7b40 100644 (file)
@@ -8,14 +8,11 @@
 
 package org.opendaylight.controller.sal.connection.implementation.internal;
 
-import java.util.HashSet;
 import java.util.Map;
-import java.util.Set;
-import java.util.Collections;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
-
 import org.opendaylight.controller.sal.connection.ConnectionConstants;
+import org.opendaylight.controller.sal.connection.ConnectionLocality;
 import org.opendaylight.controller.sal.connection.IConnectionListener;
 import org.opendaylight.controller.sal.connection.IConnectionService;
 import org.opendaylight.controller.sal.connection.IPluginInConnectionService;
@@ -34,7 +31,7 @@ public class ConnectionService implements IPluginOutConnectionService, IConnecti
     private ConcurrentMap<String, IPluginInConnectionService> pluginService =
             new ConcurrentHashMap<String, IPluginInConnectionService>();
 
-    void setPluginService (Map props, IPluginInConnectionService s) {
+    void setPluginService (Map<?, ?> props, IPluginInConnectionService s) {
         String type = null;
         Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
         if (value instanceof String) {
@@ -48,7 +45,7 @@ public class ConnectionService implements IPluginOutConnectionService, IConnecti
         }
     }
 
-    void unsetPluginService(Map props, IPluginInConnectionService s) {
+    void unsetPluginService(Map<?, ?> props, IPluginInConnectionService s) {
         String type = null;
 
         Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString());
@@ -100,14 +97,22 @@ public class ConnectionService implements IPluginOutConnectionService, IConnecti
      * @return true if node is local to this controller. false otherwise.
      */
     public boolean isLocal(Node node) {
-        if (this.connectionListener == null) return true;
+        if (this.connectionListener == null) return false;
         return connectionListener.isLocal(node);
     }
 
+    @Override
+    public ConnectionLocality getLocalityStatus(Node node) {
+        if (this.connectionListener == null) return ConnectionLocality.NOT_CONNECTED;
+        return connectionListener.getLocalityStatus(node);
+    }
+
     @Override
     public Node connect (String type, String connectionIdentifier, Map<ConnectionConstants, String> params) {
         IPluginInConnectionService s = pluginService.get(type);
-        if (s != null) return s.connect(connectionIdentifier, params);
+        if (s != null) {
+            return s.connect(connectionIdentifier, params);
+        }
         return null;
     }
 
@@ -117,7 +122,9 @@ public class ConnectionService implements IPluginOutConnectionService, IConnecti
             for (String pluginType : this.pluginService.keySet()) {
                 IPluginInConnectionService s = pluginService.get(pluginType);
                 Node node = s.connect(connectionIdentifier, params);
-                if (node != null) return node;
+                if (node != null) {
+                    return node;
+                }
             }
         }
         return null;
@@ -146,9 +153,9 @@ public class ConnectionService implements IPluginOutConnectionService, IConnecti
      */
     @Override
     public void notifyNodeDisconnectFromMaster(Node node) {
-        for (String pluginType : this.pluginService.keySet()) {
-            IPluginInConnectionService s = pluginService.get(pluginType);
-            s.notifyNodeDisconnectFromMaster(node);
+        IPluginInConnectionService s = pluginService.get(node.getType());
+        if (s != null) {
+             s.notifyNodeDisconnectFromMaster(node);
         }
     }
-}
\ No newline at end of file
+}