alshabib

graceful shutdown

...@@ -70,6 +70,36 @@ public interface OpenFlowSwitch { ...@@ -70,6 +70,36 @@ public interface OpenFlowSwitch {
70 public long getId(); 70 public long getId();
71 71
72 /** 72 /**
73 + * fetch the manufacturer description.
74 + * @return the description
75 + */
76 + public String manfacturerDescription();
77 +
78 + /**
79 + * fetch the datapath description.
80 + * @return the description
81 + */
82 + public String datapathDescription();
83 +
84 + /**
85 + * fetch the hardware description.
86 + * @return the description
87 + */
88 + public String hardwareDescription();
89 +
90 + /**
91 + * fetch the software description.
92 + * @return the description
93 + */
94 + public String softwareDescription();
95 +
96 + /**
97 + * fetch the serial number.
98 + * @return the serial
99 + */
100 + public String serialNumber();
101 +
102 + /**
73 * Disconnects the switch by closing the TCP connection. Results in a call 103 * Disconnects the switch by closing the TCP connection. Results in a call
74 * to the channel handler's channelDisconnected method for cleanup 104 * to the channel handler's channelDisconnected method for cleanup
75 */ 105 */
......
...@@ -311,4 +311,31 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver { ...@@ -311,4 +311,31 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver {
311 return Collections.unmodifiableList(ports.getEntries()); 311 return Collections.unmodifiableList(ports.getEntries());
312 } 312 }
313 313
314 + @Override
315 + public String manfacturerDescription() {
316 + return this.desc.getMfrDesc();
317 + }
318 +
319 +
320 + @Override
321 + public String datapathDescription() {
322 + return this.desc.getDpDesc();
323 + }
324 +
325 +
326 + @Override
327 + public String hardwareDescription() {
328 + return this.desc.getHwDesc();
329 + }
330 +
331 + @Override
332 + public String softwareDescription() {
333 + return this.desc.getSwDesc();
334 + }
335 +
336 + @Override
337 + public String serialNumber() {
338 + return this.desc.getSerialNum();
339 + }
340 +
314 } 341 }
......
...@@ -74,6 +74,8 @@ public class Controller { ...@@ -74,6 +74,8 @@ public class Controller {
74 protected boolean alwaysClearFlowsOnSwAdd = false; 74 protected boolean alwaysClearFlowsOnSwAdd = false;
75 private OpenFlowAgent agent; 75 private OpenFlowAgent agent;
76 76
77 + private NioServerSocketChannelFactory execFactory;
78 +
77 // Perf. related configuration 79 // Perf. related configuration
78 protected static final int SEND_BUFFER_SIZE = 4 * 1024 * 1024; 80 protected static final int SEND_BUFFER_SIZE = 4 * 1024 * 1024;
79 protected static final int BATCH_MAX_SIZE = 100; 81 protected static final int BATCH_MAX_SIZE = 100;
...@@ -155,16 +157,17 @@ public class Controller { ...@@ -155,16 +157,17 @@ public class Controller {
155 } 157 }
156 158
157 private ServerBootstrap createServerBootStrap() { 159 private ServerBootstrap createServerBootStrap() {
160 +
158 if (workerThreads == 0) { 161 if (workerThreads == 0) {
159 - return new ServerBootstrap( 162 + execFactory = new NioServerSocketChannelFactory(
160 - new NioServerSocketChannelFactory( 163 + Executors.newCachedThreadPool(),
161 - Executors.newCachedThreadPool(), 164 + Executors.newCachedThreadPool());
162 - Executors.newCachedThreadPool())); 165 + return new ServerBootstrap(execFactory);
163 } else { 166 } else {
164 - return new ServerBootstrap( 167 + execFactory = new NioServerSocketChannelFactory(
165 - new NioServerSocketChannelFactory( 168 + Executors.newCachedThreadPool(),
166 - Executors.newCachedThreadPool(), 169 + Executors.newCachedThreadPool(), workerThreads);
167 - Executors.newCachedThreadPool(), workerThreads)); 170 + return new ServerBootstrap(execFactory);
168 } 171 }
169 } 172 }
170 173
...@@ -237,6 +240,7 @@ public class Controller { ...@@ -237,6 +240,7 @@ public class Controller {
237 240
238 241
239 public void stop() { 242 public void stop() {
243 + execFactory.shutdown();
240 cg.close(); 244 cg.close();
241 } 245 }
242 246
......
...@@ -435,8 +435,8 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { ...@@ -435,8 +435,8 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
435 log.debug("Setting new switch {} to EQUAL and sending Role request", 435 log.debug("Setting new switch {} to EQUAL and sending Role request",
436 h.sw.getStringId()); 436 h.sw.getStringId());
437 h.sw.activateEqualSwitch(); 437 h.sw.activateEqualSwitch();
438 - //h.setSwitchRole(RoleState.EQUAL); 438 + h.setSwitchRole(RoleState.EQUAL);
439 - h.setSwitchRole(RoleState.MASTER); 439 +
440 h.sw.startDriverHandshake(); 440 h.sw.startDriverHandshake();
441 h.setState(WAIT_SWITCH_DRIVER_SUB_HANDSHAKE); 441 h.setState(WAIT_SWITCH_DRIVER_SUB_HANDSHAKE);
442 442
......
1 package org.onlab.onos.provider.of.device.impl; 1 package org.onlab.onos.provider.of.device.impl;
2 2
3 +import static org.slf4j.LoggerFactory.getLogger;
4 +
5 +import java.net.URI;
6 +import java.net.URISyntaxException;
7 +
3 import org.apache.felix.scr.annotations.Activate; 8 import org.apache.felix.scr.annotations.Activate;
4 import org.apache.felix.scr.annotations.Component; 9 import org.apache.felix.scr.annotations.Component;
5 import org.apache.felix.scr.annotations.Deactivate; 10 import org.apache.felix.scr.annotations.Deactivate;
...@@ -17,15 +22,11 @@ import org.onlab.onos.net.provider.AbstractProvider; ...@@ -17,15 +22,11 @@ import org.onlab.onos.net.provider.AbstractProvider;
17 import org.onlab.onos.net.provider.ProviderId; 22 import org.onlab.onos.net.provider.ProviderId;
18 import org.onlab.onos.of.controller.Dpid; 23 import org.onlab.onos.of.controller.Dpid;
19 import org.onlab.onos.of.controller.OpenFlowController; 24 import org.onlab.onos.of.controller.OpenFlowController;
25 +import org.onlab.onos.of.controller.OpenFlowSwitch;
20 import org.onlab.onos.of.controller.OpenFlowSwitchListener; 26 import org.onlab.onos.of.controller.OpenFlowSwitchListener;
21 import org.onlab.onos.of.controller.RoleState; 27 import org.onlab.onos.of.controller.RoleState;
22 import org.slf4j.Logger; 28 import org.slf4j.Logger;
23 29
24 -import java.net.URI;
25 -import java.net.URISyntaxException;
26 -
27 -import static org.slf4j.LoggerFactory.getLogger;
28 -
29 /** 30 /**
30 * Provider which uses an OpenFlow controller to detect network 31 * Provider which uses an OpenFlow controller to detect network
31 * infrastructure devices. 32 * infrastructure devices.
...@@ -93,16 +94,26 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr ...@@ -93,16 +94,26 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
93 private class InternalDeviceProvider implements OpenFlowSwitchListener { 94 private class InternalDeviceProvider implements OpenFlowSwitchListener {
94 @Override 95 @Override
95 public void switchAdded(Dpid dpid) { 96 public void switchAdded(Dpid dpid) {
97 + if (providerService == null) {
98 + return;
99 + }
96 URI uri = buildURI(dpid); 100 URI uri = buildURI(dpid);
97 - // TODO: fetch and provide switch desc information 101 + OpenFlowSwitch sw = controller.getSwitch(dpid);
102 +
98 DeviceDescription description = 103 DeviceDescription description =
99 new DefaultDeviceDescription(buildURI(dpid), Device.Type.SWITCH, 104 new DefaultDeviceDescription(buildURI(dpid), Device.Type.SWITCH,
100 - null, null, null, null); 105 + sw.manfacturerDescription(),
106 + sw.hardwareDescription(),
107 + sw.softwareDescription(),
108 + sw.softwareDescription());
101 providerService.deviceConnected(new DeviceId(uri), description); 109 providerService.deviceConnected(new DeviceId(uri), description);
102 } 110 }
103 111
104 @Override 112 @Override
105 public void switchRemoved(Dpid dpid) { 113 public void switchRemoved(Dpid dpid) {
114 + if (providerService == null) {
115 + return;
116 + }
106 URI uri = buildURI(dpid); 117 URI uri = buildURI(dpid);
107 providerService.deviceDisconnected(new DeviceId(uri)); 118 providerService.deviceDisconnected(new DeviceId(uri));
108 } 119 }
......