graceful shutdown
diff --git a/of/api/src/main/java/org/onlab/onos/of/controller/OpenFlowSwitch.java b/of/api/src/main/java/org/onlab/onos/of/controller/OpenFlowSwitch.java
index 798440a..f16bb88 100644
--- a/of/api/src/main/java/org/onlab/onos/of/controller/OpenFlowSwitch.java
+++ b/of/api/src/main/java/org/onlab/onos/of/controller/OpenFlowSwitch.java
@@ -70,6 +70,36 @@
public long getId();
/**
+ * fetch the manufacturer description.
+ * @return the description
+ */
+ public String manfacturerDescription();
+
+ /**
+ * fetch the datapath description.
+ * @return the description
+ */
+ public String datapathDescription();
+
+ /**
+ * fetch the hardware description.
+ * @return the description
+ */
+ public String hardwareDescription();
+
+ /**
+ * fetch the software description.
+ * @return the description
+ */
+ public String softwareDescription();
+
+ /**
+ * fetch the serial number.
+ * @return the serial
+ */
+ public String serialNumber();
+
+ /**
* Disconnects the switch by closing the TCP connection. Results in a call
* to the channel handler's channelDisconnected method for cleanup
*/
diff --git a/of/api/src/main/java/org/onlab/onos/of/controller/driver/AbstractOpenFlowSwitch.java b/of/api/src/main/java/org/onlab/onos/of/controller/driver/AbstractOpenFlowSwitch.java
index 7ba5a5d..0a83360 100644
--- a/of/api/src/main/java/org/onlab/onos/of/controller/driver/AbstractOpenFlowSwitch.java
+++ b/of/api/src/main/java/org/onlab/onos/of/controller/driver/AbstractOpenFlowSwitch.java
@@ -311,4 +311,31 @@
return Collections.unmodifiableList(ports.getEntries());
}
+ @Override
+ public String manfacturerDescription() {
+ return this.desc.getMfrDesc();
+ }
+
+
+ @Override
+ public String datapathDescription() {
+ return this.desc.getDpDesc();
+ }
+
+
+ @Override
+ public String hardwareDescription() {
+ return this.desc.getHwDesc();
+ }
+
+ @Override
+ public String softwareDescription() {
+ return this.desc.getSwDesc();
+ }
+
+ @Override
+ public String serialNumber() {
+ return this.desc.getSerialNum();
+ }
+
}
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);
diff --git a/providers/of/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java b/providers/of/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
index 16a4305..ad4ccad 100644
--- a/providers/of/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
+++ b/providers/of/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
@@ -1,5 +1,10 @@
package org.onlab.onos.provider.of.device.impl;
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -17,15 +22,11 @@
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.onos.of.controller.Dpid;
import org.onlab.onos.of.controller.OpenFlowController;
+import org.onlab.onos.of.controller.OpenFlowSwitch;
import org.onlab.onos.of.controller.OpenFlowSwitchListener;
import org.onlab.onos.of.controller.RoleState;
import org.slf4j.Logger;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
/**
* Provider which uses an OpenFlow controller to detect network
* infrastructure devices.
@@ -93,16 +94,26 @@
private class InternalDeviceProvider implements OpenFlowSwitchListener {
@Override
public void switchAdded(Dpid dpid) {
+ if (providerService == null) {
+ return;
+ }
URI uri = buildURI(dpid);
- // TODO: fetch and provide switch desc information
+ OpenFlowSwitch sw = controller.getSwitch(dpid);
+
DeviceDescription description =
new DefaultDeviceDescription(buildURI(dpid), Device.Type.SWITCH,
- null, null, null, null);
+ sw.manfacturerDescription(),
+ sw.hardwareDescription(),
+ sw.softwareDescription(),
+ sw.softwareDescription());
providerService.deviceConnected(new DeviceId(uri), description);
}
@Override
public void switchRemoved(Dpid dpid) {
+ if (providerService == null) {
+ return;
+ }
URI uri = buildURI(dpid);
providerService.deviceDisconnected(new DeviceId(uri));
}