@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (msg instanceof QueueCommand) { QueueCommand data = (QueueCommand) msg; QueueCommandHolder holder = queue.peek(); if (holder != null && holder.getCommand() == data) { super.write(ctx, msg, promise); } else { queue.add(new QueueCommandHolder(data, promise)); sendData(ctx.channel()); } } else { super.write(ctx, msg, promise); } }
private void sendData(Channel ch) { QueueCommandHolder command = queue.peek(); if (command != null && command.trySend()) { QueueCommand data = command.getCommand(); List<CommandData<Object, Object>> pubSubOps = data.getPubSubOperations(); if (!pubSubOps.isEmpty()) { for (CommandData<Object, Object> cd : pubSubOps) { for (Object channel : cd.getParams()) { ch.pipeline().get(CommandPubSubDecoder.class).addPubSubCommand((ChannelName) channel, cd); } } } else { ch.attr(CURRENT_COMMAND).set(data); } command.getChannelPromise().addListener(listener); ch.writeAndFlush(data, command.getChannelPromise()); } }
@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { while (true) { QueueCommandHolder command = queue.poll(); if (command == null) { break; } command.getChannelPromise().tryFailure( new WriteRedisConnectionException("Channel has been closed! Can't write command: " + LogHelper.toString(command.getCommand()) + " to channel: " + ctx.channel())); } super.channelInactive(ctx); }
public void sendNextCommand(Channel channel) { QueueCommand command = channel.attr(CommandsQueue.CURRENT_COMMAND).getAndSet(null); if (command != null) { queue.poll(); } else { QueueCommandHolder c = queue.peek(); if (c != null) { QueueCommand data = c.getCommand(); List<CommandData<Object, Object>> pubSubOps = data.getPubSubOperations(); if (!pubSubOps.isEmpty()) { queue.poll(); } } } sendData(channel); }
@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { while (true) { QueueCommandHolder command = queue.poll(); if (command == null) { break; } command.getChannelPromise().tryFailure( new WriteRedisConnectionException("Channel has been closed! Can't write command: " + LogHelper.toString(command.getCommand()) + " to channel: " + ctx.channel())); } super.channelInactive(ctx); }
public void sendNextCommand(Channel channel) { QueueCommand command = channel.attr(CommandsQueue.CURRENT_COMMAND).getAndSet(null); if (command != null) { queue.poll(); } else { QueueCommandHolder c = queue.peek(); if (c != null) { QueueCommand data = c.getCommand(); List<CommandData<Object, Object>> pubSubOps = data.getPubSubOperations(); if (!pubSubOps.isEmpty()) { queue.poll(); } } } sendData(channel); }
private void sendData(Channel ch) { QueueCommandHolder command = queue.peek(); if (command != null && command.trySend()) { QueueCommand data = command.getCommand(); List<CommandData<Object, Object>> pubSubOps = data.getPubSubOperations(); if (!pubSubOps.isEmpty()) { for (CommandData<Object, Object> cd : pubSubOps) { for (Object channel : cd.getParams()) { ch.pipeline().get(CommandPubSubDecoder.class).addPubSubCommand((ChannelName) channel, cd); } } } else { ch.attr(CURRENT_COMMAND).set(data); } command.getChannelPromise().addListener(listener); ch.writeAndFlush(data, command.getChannelPromise()); } }
@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { while (true) { QueueCommandHolder command = queue.poll(); if (command == null) { break; } command.getChannelPromise().tryFailure( new WriteRedisConnectionException("Channel has been closed! Can't write command: " + LogHelper.toString(command.getCommand()) + " to channel: " + ctx.channel())); } super.channelInactive(ctx); }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (msg instanceof QueueCommand) { QueueCommand data = (QueueCommand) msg; QueueCommandHolder holder = queue.peek(); if (holder != null && holder.getCommand() == data) { super.write(ctx, msg, promise); } else { queue.add(new QueueCommandHolder(data, promise)); sendData(ctx.channel()); } } else { super.write(ctx, msg, promise); } }
public void sendNextCommand(Channel channel) { QueueCommand command = channel.attr(CommandsQueue.CURRENT_COMMAND).getAndSet(null); if (command != null) { queue.poll(); } else { QueueCommandHolder c = queue.peek(); if (c != null) { QueueCommand data = c.getCommand(); List<CommandData<Object, Object>> pubSubOps = data.getPubSubOperations(); if (!pubSubOps.isEmpty()) { queue.poll(); } } } sendData(channel); }
private void sendData(Channel ch) { QueueCommandHolder command = queue.peek(); if (command != null && command.trySend()) { QueueCommand data = command.getCommand(); List<CommandData<Object, Object>> pubSubOps = data.getPubSubOperations(); if (!pubSubOps.isEmpty()) { for (CommandData<Object, Object> cd : pubSubOps) { for (Object channel : cd.getParams()) { ch.pipeline().get(CommandPubSubDecoder.class).addPubSubCommand((ChannelName) channel, cd); } } } else { ch.attr(CURRENT_COMMAND).set(data); } command.getChannelPromise().addListener(listener); ch.writeAndFlush(data, command.getChannelPromise()); } }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (msg instanceof QueueCommand) { QueueCommand data = (QueueCommand) msg; QueueCommandHolder holder = queue.peek(); if (holder != null && holder.getCommand() == data) { super.write(ctx, msg, promise); } else { queue.add(new QueueCommandHolder(data, promise)); sendData(ctx.channel()); } } else { super.write(ctx, msg, promise); } }