Package io.netty.channel.udt

Examples of io.netty.channel.udt.UdtMessage


            throw new ChannelException(
                    "Invalid config : increase receive buffer size to avoid message truncation");
        }

        // delivers a message
        buf.add(new UdtMessage(byteBuf));

        return 1;
    }
View Full Code Here


    @Override
    protected int doWriteMessages(final MessageBuf<Object> messageQueue,
            final boolean lastSpin) throws Exception {

        // expects a message
        final UdtMessage message = (UdtMessage) messageQueue.peek();

        final ByteBuf byteBuf = message.data();

        final int messageSize = byteBuf.readableBytes();

        final long writtenBytes;
        if (byteBuf.nioBufferCount() == 1) {
            writtenBytes = javaChannel().write(byteBuf.nioBuffer());
        } else {
            writtenBytes = javaChannel().write(byteBuf.nioBuffers());
        }

        final SelectionKey key = selectionKey();
        final int interestOps = key.interestOps();

        // did not write the message
        if (writtenBytes <= 0 && messageSize > 0) {
            if (lastSpin) {
                if ((interestOps & OP_WRITE) == 0) {
                    key.interestOps(interestOps | OP_WRITE);
                }
            }
            return 0;
        }

        // wrote message completely
        if (writtenBytes != messageSize) {
            throw new Error(
                    "Provider error: failed to write message. Provider library should be upgraded.");
        }

        // wrote the message queue completely - clear OP_WRITE.
        if (messageQueue.isEmpty()) {
            if ((interestOps & OP_WRITE) != 0) {
                key.interestOps(interestOps & ~OP_WRITE);
            }
        }

        messageQueue.remove();

        message.release();

        return 1;
    }
View Full Code Here

    public MsgEchoClientHandler(final int messageSize) {
        final ByteBuf byteBuf = Unpooled.buffer(messageSize);
        for (int i = 0; i < byteBuf.capacity(); i++) {
            byteBuf.writeByte((byte) i);
        }
        message = new UdtMessage(byteBuf);
    }
View Full Code Here

    public MsgEchoPeerHandler(final int messageSize) {
        final ByteBuf byteBuf = Unpooled.buffer(messageSize);
        for (int i = 0; i < byteBuf.capacity(); i++) {
            byteBuf.writeByte((byte) i);
        }
        message = new UdtMessage(byteBuf);
    }
View Full Code Here

            throw new ChannelException(
                    "Invalid config : increase receive buffer size to avoid message truncation");
        }

        // delivers a message
        buf.add(new UdtMessage(byteBuf));

        return 1;
    }
View Full Code Here

    }

    @Override
    protected boolean doWriteMessage(Object msg, ChannelOutboundBuffer in) throws Exception {
        // expects a message
        final UdtMessage message = (UdtMessage) msg;

        final ByteBuf byteBuf = message.content();

        final int messageSize = byteBuf.readableBytes();

        final long writtenBytes;
        if (byteBuf.nioBufferCount() == 1) {
View Full Code Here

        super(false);
        final ByteBuf byteBuf = Unpooled.buffer(MsgEchoClient.SIZE);
        for (int i = 0; i < byteBuf.capacity(); i++) {
            byteBuf.writeByte((byte) i);
        }
        message = new UdtMessage(byteBuf);
    }
View Full Code Here

        super(false);
        final ByteBuf byteBuf = Unpooled.buffer(messageSize);
        for (int i = 0; i < byteBuf.capacity(); i++) {
            byteBuf.writeByte((byte) i);
        }
        message = new UdtMessage(byteBuf);
    }
View Full Code Here

        for (int i = 0; i < byteBuf.capacity(); i++) {
            byteBuf.writeByte((byte) i);
        }

        message = new UdtMessage(byteBuf);
    }
View Full Code Here

        ctx.close();
    }

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        UdtMessage udtMsg = (UdtMessage) msg;
        if (meter != null) {
            meter.mark(udtMsg.content().readableBytes());
        }
        ctx.writeAndFlush(msg);
    }
View Full Code Here

TOP

Related Classes of io.netty.channel.udt.UdtMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.