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>
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 :
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 :
@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;
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");
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);
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;
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;
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;
*
*/
public void init() {
- Node.NodeIDType.registerIDType("OVS", String.class);
- NodeConnector.NodeConnectorIDType.registerIDType("OVS", String.class, "OVS");
this.executor = Executors.newSingleThreadScheduledExecutor();
}
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;
}
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);
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
}
}
- 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);
}
+++ /dev/null
-/*
- * 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;
- }
-}
+++ /dev/null
-/*
- * 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;
- }
-}
*/
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;
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;
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)
.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)
.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