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=e5bf5258c5faa86fff78f5959692494f0049052f;hp=df5175083b1870ef99b29443d42003eb2bb179c5;hb=99050b4a43221f1e82f2fb61bc4ea162c2c7e283;hpb=baf00b337b0d54a1aa5a83f5b125470e2a856bdd 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 df5175083b..e5bf5258c5 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 @@ -30,19 +30,17 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; 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; import org.opendaylight.controller.clustering.services.IClusterGlobalServices; import org.opendaylight.controller.clustering.services.ICoordinatorChangeAware; -import org.opendaylight.controller.connectionmanager.ConnectionLocality; import org.opendaylight.controller.connectionmanager.ConnectionMgmtScheme; import org.opendaylight.controller.connectionmanager.IConnectionManager; import org.opendaylight.controller.connectionmanager.scheme.AbstractScheme; import org.opendaylight.controller.connectionmanager.scheme.SchemeFactory; import org.opendaylight.controller.sal.connection.ConnectionConstants; +import org.opendaylight.controller.sal.connection.ConnectionLocality; import org.opendaylight.controller.sal.connection.IConnectionListener; import org.opendaylight.controller.sal.connection.IConnectionService; import org.opendaylight.controller.sal.core.Node; @@ -55,6 +53,8 @@ import org.opendaylight.controller.sal.utils.Status; import org.opendaylight.controller.sal.utils.StatusCode; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ConnectionManager implements IConnectionManager, IConnectionListener, ICoordinatorChangeAware, IListenInventoryUpdates, @@ -123,8 +123,19 @@ public class ConnectionManager implements IConnectionManager, IConnectionListene } } - public void started() { - connectionEventThread = new Thread(new EventHandler(), "ConnectionEvent Thread"); + + public void started() { + String schemeStr = System.getProperty("connection.scheme"); + for (ConnectionMgmtScheme scheme : ConnectionMgmtScheme.values()) { + AbstractScheme schemeImpl = SchemeFactory.getScheme(scheme, clusterServices); + if (schemeImpl != null) { + schemes.put(scheme, schemeImpl); + if (scheme.name().equalsIgnoreCase(schemeStr)) { + activeScheme = scheme; + } + } + } + connectionEventThread.start(); registerWithOSGIConsole(); @@ -134,21 +145,12 @@ public class ConnectionManager implements IConnectionManager, IConnectionListene } public void init() { - String schemeStr = System.getProperty("connection.scheme"); + connectionEventThread = new Thread(new EventHandler(), "ConnectionEvent Thread"); this.connectionEvents = new LinkedBlockingQueue(); schemes = new ConcurrentHashMap(); - for (ConnectionMgmtScheme scheme : ConnectionMgmtScheme.values()) { - AbstractScheme schemeImpl = SchemeFactory.getScheme(scheme, clusterServices); - if (schemeImpl != null) { - schemes.put(scheme, schemeImpl); - if (scheme.name().equalsIgnoreCase(schemeStr)) { - activeScheme = scheme; - } - } - } } - public void stop() { + public void stopping() { connectionEventThread.interrupt(); Set localNodes = getLocalNodes(); if (localNodes != null) { @@ -233,19 +235,31 @@ public class ConnectionManager implements IConnectionManager, IConnectionListene @Override public Node connect(String connectionIdentifier, Map params) { if (connectionService == null) return null; - return connectionService.connect(connectionIdentifier, params); + Node node = connectionService.connect(connectionIdentifier, params); + AbstractScheme scheme = schemes.get(activeScheme); + if (scheme != null && node != null) scheme.addNode(node); + return node; } @Override public Node connect(String type, String connectionIdentifier, Map params) { if (connectionService == null) return null; - return connectionService.connect(type, connectionIdentifier, params); + Node node = connectionService.connect(connectionIdentifier, params); + AbstractScheme scheme = schemes.get(activeScheme); + if (scheme != null && node != null) scheme.addNode(node); + return node; } @Override public Status disconnect (Node node) { + if (node == null) return new Status(StatusCode.BADREQUEST); if (connectionService == null) return new Status(StatusCode.NOSERVICE); - return connectionService.disconnect(node); + Status status = connectionService.disconnect(node); + if (status.isSuccess()) { + AbstractScheme scheme = schemes.get(activeScheme); + if (scheme != null) scheme.removeNode(node); + } + return status; } @Override