本文整理汇总了Java中org.jboss.netty.channel.ExceptionEvent类的典型用法代码示例。如果您正苦于以下问题:Java ExceptionEvent类的具体用法?Java ExceptionEvent怎么用?Java ExceptionEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExceptionEvent类属于org.jboss.netty.channel包,在下文中一共展示了ExceptionEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exceptionCaught
import org.jboss.netty.channel.ExceptionEvent; //导入依赖的package包/类
@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);
}
}
示例2: exceptionCaught
import org.jboss.netty.channel.ExceptionEvent; //导入依赖的package包/类
@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());
}
}
示例3: exceptionCaught
import org.jboss.netty.channel.ExceptionEvent; //导入依赖的package包/类
@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());
}
}
示例4: exceptionCaught
import org.jboss.netty.channel.ExceptionEvent; //导入依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
System.out.println("Server Exception Caught");
e.getCause().printStackTrace();
/**
* Very important to respond here.
* The agent will always be listening for some kind of feedback.
*/
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeInt(500);
ChannelFuture future = e.getChannel().write(buffer);
future.addListener(ChannelFutureListener.CLOSE);
}
示例5: exceptionCaught
import org.jboss.netty.channel.ExceptionEvent; //导入依赖的package包/类
/**
* 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?
}
示例6: exceptionCaught
import org.jboss.netty.channel.ExceptionEvent; //导入依赖的package包/类
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();
}
}
}
示例7: exceptionCaught
import org.jboss.netty.channel.ExceptionEvent; //导入依赖的package包/类
@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);
}
示例8: exceptionCaught
import org.jboss.netty.channel.ExceptionEvent; //导入依赖的package包/类
@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());
}
}
示例9: exceptionCaught
import org.jboss.netty.channel.ExceptionEvent; //导入依赖的package包/类
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();
}
}
示例10: exceptionCaught
import org.jboss.netty.channel.ExceptionEvent; //导入依赖的package包/类
@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;
}
LOG.error("Shuffle error: ", cause);
shuffleMetrics.failedOutput();
if (ch.isConnected()) {
LOG.error("Shuffle error " + e);
sendError(ctx, INTERNAL_SERVER_ERROR);
}
}
示例11: exceptionCaught
import org.jboss.netty.channel.ExceptionEvent; //导入依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
if(!hasCaughtException){
hasCaughtException=true;
e.getChannel().close();
String errMsg = e.getCause().getLocalizedMessage();
logger.debug("TCP Handler exceptionCaught: {} . ", errMsg);
int statusCodeInt = 1;
String statusCode = statusCodeInt + " FAILURE";
tcpWorker.onComplete(tcpWorker.responseSb.toString(), true,
errMsg, errMsg, statusCode, statusCodeInt);
}
}
示例12: exceptionCaught
import org.jboss.netty.channel.ExceptionEvent; //导入依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
if (!hasCaughtException) {
hasCaughtException = true;
String errMsg = e.getCause().toString();
logger.debug("UDP Handler exceptionCaught: {} . ", errMsg);
e.getChannel().close();
int statusCodeInt = 1;
String statusCode = statusCodeInt + " FAILURE";
udpWorker.onComplete(udpWorker.responseSb.toString(), true,
errMsg, errMsg, statusCode, statusCodeInt);
}
}
示例13: exceptionCaught
import org.jboss.netty.channel.ExceptionEvent; //导入依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
Throwable cause = e.getCause();
if (state.getState() == State.INIT_RECONNECT) {
// removed stackTrace when reconnect. so many logs.
logger.info("exceptionCaught() reconnect failed. state:{} {} Caused:{}", state.getString(), e.getChannel(), cause.getMessage());
} else {
logger.warn("exceptionCaught() UnexpectedError happened. state:{} {} Caused:{}", state.getString(), e.getChannel(), cause.getMessage(), cause);
}
// need to handle a error more precisely.
// below code dose not reconnect when node on channel is just hang up or dead without specific reasons.
// state.setClosed();
// Channel channel = e.getChannel();
// if (channel.isConnected()) {
// channel.close();
// }
}
示例14: exceptionCaught
import org.jboss.netty.channel.ExceptionEvent; //导入依赖的package包/类
@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);
}
}
示例15: exceptionCaught
import org.jboss.netty.channel.ExceptionEvent; //导入依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
Channel channel = ctx.getChannel();
logger.error(
"[channel exception] {} \n"
+
"[channel status] channelIsOpen={}, channelIsBound={}, channelIsWriteable={}, channelIsReadable={}, channelIsConnected={} \n"
+
"[stacktrace] {}",
e,
channel.isOpen(), channel.isBound(), channel.isWritable(), channel.isReadable(), channel.isConnected(),
Utils.stackTraceToStr(e.getCause())
);
if (ctx.getChannel().isOpen()) {
ctx.getChannel().close();
}
}