Search in sources :

Example 1 with RedisMessage

use of io.netty.handler.codec.redis.RedisMessage 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 RedisMessage

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

the class RedisClientHandler method channelRead.

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
    RedisMessage redisMessage = (RedisMessage) msg;
    printAggregatedRedisResponse(redisMessage);
    ReferenceCountUtil.release(redisMessage);
}
Also used : 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)

Example 3 with RedisMessage

use of io.netty.handler.codec.redis.RedisMessage 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)3 FullBulkStringRedisMessage (io.netty.handler.codec.redis.FullBulkStringRedisMessage)3 RedisMessage (io.netty.handler.codec.redis.RedisMessage)3 ErrorRedisMessage (io.netty.handler.codec.redis.ErrorRedisMessage)2 IntegerRedisMessage (io.netty.handler.codec.redis.IntegerRedisMessage)2 SimpleStringRedisMessage (io.netty.handler.codec.redis.SimpleStringRedisMessage)2 ArrayList (java.util.ArrayList)2 ByteBuf (io.netty.buffer.ByteBuf)1 RedisEncoder (io.netty.handler.codec.redis.RedisEncoder)1 EmbeddedChannelWriteReleaseHandlerContext (io.netty.microbench.channel.EmbeddedChannelWriteReleaseHandlerContext)1 Setup (org.openjdk.jmh.annotations.Setup)1