Removing ovsdb plugin dependency on sal.utils classes
[netvirt.git] / plugin / src / main / java / org / opendaylight / ovsdb / plugin / impl / ConnectionServiceImpl.java
index 9b7ee1152bb114e5768a97b9593217e569fb079b..288bc6581804c54e7ad86ea5c0c8328cf32cc4af 100644 (file)
@@ -23,12 +23,8 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ExecutionException;
 
-import org.opendaylight.controller.sal.connection.ConnectionConstants;
-import org.opendaylight.controller.sal.connection.IPluginInConnectionService;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.Property;
-import org.opendaylight.controller.sal.utils.Status;
-import org.opendaylight.controller.sal.utils.StatusCode;
 import org.opendaylight.ovsdb.lib.MonitorCallBack;
 import org.opendaylight.ovsdb.lib.OvsdbClient;
 import org.opendaylight.ovsdb.lib.OvsdbConnection;
@@ -41,8 +37,10 @@ import org.opendaylight.ovsdb.lib.message.TableUpdates;
 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
 import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
 import org.opendaylight.ovsdb.lib.schema.TableSchema;
-import org.opendaylight.ovsdb.plugin.IConnectionServiceInternal;
 import org.opendaylight.ovsdb.plugin.api.Connection;
+import org.opendaylight.ovsdb.plugin.api.ConnectionConstants;
+import org.opendaylight.ovsdb.plugin.api.Status;
+import org.opendaylight.ovsdb.plugin.api.StatusCode;
 import org.opendaylight.ovsdb.plugin.internal.IPAddressProperty;
 import org.opendaylight.ovsdb.plugin.internal.L4PortProperty;
 import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
@@ -58,9 +56,7 @@ import com.google.common.collect.Lists;
  * Represents the openflow plugin component in charge of programming the flows
  * the flow programming and relay them to functional modules above SAL.
  */
-public class ConnectionServiceImpl implements IPluginInConnectionService,
-                                              OvsdbConnectionService,
-                                              IConnectionServiceInternal,
+public class ConnectionServiceImpl implements OvsdbConnectionService,
                                               OvsdbConnectionListener {
     protected static final Logger logger = LoggerFactory.getLogger(ConnectionServiceImpl.class);
 
@@ -113,6 +109,7 @@ public class ConnectionServiceImpl implements IPluginInConnectionService,
         /* Then get connection clients */
         Collection<OvsdbClient> connections = connectionLib.getConnections();
         for (OvsdbClient client : connections) {
+            logger.info("CONNECT start connected clients client = {}", client);
             this.connected(client);
         }
     }
@@ -128,7 +125,6 @@ public class ConnectionServiceImpl implements IPluginInConnectionService,
         }
     }
 
-    @Override
     public Status disconnect(Node node) {
         String identifier = (String) node.getID();
         Connection connection = ovsdbConnections.get(identifier);
@@ -142,7 +138,6 @@ public class ConnectionServiceImpl implements IPluginInConnectionService,
         }
     }
 
-    @Override
     public Node connect(String identifier, Map<ConnectionConstants, String> params) {
         InetAddress address;
         Integer port;
@@ -186,6 +181,23 @@ public class ConnectionServiceImpl implements IPluginInConnectionService,
         return ovsdbConnections.get(identifier);
     }
 
+    @Override
+    public Node getNode (String identifier) {
+        String id = identifier;
+
+        String[] pair = identifier.split("[|,:]+");
+        if (pair[0].equals("OVS")) {
+            id = pair[1];
+        }
+
+        Connection connection = ovsdbConnections.get(id);
+        if (connection != null) {
+            return connection.getNode();
+        } else {
+            return null;
+        }
+    }
+
     @Override
     public List<Node> getNodes() {
         List<Node> nodes = new ArrayList<Node>();
@@ -195,14 +207,6 @@ public class ConnectionServiceImpl implements IPluginInConnectionService,
         return nodes;
     }
 
-    @Override
-    public void notifyClusterViewChanged() {
-    }
-
-    @Override
-    public void notifyNodeDisconnectFromMaster(Node arg0) {
-    }
-
     private Node handleNewConnection(String identifier, OvsdbClient client) throws InterruptedException, ExecutionException {
         Connection connection = new Connection(identifier, client);
         Node node = connection.getNode();