List of usage examples for io.netty.channel ChannelProgressivePromise addListener
@Override ChannelProgressivePromise addListener(GenericFutureListener<? extends Future<? super Void>> listener);
From source file:com.addthis.hydra.data.query.op.OpGroupBy.java
License:Apache License
public OpGroupBy(QueryOpProcessor processor, String args, ChannelProgressivePromise opPromise) { super(opPromise); this.memTotal = 0; this.processor = processor; this.memTip = processor.memTip(); this.rowTip = processor.rowTip(); if (!args.contains(":")) { throw new IllegalStateException("groupby query argument missing ':'"); }//from w w w.j a v a2s . c om String[] components = args.split(":", 2); this.mergeConfig = new MergeConfig(components[0]); this.queryDeclaration = components[1]; this.forwardingOp = new OpForward(opPromise, getNext()); // ops don't usually fail promises themselves, so this logic is unlikely to activate, but might as well this.errorForwarder = channelFuture -> { if (!channelFuture.isSuccess()) { opPromise.tryFailure(channelFuture.cause()); } }; opPromise.addListener(channelFuture -> { if (channelFuture.isSuccess()) { for (QueryOp queryOp : resultTable.values()) { queryOp.getOpPromise().trySuccess(); } } else { Throwable failureCause = channelFuture.cause(); for (QueryOp queryOp : resultTable.values()) { queryOp.getOpPromise().tryFailure(failureCause); } } }); }
From source file:com.addthis.hydra.data.query.op.OpGroupBy.java
License:Apache License
/** * Generate new promise for the child operation. * * @param opPromise promise of the 'groupby' query operation * * @return generated promise//from w w w. j a v a 2 s. c o m */ private ChannelProgressivePromise generateNewPromise(ChannelProgressivePromise opPromise) { final ChannelProgressivePromise result; if (opPromise.channel() == null) { result = new DefaultChannelProgressivePromise(null, ImmediateEventExecutor.INSTANCE); } else { result = opPromise.channel().newProgressivePromise(); } result.addListener(errorForwarder); return result; }