From b6d3e684e8ffc5125dc71a619ac41323924a32c5 Mon Sep 17 00:00:00 2001 From: Giovanni Meo Date: Tue, 6 Aug 2013 11:29:25 +0200 Subject: [PATCH] Controller inventory service doesn't come up - After the commit e55cbeebfe5bae130becc3facd7c6235a56529ee the InventoryShimService in OF protocol plugin was not coming up because was waiting on a service that was provided by SAL InventoryService, but this was waiting on a service provided by the protocol plugin (a typical circular dependency condition). SAL implementations should never wait on the protocol plugin, rather should track them dynamically. - In InventoryService in protocol plugin the list of pluginOutInventoryServices was initialized during init, but init is called after the necessary dependency have been met, that means that the list may already have the proper listener sets, and those will not be relearnt again. The proper initialization is the instance init, and clearing when the protocol plugin is stopping. Change-Id: I6ad24cb8e6e9fd5b4ae89a3b2557ec233b86ebed Signed-off-by: Giovanni Meo --- .../openflow/internal/InventoryService.java | 12 +++++++----- .../sal/implementation/internal/Activator.java | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryService.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryService.java index 9fded15f42..a5a071122f 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryService.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryService.java @@ -45,7 +45,8 @@ public class InventoryService implements IInventoryShimInternalListener, IPluginInInventoryService, IInventoryProvider { protected static final Logger logger = LoggerFactory .getLogger(InventoryService.class); - private Set pluginOutInventoryServices; + private Set pluginOutInventoryServices = + new CopyOnWriteArraySet(); private IController controller = null; private ConcurrentMap> nodeProps; // properties are maintained in global container only private ConcurrentMap> nodeConnectorProps; // properties are maintained in global container only @@ -82,7 +83,6 @@ public class InventoryService implements IInventoryShimInternalListener, nodeProps = new ConcurrentHashMap>(); nodeConnectorProps = new ConcurrentHashMap>(); - pluginOutInventoryServices = new CopyOnWriteArraySet(); } /** @@ -112,6 +112,7 @@ public class InventoryService implements IInventoryShimInternalListener, */ void stop() { logger.trace("STOP called!"); + pluginOutInventoryServices.clear(); } public void setPluginOutInventoryServices(IPluginOutInventoryService service) { @@ -228,8 +229,9 @@ public class InventoryService implements IInventoryShimInternalListener, private void removeNode(Node node) { logger.trace("{} removed", node); - if (nodeProps == null) + if (nodeProps == null) { return; + } // update local cache nodeProps.remove(node); @@ -252,8 +254,8 @@ public class InventoryService implements IInventoryShimInternalListener, private void updateNode(Node node, Set properties) { logger.trace("{} updated, props: {}", node, properties); - if (nodeProps == null || !nodeProps.containsKey(node) || - properties == null || properties.isEmpty()) { + if ((nodeProps == null) || !nodeProps.containsKey(node) || + (properties == null) || properties.isEmpty()) { return; } diff --git a/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/Activator.java b/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/Activator.java index fc9b9e2df4..c3afae90f8 100644 --- a/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/Activator.java +++ b/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/Activator.java @@ -102,7 +102,7 @@ public class Activator extends ComponentActivatorAbstractBase { c.add(createServiceDependency() .setService(IPluginInInventoryService.class, "(scope=Global)") .setCallbacks("setPluginService", "unsetPluginService") - .setRequired(true)); + .setRequired(false)); } } -- 2.36.6