Package com.taobao.gecko.core.buffer

Examples of com.taobao.gecko.core.buffer.IoBuffer.flip()


            IoBuffer buf =
                    IoBuffer.allocate(11 + 3 + ByteUtils.stringSize(fc.size())
                        + ByteUtils.stringSize(request.getOpaque()));
            ByteUtils.setArguments(buf, MetaEncodeCommand.RESULT_CMD, HttpStatus.Success, fc.size(),
                request.getOpaque());
            buf.flip();
            ctx.getConnection().transferFrom(buf, null, fc, 0, fc.size(), request.getOpaque(),
                new SingleRequestCallBackListener() {

                @Override
                public void onResponse(ResponseCommand responseCommand, Connection conn) {
View Full Code Here


    // value totalLen opaque\r\n
    IoBuffer makeHead(final int opaque, final long size) {
        final IoBuffer buf = IoBuffer.allocate(9 + ByteUtils.stringSize(opaque) + ByteUtils.stringSize(size));
        ByteUtils.setArguments(buf, "value", size, opaque);
        buf.flip();
        return buf;
    }


    @Override
View Full Code Here

    @Test
    public void testDecodeDataCommand() {

        final IoBuffer buf = IoBuffer.allocate(100);
        buf.put("value 5 99\r\nhello".getBytes());
        buf.flip();

        final DataCommand decodedCmd = (DataCommand) this.decoder.decode(buf, null);
        assertNotNull(decodedCmd);
        assertEquals((Integer) 99, decodedCmd.getOpaque());
        assertEquals("hello", new String(decodedCmd.getData()));
View Full Code Here

                this.flag, this.checkSum, this.getOpaque());
        }
        if (this.data != null) {
            buffer.put(this.data);
        }
        buffer.flip();
        return buffer;
    }


    @Override
View Full Code Here

                ByteUtils.setArguments(buffer, MetaEncodeCommand.TRANS_CMD, transactionKey,
                    this.transactionInfo.getSessionId(), type, this.transactionInfo.getUniqueQualifier(), this.opaque);
            }

        }
        buffer.flip();
        return buffer;
    }


    public static long getSerialversionuid() {
View Full Code Here

                IoBuffer.allocate(13 + this.getTopic().length() + this.getGroup().length()
                        + ByteUtils.stringSize(this.partition) + ByteUtils.stringSize(this.offset)
                        + ByteUtils.stringSize(this.getOpaque()));
        ByteUtils.setArguments(buf, MetaEncodeCommand.OFFSET_CMD, this.getTopic(), this.getGroup(),
            this.getPartition(), this.offset, this.getOpaque());
        buf.flip();
        return buf;
    }

}
View Full Code Here

                        + ByteUtils.stringSize(messageLen) + messageLen);
        ByteUtils.setArguments(buffer, MetaEncodeCommand.RESULT_CMD, this.code, messageLen, this.getOpaque());
        if (bytes != null) {
            buffer.put(bytes);
        }
        buffer.flip();
        return buffer;
    }


    @Override
View Full Code Here

                        + ByteUtils.stringSize(this.getOpaque()) + totalDataLength);
            ByteUtils.setArguments(buffer, MetaEncodeCommand.VALUE_CMD, totalDataLength, this.getOpaque());
            if (this.data != null) {
                buffer.put(this.data);
            }
            buffer.flip();
            return buffer;
        }
        else {
            // We don't encode header,it is done by message set.
            return null;
View Full Code Here

                IoBuffer.allocate(11 + this.getGroup().length() + ByteUtils.stringSize(this.partition)
                        + ByteUtils.stringSize(this.getOpaque()) + this.getTopic().length()
                        + ByteUtils.stringSize(this.offset) + ByteUtils.stringSize(this.maxSize));
        ByteUtils.setArguments(buffer, MetaEncodeCommand.GET_CMD, this.getTopic(), this.getGroup(), this.partition,
            this.offset, this.maxSize, this.getOpaque());
        buffer.flip();
        return buffer;
    }


    @Override
View Full Code Here

            return IoBuffer.wrap((MetaEncodeCommand.STATS_CMD + " " + " " + this.getOpaque() + "\r\n").getBytes());
        }
        else {
            final IoBuffer buf = IoBuffer.allocate(9 + this.item.length() + ByteUtils.stringSize(this.getOpaque()));
            ByteUtils.setArguments(buf, MetaEncodeCommand.STATS_CMD, this.item, this.getOpaque());
            buf.flip();
            return buf;
        }
    }

}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.