X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fprotocol_plugins%2Fopenflow%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fprotocol_plugin%2Fopenflow%2Fcore%2Finternal%2FController.java;h=c7c6c8924d29807da61aa5896c4b2b1e1b79cc59;hb=d4b6addab23cf24f20cd7969a7f1d800fda2bac1;hp=2863070cc5a7a34ff0f2d95475cd5a9359a443f3;hpb=e2f7aaa41e482815ca1d4495eb85c8653cd903ab;p=controller.git diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/Controller.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/Controller.java index 2863070cc5..c7c6c8924d 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/Controller.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/Controller.java @@ -30,6 +30,12 @@ import org.opendaylight.controller.protocol_plugin.openflow.core.IController; import org.opendaylight.controller.protocol_plugin.openflow.core.IMessageListener; import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitch; import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitchStateListener; +import org.opendaylight.controller.sal.connection.ConnectionConstants; +import org.opendaylight.controller.sal.connection.IPluginInConnectionService; +import org.opendaylight.controller.sal.connection.IPluginOutConnectionService; +import org.opendaylight.controller.sal.core.Node; +import org.opendaylight.controller.sal.utils.Status; +import org.opendaylight.controller.sal.utils.StatusCode; import org.openflow.protocol.OFMessage; import org.openflow.protocol.OFType; import org.openflow.util.HexString; @@ -38,7 +44,7 @@ import org.osgi.framework.FrameworkUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class Controller implements IController, CommandProvider { +public class Controller implements IController, CommandProvider, IPluginInConnectionService { private static final Logger logger = LoggerFactory .getLogger(Controller.class); private ControllerIO controllerIO; @@ -50,6 +56,7 @@ public class Controller implements IController, CommandProvider { // only 1 switch state listener private ISwitchStateListener switchStateListener; private AtomicInteger switchInstanceNumber; + private int MAXQUEUESIZE = 50000; /* * this thread monitors the switchEvents queue for new incoming events from @@ -107,12 +114,12 @@ public class Controller implements IController, CommandProvider { /** * Function called by the dependency manager when all the required * dependencies are satisfied - * + * */ public void init() { logger.debug("Initializing!"); this.switches = new ConcurrentHashMap(); - this.switchEvents = new LinkedBlockingQueue(); + this.switchEvents = new LinkedBlockingQueue(MAXQUEUESIZE); this.messageListeners = new ConcurrentHashMap(); this.switchStateListener = null; this.switchInstanceNumber = new AtomicInteger(0); @@ -122,7 +129,7 @@ public class Controller implements IController, CommandProvider { /** * Function called by dependency manager after "init ()" is called and after * the services provided by the class are registered in the service registry - * + * */ public void start() { logger.debug("Starting!"); @@ -145,7 +152,7 @@ public class Controller implements IController, CommandProvider { * Function called by the dependency manager before the services exported by * the component are unregistered, this will be followed by a "destroy ()" * calls - * + * */ public void stop() { for (Iterator> it = switches.entrySet().iterator(); it @@ -166,7 +173,7 @@ public class Controller implements IController, CommandProvider { * Function called by the dependency manager when at least one dependency * become unsatisfied or when the component is shutting down because for * example bundle is being stopped. - * + * */ public void destroy() { } @@ -220,11 +227,10 @@ public class Controller implements IController, CommandProvider { // create new switch int i = this.switchInstanceNumber.addAndGet(1); String instanceName = "SwitchHandler-" + i; - SwitchHandler switchHandler = new SwitchHandler(this, sc, - instanceName); + SwitchHandler switchHandler = new SwitchHandler(this, sc, instanceName); switchHandler.start(); if (sc.isConnected()) { - logger.info("Switch:{} is connected to the Controller", + logger.info("Switch:{} is connected to the Controller", sc.socket().getRemoteSocketAddress() .toString().split("/")[1]); } @@ -374,4 +380,34 @@ public class Controller implements IController, CommandProvider { help.append("\t controllerShowConnConfig\n"); return help.toString(); } + + @Override + public Status disconnect(Node node) { + ISwitch sw = getSwitch((Long) node.getID()); + if (sw != null) disconnectSwitch(sw); + return new Status(StatusCode.SUCCESS); + } + + @Override + public Node connect(String connectionIdentifier, Map params) { + return null; + } + + /** + * View Change notification + */ + public void notifyClusterViewChanged() { + for (ISwitch sw : switches.values()) { + notifySwitchAdded(sw); + } + } + + /** + * Node Disconnected from the node's master controller. + */ + @Override + public void notifyNodeDisconnectFromMaster(Node node) { + ISwitch sw = switches.get((Long)node.getID()); + if (sw != null) notifySwitchAdded(sw); + } }