Thomas Vachuska
Committed by Gerrit Code Review

Suppressing some error messages that pollute the log on switch disconnect.

Change-Id: Ia79e0efcdf8552a4be1ce6b6cb562100f077bd90
...@@ -80,6 +80,10 @@ import org.slf4j.LoggerFactory; ...@@ -80,6 +80,10 @@ import org.slf4j.LoggerFactory;
80 */ 80 */
81 class OFChannelHandler extends IdleStateAwareChannelHandler { 81 class OFChannelHandler extends IdleStateAwareChannelHandler {
82 private static final Logger log = LoggerFactory.getLogger(OFChannelHandler.class); 82 private static final Logger log = LoggerFactory.getLogger(OFChannelHandler.class);
83 +
84 + private static final String RESET_BY_PEER = "Connection reset by peer";
85 + private static final String BROKEN_PIPE = "Broken pipe";
86 +
83 private final Controller controller; 87 private final Controller controller;
84 private OpenFlowSwitchDriver sw; 88 private OpenFlowSwitchDriver sw;
85 private long thisdpid; // channelHandler cached value of connected switch id 89 private long thisdpid; // channelHandler cached value of connected switch id
...@@ -1094,11 +1098,14 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { ...@@ -1094,11 +1098,14 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
1094 } else if (e.getCause() instanceof ClosedChannelException) { 1098 } else if (e.getCause() instanceof ClosedChannelException) {
1095 log.debug("Channel for sw {} already closed", getSwitchInfoString()); 1099 log.debug("Channel for sw {} already closed", getSwitchInfoString());
1096 } else if (e.getCause() instanceof IOException) { 1100 } else if (e.getCause() instanceof IOException) {
1097 - log.error("Disconnecting switch {} due to IO Error: {}", 1101 + if (!e.getCause().getMessage().equals(RESET_BY_PEER) &&
1098 - getSwitchInfoString(), e.getCause().getMessage()); 1102 + !e.getCause().getMessage().equals(BROKEN_PIPE)) {
1099 - if (log.isDebugEnabled()) { 1103 + log.error("Disconnecting switch {} due to IO Error: {}",
1100 - // still print stack trace if debug is enabled 1104 + getSwitchInfoString(), e.getCause().getMessage());
1101 - log.debug("StackTrace for previous Exception: ", e.getCause()); 1105 + if (log.isDebugEnabled()) {
1106 + // still print stack trace if debug is enabled
1107 + log.debug("StackTrace for previous Exception: ", e.getCause());
1108 + }
1102 } 1109 }
1103 ctx.getChannel().close(); 1110 ctx.getChannel().close();
1104 } else if (e.getCause() instanceof SwitchStateException) { 1111 } else if (e.getCause() instanceof SwitchStateException) {
......