Remove IPlugin{in,out}Inventory* interfaces. 83/15483/1
authorSam Hague <shague@redhat.com>
Thu, 19 Feb 2015 03:04:48 +0000 (22:04 -0500)
committerSam Hague <shague@redhat.com>
Thu, 19 Feb 2015 03:04:48 +0000 (22:04 -0500)
This patch removes ovsdb plugin module's dependency on IPluginInInventory* and IPluginOutInventory* interfaces.

Patch has TODO item's that will be implemented and pushed in upcoming patches.

Change-Id: I69b9bab711d9e346629ede9ff8eec97989af31cc
Also-by: Anil Vishnoi <vishnoianil@gmail.com>
Signed-off-by: Sam Hague <shague@redhat.com>
integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/plugin/OvsdbPluginIT.java
integrationtest/src/test/java/org/opendaylight/ovsdb/integrationtest/plugin/OvsdbPluginV3IT.java
plugin-shell/src/main/java/org/opendaylight/ovsdb/plugin/shell/PrintCache.java
plugin-shell/src/test/java/org/opendaylight/ovsdb/plugin/shell/PrintCacheTest.java
plugin/src/main/java/org/opendaylight/ovsdb/plugin/api/OvsdbInventoryService.java
plugin/src/main/java/org/opendaylight/ovsdb/plugin/impl/InventoryServiceImpl.java
plugin/src/main/java/org/opendaylight/ovsdb/plugin/impl/NodeConnectorFactory.java [deleted file]
plugin/src/main/java/org/opendaylight/ovsdb/plugin/impl/NodeFactory.java [deleted file]
plugin/src/main/java/org/opendaylight/ovsdb/plugin/internal/Activator.java

index 0ab7419335395d3ccef503ede04cda3b3bccfe38..c5f9063a7f0b52fe58d31507c18e1ae948393fdd 100644 (file)
@@ -141,7 +141,8 @@ public class OvsdbPluginIT extends OvsdbIntegrationTestBase {
         if (connectionInfo.getType().equals(OvsdbConnectionInfo.ConnectionType.PASSIVE)) {
             identifier = connectionInfo.getRemoteAddress().getHostAddress()+":"+connectionInfo.getRemotePort();
         }
-        assertEquals(Node.fromString("OVS|" + identifier), connectionService.getNodes().get(0));
+        /* TODO Node.fromString lookup fails because the "OVS|id" is no longer written to the node.*/
+        //assertEquals(Node.fromString("OVS|" + identifier), connectionService.getNodes().get(0));
         System.out.println("Nodes = "+ connectionService.getNodes());
         /*
          * Test sequence :
index f88abca19fdae50c7c6a86df206f4f9a4cdabc69..679711db5e4fb6ac86c26b4183b83909442fc57f 100644 (file)
@@ -137,7 +137,8 @@ public class OvsdbPluginV3IT extends OvsdbIntegrationTestBase {
         if (connectionInfo.getType().equals(OvsdbConnectionInfo.ConnectionType.PASSIVE)) {
             identifier = connectionInfo.getRemoteAddress().getHostAddress()+":"+connectionInfo.getRemotePort();
         }
-        assertEquals(Node.fromString("OVS|" + identifier), connectionService.getNodes().get(0));
+        /* TODO Node.fromString lookup fails because the "OVS|id" is no longer written to the node.*/
+        //assertEquals(Node.fromString("OVS|" + identifier), connectionService.getNodes().get(0));
         log.info("Nodes = "+ connectionService.getNodes());
         /*
          * Test sequence :
index 9dc951db5fc0eac913ce9c041ff449eed4e2530f..9b4cfa34215ea2ddd241382bfbf57b8670497b70 100644 (file)
@@ -24,6 +24,7 @@ public class PrintCache extends OsgiCommandSupport{
 
     @Override
     protected Object doExecute() throws Exception {
+        /* TODO Node.fromString lookup fails because the "OVS|id" is no longer written to the node.*/
         Node node = Node.fromString(nodeName);
         ovsdbInventory.printCache(node);
         return null;
index 7629a24b052effebddbab31af855bd2ef2240519..e28c86f8ed7ea0f94281b2eef9bb0ed3c4e002bb 100644 (file)
@@ -62,6 +62,7 @@ public class PrintCacheTest {
         assertEquals(Version.fromString("6.12.0"), schema.getVersion());
 
         // mock a node since PrintCache requires a Node
+        /* TODO Node.fromString lookup fails because the "OVS|id" is no longer written to the node.*/
         Node.NodeIDType.registerIDType(OVS, String.class);
         NodeConnector.NodeConnectorIDType.registerIDType(OVS, String.class, OVS);
         Node node = new Node(OVS, "1");
index cb086ee1a2a5b7fb539a42ee3945a152efeb3b3e..5d4d3d2035480870894cfa85abebf6d2325e26f5 100644 (file)
@@ -16,11 +16,10 @@ import java.util.concurrent.ConcurrentMap;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.UpdateType;
-import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
 import org.opendaylight.ovsdb.lib.message.TableUpdates;
 import org.opendaylight.ovsdb.lib.notation.Row;
 
-public interface OvsdbInventoryService extends IPluginInInventoryService {
+public interface OvsdbInventoryService {
     public ConcurrentMap<String, ConcurrentMap<String, Row>> getCache(Node n, String databaseName);
     public ConcurrentMap<String, Row> getTableCache(Node n, String databaseName, String tableName);
     public Row getRow (Node n, String databaseName, String tableName, String uuid);
index 09de603c0949ff20e02e4b67ee5c0cd3a6317c13..3693e167da3ca1c73e61e42008580fee10c8ad0b 100644 (file)
 package org.opendaylight.ovsdb.plugin.impl;
 
 import java.net.InetAddress;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CopyOnWriteArraySet;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
@@ -25,7 +23,6 @@ import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.UpdateType;
-import org.opendaylight.controller.sal.inventory.IPluginOutInventoryService;
 import org.opendaylight.ovsdb.lib.message.TableUpdate;
 import org.opendaylight.ovsdb.lib.message.TableUpdates;
 import org.opendaylight.ovsdb.lib.notation.Row;
@@ -50,10 +47,7 @@ import com.google.common.collect.Maps;
 public class InventoryServiceImpl implements OvsdbInventoryService {
     private static final Logger logger = LoggerFactory
             .getLogger(InventoryServiceImpl.class);
-    private final Set<IPluginOutInventoryService> pluginOutInventoryServices =
-            new CopyOnWriteArraySet<IPluginOutInventoryService>();
     private ConcurrentMap<Node, Map<String, Property>> nodeProps = new ConcurrentHashMap<Node, Map<String, Property>>();
-    private ConcurrentMap<NodeConnector, Map<String, Property>> nodeConnectorProps = new ConcurrentHashMap<NodeConnector, Map<String, Property>>();
     private ConcurrentMap<Node, NodeDatabase> dbCache = Maps.newConcurrentMap();
     private ScheduledExecutorService executor;
     private OvsdbConfigurationService ovsdbConfigurationService;
@@ -66,8 +60,6 @@ public class InventoryServiceImpl implements OvsdbInventoryService {
      *
      */
     public void init() {
-        Node.NodeIDType.registerIDType("OVS", String.class);
-        NodeConnector.NodeConnectorIDType.registerIDType("OVS", String.class, "OVS");
         this.executor = Executors.newSingleThreadScheduledExecutor();
     }
 
@@ -98,14 +90,6 @@ public class InventoryServiceImpl implements OvsdbInventoryService {
         this.executor.shutdownNow();
     }
 
-    public void setPluginOutInventoryServices(IPluginOutInventoryService service) {
-            this.pluginOutInventoryServices.add(service);
-    }
-
-    public void unsetPluginOutInventoryServices(IPluginOutInventoryService service) {
-            this.pluginOutInventoryServices.remove(service);
-    }
-
     public void setOvsdbConfigurationService(OvsdbConfigurationService service) {
         ovsdbConfigurationService = service;
     }
@@ -114,18 +98,6 @@ public class InventoryServiceImpl implements OvsdbInventoryService {
         ovsdbConfigurationService = null;
     }
 
-    @Override
-    public ConcurrentMap<Node, Map<String, Property>> getNodeProps() {
-        return nodeProps;
-    }
-
-    @Override
-    public ConcurrentMap<NodeConnector, Map<String, Property>> getNodeConnectorProps(
-            Boolean refresh) {
-        return nodeConnectorProps;
-    }
-
-
     @Override
     public ConcurrentMap<String, ConcurrentMap<String, Row>> getCache(Node n, String databaseName) {
         NodeDatabase db = dbCache.get(n);
@@ -257,9 +229,14 @@ public class InventoryServiceImpl implements OvsdbInventoryService {
             nProp.put(prop.getName(), prop);
         }
         nodeProps.put(node, nProp);
+        /*
+         * TODO: Remove following code. It updates to sal about newly added node and
+         * it's property. To move this bundle to MD-SAL we need to store this data in
+         * md-sal config/operational data store.
         for (IPluginOutInventoryService service : pluginOutInventoryServices) {
             service.updateNode(node, type, props);
         }
+        */
     }
 
     @Override
@@ -270,18 +247,18 @@ public class InventoryServiceImpl implements OvsdbInventoryService {
             }
         }
 
-        for (IPluginOutInventoryService service : pluginOutInventoryServices) {
+        /*
+         * TODO: Remove following code. It updates to sal about newly added node and
+         * it's property. To move this bundle to MD-SAL we need to store this data in
+         * md-sal config/operational data store.
+         for (IPluginOutInventoryService service : pluginOutInventoryServices) {
             service.updateNode(node, UpdateType.REMOVED, null);
         }
+        */
         nodeProps.remove(node);
         dbCache.remove(node);
     }
 
-    @Override
-    public Set<Node> getConfiguredNotConnectedNodes() {
-        return Collections.emptySet();
-    }
-
     private void listenerAdded(OvsdbInventoryListener listener) {
         this.ovsdbInventoryListeners.add(listener);
     }
diff --git a/plugin/src/main/java/org/opendaylight/ovsdb/plugin/impl/NodeConnectorFactory.java b/plugin/src/main/java/org/opendaylight/ovsdb/plugin/impl/NodeConnectorFactory.java
deleted file mode 100644 (file)
index 0240f90..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2013 Red Hat, Inc.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Authors : Madhu Venugopal, Brent Salisbury
- */
-package org.opendaylight.ovsdb.plugin.impl;
-
-import org.opendaylight.controller.sal.core.NodeConnector;
-import org.opendaylight.controller.sal.utils.INodeConnectorFactory;
-import org.opendaylight.controller.sal.core.Node;
-
-public class NodeConnectorFactory implements INodeConnectorFactory {
-    public NodeConnector fromStringNoNode(String typeStr, String IDStr,
-              Node n){
-          if(typeStr.equals("OVS")){
-              try {
-                  return new NodeConnector(typeStr, IDStr, n);
-              } catch (Exception ex) {
-                  return null;
-              }
-          }
-          return null;
-      }
-}
diff --git a/plugin/src/main/java/org/opendaylight/ovsdb/plugin/impl/NodeFactory.java b/plugin/src/main/java/org/opendaylight/ovsdb/plugin/impl/NodeFactory.java
deleted file mode 100644 (file)
index 1ad2697..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2013 Red Hat, Inc.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Authors : Madhu Venugopal, Brent Salisbury
- */
-package org.opendaylight.ovsdb.plugin.impl;
-
-import org.opendaylight.controller.sal.core.ConstructionException;
-import org.opendaylight.controller.sal.utils.INodeFactory;
-import org.opendaylight.controller.sal.core.Node;
-
-public class NodeFactory implements INodeFactory {
-
-      public Node fromString(String nodeType, String nodeId){
-          if(nodeType.equals("OVS"))
-              try{
-                  return new Node("OVS", nodeId);
-              } catch(ConstructionException e)
-              {
-                  return null;
-              }
-          return null;
-      }
-}
index c0ac4ca5363c29f1acf269cba4e86884eba1fd78..fd208b14375e86a71bac88e0abda550d94b4355d 100644 (file)
@@ -9,18 +9,10 @@
  */
 package org.opendaylight.ovsdb.plugin.internal;
 
-import java.util.Dictionary;
-import java.util.Hashtable;
-
 import org.apache.felix.dm.DependencyActivatorBase;
 import org.apache.felix.dm.DependencyManager;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
-import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
-import org.opendaylight.controller.sal.inventory.IPluginOutInventoryService;
-import org.opendaylight.controller.sal.utils.GlobalConstants;
-import org.opendaylight.controller.sal.utils.INodeConnectorFactory;
-import org.opendaylight.controller.sal.utils.INodeFactory;
 import org.opendaylight.ovsdb.lib.OvsdbConnection;
 import org.opendaylight.ovsdb.lib.OvsdbConnectionListener;
 import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
@@ -30,8 +22,6 @@ import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryService;
 import org.opendaylight.ovsdb.plugin.impl.ConfigurationServiceImpl;
 import org.opendaylight.ovsdb.plugin.impl.ConnectionServiceImpl;
 import org.opendaylight.ovsdb.plugin.impl.InventoryServiceImpl;
-import org.opendaylight.ovsdb.plugin.impl.NodeConnectorFactory;
-import org.opendaylight.ovsdb.plugin.impl.NodeFactory;
 
 import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
@@ -51,11 +41,8 @@ public class Activator extends DependencyActivatorBase {
         Node.NodeIDType.registerIDType("OVS", String.class);
         NodeConnector.NodeConnectorIDType.registerIDType("OVS", String.class, "OVS");
 
-        Dictionary<String, Object> props = new Hashtable<String, Object>();
-        props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
-
         manager.add(createComponent()
-                        .setInterface(OvsdbConfigurationService.class.getName(), props)
+                        .setInterface(OvsdbConfigurationService.class.getName(), null)
                         .setImplementation(ConfigurationServiceImpl.class)
                         .add(createServiceDependency()
                                         .setService(OvsdbConnectionService.class)
@@ -64,12 +51,10 @@ public class Activator extends DependencyActivatorBase {
                                 .setService(OvsdbInventoryService.class)
                                 .setRequired(true)));
 
-        Dictionary<String, Object> props2 = new Hashtable<String, Object>();
-        props2.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
         manager.add(createComponent()
                         .setInterface(
                                 new String[] {OvsdbConnectionService.class.getName(),
-                                        OvsdbConnectionListener.class.getName()}, props2)
+                                        OvsdbConnectionListener.class.getName()}, null)
                         .setImplementation(ConnectionServiceImpl.class)
                         .add(createServiceDependency()
                                 .setService(OvsdbInventoryService.class)
@@ -79,41 +64,15 @@ public class Activator extends DependencyActivatorBase {
                                 .setRequired(true))
         );
 
-        Dictionary<String, Object> props3 = new Hashtable<>();
-        props3.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
-        props3.put("scope", "Global");
         manager.add(createComponent()
-                        .setInterface(
-                                new String[]{IPluginInInventoryService.class.getName(),
-                                        OvsdbInventoryService.class.getName()}, props3)
+                        .setInterface(OvsdbInventoryService.class.getName(), null)
                         .setImplementation(InventoryServiceImpl.class)
-                        .add(createServiceDependency()
-                                .setService(IPluginOutInventoryService.class, "(scope=Global)")
-                                .setCallbacks("setPluginOutInventoryServices",
-                                        "unsetPluginOutInventoryServices")
-                                .setRequired(true))
                         .add(createServiceDependency()
                                 .setService(OvsdbInventoryListener.class)
                                 .setCallbacks("listenerAdded", "listenerRemoved"))
                         .add(createServiceDependency()
                                 .setService(OvsdbConfigurationService.class)
                                 .setRequired(false)));
-
-        Dictionary<String, Object> props4 = new Hashtable<String, Object>();
-        props4.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
-        props4.put("protocolName", "OVS");
-
-        manager.add(createComponent()
-                .setInterface(INodeFactory.class.getName(), props4)
-                .setImplementation(NodeFactory.class));
-
-        Dictionary<String, Object> props5 = new Hashtable<String, Object>();
-        props5.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), "OVS");
-        props5.put("protocolName", "OVS");
-
-        manager.add(createComponent()
-                .setInterface(INodeConnectorFactory.class.getName(), props5)
-                .setImplementation(NodeConnectorFactory.class));
     }
 
     @Override