alshabib

graceful shutdown

......@@ -70,6 +70,36 @@ public interface OpenFlowSwitch {
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
*/
......
......@@ -311,4 +311,31 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver {
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();
}
}
......
......@@ -74,6 +74,8 @@ public class Controller {
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 @@ public class Controller {
}
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 class Controller {
public void stop() {
execFactory.shutdown();
cg.close();
}
......
......@@ -435,8 +435,8 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
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);
......
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.AbstractProvider;
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 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
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));
}
......