X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fprotocol_plugins%2Fstub%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fprotocol_plugins%2Fstub%2Finternal%2FInventoryService.java;fp=opendaylight%2Fprotocol_plugins%2Fstub%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fprotocol_plugins%2Fstub%2Finternal%2FInventoryService.java;h=b94ffec1ddba5d1f6cc699813d22fea6b02c7c0e;hp=22a4343f332ed2e79e7f7ecc979d8535acc4ea26;hb=4b8ee62fd8f0fd6fb9b1ffed543e08e989b543e0;hpb=fcd28f3b8399eb304c92c52eb1a697f828630e1c diff --git a/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/InventoryService.java b/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/InventoryService.java index 22a4343f33..b94ffec1dd 100644 --- a/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/InventoryService.java +++ b/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/InventoryService.java @@ -12,11 +12,11 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.CopyOnWriteArraySet; import org.apache.felix.dm.Component; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import org.opendaylight.controller.sal.core.Actions; import org.opendaylight.controller.sal.core.Bandwidth; import org.opendaylight.controller.sal.core.Buffers; @@ -29,7 +29,9 @@ import org.opendaylight.controller.sal.core.Property; import org.opendaylight.controller.sal.core.State; import org.opendaylight.controller.sal.core.Tables; import org.opendaylight.controller.sal.core.TimeStamp; +import org.opendaylight.controller.sal.core.UpdateType; import org.opendaylight.controller.sal.inventory.IPluginInInventoryService; +import org.opendaylight.controller.sal.inventory.IPluginOutInventoryService; import org.opendaylight.controller.sal.utils.NodeCreator; import org.opendaylight.controller.sal.utils.NodeConnectorCreator; @@ -55,6 +57,22 @@ public class InventoryService implements IPluginInInventoryService { // global // container // only + private final Set pluginOutInventoryServices = + new CopyOnWriteArraySet(); + + public void setPluginOutInventoryServices(IPluginOutInventoryService service) { + logger.trace("Got a service set request {}", service); + if (this.pluginOutInventoryServices != null) { + this.pluginOutInventoryServices.add(service); + } + } + + public void unsetPluginOutInventoryServices(IPluginOutInventoryService service) { + logger.trace("Got a service UNset request"); + if (this.pluginOutInventoryServices != null) { + this.pluginOutInventoryServices.remove(service); + } + } /** * Function called by the dependency manager when all the required @@ -173,6 +191,29 @@ public class InventoryService implements IPluginInInventoryService { void start() { } + /** + * Method called when the plugin has exposed it's services, this will be + * used to publish the updates so connection manager can think the + * connection is local + */ + void started() { + // update sal and discovery + for (IPluginOutInventoryService service : pluginOutInventoryServices) { + for (Node node : nodeProps.keySet()) { + Set props = new HashSet(nodeProps.get(node) + .values()); + service.updateNode(node, UpdateType.ADDED, props); + logger.trace("Adding Node {} with props {}", node, props); + } + for (NodeConnector nc : nodeConnectorProps.keySet()) { + Set props = new HashSet(nodeConnectorProps.get(nc) + .values()); + service.updateNodeConnector(nc, UpdateType.ADDED, props); + logger.trace("Adding NodeConnectors {} with props {}", nc, props); + } + } + } + /** * Function called by the dependency manager before the services exported by * the component are unregistered, this will be followed by a "destroy ()" @@ -180,6 +221,7 @@ public class InventoryService implements IPluginInInventoryService { * */ void stop() { + pluginOutInventoryServices.clear(); } /**