当前位置: 首页>>代码示例>>Java>>正文


Java ChannelHandlerContext.fireExceptionCaught方法代码示例

本文整理汇总了Java中io.netty.channel.ChannelHandlerContext.fireExceptionCaught方法的典型用法代码示例。如果您正苦于以下问题:Java ChannelHandlerContext.fireExceptionCaught方法的具体用法?Java ChannelHandlerContext.fireExceptionCaught怎么用?Java ChannelHandlerContext.fireExceptionCaught使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.netty.channel.ChannelHandlerContext的用法示例。


在下文中一共展示了ChannelHandlerContext.fireExceptionCaught方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: exceptionCaught

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable error) throws Exception {
    if (firstError != null) {
        // Handle only the very first error.
        return;
    }

    // Propagate exception through the pipeline if there are some other handlers.
    if (ctx.pipeline().last() != this) {
        ctx.fireExceptionCaught(error);
    }

    if (error instanceof CodecException) {
        // Ignore since this is an application-level error.
        return;
    }

    if (trace) {
        log.trace("Exception caught in state handler [to={}]", id, error);
    }

    firstError = NettyErrorUtils.unwrap(error);

    ctx.close();
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:26,代码来源:NettyClient.java

示例2: decode

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
private Object decode(ChannelHandlerContext ctx, ByteBuf buffer)
{
    int frameOffset = buffer.readerIndex();
    try {
        TTransport transport = new TChannelBufferInputTransport(buffer);
        TProtocolReader protocol = protocolFactory.getProtocol(transport);

        protocol.readMessageBegin();
        TProtocolUtil.skip(protocol, TType.STRUCT);
        protocol.readMessageEnd();

        int frameLength = buffer.readerIndex() - frameOffset;
        if (frameLength > maxFrameSize) {
            ctx.fireExceptionCaught(new TooLongFrameException("Response message exceeds max size " + maxFrameSize + ": " + frameLength + " - discarded"));
        }

        return buffer.slice(frameOffset, frameLength).retain();
    }
    catch (Throwable th) {
        buffer.readerIndex(frameOffset);
        return null;
    }
}
 
开发者ID:airlift,项目名称:drift,代码行数:24,代码来源:ThriftUnframedDecoder.java

示例3: channelInactive

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
    if (metrics != null) {
        metrics.onDisconnect();
    }

    if (state == CONNECTING) {
        state = DISCONNECTED;

        ctx.fireExceptionCaught(new ConnectException("Got disconnected on handshake [channel=" + id + ']'));
    } else {
        state = DISCONNECTED;

        super.channelInactive(ctx);
    }
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:17,代码来源:NettyClientHandler.java

示例4: exceptionCaught

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
	if(cause instanceof IOException)
	{
		if (logger.isEnabled(internalLevel)) 
		{
			logger.log(internalLevel,cause.getClass().getName()+":"+cause.getLocalizedMessage());
	    }
		return;
	}
	if (logger.isEnabled(internalLevel)) 
	{
		logger.log(internalLevel, format(ctx, "EXCEPTION", cause),cause);
    }
	ctx.fireExceptionCaught(cause);
}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:17,代码来源:LoggerHandler.java

示例5: channelRead

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
  // This must be a single byte buffer - after that follow the SSL handshake
  ByteBuf byteBuf = (ByteBuf) msg;
  byte b = byteBuf.getByte(0);
  byteBuf.release();
  switch (b) {
    case SSL_YES: {
      conn.upgradeToSSL(v -> {
        ctx.pipeline().remove(this);
        upgradeFuture.complete();
      });
      break;
    }
    case SSL_NO: {
      // This case is not tested as our test db is configured for SSL
      ctx.fireExceptionCaught(new Exception("Postgres does not handle SSL"));
      break;
    }
    default:
      ctx.fireExceptionCaught(new Exception("Invalid connection data"));
      break;
  }
}
 
开发者ID:vietj,项目名称:reactive-pg-client,代码行数:25,代码来源:InitiateSslHandler.java

示例6: channelRead

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void channelRead(ChannelHandlerContext ctx, Object message) throws Exception {
    if (message instanceof SyncMessage) {
        handleSyncMessage((SyncMessage)message, ctx.channel());
    } else if (message instanceof List) {
        for (Object i : (List<?>)message) {
            if (i instanceof SyncMessage) {
                try {
                    handleSyncMessage((SyncMessage)i,
                                         ctx.channel());
                } catch (Exception ex) {
                    ctx.fireExceptionCaught(ex);
                }
            }
        }
    } else {
        handleUnknownMessage(ctx, message);
    }
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:20,代码来源:AbstractRPCChannelHandler.java

示例7: readTimedOut

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
/**
 * Is called when a read timeout was detected.
 */
protected void readTimedOut(ChannelHandlerContext ctx) throws Exception {
    if (!closed) {
        ctx.fireExceptionCaught(ReadTimeoutException.INSTANCE);
        ctx.close();
        closed = true;
    }
}
 
开发者ID:lemonJun,项目名称:TakinRPC,代码行数:11,代码来源:ReadTimeoutHandler.java

示例8: exceptionCaught

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public final void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
		throws Exception {
	if(cause instanceof IOException)
	{
		return;
	}
	log.error(ctx.channel() + ":"+cause.toString());
	ctx.fireExceptionCaught(cause);
}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:11,代码来源:AbstractListenerHandler.java

示例9: channelRead0

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void channelRead0(ChannelHandlerContext ctx, Iterable<OFMessage> msgList) throws Exception {
	for (OFMessage ofm : msgList) {
		try {
			// Do the actual packet processing
			state.processOFMessage(ofm);
		}
		catch (Exception ex) {
			// We are the last handler in the stream, so run the
			// exception through the channel again by passing in
			// ctx.getChannel().
			ctx.fireExceptionCaught(ex);
		}
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:16,代码来源:OFChannelHandler.java

示例10: channelInactive

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
        System.out.println("inactive");
        ctx.fireExceptionCaught(new Throwable());
//        ctx.fireChannelRead(new Object());
    }
 
开发者ID:alamby,项目名称:upgradeToy,代码行数:7,代码来源:SimpleServerHandler.java

示例11: exceptionCaught

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
        throws Exception {
    System.out.println(cause);
    ctx.fireExceptionCaught(cause);
}
 
开发者ID:recklessMo,项目名称:nettyRpc,代码行数:7,代码来源:BusinessServerHandler.java

示例12: userEventTriggered

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
    if (evt instanceof SslHandshakeCompletionEvent) {
        if (((SslHandshakeCompletionEvent)evt).isSuccess()) {
            if (debug) {
                log.debug("SSL connection established [to={}]", id);
            }

            handshake(ctx);
        }

        super.userEventTriggered(ctx, evt);
    } else if (evt instanceof AutoReadChangeEvent) {
        if (evt == AutoReadChangeEvent.PAUSE) {
            // Completely ignore read timeouts.
            ignoreTimeouts = -1;
        } else {
            // Ignore next timeout.
            ignoreTimeouts = 1;
        }
    } else if (evt instanceof IdleStateEvent) {
        if (state == CONNECTING || state == CONNECTED) {
            IdleStateEvent idle = (IdleStateEvent)evt;

            if (idle.state() == IdleState.WRITER_IDLE) {
                if (hbFlushed) {
                    // Make sure that we don't push multiple heartbeats to the network buffer simultaneously.
                    // Need to perform this check since remote peer can hang and stop reading
                    // while this channel will still be trying to put more and more heartbeats on its send buffer.
                    hbFlushed = false;

                    ctx.writeAndFlush(Heartbeat.INSTANCE).addListener(hbOnFlush);
                }
            } else {
                // Reader idle.
                // Ignore if auto-reading was disabled since in such case we will not read any heartbeats.
                if (ignoreTimeouts != -1 && ctx.channel().config().isAutoRead()) {
                    // Check if timeout should be ignored.
                    if (ignoreTimeouts > 0) {
                        // Decrement the counter of ignored timeouts.
                        ignoreTimeouts--;
                    } else {
                        if (state == CONNECTING) {
                            ctx.fireExceptionCaught(new ConnectTimeoutException("Timeout while connecting to " + id));
                        } else if (state == CONNECTED) {
                            ctx.fireExceptionCaught(new SocketTimeoutException("Timeout while reading data from " + id));
                        }
                    }
                }
            }
        }
    } else {
        super.userEventTriggered(ctx, evt);
    }
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:56,代码来源:NettyClientHandler.java

示例13: exceptionCaught

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
    log(() -> format(ctx, "EXCEPTION", cause));
    ctx.fireExceptionCaught(cause);
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:6,代码来源:LoggingHandler.java


注:本文中的io.netty.channel.ChannelHandlerContext.fireExceptionCaught方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。