• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CorruptedFrameException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jboss.netty.handler.codec.frame.CorruptedFrameException的典型用法代码示例。如果您正苦于以下问题:Java CorruptedFrameException类的具体用法?Java CorruptedFrameException怎么用?Java CorruptedFrameException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CorruptedFrameException类属于org.jboss.netty.handler.codec.frame包,在下文中一共展示了CorruptedFrameException类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: exceptionCaught

import org.jboss.netty.handler.codec.frame.CorruptedFrameException; //导入依赖的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


示例2: decode

import org.jboss.netty.handler.codec.frame.CorruptedFrameException; //导入依赖的package包/类
@Override
protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, State state) throws Exception {
    switch (state) {
    case READ_PREFIX: {
        message = new RpcResponse();
        message.setCode(buffer.readByte());
        int start = buffer.readerIndex();
        int stop = start + actualReadableBytes();
        for (int i = start; i < stop; i++) {
            if (buffer.getByte(i) != RpcConstants.FRAME_START) {
                buffer.skipBytes(i - start);
                break;
            }
        }
        checkpoint(State.READ_CONTENT);
    }
    case READ_CONTENT: {
        boolean eot = false;
        while (!eot) {
            RpcResponse.Line line = new RpcResponse.Line();
            eot = readLine(buffer, line, RpcConstants.MAX_FRAME_LEN);
            message.appendLine(line);
            checkpoint();
        }
        checkpoint(State.READ_PREFIX);
        break;
    }
    default:
        // Should not get here, all cases are handled
        throw new CorruptedFrameException();
    }

    return message;
}
 
开发者ID:OSEHRA,项目名称:vista-soa-ri,代码行数:35,代码来源:RpcResponseDecoder.java


示例3: decodeParameter

import org.jboss.netty.handler.codec.frame.CorruptedFrameException; //导入依赖的package包/类
public static Parameter decodeParameter(ChannelBuffer in) throws CorruptedFrameException {
    Parameter param = null;
    // Fist byte indicates the parameter type
    byte b = in.readByte();
    switch (b) {
    case RpcConstants.FRAME_STOP:
        return null;
    case RpcConstants.PARAM_TYPE_LITERAL: {
        param = new LiteralParameter(decodeField(in));
        break;
    }
    case RpcConstants.PARAM_TYPE_REF: {
        param = new ReferenceParameter(decodeField(in));
        break;
    }
    case RpcConstants.PARAM_TYPE_MAP: {
        param = new MapParameter(decodeMap(in));
        break;
    }
    case RpcConstants.PARAM_TYPE_GLOBAL: {
        param = new GlobalParameter(decodeField(in), decodeField(in));
        break;
    }
    case RpcConstants.PARAM_TYPE_EMPTY: {
        param = new EmptyParameter();
        break;
    }
    case RpcConstants.PARAM_TYPE_STREAM: {
        // TODO: implement me
        break;
    }
    default:
        throw new CorruptedFrameException("Unkown RPC parameter type: '" + String.format("%02x ", b) + "'");
    }
    
    b = in.readByte();
    if (b != RpcConstants.PARAM_STOP) {
        throw new CorruptedFrameException("Expected end of parameter, got '" + String.format("%02x ", b) + "' instead");
    }
    return param;
}
 
开发者ID:OSEHRA,项目名称:vista-soa-ri,代码行数:42,代码来源:RpcCodecUtils.java


示例4: decode

import org.jboss.netty.handler.codec.frame.CorruptedFrameException; //导入依赖的package包/类
protected Object decode(ChannelHandlerContext ctx, ChannelBuffer buffer) throws Exception {
    if (lengthBytesToRead > 0) {
        if (lengthBytesToRead > buffer.readableBytes()) {
            lengthBytesToRead -= buffer.readableBytes();
            lengthBuffer.writeBytes(buffer);
            return null;
        } else {
            lengthBuffer.writeBytes(buffer, lengthBytesToRead);
            lengthBytesToRead = 0;
            frameBytesToRead = lengthBuffer.getUnsignedInt(0);

            if (frameBytesToRead < 0) {
                skipFrame = true;
                frameBytesToRead = 0;
                Channels.fireExceptionCaught(ctx, new CorruptedFrameException("negative frame length: " +
                    frameBytesToRead));
            } else if (frameBytesToRead > maxFrameLength) {
                skipFrame = true;
                Channels.fireExceptionCaught(ctx, new TooLongFrameException("frame length exceeds " +
                    maxFrameLength + ": " + frameBytesToRead));
            } else {
                skipFrame = false;
                frameBuffer = getBuffer(ctx.getChannel().getConfig().getBufferFactory(),
                        (int) frameBytesToRead);
            }
        }
    }

    if (frameBytesToRead > buffer.readableBytes()) {
        frameBytesToRead -= buffer.readableBytes();
        if (skipFrame) {
            buffer.skipBytes(buffer.readableBytes());
        } else {
            frameBuffer.writeBytes(buffer);
        }
        return null;
    } else {
        lengthBuffer.setIndex(0, 0);
        lengthBytesToRead = lengthFieldLength;
        if (skipFrame) {
            buffer.skipBytes((int) frameBytesToRead);
            frameBytesToRead = 0;
            return null;
        } else {
            frameBuffer.writeBytes(buffer, (int) frameBytesToRead);
            frameBytesToRead = 0;
            PNPFrame m = PNPFrame.constructMessage(frameBuffer, 0);
            frameBuffer = null;
            return m;
        }
    }
}
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:53,代码来源:PNPClientFrameDecoder.java


示例5: decode

import org.jboss.netty.handler.codec.frame.CorruptedFrameException; //导入依赖的package包/类
protected Object decode(ChannelHandlerContext ctx, ChannelBuffer buffer) throws Exception {
    if (!firstFrame) {
        this.pnpServerHandler.bytesAvailable();
    }

    if (lengthBytesToRead > 0) {
        if (lengthBytesToRead > buffer.readableBytes()) {
            lengthBytesToRead -= buffer.readableBytes();
            lengthBuffer.writeBytes(buffer);
            return null;
        } else {
            lengthBuffer.writeBytes(buffer, lengthBytesToRead);
            lengthBytesToRead = 0;

            frameBytesToRead = lengthBuffer.getUnsignedInt(0);
            if (frameBytesToRead < 0) {
                skipFrame = true;
                frameBytesToRead = 0;
                Channels.fireExceptionCaught(ctx, new CorruptedFrameException("negative frame length: " +
                    frameBytesToRead));
            } else if (frameBytesToRead > maxFrameLength) {
                skipFrame = true;
                Channels.fireExceptionCaught(ctx, new TooLongFrameException("frame length exceeds " +
                    maxFrameLength + ": " + frameBytesToRead));
            } else {
                skipFrame = false;
                frameBuffer = getBuffer(ctx.getChannel().getConfig().getBufferFactory(),
                        (int) frameBytesToRead);
            }
        }
    }

    if (frameBytesToRead > buffer.readableBytes()) {
        frameBytesToRead -= buffer.readableBytes();
        if (skipFrame) {
            buffer.skipBytes(buffer.readableBytes());
        } else {
            frameBuffer.writeBytes(buffer);
        }
        return null;
    } else {
        lengthBuffer.setIndex(0, 0);
        lengthBytesToRead = lengthFieldLength;
        if (skipFrame) {
            buffer.skipBytes((int) frameBytesToRead);
            frameBytesToRead = 0;
            return null;
        } else {
            frameBuffer.writeBytes(buffer, (int) frameBytesToRead);
            frameBytesToRead = 0;

            PNPFrame m = null;
            try {
                m = PNPFrame.constructMessage(frameBuffer, 0);
            } catch (Exception e) {
                this.pnpServerHandler.clientLeave();
                throw e;
            }

            frameBuffer = null;

            if (firstFrame) {
                if (m.getType() == PNPFrame.MessageType.HEARTBEAT_ADV) {
                    PNPFrameHeartbeatAdvertisement ahFrame = (PNPFrameHeartbeatAdvertisement) m;

                    long heartbeatPeriod = ahFrame.getHeartbeatPeriod();
                    Heartbeater heartbeater = new Heartbeater(ctx.getChannel(), timer, heartbeatPeriod);
                    this.pnpServerHandler.setHeartBeater(heartbeater);

                    this.firstFrame = false;
                    return null; // Do not sent the first frame to the handler
                } else {
                    throw new PNPException("Invalid first frame type must be " +
                        MessageType.HEARTBEAT_ADV + " but is " + m.getType());
                }
            }

            return m;
        }
    }
}
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:82,代码来源:PNPServerFrameDecoder.java



注:本文中的org.jboss.netty.handler.codec.frame.CorruptedFrameException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IResolutionPolicy类代码示例发布时间:2022-05-23
下一篇:
Java Visitor类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap