X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconnectionmanager%2Fimplementation%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconnectionmanager%2Finternal%2FConnectionManager.java;h=e2d8f6b03b270f7f602de6b4470bc0a971487f61;hp=c4b7d4fe6cf52b9b517d75c53d596778700528d8;hb=68ef34f0d8f426ce525ccefb4e5a36162f2eb717;hpb=2d36fc2f0b7691efe2f641beacd146c260676fea diff --git a/opendaylight/connectionmanager/implementation/src/main/java/org/opendaylight/controller/connectionmanager/internal/ConnectionManager.java b/opendaylight/connectionmanager/implementation/src/main/java/org/opendaylight/controller/connectionmanager/internal/ConnectionManager.java index c4b7d4fe6c..e2d8f6b03b 100644 --- a/opendaylight/connectionmanager/implementation/src/main/java/org/opendaylight/controller/connectionmanager/internal/ConnectionManager.java +++ b/opendaylight/connectionmanager/implementation/src/main/java/org/opendaylight/controller/connectionmanager/internal/ConnectionManager.java @@ -32,7 +32,6 @@ import java.util.concurrent.LinkedBlockingQueue; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import org.eclipse.osgi.framework.console.CommandInterpreter; import org.eclipse.osgi.framework.console.CommandProvider; import org.opendaylight.controller.clustering.services.ICacheUpdateAware; @@ -49,6 +48,7 @@ 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.IInventoryService; import org.opendaylight.controller.sal.inventory.IListenInventoryUpdates; import org.opendaylight.controller.sal.utils.Status; import org.opendaylight.controller.sal.utils.StatusCode; @@ -66,6 +66,7 @@ public class ConnectionManager implements IConnectionManager, IConnectionListene private IConnectionService connectionService; private Thread connectionEventThread; private BlockingQueue connectionEvents; + private IInventoryService inventoryService; public void setClusterServices(IClusterGlobalServices i) { this.clusterServices = i; @@ -87,12 +88,48 @@ public class ConnectionManager implements IConnectionManager, IConnectionListene } } + public void setInventoryService(IInventoryService service) { + logger.trace("Got inventory service set request {}", service); + this.inventoryService = service; + } + + public void unsetInventoryService(IInventoryService service) { + logger.trace("Got a service UNset request"); + this.inventoryService = null; + } + + private void getInventories() { + Map> nodeProp = this.inventoryService.getNodeProps(); + for (Map.Entry> entry : nodeProp.entrySet()) { + Node node = entry.getKey(); + logger.debug("getInventories for node:{}", new Object[] { node }); + Map propMap = entry.getValue(); + Set props = new HashSet(); + for (Property property : propMap.values()) { + props.add(property); + } + updateNode(node, UpdateType.ADDED, props); + } + + Map> nodeConnectorProp = this.inventoryService.getNodeConnectorProps(); + for (Map.Entry> entry : nodeConnectorProp.entrySet()) { + Map propMap = entry.getValue(); + Set props = new HashSet(); + for (Property property : propMap.values()) { + props.add(property); + } + updateNodeConnector(entry.getKey(), UpdateType.ADDED, props); + } + } + public void started() { connectionEventThread = new Thread(new EventHandler(), "ConnectionEvent Thread"); connectionEventThread.start(); registerWithOSGIConsole(); notifyClusterViewChanged(); + // Should pull the Inventory updates in case we missed it + getInventories(); } public void init() { @@ -176,9 +213,6 @@ public class ConnectionManager implements IConnectionManager, IConnectionListene @Override public void coordinatorChanged() { - AbstractScheme scheme = schemes.get(activeScheme); - if (scheme == null) return; - scheme.handleClusterViewChanged(); notifyClusterViewChanged(); } @@ -202,8 +236,7 @@ public class ConnectionManager implements IConnectionManager, IConnectionListene @Override public void entryCreated(Node key, String cacheName, boolean originLocal) { - AbstractScheme scheme = schemes.get(activeScheme); - logger.debug("Created : {} cache : {} existingValue : {}", key, cacheName, scheme.getNodeConnections().get(key)); + if (originLocal) return; } /* @@ -277,6 +310,9 @@ public class ConnectionManager implements IConnectionManager, IConnectionListene connectionService.notifyNodeDisconnectFromMaster(node); break; case CLUSTER_VIEW_CHANGED: + AbstractScheme scheme = schemes.get(activeScheme); + if (scheme == null) return; + scheme.handleClusterViewChanged(); connectionService.notifyClusterViewChanged(); break; default: