Java Code Examples for org.jboss.netty.channel.ExceptionEvent.getCause()

The following are Jave code examples for showing how to use getCause() of the org.jboss.netty.channel.ExceptionEvent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: hadoop   File: ShuffleHandler.java   View Source Code Vote up 6 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
    throws Exception {
  Channel ch = e.getChannel();
  Throwable cause = e.getCause();
  if (cause instanceof TooLongFrameException) {
    sendError(ctx, BAD_REQUEST);
    return;
  } else if (cause instanceof IOException) {
    if (cause instanceof ClosedChannelException) {
      LOG.debug("Ignoring closed channel error", cause);
      return;
    }
    String message = String.valueOf(cause.getMessage());
    if (IGNORABLE_ERROR_MESSAGE.matcher(message).matches()) {
      LOG.debug("Ignoring client socket close", cause);
      return;
    }
  }

  LOG.error("Shuffle error: ", cause);
  if (ch.isConnected()) {
    LOG.error("Shuffle error " + e);
    sendError(ctx, INTERNAL_SERVER_ERROR);
  }
}
 
Example 2
Project: athena   File: OspfInterfaceChannelHandler.java   View Source Code Vote up 6 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent
        e) throws Exception {
    log.debug("[exceptionCaught]: " + e.toString());
    if (e.getCause() instanceof ReadTimeoutException) {
        log.debug("Disconnecting device {} due to read timeout", e.getChannel().getRemoteAddress());
        return;
    } else if (e.getCause() instanceof ClosedChannelException) {
        log.debug("Channel for OSPF {} already closed", e.getChannel().getRemoteAddress());
    } else if (e.getCause() instanceof IOException) {
        log.debug("Disconnecting OSPF {} due to IO Error: {}", e.getChannel().getRemoteAddress(),
                  e.getCause().getMessage());
    } else if (e.getCause() instanceof OspfParseException) {
        OspfParseException errMsg = (OspfParseException) e.getCause();
        byte errorCode = errMsg.errorCode();
        byte errorSubCode = errMsg.errorSubCode();
        log.debug("Error while parsing message from OSPF {}, ErrorCode {}",
                  e.getChannel().getRemoteAddress(), errorCode);
    } else if (e.getCause() instanceof RejectedExecutionException) {
        log.debug("Could not process message: queue full");
    } else {
        log.debug("Error while processing message from OSPF {}, {}",
                  e.getChannel().getRemoteAddress(), e.getCause().getMessage());
    }
}
 
Example 3
Project: athena   File: IsisChannelHandler.java   View Source Code Vote up 6 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    if (e.getCause() instanceof ReadTimeoutException) {
        log.debug("Disconnecting device {} due to read timeout", e.getChannel().getRemoteAddress());
        return;
    } else if (e.getCause() instanceof ClosedChannelException) {
        log.debug("Channel for ISIS {} already closed", e.getChannel().getRemoteAddress());
    } else if (e.getCause() instanceof IOException) {
        log.debug("Disconnecting ISIS {} due to IO Error: {}", e.getChannel().getRemoteAddress(),
                  e.getCause().getMessage());
    } else if (e.getCause() instanceof IsisParseException) {
        IsisParseException errMsg = (IsisParseException) e.getCause();
        byte errorCode = errMsg.errorCode();
        byte errorSubCode = errMsg.errorSubCode();
        log.debug("Error while parsing message from ISIS {}, ErrorCode {}",
                  e.getChannel().getRemoteAddress(), errorCode);
    } else if (e.getCause() instanceof RejectedExecutionException) {
        log.debug("Could not process message: queue full");
    } else {
        log.debug("Error while processing message from ISIS {}, {}",
                  e.getChannel().getRemoteAddress(), e.getCause().getMessage());
    }
}
 
Example 4
Project: aliyun-oss-hadoop-fs   File: ShuffleHandler.java   View Source Code Vote up 6 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
    throws Exception {
  Channel ch = e.getChannel();
  Throwable cause = e.getCause();
  if (cause instanceof TooLongFrameException) {
    sendError(ctx, BAD_REQUEST);
    return;
  } else if (cause instanceof IOException) {
    if (cause instanceof ClosedChannelException) {
      LOG.debug("Ignoring closed channel error", cause);
      return;
    }
    String message = String.valueOf(cause.getMessage());
    if (IGNORABLE_ERROR_MESSAGE.matcher(message).matches()) {
      LOG.debug("Ignoring client socket close", cause);
      return;
    }
  }

  LOG.error("Shuffle error: ", cause);
  if (ch.isConnected()) {
    LOG.error("Shuffle error " + e);
    sendError(ctx, INTERNAL_SERVER_ERROR);
  }
}
 
Example 5
Project: bigstreams   File: PerChannelBookieClient.java   View Source Code Vote up 6 votes
/**
 * Called by netty when an exception happens in one of the netty threads
 * (mostly due to what we do in the netty threads)
 */
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    Throwable t = e.getCause();
    if (t instanceof CorruptedFrameException || t instanceof TooLongFrameException) {
        LOG.error("Corrupted fram recieved from bookie: " + e.getChannel().getRemoteAddress());
        return;
    }
    if (t instanceof IOException) {
        // these are thrown when a bookie fails, logging them just pollutes
        // the logs (the failure is logged from the listeners on the write
        // operation), so I'll just ignore it here.
        return;
    }

    LOG.fatal("Unexpected exception caught by bookie client channel handler", t);
    // Since we are a library, cant terminate App here, can we?
}
 
Example 6
Project: big-c   File: ShuffleHandler.java   View Source Code Vote up 6 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
    throws Exception {
  Channel ch = e.getChannel();
  Throwable cause = e.getCause();
  if (cause instanceof TooLongFrameException) {
    sendError(ctx, BAD_REQUEST);
    return;
  } else if (cause instanceof IOException) {
    if (cause instanceof ClosedChannelException) {
      LOG.debug("Ignoring closed channel error", cause);
      return;
    }
    String message = String.valueOf(cause.getMessage());
    if (IGNORABLE_ERROR_MESSAGE.matcher(message).matches()) {
      LOG.debug("Ignoring client socket close", cause);
      return;
    }
  }

  LOG.error("Shuffle error: ", cause);
  if (ch.isConnected()) {
    LOG.error("Shuffle error " + e);
    sendError(ctx, INTERNAL_SERVER_ERROR);
  }
}
 
Example 7
Project: fastcatsearch3   File: HttpTransportModule.java   View Source Code Vote up 6 votes
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
//		logger.error("exceptionCaught", e.getCause());
		if (e.getCause() instanceof ReadTimeoutException) {
			if (logger.isTraceEnabled()) {
				logger.trace("Connection timeout [{}]", ctx.getChannel().getRemoteAddress());
			}
			ctx.getChannel().close();
		} else {
			if (!isLoaded) {
				// ignore
				return;
			}
			if (!NetworkExceptionHelper.isCloseConnectionException(e.getCause())) {
//				logger.warn("Caught exception while handling client http traffic, closing connection {}", e.getCause(), ctx.getChannel());
				ctx.getChannel().close();
			} else {
//				logger.debug("Caught exception while handling client http traffic, closing connection {}", e.getCause(), ctx.getChannel());
				ctx.getChannel().close();
			}
		}
		
	}
 
Example 8
Project: BJAF3.x   File: RpcServerHandler.java   View Source Code Vote up 6 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
		throws Exception {
	Throwable te = e.getCause();
	if (te instanceof java.io.IOException) {// 网络异常,也有可能是soLinger参数引起
		return;
	}
	logger.error("Unexpected exception from downstream.{}", e.getCause());
	Channel c = e.getChannel();
	try {
		if (c.isWritable()) {
			RpcResponse res = new RpcResponse();
			res.setReturnFlag(RpcConst.ERR_CODE_SERVER_CHANNEL_EXCEPTION);
			res.setReturnMsg(logger.getStackTraceInfo(e.getCause()));
			c.write(res);
		}
	} finally {
		c.close();
	}
	// super.exceptionCaught(ctx, e);
}
 
Example 9
Project: elasticsearch-client-http   File: HttpClient.java   View Source Code Vote up 6 votes
@SuppressWarnings("unchecked")
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    HttpContext<R, T> httpContext = httpContextMap.get(ctx.getChannel());
    try {
        if (httpContext != null && httpContext.getListener() != null) {
            httpContext.getListener().onFailure(e.getCause());
        } else {
            Throwable t = e.getCause();
            logger.error(t.getMessage(), t);
        }
    } finally {
        ctx.getChannel().close();
        httpContextMap.remove(ctx.getChannel());
    }
}
 
Example 10
Project: nfs-client-java   File: ClientIOHandler.java   View Source Code Vote up 6 votes
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    Throwable cause = e.getCause();

    // do not print exception if it is BindException.
    // we are trying to search available port below 1024. It is not good to
    // print a flood
    // of error logs during the searching.
    if (cause instanceof java.net.BindException) {
        return;
    }

    LOG.error("Exception on connection to " + getRemoteAddress(), e.getCause());

    // close the channel unless we are connecting and it is
    // NotYetConnectedException
    if (!((cause instanceof NotYetConnectedException)
            && _connection.getConnectionState().equals(Connection.State.CONNECTING))) {
        ctx.getChannel().close();
    }
}
 
Example 11
Project: hadoop-2.6.0-cdh5.4.3   File: ShuffleHandler.java   View Source Code Vote up 6 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
    throws Exception {
  Channel ch = e.getChannel();
  Throwable cause = e.getCause();
  if (cause instanceof TooLongFrameException) {
    sendError(ctx, BAD_REQUEST);
    return;
  } else if (cause instanceof IOException) {
    if (cause instanceof ClosedChannelException) {
      LOG.debug("Ignoring closed channel error", cause);
      return;
    }
    String message = String.valueOf(cause.getMessage());
    if (IGNORABLE_ERROR_MESSAGE.matcher(message).matches()) {
      LOG.debug("Ignoring client socket close", cause);
      return;
    }
  }

  LOG.error("Shuffle error: ", cause);
  if (ch.isConnected()) {
    LOG.error("Shuffle error " + e);
    sendError(ctx, INTERNAL_SERVER_ERROR);
  }
}
 
Example 12
Project: hadoop-plus   File: ShuffleHandler.java   View Source Code Vote up 6 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
    throws Exception {
  Channel ch = e.getChannel();
  Throwable cause = e.getCause();
  if (cause instanceof TooLongFrameException) {
    sendError(ctx, BAD_REQUEST);
    return;
  } else if (cause instanceof IOException) {
    if (cause instanceof ClosedChannelException) {
      LOG.debug("Ignoring closed channel error", cause);
      return;
    }
    String message = String.valueOf(cause.getMessage());
    if (IGNORABLE_ERROR_MESSAGE.matcher(message).matches()) {
      LOG.debug("Ignoring client socket close", cause);
      return;
    }
  }

  LOG.error("Shuffle error: ", cause);
  if (ch.isConnected()) {
    LOG.error("Shuffle error " + e);
    sendError(ctx, INTERNAL_SERVER_ERROR);
  }
}
 
Example 13
Project: FlexMap   File: ShuffleHandler.java   View Source Code Vote up 6 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
    throws Exception {
  Channel ch = e.getChannel();
  Throwable cause = e.getCause();
  if (cause instanceof TooLongFrameException) {
    sendError(ctx, BAD_REQUEST);
    return;
  } else if (cause instanceof IOException) {
    if (cause instanceof ClosedChannelException) {
      LOG.debug("Ignoring closed channel error", cause);
      return;
    }
    String message = String.valueOf(cause.getMessage());
    if (IGNORABLE_ERROR_MESSAGE.matcher(message).matches()) {
      LOG.debug("Ignoring client socket close", cause);
      return;
    }
  }

  LOG.error("Shuffle error: ", cause);
  if (ch.isConnected()) {
    LOG.error("Shuffle error " + e);
    sendError(ctx, INTERNAL_SERVER_ERROR);
  }
}
 
Example 14
Project: my-dev   File: NettyServerUpstreamHandler.java   View Source Code Vote up 6 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    Throwable t = e.getCause();

    if (this.channelHandler != null) {
        this.channelHandler.onError(this.createContext(t));
    }

    e.getChannel().close();

    if (t instanceof IOException) {
        this.ioErrorLogger.error(Text.ERROR_AT_SERVER, t);
    } else {
        this.logger.error(Text.ERROR_AT_SERVER, t);
    }
}
 
Example 15
Project: hadoop-TCP   File: ShuffleHandler.java   View Source Code Vote up 6 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
    throws Exception {
  Channel ch = e.getChannel();
  Throwable cause = e.getCause();
  if (cause instanceof TooLongFrameException) {
    sendError(ctx, BAD_REQUEST);
    return;
  } else if (cause instanceof IOException) {
    if (cause instanceof ClosedChannelException) {
      LOG.debug("Ignoring closed channel error", cause);
      return;
    }
    String message = String.valueOf(cause.getMessage());
    if (IGNORABLE_ERROR_MESSAGE.matcher(message).matches()) {
      LOG.debug("Ignoring client socket close", cause);
      return;
    }
  }

  LOG.error("Shuffle error: ", cause);
  if (ch.isConnected()) {
    LOG.error("Shuffle error " + e);
    sendError(ctx, INTERNAL_SERVER_ERROR);
  }
}
 
Example 16
Project: BettaServer   File: BettaUdpFileServerHandler.java   View Source Code Vote up 6 votes
@Override
public void exceptionCaught( ChannelHandlerContext ctx, ExceptionEvent e ) throws Exception
{
    Channel ch = e.getChannel( ) ;
    Throwable cause = e.getCause( ) ;
    if( cause instanceof TooLongFrameException )
    {
        sendError( ctx, BAD_REQUEST ) ;
        return ;
    }
    
    cause.printStackTrace( ) ;
    if( ch.isConnected( ) )
    {
        sendError( ctx, INTERNAL_SERVER_ERROR ) ;
    }
}
 
Example 17
Project: hardfs   File: ShuffleHandler.java   View Source Code Vote up 6 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
    throws Exception {
  Channel ch = e.getChannel();
  Throwable cause = e.getCause();
  if (cause instanceof TooLongFrameException) {
    sendError(ctx, BAD_REQUEST);
    return;
  } else if (cause instanceof IOException) {
    if (cause instanceof ClosedChannelException) {
      LOG.debug("Ignoring closed channel error", cause);
      return;
    }
    String message = String.valueOf(cause.getMessage());
    if (IGNORABLE_ERROR_MESSAGE.matcher(message).matches()) {
      LOG.debug("Ignoring client socket close", cause);
      return;
    }
  }

  LOG.error("Shuffle error: ", cause);
  if (ch.isConnected()) {
    LOG.error("Shuffle error " + e);
    sendError(ctx, INTERNAL_SERVER_ERROR);
  }
}
 
Example 18
Project: hadoop-on-lustre2   File: ShuffleHandler.java   View Source Code Vote up 6 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
    throws Exception {
  Channel ch = e.getChannel();
  Throwable cause = e.getCause();
  if (cause instanceof TooLongFrameException) {
    sendError(ctx, BAD_REQUEST);
    return;
  } else if (cause instanceof IOException) {
    if (cause instanceof ClosedChannelException) {
      LOG.debug("Ignoring closed channel error", cause);
      return;
    }
    String message = String.valueOf(cause.getMessage());
    if (IGNORABLE_ERROR_MESSAGE.matcher(message).matches()) {
      LOG.debug("Ignoring client socket close", cause);
      return;
    }
  }

  LOG.error("Shuffle error: ", cause);
  if (ch.isConnected()) {
    LOG.error("Shuffle error " + e);
    sendError(ctx, INTERNAL_SERVER_ERROR);
  }
}
 
Example 19
Project: httptunnel   File: HttpTunnelClientChannelSendHandler.java   View Source Code Vote up 6 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
	final Throwable error = e.getCause();

	if (error instanceof IOException // Connection reset etc
		|| error instanceof ClosedChannelException || error instanceof IllegalArgumentException) { // Invalid
																									// protocol
																									// format
																									// -
																									// bots
																									// etc
		if (LOG.isDebugEnabled())
			LOG.debug("Exception from HttpTunnel send handler: " + error);

		return;
	}

	if (LOG.isWarnEnabled())
		LOG.warn("Exception from HttpTunnel send handler: " + error);
}
 
Example 20
Project: httptunnel   File: HttpTunnelAcceptedChannelHandler.java   View Source Code Vote up 6 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
	final Throwable error = e.getCause();

	if (error instanceof IOException // Connection reset etc
		|| error instanceof ClosedChannelException || error instanceof IllegalArgumentException) { // Invalid
																									// protocol
																									// format
																									// -
																									// bots
																									// etc
		if (LOG.isDebugEnabled())
			LOG.debug("Exception from HttpTunnel send handler: " + error);

		return;
	}

	if (LOG.isWarnEnabled())
		LOG.warn("Exception from HttpTunnel accepted channel handler: " + error);
}
 
Example 21
Project: tez   File: ShuffleHandler.java   View Source Code Vote up 6 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
    throws Exception {
  Channel ch = e.getChannel();
  Throwable cause = e.getCause();
  if (cause instanceof TooLongFrameException) {
    sendError(ctx, BAD_REQUEST);
    return;
  } else if (cause instanceof IOException) {
    if (cause instanceof ClosedChannelException) {
      LOG.debug("Ignoring closed channel error", cause);
      return;
    }
    String message = String.valueOf(cause.getMessage());
    if (IGNORABLE_ERROR_MESSAGE.matcher(message).matches()) {
      LOG.debug("Ignoring client socket close", cause);
      return;
    }
  }

  LOG.error("Shuffle error: ", cause);
  if (ch.isConnected()) {
    LOG.error("Shuffle error " + e);
    sendError(ctx, INTERNAL_SERVER_ERROR);
  }
}
 
Example 22
Project: tez   File: ShuffleHandler.java   View Source Code Vote up 6 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
    throws Exception {
  Channel ch = e.getChannel();
  Throwable cause = e.getCause();
  if (cause instanceof TooLongFrameException) {
    sendError(ctx, BAD_REQUEST);
    return;
  } else if (cause instanceof IOException) {
    if (cause instanceof ClosedChannelException) {
      LOG.debug("Ignoring closed channel error", cause);
      return;
    }
    String message = String.valueOf(cause.getMessage());
    if (IGNORABLE_ERROR_MESSAGE.matcher(message).matches()) {
      LOG.debug("Ignoring client socket close", cause);
      return;
    }
  }

  LOG.error("Shuffle error: ", cause);
  if (ch.isConnected()) {
    LOG.error("Shuffle error " + e);
    sendError(ctx, INTERNAL_SERVER_ERROR);
  }
}
 
Example 23
Project: voyage   File: NettyRpcServerHandler.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
		throws Exception {
	RpcRequest request = (RpcRequest) ctx.getAttachment();
	if (e.getCause() instanceof ReadTimeoutException) {
		// The connection was OK but there was no traffic for last period.
		logger.warn("Disconnecting due to no inbound traffic");
	} else {
		logger.error("", e);
	}
	e.getChannel().close().awaitUninterruptibly();
}
 
Example 24
Project: Elasticsearch   File: NettyTransport.java   View Source Code Vote up 5 votes
protected void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    if (!lifecycle.started()) {
        // ignore
        return;
    }
    if (isCloseConnectionException(e.getCause())) {
        logger.trace("close connection exception caught on transport layer [{}], disconnecting from relevant node", e.getCause(), ctx.getChannel());
        // close the channel, which will cause a node to be disconnected if relevant
        ctx.getChannel().close();
        disconnectFromNodeChannel(ctx.getChannel(), e.getCause());
    } else if (isConnectException(e.getCause())) {
        logger.trace("connect exception caught on transport layer [{}]", e.getCause(), ctx.getChannel());
        // close the channel as safe measure, which will cause a node to be disconnected if relevant
        ctx.getChannel().close();
        disconnectFromNodeChannel(ctx.getChannel(), e.getCause());
    } else if (e.getCause() instanceof CancelledKeyException) {
        logger.trace("cancelled key exception caught on transport layer [{}], disconnecting from relevant node", e.getCause(), ctx.getChannel());
        // close the channel as safe measure, which will cause a node to be disconnected if relevant
        ctx.getChannel().close();
        disconnectFromNodeChannel(ctx.getChannel(), e.getCause());
    } else if (e.getCause() instanceof SizeHeaderFrameDecoder.HttpOnTransportException) {
        // in case we are able to return data, serialize the exception content and sent it back to the client
        if (ctx.getChannel().isOpen()) {
            ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(e.getCause().getMessage().getBytes(Charsets.UTF_8));
            ChannelFuture channelFuture = ctx.getChannel().write(buffer);
            channelFuture.addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                    future.getChannel().close();
                }
            });
        }
    } else {
        logger.warn("exception caught on transport layer [{}], closing connection", e.getCause(), ctx.getChannel());
        // close the channel, which will cause a node to be disconnected if relevant
        ctx.getChannel().close();
        disconnectFromNodeChannel(ctx.getChannel(), e.getCause());
    }
}
 
Example 25
Project: hadoop   File: TestDelegationTokenRemoteFetcher.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
    throws Exception {
  Channel ch = e.getChannel();
  Throwable cause = e.getCause();

  if (LOG.isDebugEnabled())
    LOG.debug(cause.getMessage());
  ch.close().addListener(ChannelFutureListener.CLOSE);
}
 
Example 26
Project: bigstreams   File: TestFilesSendWorker.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
		throws Exception {

	Throwable t = e.getCause();
	if (t != null) {
		t.printStackTrace();
	}

	e.getChannel().close();
}
 
Example 27
Project: bigstreams   File: TestFilesSendWorkerConflict.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
		throws Exception {

	Throwable t = e.getCause();
	if (t != null) {
		t.printStackTrace();
	}

	e.getChannel().close();
}
 
Example 28
Project: bigstreams   File: CoordinationLockHandler.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
		throws Exception {

	e.getChannel().close();
	
	coordinationStatus.setStatus(STATUS.UNKOWN_ERROR, e.toString());
	Throwable error = e.getCause();
	LOG.error(e.toString(), error);

}
 
Example 29
Project: big-c   File: TestDelegationTokenRemoteFetcher.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
    throws Exception {
  Channel ch = e.getChannel();
  Throwable cause = e.getCause();

  if (LOG.isDebugEnabled())
    LOG.debug(cause.getMessage());
  ch.close().addListener(ChannelFutureListener.CLOSE);
}
 
Example 30
Project: incubator-omid   File: TSOChannelHandler.java   View Source Code Vote up 5 votes
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
    if (e.getCause() instanceof ClosedChannelException) {
        LOG.warn("ClosedChannelException caught. Cause: ", e.getCause());
        return;
    }
    LOG.warn("Unexpected exception from downstream. Closing channel {}", ctx.getChannel(), e.getCause());
    ctx.getChannel().close();
}
 
Example 31
Project: incubator-omid   File: ProgrammableTSOServer.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
    if (e.getCause() instanceof ClosedChannelException) {
        return;
    }
    LOG.warn("TSOHandler: Unexpected exception from downstream.", e.getCause());
    Channels.close(e.getChannel());
}
 
Example 32
Project: Camel   File: HttpServerChannelHandler.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent exceptionEvent) throws Exception {

    // only close if we are still allowed to run
    if (consumer.isRunAllowed()) {

        if (exceptionEvent.getCause() instanceof ClosedChannelException) {
            LOG.debug("Channel already closed. Ignoring this exception.");
        } else {
            LOG.debug("Closing channel as an exception was thrown from Netty", exceptionEvent.getCause());
            // close channel in case an exception was thrown
            NettyHelper.close(exceptionEvent.getChannel());
        }
    }
}
 
Example 33
Project: Camel   File: HttpServerMultiplexChannelHandler.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    HttpServerChannelHandler handler = (HttpServerChannelHandler) ctx.getAttachment();
    if (handler != null) {
        handler.exceptionCaught(ctx, e);
    } else {
        if (e.getCause() instanceof ClosedChannelException) {
            // The channel is closed so we do nothing here
            LOG.debug("Channel already closed. Ignoring this exception.");
            return;
        } else {
            if ("Broken pipe".equals(e.getCause().getMessage())) {
                // Can't recover channel at this point. Only valid thing to do is close. A TCP RST is a possible cause for this.
                // Note that trying to write to channel in this state will cause infinite recursion in netty 3.x
                LOG.debug("Channel pipe is broken. Closing channel now.", e);                    
                ctx.getChannel().close();
            } else {
                // we cannot throw the exception here
                LOG.warn("HttpServerChannelHandler is not found as attachment to handle exception, send 404 back to the client.", e.getCause());
                // Now we just send 404 back to the client
                HttpResponse response = new DefaultHttpResponse(HTTP_1_1, NOT_FOUND);
                response.headers().set(Exchange.CONTENT_TYPE, "text/plain");
                response.headers().set(Exchange.CONTENT_LENGTH, 0);
                // Here we don't want to expose the exception detail to the client
                response.setContent(ChannelBuffers.copiedBuffer(new byte[]{}));                
                
                ctx.getChannel().write(response).syncUninterruptibly();
                // close the channel after send error message
                ctx.getChannel().close();
            }
        }
    }
}
 
Example 34
Project: Camel   File: ClientChannelHandler.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent exceptionEvent) throws Exception {
    if (LOG.isTraceEnabled()) {
        LOG.trace("Exception caught at Channel: " + ctx.getChannel(), exceptionEvent.getCause());
    }
     
    if (exceptionHandled) {
        // ignore subsequent exceptions being thrown
        return;
    }

    exceptionHandled = true;
    Throwable cause = exceptionEvent.getCause();

    if (LOG.isDebugEnabled()) {
        LOG.debug("Closing channel as an exception was thrown from Netty", cause);
    }

    Exchange exchange = getExchange(ctx);
    AsyncCallback callback = getAsyncCallback(ctx);

    // the state may not be set
    if (exchange != null && callback != null) {
        Throwable initialCause = exchange.getException();
        if (initialCause != null && initialCause.getCause() == null) {
            initialCause.initCause(cause);
        } else {
            // set the cause on the exchange
            exchange.setException(cause);
        }

        // close channel in case an exception was thrown
        NettyHelper.close(exceptionEvent.getChannel());

        // signal callback
        callback.done(false);
    }
}
 
Example 35
Project: hadoop-2.6.0-cdh5.4.3   File: TestDelegationTokenRemoteFetcher.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
    throws Exception {
  Channel ch = e.getChannel();
  Throwable cause = e.getCause();

  if (LOG.isDebugEnabled())
    LOG.debug(cause.getMessage());
  ch.close().addListener(ChannelFutureListener.CLOSE);
}
 
Example 36
Project: jstorm-0.9.6.3-   File: StormClientHandler.java   View Source Code Vote up 5 votes
/**
 * 
 * @see org.jboss.netty.channel.SimpleChannelUpstreamHandler#exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext, org.jboss.netty.channel.ExceptionEvent)
 */
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent event) {
	Throwable cause = event.getCause();
	if (being_closed.get() == false) {
		if (!(cause instanceof ConnectException)) {
			LOG.info("Connection failed:" + client.getRemoteAddr(), cause);
		}

		client.exceptionChannel(event.getChannel());
		client.reconnect();
	}
}
 
Example 37
Project: learn_jstorm   File: StormClientHandler.java   View Source Code Vote up 5 votes
/**
 * 
 * @see org.jboss.netty.channel.SimpleChannelUpstreamHandler#exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext, org.jboss.netty.channel.ExceptionEvent)
 */
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent event) {
	Throwable cause = event.getCause();
	if (being_closed.get() == false) {
		if (!(cause instanceof ConnectException)) {
			LOG.info("Connection failed:" + client.getRemoteAddr(), cause);
		}

		client.exceptionChannel(event.getChannel());
		client.reconnect();
	}
}
 
Example 38
Project: floodlightLB   File: AbstractRPCChannelHandler.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx,
                            ExceptionEvent e) throws Exception {
    if (e.getCause() instanceof ReadTimeoutException) {
        // read timeout
        logger.error("[{}->{}] Disconnecting RPC node due to read timeout",
                     getLocalNodeIdString(), getRemoteNodeIdString());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof HandshakeTimeoutException) {
        // read timeout
        logger.error("[{}->{}] Disconnecting RPC node due to " +
                "handshake timeout",
                getLocalNodeIdString(), getRemoteNodeIdString());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof ConnectException ||
               e.getCause() instanceof IOException) {
        logger.debug("[{}->{}] {}: {}", 
                     new Object[] {getLocalNodeIdString(),
                                   getRemoteNodeIdString(), 
                                   e.getCause().getClass().getName(),
                                   e.getCause().getMessage()});
    } else {
        logger.error("[{}->{}] An error occurred on RPC channel",
                     new Object[]{getLocalNodeIdString(), 
                                  getRemoteNodeIdString(),
                                  e.getCause()});
        ctx.getChannel().close();
    }
}
 
Example 39
Project: eventsource-android   File: EventSourceChannelHandler.java   View Source Code Vote up 5 votes
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
    throws Exception {
  Throwable error = e.getCause();
  if (error instanceof ConnectException) {
    error = new EventSourceException("Failed to connect to " + uri, error);
  }
  eventSourceHandler.onError(error);
  ctx.getChannel().close();
}
 
Example 40
Project: FlexMap   File: TestDelegationTokenRemoteFetcher.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
    throws Exception {
  Channel ch = e.getChannel();
  Throwable cause = e.getCause();

  if (LOG.isDebugEnabled())
    LOG.debug(cause.getMessage());
  ch.close().addListener(ChannelFutureListener.CLOSE);
}
 
Example 41
Project: cellhealth-ng   File: Handler.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
    Throwable cause = e.getCause();
    if (cause instanceof ConnectException) {
        this.startTime = -1;
        L4j.getL4j().error(new StringBuilder(Error.ERROR_CONNECT).append(cause.getMessage()).toString(), cause);
    }
    if (cause instanceof ReadTimeoutException) {
        L4j.getL4j().error(new StringBuilder(Error.DISCONNECTING_TIMEOUT).append(cause.getMessage()).toString());
    } else {
        L4j.getL4j().error(new StringBuilder(Error.DISCONNECTING_TRAFFIC).append(cause.getMessage()).toString());
    }
    ctx.getChannel().close();
}
 
Example 42
Project: streamdataio-android   File: EventSourceChannelHandler.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    Throwable error = e.getCause();
    if (error instanceof ConnectException) {
        error = new EventSourceException("Failed to connect to " + uri, error);
    }
    eventSourceHandler.onError(error);
    ctx.getChannel().close();
}
 
Example 43
Project: Tstream   File: StormClientHandler.java   View Source Code Vote up 5 votes
/**
 * 
 * @see org.jboss.netty.channel.SimpleChannelUpstreamHandler#exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext, org.jboss.netty.channel.ExceptionEvent)
 */
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent event) {
	Throwable cause = event.getCause();
	if (being_closed.get() == false) {
		if (!(cause instanceof ConnectException)) {
			LOG.info("Connection failed:" + client.getRemoteAddr(), cause);
		}

		client.exceptionChannel(event.getChannel());
		client.reconnect();
	}
}
 
Example 44
Project: elasticsearch-syslog   File: SyslogService.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    if (e.getCause() instanceof BindException) {
        // ignore, this happens when we retry binding to several ports, its fine if we fail...
        return;
    }
    logger.warn("failure caught", e.getCause());
    throw new IOException(e.getCause());
}
 
Example 45
Project: guagua   File: NettyMasterCoordinator.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
    LOG.error("error in service handler", e.getCause());
    e.getChannel().close();
    Throwable cause = e.getCause();
    if(cause != null && cause instanceof GuaguaRuntimeException) {
        throw (GuaguaRuntimeException) cause;
    } else {
        throw new GuaguaRuntimeException(e.getCause());
    }
}
 
Example 46
Project: archived-net-virt-platform   File: JSONMsgHandler.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
    throws Exception {
    if (e.getCause() instanceof IllegalStateException) {
        // hiding exception logging - expected because of the way we do
        // JSON message decoding
        // logger.debug("Illegal State exception ", 
        //        e.getCause().toString());
    } else if (e.getCause() instanceof UnrecognizedPropertyException) {
        logger.error("Jackson unrecognized property error {}", 
                e.getCause());
    } else if (e.getCause() instanceof JsonMappingException) {
        logger.error("Jackson mapping error {}", 
                e.getCause());
    } else if (e.getCause() instanceof JsonParseException) {
        logger.error("Jackson parsing error {}", 
                e.getCause());
    } else if (e.getCause() instanceof ClosedChannelException) {
        logger.error("Netty closed channel error", e.getCause());
    } else if (e.getCause() instanceof ConnectException) {
        logger.error("Connection refused", e.getCause());
    } else if (e.getCause() instanceof IOException) {
        logger.error("IO problem", e.getCause());
    } else {
        super.exceptionCaught(ctx, e);
    }
}
 
Example 47
Project: onos   File: BgpChannelHandler.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {

    log.error("[exceptionCaught]: " + e.toString());

    if (e.getCause() instanceof ClosedChannelException) {
        bgpController.activeSessionExceptionAdd(peerAddr, e.getCause().toString());
        log.debug("Channel for bgp {} already closed", getPeerInfoString());
    } else if (e.getCause() instanceof IOException) {
        log.error("Disconnecting peer {} due to IO Error: {}", getPeerInfoString(), e.getCause().getMessage());
        bgpController.closedSessionExceptionAdd(peerAddr, e.getCause().toString());
        if (log.isDebugEnabled()) {
            // still print stack trace if debug is enabled
            log.debug("StackTrace for previous Exception: ", e.getCause());
        }
        stopSessionTimers();
        ctx.getChannel().close();
    } else if (e.getCause() instanceof BgpParseException) {
        byte[] data = new byte[] {};
        BgpParseException errMsg = (BgpParseException) e.getCause();
        byte errorCode = errMsg.getErrorCode();
        byte errorSubCode = errMsg.getErrorSubCode();
        bgpController.activeSessionExceptionAdd(peerAddr, e.getCause().toString());
        ChannelBuffer tempCb = errMsg.getData();
        if (tempCb != null) {
            int dataLength = tempCb.readableBytes();
            data = new byte[dataLength];
            tempCb.readBytes(data, 0, dataLength);
        }
        sendNotification(errorCode, errorSubCode, data);
    } else if (e.getCause() instanceof RejectedExecutionException) {
        log.warn("Could not process message: queue full");
        bgpController.activeSessionExceptionAdd(peerAddr, e.getCause().toString());
    } else {
        stopSessionTimers();
        log.error("Error while processing message from peer " + getPeerInfoString() + "state " + this.state);
        bgpController.closedSessionExceptionAdd(peerAddr, e.getCause().toString());
        ctx.getChannel().close();
    }
}
 
Example 48
Project: CoVisor   File: ReconnectHandler.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(final ChannelHandlerContext ctx,
        final ExceptionEvent e) {

    final Throwable cause = e.getCause();
    if (cause instanceof ConnectException) {
        return;
    }

    ctx.sendUpstream(e);
}
 
Example 49
Project: incubator-storm   File: StormClientHandler.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent event) {
    Throwable cause = event.getCause();
    if (!(cause instanceof ConnectException)) {
        LOG.info("Connection to "+client.remote_addr+" failed:", cause);
    }
    client.reconnect();
}
 
Example 50
Project: trap   File: NettyWSClient.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception
{
	final Throwable t = e.getCause();
	t.printStackTrace();
	e.getChannel().close();
}
 
Example 51
Project: archived-net-virt-platform   File: OVSDBServerHandler.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
    throws Exception {
    if (e.getCause() instanceof IllegalStateException) {
        logger.debug("Illegal State exception {}", 
                e.getCause().toString());
    } else {
        super.exceptionCaught(ctx, e);
    }
}
 
Example 52
Project: daisy-network   File: RpcServiceHandler.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
		throws Exception {
	if (e.getCause() instanceof IOException) {
		logger.warn(e.getCause().getMessage());
	} else {
		logger.error("server failed", e.getCause());
	}
	e.getChannel().close();
}
 
Example 53
Project: daisy-network   File: RpcClientHandler.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
		throws Exception {
	if (e.getCause() instanceof ConnectException) {
		logger.warn("connect refused :{}({}/{})", new Object[] {
				serverConfig.getName(), serverConfig.getInternalIp(),
				serverConfig.getInternalPort() });
	} else {
		logger.error("exception exists:", e.getCause());
	}
}
 
Example 54
Project: onos   File: FpmSessionHandler.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
        throws Exception {
    if (e.getCause() instanceof ReadTimeoutException) {
        log.warn("Haven't heard from FPM client for a while");
    } else {
        log.error("Exception thrown while handling FPM message", e.getCause());
    }
    if (channel != null) {
        channel.close();
    }
    handleDisconnect();
}
 
Example 55
Project: andy   File: SpdySessionHandler.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
        throws Exception {

    Throwable cause = e.getCause();
    if (cause instanceof SpdyProtocolException) {
        issueSessionError(ctx, e.getChannel(), null, SpdySessionStatus.PROTOCOL_ERROR);
    }

    super.exceptionCaught(ctx, e);
}
 
Example 56
Project: James   File: ImapChannelUpstreamHandler.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    getLogger(ctx.getChannel()).debug("Error while processing imap request", e.getCause());

    if (e.getCause() instanceof TooLongFrameException) {

        // Max line length exceeded
        // See RFC 2683 section 3.2.1
        //
        // "For its part, a server should allow for a command line of at
        // least
        // 8000 octets. This provides plenty of leeway for accepting
        // reasonable
        // length commands from clients. The server should send a BAD
        // response
        // to a command that does not end within the server's maximum
        // accepted
        // command length."
        //
        // See also JAMES-1190
        ImapResponseComposer composer = (ImapResponseComposer) ctx.getAttachment();
        composer.untaggedResponse(ImapConstants.BAD + " failed. Maximum command line length exceeded");
    } else {
        // logout on error not sure if that is the best way to handle it
        final ImapSession imapSession = (ImapSession) attributes.get(ctx.getChannel());
        if (imapSession != null)
            imapSession.logout();

        // Make sure we close the channel after all the buffers were flushed out
        Channel channel = ctx.getChannel();
        if (channel.isConnected()) {
            channel.write(ChannelBuffers.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
        }

    }

}
 
Example 57
Project: jstorm   File: StormClientHandler.java   View Source Code Vote up 5 votes
/**
 * @see org.jboss.netty.channel.SimpleChannelUpstreamHandler#exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext,
 * org.jboss.netty.channel.ExceptionEvent)
 */
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent event) {
    Throwable cause = event.getCause();
    if (!being_closed.get()) {
        if (!(cause instanceof ConnectException)) {
            LOG.info("Connection failed:" + client.getRemoteAddr(), cause);
        }

        client.exceptionChannel(event.getChannel());
        client.reconnect();
    }
}
 
Example 58
Project: jmemcached   File: MemcachedResponseEncoder.java   View Source Code Vote up 5 votes
/**
 * Handle exceptions in protocol processing. Exceptions are either client or internal errors.  Report accordingly.
 *
 * @param ctx
 * @param e
 * @throws Exception
 */
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    try {
        throw e.getCause();
    } catch (ClientException ce) {
        if (ctx.getChannel().isOpen())
            ctx.getChannel().write(CLIENT_ERROR);
    } catch (Throwable tr) {
        logger.error("error", tr);
        if (ctx.getChannel().isOpen())
            ctx.getChannel().write(ERROR);
    }
}
 
Example 59
Project: jmemcached   File: MemcachedBinaryResponseEncoder.java   View Source Code Vote up 5 votes
/**
 * Handle exceptions in protocol processing. Exceptions are either client or internal errors.  Report accordingly.
 *
 * @param ctx
 * @param e
 * @throws Exception
 */
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    try {
        throw e.getCause();
    } catch (UnknownCommandException unknownCommand) {
        if (ctx.getChannel().isOpen())
            ctx.getChannel().write(constructHeader(MemcachedBinaryCommandDecoder.BinaryOp.Noop, null, null, null, (short)0x0081, 0, 0));
    } catch (Throwable err) {
        logger.error("error", err);
        if (ctx.getChannel().isOpen())
            ctx.getChannel().close();
    }
}
 
Example 60
Project: jmx-daemon   File: JmxRequestHandler.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    if (e.getCause() instanceof IOException && e.getCause().getMessage().equals("Connection reset by peer")) {
        // we don't care
        return;
    }
    log.warn("Unexpected Error", e.getCause());
    ctx.getChannel().close();
}
 
Example 61
Project: sedge   File: MessagingServer.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
        throws Exception {
    if (e.getCause() instanceof ClosedChannelException) {
        // these are part of life
        // XXX Debug logging might be good
        return;
    }
    super.exceptionCaught(ctx, e);
}
 
Example 62
Project: OpenVirteX   File: ReconnectHandler.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(final ChannelHandlerContext ctx,
        final ExceptionEvent e) {

    final Throwable cause = e.getCause();
    if (cause instanceof ConnectException) {
        return;
    }

    ctx.sendUpstream(e);
}
 
Example 63
Project: sedge   File: MessagingClient.java   View Source Code Vote up 5 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
        throws Exception {
    if (e.getCause() instanceof ClosedChannelException) {
        // these are part of life
        // XXX Debug logging might be good
        return;
    }
    super.exceptionCaught(ctx, e);
}
 
Example 64
Project: athena   File: OFChannelHandler.java   View Source Code Vote up 4 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
        throws Exception {
    if (e.getCause() instanceof ReadTimeoutException) {
        // switch timeout
        log.error("Disconnecting switch {} due to read timeout",
                getSwitchInfoString());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof HandshakeTimeoutException) {
        log.error("Disconnecting switch {}: failed to complete handshake",
                getSwitchInfoString());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof ClosedChannelException) {
        log.debug("Channel for sw {} already closed", getSwitchInfoString());
    } else if (e.getCause() instanceof IOException) {
        if (!e.getCause().getMessage().equals(RESET_BY_PEER) &&
                !e.getCause().getMessage().equals(BROKEN_PIPE)) {
            log.error("Disconnecting switch {} due to IO Error: {}",
                      getSwitchInfoString(), e.getCause().getMessage());
            if (log.isDebugEnabled()) {
                // still print stack trace if debug is enabled
                log.debug("StackTrace for previous Exception: ", e.getCause());
            }
        }
        ctx.getChannel().close();
    } else if (e.getCause() instanceof SwitchStateException) {
        log.error("Disconnecting switch {} due to switch state error: {}",
                getSwitchInfoString(), e.getCause().getMessage());
        if (log.isDebugEnabled()) {
            // still print stack trace if debug is enabled
            log.debug("StackTrace for previous Exception: ", e.getCause());
        }
        ctx.getChannel().close();
    } else if (e.getCause() instanceof OFParseError) {
        log.error("Disconnecting switch "
                + getSwitchInfoString() +
                " due to message parse failure",
                e.getCause());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof RejectedExecutionException) {
        log.warn("Could not process message: queue full");
    } else {
        log.error("Error while processing message from switch "
                + getSwitchInfoString()
                + "state " + this.state, e.getCause());
        ctx.getChannel().close();
    }
}
 
Example 65
Project: athena   File: PcepChannelHandler.java   View Source Code Vote up 4 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    PcepErrorMsg errMsg;
    log.info("exceptionCaught: " + e.toString());

    if (e.getCause() instanceof ReadTimeoutException) {
        if (ChannelState.OPENWAIT == state) {
            // When ReadTimeout timer is expired in OPENWAIT state, it is considered
            // OpenWait timer.
            errMsg = getErrorMsg(PcepErrorDetailInfo.ERROR_TYPE_1, PcepErrorDetailInfo.ERROR_VALUE_2);
            log.debug("Sending PCEP-ERROR message to PCC.");
            channel.write(Collections.singletonList(errMsg));
            channel.close();
            state = ChannelState.INIT;
            return;
        } else if (ChannelState.KEEPWAIT == state) {
            // When ReadTimeout timer is expired in KEEPWAIT state, is is considered
            // KeepWait timer.
            errMsg = getErrorMsg(PcepErrorDetailInfo.ERROR_TYPE_1, PcepErrorDetailInfo.ERROR_VALUE_7);
            log.debug("Sending PCEP-ERROR message to PCC.");
            channel.write(Collections.singletonList(errMsg));
            channel.close();
            state = ChannelState.INIT;
            return;
        }
    } else if (e.getCause() instanceof ClosedChannelException) {
        log.debug("Channel for pc {} already closed", getClientInfoString());
    } else if (e.getCause() instanceof IOException) {
        log.error("Disconnecting client {} due to IO Error: {}", getClientInfoString(), e.getCause().getMessage());
        if (log.isDebugEnabled()) {
            // still print stack trace if debug is enabled
            log.debug("StackTrace for previous Exception: ", e.getCause());
        }
        channel.close();
    } else if (e.getCause() instanceof PcepParseException) {
        PcepParseException errMsgParse = (PcepParseException) e.getCause();
        byte errorType = errMsgParse.getErrorType();
        byte errorValue = errMsgParse.getErrorValue();

        if ((errorType == (byte) 0x0) && (errorValue == (byte) 0x0)) {
            processUnknownMsg();
        } else {
            errMsg = getErrorMsg(errorType, errorValue);
            log.debug("Sending PCEP-ERROR message to PCC.");
            channel.write(Collections.singletonList(errMsg));
        }
    } else if (e.getCause() instanceof RejectedExecutionException) {
        log.warn("Could not process message: queue full");
    } else {
        log.error("Error while processing message from client " + getClientInfoString() + "state " + this.state);
        channel.close();
    }
}
 
Example 66
Project: athena   File: BgpChannelHandler.java   View Source Code Vote up 4 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {

    log.info("[exceptionCaught]: " + e.toString());

    if (e.getCause() instanceof ReadTimeoutException) {
        // device timeout
        log.error("Disconnecting device {} due to read timeout", getPeerInfoString());
        sendNotification(BgpErrorType.HOLD_TIMER_EXPIRED, (byte) 0, null);
        state = ChannelState.IDLE;
        stopKeepAliveTimer();
        ctx.getChannel().close();
        return;
    } else if (e.getCause() instanceof ClosedChannelException) {
        log.debug("Channel for bgp {} already closed", getPeerInfoString());
    } else if (e.getCause() instanceof IOException) {
        log.error("Disconnecting peer {} due to IO Error: {}", getPeerInfoString(), e.getCause().getMessage());
        if (log.isDebugEnabled()) {
            // still print stack trace if debug is enabled
            log.debug("StackTrace for previous Exception: ", e.getCause());
        }
        stopKeepAliveTimer();
        ctx.getChannel().close();
    } else if (e.getCause() instanceof BgpParseException) {
        byte[] data = new byte[] {};
        BgpParseException errMsg = (BgpParseException) e.getCause();
        byte errorCode = errMsg.getErrorCode();
        byte errorSubCode = errMsg.getErrorSubCode();
        ChannelBuffer tempCb = errMsg.getData();
        if (tempCb != null) {
            int dataLength = tempCb.readableBytes();
            data = new byte[dataLength];
            tempCb.readBytes(data, 0, dataLength);
        }
        sendNotification(errorCode, errorSubCode, data);
    } else if (e.getCause() instanceof RejectedExecutionException) {
        log.warn("Could not process message: queue full");
    } else {
        stopKeepAliveTimer();
        log.error("Error while processing message from peer " + getPeerInfoString() + "state " + this.state);
        ctx.getChannel().close();
    }
}
 
Example 67
Project: iTAP-controller   File: AbstractRPCChannelHandler.java   View Source Code Vote up 4 votes
@Override
@LogMessageDocs({
    @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] Disconnecting client due to read timeout",
            explanation="The connected client has failed to send any " +
                        "messages or respond to echo requests",
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
    @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] Disconnecting RPC node due to " +
                "handshake timeout",
            explanation="The remote node did not complete the handshake",
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
            @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] IOException: {message}",
            explanation="There was an error communicating with the " + 
                        "remote client",
            recommendation=LogMessageDoc.GENERIC_ACTION),
            @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] ConnectException: {message} {error}",
            explanation="There was an error connecting to the " + 
                        "remote node",
            recommendation=LogMessageDoc.GENERIC_ACTION),
    @LogMessageDoc(level="ERROR",
            message="[{}->{}] An error occurred on RPC channel",
            explanation="An error occurred processing the message",
            recommendation=LogMessageDoc.GENERIC_ACTION),
})
public void exceptionCaught(ChannelHandlerContext ctx,
                            ExceptionEvent e) throws Exception {
    if (e.getCause() instanceof ReadTimeoutException) {
        // read timeout
        logger.error("[{}->{}] Disconnecting RPC node due to read timeout",
                     getLocalNodeIdString(), getRemoteNodeIdString());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof HandshakeTimeoutException) {
        // read timeout
        logger.error("[{}->{}] Disconnecting RPC node due to " +
                "handshake timeout",
                getLocalNodeIdString(), getRemoteNodeIdString());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof ConnectException ||
               e.getCause() instanceof IOException) {
        logger.debug("[{}->{}] {}: {}", 
                     new Object[] {getLocalNodeIdString(),
                                   getRemoteNodeIdString(), 
                                   e.getCause().getClass().getName(),
                                   e.getCause().getMessage()});
    } else {
        logger.error("[{}->{}] An error occurred on RPC channel",
                     new Object[]{getLocalNodeIdString(), 
                                  getRemoteNodeIdString(),
                                  e.getCause()});
        ctx.getChannel().close();
    }
}
 
Example 68
Project: bigstreams   File: LogWriterHandler.java   View Source Code Vote up 4 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
		throws Exception {

	AgentSession agentSession = (AgentSession) ctx.getAttachment();

	if (agentSession == null) {
		agentSession = new AgentSession("unkown");
	}

	Throwable exception = e.getCause();
	NetworkCodes.CODE code = null;
	CollectorStatus.STATUS stat = null;

	if (exception instanceof java.net.ConnectException) {
		code = NetworkCodes.CODE.COORDINATION_CONNECTION_ERROR;
		stat = CollectorStatus.STATUS.COORDINATION_ERROR;
	} else if (exception instanceof CoordinationException) {
		CoordinationException coordExcp = (CoordinationException) exception;
		if (coordExcp.isConnectException()) {
			code = NetworkCodes.CODE.COORDINATION_CONNECTION_ERROR;
			stat = CollectorStatus.STATUS.COORDINATION_ERROR;
		} else {
			code = NetworkCodes.CODE.COORDINATION_LOCK_ERROR;
			stat = CollectorStatus.STATUS.COORDINATION_LOCK_ERROR;
		}
	} else {
		code = NetworkCodes.CODE.UNKOWN;
		stat = CollectorStatus.STATUS.UNKOWN_ERROR;
	}

	// WRITE STATUS
	try {

		/**
		 * Very important to respond here. The agent will always be
		 * listening for some kind of feedback.
		 */
		ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
		buffer.writeInt(code.num());
		buffer.writeBytes(code.msg().getBytes("UTF-8"));

		if (e.getChannel().isOpen()) {

			ChannelFuture future = e.getChannel().write(buffer);

			future.addListener(ChannelFutureListener.CLOSE);

		} else {
			LOG.error("Channel was closed by agent "
					+ agentSession.getAgentName() + ": exception: "
					+ code.num() + " " + code.msg() + " cause: "
					+ exception + " cannot be written to agent");
		}
		collectorStatus.setStatus(stat, e.getCause().toString());

		collectorStatus.incCounter("Errors_Caught", 1);

		LOG.error(agentSession.toString());
		LOG.error(exception.toString(), exception);
		
		// LOG.error(exception, exception);
	} catch (Throwable t) {
		LOG.error("Throwed exception in catchException " + t);
	}

}
 
Example 69
Project: QoS-floodlight   File: AbstractRPCChannelHandler.java   View Source Code Vote up 4 votes
@Override
@LogMessageDocs({
    @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] Disconnecting client due to read timeout",
            explanation="The connected client has failed to send any " +
                        "messages or respond to echo requests",
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
    @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] Disconnecting RPC node due to " +
                "handshake timeout",
            explanation="The remote node did not complete the handshake",
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
            @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] IOException: {message}",
            explanation="There was an error communicating with the " + 
                        "remote client",
            recommendation=LogMessageDoc.GENERIC_ACTION),
            @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] ConnectException: {message} {error}",
            explanation="There was an error connecting to the " + 
                        "remote node",
            recommendation=LogMessageDoc.GENERIC_ACTION),
    @LogMessageDoc(level="ERROR",
            message="[{}->{}] An error occurred on RPC channel",
            explanation="An error occurred processing the message",
            recommendation=LogMessageDoc.GENERIC_ACTION),
})
public void exceptionCaught(ChannelHandlerContext ctx,
                            ExceptionEvent e) throws Exception {
    if (e.getCause() instanceof ReadTimeoutException) {
        // read timeout
        logger.error("[{}->{}] Disconnecting RPC node due to read timeout",
                     getLocalNodeIdString(), getRemoteNodeIdString());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof HandshakeTimeoutException) {
        // read timeout
        logger.error("[{}->{}] Disconnecting RPC node due to " +
                "handshake timeout",
                getLocalNodeIdString(), getRemoteNodeIdString());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof ConnectException ||
               e.getCause() instanceof IOException) {
        logger.debug("[{}->{}] {}: {}", 
                     new Object[] {getLocalNodeIdString(),
                                   getRemoteNodeIdString(), 
                                   e.getCause().getClass().getName(),
                                   e.getCause().getMessage()});
    } else {
        logger.error("[{}->{}] An error occurred on RPC channel",
                     new Object[]{getLocalNodeIdString(), 
                                  getRemoteNodeIdString(),
                                  e.getCause()});
        ctx.getChannel().close();
    }
}
 
Example 70
Project: nfs-rpc   File: NettyClientHandler.java   View Source Code Vote up 4 votes
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
  if (!(e.getCause() instanceof IOException)) {
    // only log
    LOGGER.error("catch some exception not IOException", e.getCause());
  }
}
 
Example 71
Project: nfs-rpc   File: NettyServerHandler.java   View Source Code Vote up 4 votes
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
  if (!(e.getCause() instanceof IOException)) {
    // only log
    LOGGER.error("catch some exception not IOException", e.getCause());
  }
}
 
Example 72
Project: fast-failover-demo   File: AbstractRPCChannelHandler.java   View Source Code Vote up 4 votes
@Override
@LogMessageDocs({
    @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] Disconnecting client due to read timeout",
            explanation="The connected client has failed to send any " +
                        "messages or respond to echo requests",
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
    @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] Disconnecting RPC node due to " +
                "handshake timeout",
            explanation="The remote node did not complete the handshake",
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
            @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] IOException: {message}",
            explanation="There was an error communicating with the " + 
                        "remote client",
            recommendation=LogMessageDoc.GENERIC_ACTION),
            @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] ConnectException: {message} {error}",
            explanation="There was an error connecting to the " + 
                        "remote node",
            recommendation=LogMessageDoc.GENERIC_ACTION),
    @LogMessageDoc(level="ERROR",
            message="[{}->{}] An error occurred on RPC channel",
            explanation="An error occurred processing the message",
            recommendation=LogMessageDoc.GENERIC_ACTION),
})
public void exceptionCaught(ChannelHandlerContext ctx,
                            ExceptionEvent e) throws Exception {
    if (e.getCause() instanceof ReadTimeoutException) {
        // read timeout
        logger.error("[{}->{}] Disconnecting RPC node due to read timeout",
                     getLocalNodeIdString(), getRemoteNodeIdString());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof HandshakeTimeoutException) {
        // read timeout
        logger.error("[{}->{}] Disconnecting RPC node due to " +
                "handshake timeout",
                getLocalNodeIdString(), getRemoteNodeIdString());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof ConnectException ||
               e.getCause() instanceof IOException) {
        logger.debug("[{}->{}] {}: {}", 
                     new Object[] {getLocalNodeIdString(),
                                   getRemoteNodeIdString(), 
                                   e.getCause().getClass().getName(),
                                   e.getCause().getMessage()});
    } else {
        logger.error("[{}->{}] An error occurred on RPC channel",
                     new Object[]{getLocalNodeIdString(), 
                                  getRemoteNodeIdString(),
                                  e.getCause()});
        ctx.getChannel().close();
    }
}
 
Example 73
Project: migration-tool   File: NettyClientHandler.java   View Source Code Vote up 4 votes
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
	if (!(e.getCause() instanceof IOException)) {
		log.error("catch some exception not IOException", e.getCause());
	}
}
 
Example 74
Project: migration-tool   File: NettyServerHandler.java   View Source Code Vote up 4 votes
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
	if (!(e.getCause() instanceof IOException)) {
		log.error("catch some exception not IOException", e.getCause());
	}
}
 
Example 75
Project: floodlightLB   File: OFChannelHandler.java   View Source Code Vote up 4 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
		throws Exception {
	if (e.getCause() instanceof ReadTimeoutException) {

		if (featuresReply.getVersion().compareTo(OFVersion.OF_13) < 0) {
			log.error("Disconnecting switch {} due to read timeout on main cxn.",
					getConnectionInfoString());
			ctx.getChannel().close();
		} else {
			if (featuresReply.getAuxiliaryId().equals(OFAuxId.MAIN)) {
				log.error("Disconnecting switch {} due to read timeout on main cxn.",
						getConnectionInfoString());
				ctx.getChannel().close();
			} else {
				// We only don't disconnect on aux connections
				log.warn("Switch {} encountered read timeout on aux cxn.",
						getConnectionInfoString());
			}
		}
		// Increment counters
		counters.switchDisconnectReadTimeout.increment();

	} else if (e.getCause() instanceof HandshakeTimeoutException) {
		log.error("Disconnecting switch {}: failed to complete handshake. Channel handshake complete : {}",
				getConnectionInfoString(),
				this.state.channelHandshakeComplete);
		counters.switchDisconnectHandshakeTimeout.increment();
		ctx.getChannel().close();
	} else if (e.getCause() instanceof ClosedChannelException) {
		log.debug("Channel for sw {} already closed", getConnectionInfoString());
	} else if (e.getCause() instanceof IOException) {
		log.error("Disconnecting switch {} due to IO Error: {}",
				getConnectionInfoString(), e.getCause().getMessage());
		if (log.isDebugEnabled()) {
			// still print stack trace if debug is enabled
			log.debug("StackTrace for previous Exception: ", e.getCause());
		}
		counters.switchDisconnectIOError.increment();
		ctx.getChannel().close();
	} else if (e.getCause() instanceof SwitchStateException) {
		log.error("Disconnecting switch {} due to switch state error: {}",
				getConnectionInfoString(), e.getCause().getMessage());
		if (log.isDebugEnabled()) {
			// still print stack trace if debug is enabled
			log.debug("StackTrace for previous Exception: ", e.getCause());
		}
		counters.switchDisconnectSwitchStateException.increment();
		ctx.getChannel().close();
	} else if (e.getCause() instanceof OFAuxException) {
		log.error("Disconnecting switch {} due to OF Aux error: {}",
				getConnectionInfoString(), e.getCause().getMessage());
		if (log.isDebugEnabled()) {
			// still print stack trace if debug is enabled
			log.debug("StackTrace for previous Exception: ", e.getCause());
		}
		counters.switchDisconnectSwitchStateException.increment();
		ctx.getChannel().close();
	} else if (e.getCause() instanceof OFParseError) {
		log.error("Disconnecting switch "
				+ getConnectionInfoString() +
				" due to message parse failure",
				e.getCause());
		counters.switchDisconnectParseError.increment();
		ctx.getChannel().close();
	} else if (e.getCause() instanceof RejectedExecutionException) {
		log.warn("Could not process message: queue full");
		counters.rejectedExecutionException.increment();
	} else if (e.getCause() instanceof IllegalArgumentException) {
		log.error("Illegal argument exception with switch {}. {}", getConnectionInfoString(), e.getCause());
		counters.switchSslConfigurationError.increment();
		ctx.getChannel().close();
	} else {
		log.error("Error while processing message from switch "
				+ getConnectionInfoString()
				+ "state " + this.state, e.getCause());
		counters.switchDisconnectOtherException.increment();
		ctx.getChannel().close();
	}
}
 
Example 76
Project: DSC   File: AbstractRPCChannelHandler.java   View Source Code Vote up 4 votes
@Override
@LogMessageDocs({
    @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] Disconnecting client due to read timeout",
            explanation="The connected client has failed to send any " +
                        "messages or respond to echo requests",
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
    @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] Disconnecting RPC node due to " +
                "handshake timeout",
            explanation="The remote node did not complete the handshake",
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
            @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] IOException: {message}",
            explanation="There was an error communicating with the " + 
                        "remote client",
            recommendation=LogMessageDoc.GENERIC_ACTION),
            @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] ConnectException: {message} {error}",
            explanation="There was an error connecting to the " + 
                        "remote node",
            recommendation=LogMessageDoc.GENERIC_ACTION),
    @LogMessageDoc(level="ERROR",
            message="[{}->{}] An error occurred on RPC channel",
            explanation="An error occurred processing the message",
            recommendation=LogMessageDoc.GENERIC_ACTION),
})
public void exceptionCaught(ChannelHandlerContext ctx,
                            ExceptionEvent e) throws Exception {
    if (e.getCause() instanceof ReadTimeoutException) {
        // read timeout
        logger.error("[{}->{}] Disconnecting RPC node due to read timeout",
                     getLocalNodeIdString(), getRemoteNodeIdString());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof HandshakeTimeoutException) {
        // read timeout
        logger.error("[{}->{}] Disconnecting RPC node due to " +
                "handshake timeout",
                getLocalNodeIdString(), getRemoteNodeIdString());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof ConnectException ||
               e.getCause() instanceof IOException) {
        logger.debug("[{}->{}] {}: {}", 
                     new Object[] {getLocalNodeIdString(),
                                   getRemoteNodeIdString(), 
                                   e.getCause().getClass().getName(),
                                   e.getCause().getMessage()});
    } else {
        logger.error("[{}->{}] An error occurred on RPC channel",
                     new Object[]{getLocalNodeIdString(), 
                                  getRemoteNodeIdString(),
                                  e.getCause()});
        ctx.getChannel().close();
    }
}
 
Example 77
Project: floodlight_with_topoguard   File: AbstractRPCChannelHandler.java   View Source Code Vote up 4 votes
@Override
@LogMessageDocs({
    @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] Disconnecting client due to read timeout",
            explanation="The connected client has failed to send any " +
                        "messages or respond to echo requests",
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
    @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] Disconnecting RPC node due to " +
                "handshake timeout",
            explanation="The remote node did not complete the handshake",
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
            @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] IOException: {message}",
            explanation="There was an error communicating with the " + 
                        "remote client",
            recommendation=LogMessageDoc.GENERIC_ACTION),
            @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] ConnectException: {message} {error}",
            explanation="There was an error connecting to the " + 
                        "remote node",
            recommendation=LogMessageDoc.GENERIC_ACTION),
    @LogMessageDoc(level="ERROR",
            message="[{}->{}] An error occurred on RPC channel",
            explanation="An error occurred processing the message",
            recommendation=LogMessageDoc.GENERIC_ACTION),
})
public void exceptionCaught(ChannelHandlerContext ctx,
                            ExceptionEvent e) throws Exception {
    if (e.getCause() instanceof ReadTimeoutException) {
        // read timeout
        logger.error("[{}->{}] Disconnecting RPC node due to read timeout",
                     getLocalNodeIdString(), getRemoteNodeIdString());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof HandshakeTimeoutException) {
        // read timeout
        logger.error("[{}->{}] Disconnecting RPC node due to " +
                "handshake timeout",
                getLocalNodeIdString(), getRemoteNodeIdString());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof ConnectException ||
               e.getCause() instanceof IOException) {
        logger.debug("[{}->{}] {}: {}", 
                     new Object[] {getLocalNodeIdString(),
                                   getRemoteNodeIdString(), 
                                   e.getCause().getClass().getName(),
                                   e.getCause().getMessage()});
    } else {
        logger.error("[{}->{}] An error occurred on RPC channel",
                     new Object[]{getLocalNodeIdString(), 
                                  getRemoteNodeIdString(),
                                  e.getCause()});
        ctx.getChannel().close();
    }
}
 
Example 78
Project: floodlight   File: AbstractRPCChannelHandler.java   View Source Code Vote up 4 votes
@Override
@LogMessageDocs({
    @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] Disconnecting client due to read timeout",
            explanation="The connected client has failed to send any " +
                        "messages or respond to echo requests",
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
    @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] Disconnecting RPC node due to " +
                "handshake timeout",
            explanation="The remote node did not complete the handshake",
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
            @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] IOException: {message}",
            explanation="There was an error communicating with the " + 
                        "remote client",
            recommendation=LogMessageDoc.GENERIC_ACTION),
            @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] ConnectException: {message} {error}",
            explanation="There was an error connecting to the " + 
                        "remote node",
            recommendation=LogMessageDoc.GENERIC_ACTION),
    @LogMessageDoc(level="ERROR",
            message="[{}->{}] An error occurred on RPC channel",
            explanation="An error occurred processing the message",
            recommendation=LogMessageDoc.GENERIC_ACTION),
})
public void exceptionCaught(ChannelHandlerContext ctx,
                            ExceptionEvent e) throws Exception {
    if (e.getCause() instanceof ReadTimeoutException) {
        // read timeout
        logger.error("[{}->{}] Disconnecting RPC node due to read timeout",
                     getLocalNodeIdString(), getRemoteNodeIdString());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof HandshakeTimeoutException) {
        // read timeout
        logger.error("[{}->{}] Disconnecting RPC node due to " +
                "handshake timeout",
                getLocalNodeIdString(), getRemoteNodeIdString());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof ConnectException ||
               e.getCause() instanceof IOException) {
        logger.debug("[{}->{}] {}: {}", 
                     new Object[] {getLocalNodeIdString(),
                                   getRemoteNodeIdString(), 
                                   e.getCause().getClass().getName(),
                                   e.getCause().getMessage()});
    } else {
        logger.error("[{}->{}] An error occurred on RPC channel",
                     new Object[]{getLocalNodeIdString(), 
                                  getRemoteNodeIdString(),
                                  e.getCause()});
        ctx.getChannel().close();
    }
}
 
Example 79
Project: archived-net-virt-platform   File: Controller.java   View Source Code Vote up 4 votes
@Override
@LogMessageDocs({
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to read timeout",
            explanation="The connected switch has failed to send any " +
                        "messages or respond to echo requests",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch}: failed to " +
                    "complete handshake",
            explanation="The switch did not respond correctly " +
                        "to handshake messages",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to IO Error: {}",
            explanation="There was an error communicating with the switch",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to switch " +
                    "state error: {error}",
            explanation="The switch sent an unexpected message",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to " +
                    "message parse failure",
            explanation="Could not parse a message from the switch",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Terminating controller due to storage exception",
            explanation=ERROR_DATABASE,
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
    @LogMessageDoc(level="ERROR",
            message="Could not process message: queue full",
            explanation="OpenFlow messages are arriving faster than " +
                        " the controller can process them.",
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
    @LogMessageDoc(level="ERROR",
            message="Error while processing message " +
                    "from switch {switch} {cause}",
            explanation="An error occurred processing the switch message",
            recommendation=LogMessageDoc.GENERIC_ACTION)
})
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
        throws Exception {
    if (e.getCause() instanceof ReadTimeoutException) {
        // switch timeout
        log.error("Disconnecting switch {} due to read timeout", sw);
        ctx.getChannel().close();
    } else if (e.getCause() instanceof HandshakeTimeoutException) {
        log.error("Disconnecting switch {}: failed to complete handshake",
                  sw);
        ctx.getChannel().close();
    } else if (e.getCause() instanceof ClosedChannelException) {
        //log.warn("Channel for sw {} already closed", sw);
    } else if (e.getCause() instanceof IOException) {
        log.error("Disconnecting switch {} due to IO Error: {}",
                  sw, e.getCause().getMessage());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof SwitchStateException) {
        log.error("Disconnecting switch {} due to switch state error: {}",
                  sw, e.getCause().getMessage());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof MessageParseException) {
        log.error("Disconnecting switch " + sw +
                  " due to message parse failure",
                  e.getCause());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof StorageException) {
        log.error("Terminating controller due to storage exception",
                  e.getCause());
        terminate();
    } else if (e.getCause() instanceof RejectedExecutionException) {
        log.warn("Could not process message: queue full");
    } else {
        log.error("Error while processing message from switch " + sw,
                  e.getCause());
        ctx.getChannel().close();
    }
}
 
Example 80
Project: floodlight-qosmanager   File: Controller.java   View Source Code Vote up 4 votes
@Override
@LogMessageDocs({
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to read timeout",
            explanation="The connected switch has failed to send any " + 
                        "messages or respond to echo requests",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch}: failed to " + 
                    "complete handshake",
            explanation="The switch did not respond correctly " + 
                        "to handshake messages",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to IO Error: {}",
            explanation="There was an error communicating with the switch",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to switch " + 
                    "state error: {error}",
            explanation="The switch sent an unexpected message",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to " +
                    "message parse failure",
            explanation="Could not parse a message from the switch",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Terminating controller due to storage exception",
            explanation=ERROR_DATABASE,
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
    @LogMessageDoc(level="ERROR",
            message="Could not process message: queue full",
            explanation="OpenFlow messages are arriving faster than " +
                        " the controller can process them.",
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
    @LogMessageDoc(level="ERROR",
            message="Error while processing message " +
                    "from switch {switch} {cause}",
            explanation="An error occurred processing the switch message",
            recommendation=LogMessageDoc.GENERIC_ACTION),
})
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
        throws Exception {
    if (e.getCause() instanceof ReadTimeoutException) {
        // switch timeout
        log.error("Disconnecting switch {} due to read timeout", sw);
        ctx.getChannel().close();
    } else if (e.getCause() instanceof HandshakeTimeoutException) {
        log.error("Disconnecting switch {}: failed to complete handshake", 
                  sw);
        ctx.getChannel().close();
    } else if (e.getCause() instanceof ClosedChannelException) {
        //log.warn("Channel for sw {} already closed", sw);
    } else if (e.getCause() instanceof IOException) {
        log.error("Disconnecting switch {} due to IO Error: {}",
                  sw, e.getCause().getMessage());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof SwitchStateException) {
        log.error("Disconnecting switch {} due to switch state error: {}", 
                  sw, e.getCause().getMessage());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof MessageParseException) {
        log.error("Disconnecting switch " + sw +
                  " due to message parse failure", 
                  e.getCause());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof StorageException) {
        log.error("Terminating controller due to storage exception", 
                  e.getCause());
        terminate();
    } else if (e.getCause() instanceof RejectedExecutionException) {
        log.warn("Could not process message: queue full");
    } else {
        log.error("Error while processing message from switch " + sw,
                  e.getCause());
        ctx.getChannel().close();
    }
}
 
Example 81
Project: CoVisor   File: ControllerChannelHandler.java   View Source Code Vote up 4 votes
@Override
public void exceptionCaught(final ChannelHandlerContext ctx,
        final ExceptionEvent e) throws Exception {
    if (e.getCause() instanceof ReadTimeoutException) {
        // switch timeout
        this.log.error("Disconnecting ctrl {} due to read timeout ",
                this.getSwitchInfoString(), e.getCause());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof HandshakeTimeoutException) {
        this.log.error(
                "Disconnecting ctrl {} failed to complete handshake ",
                this.getSwitchInfoString(), e.getCause());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof ClosedChannelException) {
        this.log.error("Channel for ctrl {} already closed",
                this.getSwitchInfoString(), e.getCause());
    } else if (e.getCause() instanceof IOException) {
        this.log.error("Disconnecting ctrl {} due to IO Error.",
                this.getSwitchInfoString(), e.getCause());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof SwitchStateException) {
        this.log.error("Disconnecting ctrl {} due to switch state error",
                this.getSwitchInfoString(), e.getCause());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof MessageParseException) {
        this.log.error(
                "Disconnecting ctrl {} due to message parse failure",
                this.getSwitchInfoString(), e.getCause());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof RejectedExecutionException) {
        this.log.error("Could not process message: queue full",
                e.getCause());

    } else {

        this.log.error(
                "Error while processing message from switch {} state {}",
                this.getSwitchInfoString(), this.state, e.getCause());

        ctx.getChannel().close();
        throw new RuntimeException(e.getCause());
    }
}
 
Example 82
Project: multicastSDN   File: AbstractRPCChannelHandler.java   View Source Code Vote up 4 votes
@Override
@LogMessageDocs({
    @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] Disconnecting client due to read timeout",
            explanation="The connected client has failed to send any " +
                        "messages or respond to echo requests",
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
    @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] Disconnecting RPC node due to " +
                "handshake timeout",
            explanation="The remote node did not complete the handshake",
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
            @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] IOException: {message}",
            explanation="There was an error communicating with the " + 
                        "remote client",
            recommendation=LogMessageDoc.GENERIC_ACTION),
            @LogMessageDoc(level="ERROR",
            message="[{id}->{id}] ConnectException: {message} {error}",
            explanation="There was an error connecting to the " + 
                        "remote node",
            recommendation=LogMessageDoc.GENERIC_ACTION),
    @LogMessageDoc(level="ERROR",
            message="[{}->{}] An error occurred on RPC channel",
            explanation="An error occurred processing the message",
            recommendation=LogMessageDoc.GENERIC_ACTION),
})
public void exceptionCaught(ChannelHandlerContext ctx,
                            ExceptionEvent e) throws Exception {
    if (e.getCause() instanceof ReadTimeoutException) {
        // read timeout
        logger.error("[{}->{}] Disconnecting RPC node due to read timeout",
                     getLocalNodeIdString(), getRemoteNodeIdString());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof HandshakeTimeoutException) {
        // read timeout
        logger.error("[{}->{}] Disconnecting RPC node due to " +
                "handshake timeout",
                getLocalNodeIdString(), getRemoteNodeIdString());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof ConnectException ||
               e.getCause() instanceof IOException) {
        logger.debug("[{}->{}] {}: {}", 
                     new Object[] {getLocalNodeIdString(),
                                   getRemoteNodeIdString(), 
                                   e.getCause().getClass().getName(),
                                   e.getCause().getMessage()});
    } else {
        logger.error("[{}->{}] An error occurred on RPC channel",
                     new Object[]{getLocalNodeIdString(), 
                                  getRemoteNodeIdString(),
                                  e.getCause()});
        ctx.getChannel().close();
    }
}
 
Example 83
Project: onos   File: PcepChannelHandler.java   View Source Code Vote up 4 votes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    PcepErrorMsg errMsg;
    log.info("exceptionCaught: " + e.toString());

    if (e.getCause() instanceof ReadTimeoutException) {
        if (ChannelState.OPENWAIT == state) {
            // When ReadTimeout timer is expired in OPENWAIT state, it is considered
            // OpenWait timer.
            errMsg = getErrorMsg(PcepErrorDetailInfo.ERROR_TYPE_1, PcepErrorDetailInfo.ERROR_VALUE_2);
            log.debug("Sending PCEP-ERROR message to PCC.");
            controller.peerExceptions(peerAddr, e.getCause().toString());
            channel.write(Collections.singletonList(errMsg));
            channel.close();
            state = ChannelState.INIT;
            return;
        } else if (ChannelState.KEEPWAIT == state) {
            // When ReadTimeout timer is expired in KEEPWAIT state, is is considered
            // KeepWait timer.
            errMsg = getErrorMsg(PcepErrorDetailInfo.ERROR_TYPE_1, PcepErrorDetailInfo.ERROR_VALUE_7);
            log.debug("Sending PCEP-ERROR message to PCC.");
            controller.peerExceptions(peerAddr, e.getCause().toString());
            channel.write(Collections.singletonList(errMsg));
            channel.close();
            state = ChannelState.INIT;
            return;
        }
    } else if (e.getCause() instanceof ClosedChannelException) {
        controller.peerExceptions(peerAddr, e.getCause().toString());
        log.debug("Channel for pc {} already closed", getClientInfoString());
    } else if (e.getCause() instanceof IOException) {
        controller.peerExceptions(peerAddr, e.getCause().toString());
        log.error("Disconnecting client {} due to IO Error: {}", getClientInfoString(), e.getCause().getMessage());
        if (log.isDebugEnabled()) {
            // still print stack trace if debug is enabled
            log.debug("StackTrace for previous Exception: ", e.getCause());
        }
        channel.close();
    } else if (e.getCause() instanceof PcepParseException) {
        controller.peerExceptions(peerAddr, e.getCause().toString());
        PcepParseException errMsgParse = (PcepParseException) e.getCause();
        byte errorType = errMsgParse.getErrorType();
        byte errorValue = errMsgParse.getErrorValue();

        if ((errorType == (byte) 0x0) && (errorValue == (byte) 0x0)) {
            processUnknownMsg();
        } else {
            errMsg = getErrorMsg(errorType, errorValue);
            log.debug("Sending PCEP-ERROR message to PCC.");
            channel.write(Collections.singletonList(errMsg));
        }
    } else if (e.getCause() instanceof RejectedExecutionException) {
        log.warn("Could not process message: queue full");
        controller.peerExceptions(peerAddr, e.getCause().toString());
    } else {
        log.error("Error while processing message from client " + getClientInfoString() + "state " + this.state);
        controller.peerExceptions(peerAddr, e.getCause().toString());
        channel.close();
    }
}
 
Example 84
Project: floodlight-nfv   File: Controller.java   View Source Code Vote up 4 votes
@Override
@LogMessageDocs({
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to read timeout",
            explanation="The connected switch has failed to send any " +
                        "messages or respond to echo requests",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch}: failed to " +
                    "complete handshake",
            explanation="The switch did not respond correctly " +
                        "to handshake messages",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to IO Error: {}",
            explanation="There was an error communicating with the switch",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to switch " +
                    "state error: {error}",
            explanation="The switch sent an unexpected message",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to " +
                    "message parse failure",
            explanation="Could not parse a message from the switch",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Terminating controller due to storage exception",
            explanation=ERROR_DATABASE,
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
    @LogMessageDoc(level="ERROR",
            message="Could not process message: queue full",
            explanation="OpenFlow messages are arriving faster than " +
                        " the controller can process them.",
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
    @LogMessageDoc(level="ERROR",
            message="Error while processing message " +
                    "from switch {switch} {cause}",
            explanation="An error occurred processing the switch message",
            recommendation=LogMessageDoc.GENERIC_ACTION)
})
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
        throws Exception {
    if (e.getCause() instanceof ReadTimeoutException) {
        // switch timeout
        log.error("Disconnecting switch {} due to read timeout", sw);
        ctx.getChannel().close();
    } else if (e.getCause() instanceof HandshakeTimeoutException) {
        log.error("Disconnecting switch {}: failed to complete handshake",
                  sw);
        ctx.getChannel().close();
    } else if (e.getCause() instanceof ClosedChannelException) {
        //log.warn("Channel for sw {} already closed", sw);
    } else if (e.getCause() instanceof IOException) {
        log.error("Disconnecting switch {} due to IO Error: {}",
                  sw, e.getCause().getMessage());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof SwitchStateException) {
        log.error("Disconnecting switch {} due to switch state error: {}",
                  sw, e.getCause().getMessage());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof MessageParseException) {
        log.error("Disconnecting switch " + sw +
                  " due to message parse failure",
                  e.getCause());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof StorageException) {
        log.error("Terminating controller due to storage exception",
                  e.getCause());
        terminate();
    } else if (e.getCause() instanceof RejectedExecutionException) {
        log.warn("Could not process message: queue full");
    } else {
        log.error("Error while processing message from switch " + sw,
                  e.getCause());
        ctx.getChannel().close();
    }
}
 
Example 85
Project: sdn-project   File: Controller.java   View Source Code Vote up 4 votes
@Override
@LogMessageDocs({
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to read timeout",
            explanation="The connected switch has failed to send any " + 
                        "messages or respond to echo requests",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch}: failed to " + 
                    "complete handshake",
            explanation="The switch did not respond correctly " + 
                        "to handshake messages",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to IO Error: {}",
            explanation="There was an error communicating with the switch",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to switch " + 
                    "state error: {error}",
            explanation="The switch sent an unexpected message",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to " +
                    "message parse failure",
            explanation="Could not parse a message from the switch",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Terminating controller due to storage exception",
            explanation=ERROR_DATABASE,
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
    @LogMessageDoc(level="ERROR",
            message="Could not process message: queue full",
            explanation="OpenFlow messages are arriving faster than " +
                        " the controller can process them.",
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
    @LogMessageDoc(level="ERROR",
            message="Error while processing message " +
                    "from switch {switch} {cause}",
            explanation="An error occurred processing the switch message",
            recommendation=LogMessageDoc.GENERIC_ACTION)
})
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
        throws Exception {
    if (e.getCause() instanceof ReadTimeoutException) {
        // switch timeout
        log.error("Disconnecting switch {} due to read timeout", sw);
        ctx.getChannel().close();
    } else if (e.getCause() instanceof HandshakeTimeoutException) {
        log.error("Disconnecting switch {}: failed to complete handshake", 
                  sw);
        ctx.getChannel().close();
    } else if (e.getCause() instanceof ClosedChannelException) {
        //log.warn("Channel for sw {} already closed", sw);
    } else if (e.getCause() instanceof IOException) {
        log.error("Disconnecting switch {} due to IO Error: {}",
                  sw, e.getCause().getMessage());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof SwitchStateException) {
        log.error("Disconnecting switch {} due to switch state error: {}", 
                  sw, e.getCause().getMessage());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof MessageParseException) {
        log.error("Disconnecting switch " + sw +
                  " due to message parse failure", 
                  e.getCause());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof StorageException) {
        log.error("Terminating controller due to storage exception", 
                  e.getCause());
        terminate();
    } else if (e.getCause() instanceof RejectedExecutionException) {
        log.warn("Could not process message: queue full");
    } else {
        log.error("Error while processing message from switch " + sw,
                  e.getCause());
        ctx.getChannel().close();
    }
}
 
Example 86
Project: floodlight-oss   File: Controller.java   View Source Code Vote up 4 votes
@Override
@LogMessageDocs({
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to read timeout",
            explanation="The connected switch has failed to send any " +
                        "messages or respond to echo requests",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch}: failed to " +
                    "complete handshake",
            explanation="The switch did not respond correctly " +
                        "to handshake messages",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to IO Error: {}",
            explanation="There was an error communicating with the switch",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to switch " +
                    "state error: {error}",
            explanation="The switch sent an unexpected message",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to " +
                    "message parse failure",
            explanation="Could not parse a message from the switch",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Terminating controller due to storage exception",
            explanation=ERROR_DATABASE,
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
    @LogMessageDoc(level="ERROR",
            message="Could not process message: queue full",
            explanation="OpenFlow messages are arriving faster than " +
                        " the controller can process them.",
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
    @LogMessageDoc(level="ERROR",
            message="Error while processing message " +
                    "from switch {switch} {cause}",
            explanation="An error occurred processing the switch message",
            recommendation=LogMessageDoc.GENERIC_ACTION)
})
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
        throws Exception {
    if (e.getCause() instanceof ReadTimeoutException) {
        // switch timeout
        log.error("Disconnecting switch {} due to read timeout", sw);
        ctx.getChannel().close();
    } else if (e.getCause() instanceof HandshakeTimeoutException) {
        log.error("Disconnecting switch {}: failed to complete handshake",
                  sw);
        ctx.getChannel().close();
    } else if (e.getCause() instanceof ClosedChannelException) {
        //log.warn("Channel for sw {} already closed", sw);
    } else if (e.getCause() instanceof IOException) {
        log.error("Disconnecting switch {} due to IO Error: {}",
                  sw, e.getCause().getMessage());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof SwitchStateException) {
        log.error("Disconnecting switch {} due to switch state error: {}",
                  sw, e.getCause().getMessage());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof MessageParseException) {
        log.error("Disconnecting switch " + sw +
                  " due to message parse failure",
                  e.getCause());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof StorageException) {
        log.error("Terminating controller due to storage exception",
                  e.getCause());
        terminate();
    } else if (e.getCause() instanceof RejectedExecutionException) {
        log.warn("Could not process message: queue full");
    } else {
        log.error("Error while processing message from switch " + sw,
                  e.getCause());
        ctx.getChannel().close();
    }
}
 
Example 87
Project: my-floodlight   File: Controller.java   View Source Code Vote up 4 votes
@Override
@LogMessageDocs({
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to read timeout",
            explanation="The connected switch has failed to send any " + 
                        "messages or respond to echo requests",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch}: failed to " + 
                    "complete handshake",
            explanation="The switch did not respond correctly " + 
                        "to handshake messages",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to IO Error: {}",
            explanation="There was an error communicating with the switch",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to switch " + 
                    "state error: {error}",
            explanation="The switch sent an unexpected message",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to " +
                    "message parse failure",
            explanation="Could not parse a message from the switch",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Terminating controller due to storage exception",
            explanation=ERROR_DATABASE,
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
    @LogMessageDoc(level="ERROR",
            message="Could not process message: queue full",
            explanation="OpenFlow messages are arriving faster than " +
                        " the controller can process them.",
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
    @LogMessageDoc(level="ERROR",
            message="Error while processing message " +
                    "from switch {switch} {cause}",
            explanation="An error occurred processing the switch message",
            recommendation=LogMessageDoc.GENERIC_ACTION)
})
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
        throws Exception {
    if (e.getCause() instanceof ReadTimeoutException) {
        // switch timeout
        log.error("Disconnecting switch {} due to read timeout", sw);
        ctx.getChannel().close();
    } else if (e.getCause() instanceof HandshakeTimeoutException) {
        log.error("Disconnecting switch {}: failed to complete handshake", 
                  sw);
        ctx.getChannel().close();
    } else if (e.getCause() instanceof ClosedChannelException) {
        //log.warn("Channel for sw {} already closed", sw);
    } else if (e.getCause() instanceof IOException) {
        log.error("Disconnecting switch {} due to IO Error: {}",
                  sw, e.getCause().getMessage());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof SwitchStateException) {
        log.error("Disconnecting switch {} due to switch state error: {}", 
                  sw, e.getCause().getMessage());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof MessageParseException) {
        log.error("Disconnecting switch " + sw +
                  " due to message parse failure", 
                  e.getCause());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof StorageException) {
        log.error("Terminating controller due to storage exception", 
                  e.getCause());
        terminate();
    } else if (e.getCause() instanceof RejectedExecutionException) {
        log.warn("Could not process message: queue full");
    } else {
        log.error("Error while processing message from switch " + sw,
                  e.getCause());
        ctx.getChannel().close();
    }
}
 
Example 88
Project: OpenVirteX   File: SwitchChannelHandler.java   View Source Code Vote up 4 votes
@Override
public void exceptionCaught(final ChannelHandlerContext ctx,
        final ExceptionEvent e) throws Exception {
    if (e.getCause() instanceof ReadTimeoutException) {
        // switch timeout
        this.log.error("Disconnecting switch {} due to read timeout ",
                this.getSwitchInfoString());

        ctx.getChannel().close();
    } else if (e.getCause() instanceof HandshakeTimeoutException) {
        this.log.error(
                "Disconnecting switch {} failed to complete handshake ",
                this.getSwitchInfoString());

        ctx.getChannel().close();
    } else if (e.getCause() instanceof ClosedChannelException) {
        this.log.error(
                "Channel for sw {} already closed; switch needs to reconnect",
                this.getSwitchInfoString());

    } else if (e.getCause() instanceof IOException) {
        this.log.error("Disconnecting switch {} due to IO Error.",
                this.getSwitchInfoString());

        ctx.getChannel().close();
    } else if (e.getCause() instanceof SwitchStateException) {
        this.log.error("Disconnecting switch {} due to switch state error",
                this.getSwitchInfoString());

        ctx.getChannel().close();
    } else if (e.getCause() instanceof MessageParseException) {
        this.log.error(
                "Disconnecting switch {} due to message parse failure",
                this.getSwitchInfoString());

        ctx.getChannel().close();
    } else if (e.getCause() instanceof RejectedExecutionException) {
        this.log.error("Could not process message: queue full",
                e.getCause());

    } else {

        this.log.error(
                "Error while processing message from switch {} state {}",
                this.getSwitchInfoString(), this.state, e.getCause());

        ctx.getChannel().close();
        throw new RuntimeException(e.getCause());
    }
    this.log.debug(e.getCause());
}
 
Example 89
Project: OpenVirteX   File: ControllerChannelHandler.java   View Source Code Vote up 4 votes
@Override
public void exceptionCaught(final ChannelHandlerContext ctx,
        final ExceptionEvent e) throws Exception {
    if (e.getCause() instanceof ReadTimeoutException) {
        // switch timeout
        this.log.error("Disconnecting ctrl {} due to read timeout ",
                this.getSwitchInfoString(), e.getCause());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof HandshakeTimeoutException) {
        this.log.error(
                "Disconnecting ctrl {} failed to complete handshake ",
                this.getSwitchInfoString(), e.getCause());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof ClosedChannelException) {
        this.log.error("Channel for ctrl {} already closed",
                this.getSwitchInfoString(), e.getCause());
    } else if (e.getCause() instanceof IOException) {
        this.log.error("Disconnecting ctrl {} due to IO Error.",
                this.getSwitchInfoString(), e.getCause());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof SwitchStateException) {
        this.log.error("Disconnecting ctrl {} due to switch state error",
                this.getSwitchInfoString(), e.getCause());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof MessageParseException) {
        this.log.error(
                "Disconnecting ctrl {} due to message parse failure",
                this.getSwitchInfoString(), e.getCause());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof RejectedExecutionException) {
        this.log.error("Could not process message: queue full",
                e.getCause());

    } else {

        this.log.error(
                "Error while processing message from switch {} state {}",
                this.getSwitchInfoString(), this.state, e.getCause());

        ctx.getChannel().close();
        throw new RuntimeException(e.getCause());
    }
}
 
Example 90
Project: FL_HAND   File: Controller.java   View Source Code Vote up 4 votes
@Override
@LogMessageDocs({
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to read timeout",
            explanation="The connected switch has failed to send any " +
                        "messages or respond to echo requests",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch}: failed to " +
                    "complete handshake",
            explanation="The switch did not respond correctly " +
                        "to handshake messages",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to IO Error: {}",
            explanation="There was an error communicating with the switch",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to switch " +
                    "state error: {error}",
            explanation="The switch sent an unexpected message",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Disconnecting switch {switch} due to " +
                    "message parse failure",
            explanation="Could not parse a message from the switch",
            recommendation=LogMessageDoc.CHECK_SWITCH),
    @LogMessageDoc(level="ERROR",
            message="Terminating controller due to storage exception",
            explanation=ERROR_DATABASE,
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
    @LogMessageDoc(level="ERROR",
            message="Could not process message: queue full",
            explanation="OpenFlow messages are arriving faster than " +
                        " the controller can process them.",
            recommendation=LogMessageDoc.CHECK_CONTROLLER),
    @LogMessageDoc(level="ERROR",
            message="Error while processing message " +
                    "from switch {switch} {cause}",
            explanation="An error occurred processing the switch message",
            recommendation=LogMessageDoc.GENERIC_ACTION)
})
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
        throws Exception {
    if (e.getCause() instanceof ReadTimeoutException) {
        // switch timeout
        log.error("Disconnecting switch {} due to read timeout", sw);
        ctx.getChannel().close();
    } else if (e.getCause() instanceof HandshakeTimeoutException) {
        log.error("Disconnecting switch {}: failed to complete handshake",
                  sw);
        ctx.getChannel().close();
    } else if (e.getCause() instanceof ClosedChannelException) {
        //log.warn("Channel for sw {} already closed", sw);
    } else if (e.getCause() instanceof IOException) {
        log.error("Disconnecting switch {} due to IO Error: {}",
                  sw, e.getCause().getMessage());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof SwitchStateException) {
        log.error("Disconnecting switch {} due to switch state error: {}",
                  sw, e.getCause().getMessage());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof MessageParseException) {
        log.error("Disconnecting switch " + sw +
                  " due to message parse failure",
                  e.getCause());
        ctx.getChannel().close();
    } else if (e.getCause() instanceof StorageException) {
        log.error("Terminating controller due to storage exception",
                  e.getCause());
        terminate();
    } else if (e.getCause() instanceof RejectedExecutionException) {
        log.warn("Could not process message: queue full");
    } else {
        log.error("Error while processing message from switch " + sw,
                  e.getCause());
        ctx.getChannel().close();
    }
}