Search in sources :

Example 1 with FullBulkStringRedisMessage

use of io.netty.handler.codec.redis.FullBulkStringRedisMessage in project netty by netty.

the class RedisEncoderBenchmark method setup.

@Setup(Level.Trial)
public void setup() {
    byte[] bytes = new byte[256];
    content = Unpooled.buffer(bytes.length);
    content.writeBytes(bytes);
    ByteBuf testContent = Unpooled.unreleasableBuffer(content.asReadOnly());
    List<RedisMessage> rList = new ArrayList<RedisMessage>(arraySize);
    for (int i = 0; i < arraySize; ++i) {
        rList.add(new FullBulkStringRedisMessage(testContent));
    }
    redisArray = new ArrayRedisMessage(rList);
    encoder = new RedisEncoder();
    context = new EmbeddedChannelWriteReleaseHandlerContext(pooledAllocator ? PooledByteBufAllocator.DEFAULT : UnpooledByteBufAllocator.DEFAULT, encoder) {

        @Override
        protected void handleException(Throwable t) {
            handleUnexpectedException(t);
        }
    };
}
Also used : FullBulkStringRedisMessage(io.netty.handler.codec.redis.FullBulkStringRedisMessage) ArrayRedisMessage(io.netty.handler.codec.redis.ArrayRedisMessage) RedisMessage(io.netty.handler.codec.redis.RedisMessage) FullBulkStringRedisMessage(io.netty.handler.codec.redis.FullBulkStringRedisMessage) ArrayRedisMessage(io.netty.handler.codec.redis.ArrayRedisMessage) RedisEncoder(io.netty.handler.codec.redis.RedisEncoder) ArrayList(java.util.ArrayList) EmbeddedChannelWriteReleaseHandlerContext(io.netty.microbench.channel.EmbeddedChannelWriteReleaseHandlerContext) ByteBuf(io.netty.buffer.ByteBuf) Setup(org.openjdk.jmh.annotations.Setup)

Example 2 with FullBulkStringRedisMessage

use of io.netty.handler.codec.redis.FullBulkStringRedisMessage in project netty by netty.

the class RedisClientHandler method write.

@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
    String[] commands = ((String) msg).split("\\s+");
    List<RedisMessage> children = new ArrayList<RedisMessage>(commands.length);
    for (String cmdString : commands) {
        children.add(new FullBulkStringRedisMessage(ByteBufUtil.writeUtf8(ctx.alloc(), cmdString)));
    }
    RedisMessage request = new ArrayRedisMessage(children);
    ctx.write(request, promise);
}
Also used : FullBulkStringRedisMessage(io.netty.handler.codec.redis.FullBulkStringRedisMessage) IntegerRedisMessage(io.netty.handler.codec.redis.IntegerRedisMessage) ArrayRedisMessage(io.netty.handler.codec.redis.ArrayRedisMessage) ErrorRedisMessage(io.netty.handler.codec.redis.ErrorRedisMessage) SimpleStringRedisMessage(io.netty.handler.codec.redis.SimpleStringRedisMessage) RedisMessage(io.netty.handler.codec.redis.RedisMessage) FullBulkStringRedisMessage(io.netty.handler.codec.redis.FullBulkStringRedisMessage) ArrayRedisMessage(io.netty.handler.codec.redis.ArrayRedisMessage) ArrayList(java.util.ArrayList)

Aggregations

ArrayRedisMessage (io.netty.handler.codec.redis.ArrayRedisMessage)2 FullBulkStringRedisMessage (io.netty.handler.codec.redis.FullBulkStringRedisMessage)2 RedisMessage (io.netty.handler.codec.redis.RedisMessage)2 ArrayList (java.util.ArrayList)2 ByteBuf (io.netty.buffer.ByteBuf)1 ErrorRedisMessage (io.netty.handler.codec.redis.ErrorRedisMessage)1 IntegerRedisMessage (io.netty.handler.codec.redis.IntegerRedisMessage)1 RedisEncoder (io.netty.handler.codec.redis.RedisEncoder)1 SimpleStringRedisMessage (io.netty.handler.codec.redis.SimpleStringRedisMessage)1 EmbeddedChannelWriteReleaseHandlerContext (io.netty.microbench.channel.EmbeddedChannelWriteReleaseHandlerContext)1 Setup (org.openjdk.jmh.annotations.Setup)1