Thomas Vachuska

ONOS-180 Suppressing a few superfluous stack traces on shutdown.

Change-Id: If648b9d7658e8ee57a0e9eb157b12120f0ea20bd
...@@ -21,6 +21,7 @@ import java.net.InetSocketAddress; ...@@ -21,6 +21,7 @@ import java.net.InetSocketAddress;
21 import java.net.SocketAddress; 21 import java.net.SocketAddress;
22 import java.util.Collections; 22 import java.util.Collections;
23 import java.util.List; 23 import java.util.List;
24 +import java.util.concurrent.RejectedExecutionException;
24 import java.util.concurrent.atomic.AtomicInteger; 25 import java.util.concurrent.atomic.AtomicInteger;
25 26
26 import org.jboss.netty.channel.Channel; 27 import org.jboss.netty.channel.Channel;
...@@ -50,6 +51,8 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver { ...@@ -50,6 +51,8 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver {
50 51
51 protected final Logger log = LoggerFactory.getLogger(getClass()); 52 protected final Logger log = LoggerFactory.getLogger(getClass());
52 53
54 + private static final String SHUTDOWN_MSG = "Worker has already been shutdown";
55 +
53 protected Channel channel; 56 protected Channel channel;
54 protected String channelId; 57 protected String channelId;
55 58
...@@ -97,14 +100,26 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver { ...@@ -97,14 +100,26 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver {
97 @Override 100 @Override
98 public final void sendMsg(OFMessage m) { 101 public final void sendMsg(OFMessage m) {
99 if (role == RoleState.MASTER) { 102 if (role == RoleState.MASTER) {
103 + try {
100 this.write(m); 104 this.write(m);
105 + } catch (RejectedExecutionException e) {
106 + if (!e.getMessage().contains(SHUTDOWN_MSG)) {
107 + throw e;
108 + }
109 + }
101 } 110 }
102 } 111 }
103 112
104 @Override 113 @Override
105 public final void sendMsg(List<OFMessage> msgs) { 114 public final void sendMsg(List<OFMessage> msgs) {
106 if (role == RoleState.MASTER) { 115 if (role == RoleState.MASTER) {
116 + try {
107 this.write(msgs); 117 this.write(msgs);
118 + } catch (RejectedExecutionException e) {
119 + if (!e.getMessage().contains(SHUTDOWN_MSG)) {
120 + throw e;
121 + }
122 + }
108 } 123 }
109 } 124 }
110 125
...@@ -296,7 +311,6 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver { ...@@ -296,7 +311,6 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver {
296 } 311 }
297 } else { 312 } else {
298 log.warn("Failed to set role for {}", this.getStringId()); 313 log.warn("Failed to set role for {}", this.getStringId());
299 - return;
300 } 314 }
301 } 315 }
302 316
......