當前位置: 首頁>>代碼示例>>Java>>正文


Java ExceptionEvent.getCause方法代碼示例

本文整理匯總了Java中org.jboss.netty.channel.ExceptionEvent.getCause方法的典型用法代碼示例。如果您正苦於以下問題:Java ExceptionEvent.getCause方法的具體用法?Java ExceptionEvent.getCause怎麽用?Java ExceptionEvent.getCause使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jboss.netty.channel.ExceptionEvent的用法示例。


在下文中一共展示了ExceptionEvent.getCause方法的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);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:27,代碼來源:ShuffleHandler.java

示例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());
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:26,代碼來源:OspfInterfaceChannelHandler.java

示例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());
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:24,代碼來源:IsisChannelHandler.java

示例4: 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?
}
 
開發者ID:gerritjvv,項目名稱:bigstreams,代碼行數:22,代碼來源:PerChannelBookieClient.java

示例5: 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();
			}
		}
		
	}
 
開發者ID:gncloud,項目名稱:fastcatsearch3,代碼行數:23,代碼來源:HttpTransportModule.java

示例6: 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);
}
 
開發者ID:jbeetle,項目名稱:BJAF3.x,代碼行數:22,代碼來源:RpcServerHandler.java

示例7: 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());
    }
}
 
開發者ID:jprante,項目名稱:elasticsearch-client-http,代碼行數:17,代碼來源:HttpClient.java

示例8: 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();
    }
}
 
開發者ID:EMCECS,項目名稱:nfs-client-java,代碼行數:21,代碼來源:ClientIOHandler.java

示例9: 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);
    }
}
 
開發者ID:kuiwang,項目名稱:my-dev,代碼行數:17,代碼來源:NettyServerUpstreamHandler.java

示例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 ;
    }
    
    cause.printStackTrace( ) ;
    if( ch.isConnected( ) )
    {
        sendError( ctx, INTERNAL_SERVER_ERROR ) ;
    }
}
 
開發者ID:wsyssantos,項目名稱:BettaServer,代碼行數:18,代碼來源:BettaUdpFileServerHandler.java

示例11: exceptionCaught

import org.jboss.netty.channel.ExceptionEvent; //導入方法依賴的package包/類
@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);
}
 
開發者ID:reines,項目名稱:httptunnel,代碼行數:21,代碼來源:HttpTunnelClientChannelSendHandler.java

示例12: exceptionCaught

import org.jboss.netty.channel.ExceptionEvent; //導入方法依賴的package包/類
@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);
}
 
開發者ID:reines,項目名稱:httptunnel,代碼行數:21,代碼來源:HttpTunnelAcceptedChannelHandler.java

示例13: exceptionCaught

import org.jboss.netty.channel.ExceptionEvent; //導入方法依賴的package包/類
@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();
}
 
開發者ID:zhaoshiling1017,項目名稱:voyage,代碼行數:13,代碼來源:NettyRpcServerHandler.java

示例14: exceptionCaught

import org.jboss.netty.channel.ExceptionEvent; //導入方法依賴的package包/類
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());
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:40,代碼來源:NettyTransport.java

示例15: 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 (LOG.isDebugEnabled())
    LOG.debug(cause.getMessage());
  ch.close().addListener(ChannelFutureListener.CLOSE);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:11,代碼來源:TestDelegationTokenRemoteFetcher.java


注:本文中的org.jboss.netty.channel.ExceptionEvent.getCause方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。