graceful shutdown
diff --git a/of/ctl/src/main/java/org/onlab/onos/of/controller/impl/Controller.java b/of/ctl/src/main/java/org/onlab/onos/of/controller/impl/Controller.java
index d45bb07..44d70ac 100644
--- a/of/ctl/src/main/java/org/onlab/onos/of/controller/impl/Controller.java
+++ b/of/ctl/src/main/java/org/onlab/onos/of/controller/impl/Controller.java
@@ -74,6 +74,8 @@
protected boolean alwaysClearFlowsOnSwAdd = false;
private OpenFlowAgent agent;
+ private NioServerSocketChannelFactory execFactory;
+
// Perf. related configuration
protected static final int SEND_BUFFER_SIZE = 4 * 1024 * 1024;
protected static final int BATCH_MAX_SIZE = 100;
@@ -155,16 +157,17 @@
}
private ServerBootstrap createServerBootStrap() {
+
if (workerThreads == 0) {
- return new ServerBootstrap(
- new NioServerSocketChannelFactory(
- Executors.newCachedThreadPool(),
- Executors.newCachedThreadPool()));
+ execFactory = new NioServerSocketChannelFactory(
+ Executors.newCachedThreadPool(),
+ Executors.newCachedThreadPool());
+ return new ServerBootstrap(execFactory);
} else {
- return new ServerBootstrap(
- new NioServerSocketChannelFactory(
- Executors.newCachedThreadPool(),
- Executors.newCachedThreadPool(), workerThreads));
+ execFactory = new NioServerSocketChannelFactory(
+ Executors.newCachedThreadPool(),
+ Executors.newCachedThreadPool(), workerThreads);
+ return new ServerBootstrap(execFactory);
}
}
@@ -237,6 +240,7 @@
public void stop() {
+ execFactory.shutdown();
cg.close();
}
diff --git a/of/ctl/src/main/java/org/onlab/onos/of/controller/impl/OFChannelHandler.java b/of/ctl/src/main/java/org/onlab/onos/of/controller/impl/OFChannelHandler.java
index 66c1e60..8af45e1 100644
--- a/of/ctl/src/main/java/org/onlab/onos/of/controller/impl/OFChannelHandler.java
+++ b/of/ctl/src/main/java/org/onlab/onos/of/controller/impl/OFChannelHandler.java
@@ -435,8 +435,8 @@
log.debug("Setting new switch {} to EQUAL and sending Role request",
h.sw.getStringId());
h.sw.activateEqualSwitch();
- //h.setSwitchRole(RoleState.EQUAL);
- h.setSwitchRole(RoleState.MASTER);
+ h.setSwitchRole(RoleState.EQUAL);
+
h.sw.startDriverHandshake();
h.setState(WAIT_SWITCH_DRIVER_SUB_HANDSHAKE);