/** * Returns an unmodifiable Iterator over a copy of this Headers' contents. */ @Override public Iterator<Tuple2<String, Object>> iterator() { synchronized (this.monitor) { List<Tuple2<String, Object>> headers = new ArrayList<Tuple2<String, Object>>(this.headers.size()); for (Map.Entry<String, Object> header : this.headers.entrySet()) { headers.add(Tuple.of(header.getKey(), header.getValue())); } return Collections.unmodifiableList(headers).iterator(); } }
/** * Create a {@link TupleN} with the given objects. * * @param t1 The first value in the tuple. * @param t2 The second value in the tuple. * @param t3 The third value in the tuple. * @param t4 The fourth value in the tuple. * @param t5 The fifth value in the tuple. * @param t6 The sixth value in the tuple. * @param t7 The seventh value in the tuple. * @param t8 The eighth value in the tuple. * @param tRest The rest of the values. * @param <T1> The type of the first value. * @param <T2> The type of the second value. * @param <T3> The type of the third value. * @param <T4> The type of the fourth value. * @param <T5> The type of the fifth value. * @param <T6> The type of the sixth value. * @param <T7> The type of the seventh value. * @param <TRest> The type of the last tuple. * @return The new {@link Tuple8}. */ public static <T1, T2, T3, T4, T5, T6, T7, T8, TRest extends Tuple> TupleN<T1, T2, T3, T4, T5, T6, T7, T8, TRest> of(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, Object... tRest) { return new TupleN<T1, T2, T3, T4, T5, T6, T7, T8, TRest>(t1, t2, t3, t4, t5, t6, t7, t8, new Tuple(tRest)); }
@Override public void accept(Tuple tup) { cl.call(tup.toArray()); }
@Override protected void flush() { ioChannel.write(Tuple.of(null, true)); }
@Override protected void write(Object data, final Deferred<Void, Promise<Void>> onComplete, boolean flush) { ChannelFuture writeFuture = ioChannel.write(Tuple.of(data, flush)); writeFuture.addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { boolean success = future.isSuccess(); if (!success) { Throwable t = future.cause(); getEventsReactor().notify(t.getClass(), Event.wrap(t)); if (null != onComplete) { onComplete.accept(t); } } else if (null != onComplete) { onComplete.accept((Void) null); } } }); }
public Tuple2<InetSocketAddress, Long> reconnect(InetSocketAddress currentAddress, int attempt) { Tuple2<InetSocketAddress, Long> rv = null; synchronized(IncrementalBackoffReconnectSpec.this) { if(!addresses.isEmpty()) { if(IncrementalBackoffReconnectSpec.this.maxAttempts == -1 || IncrementalBackoffReconnectSpec.this.maxAttempts > attempt ) { rv = Tuple.of(endpoints.get(),determineInterval(attempt)); } } else { rv = Tuple.of(currentAddress,determineInterval(attempt)); } } return rv; } };
public Tuple2<InetSocketAddress, Long> reconnect(InetSocketAddress currentAddress, int attempt) { Tuple2<InetSocketAddress, Long> rv = null; synchronized(IncrementalBackoffReconnectSpec.this) { if(!addresses.isEmpty()) { if(IncrementalBackoffReconnectSpec.this.maxAttempts == -1 || IncrementalBackoffReconnectSpec.this.maxAttempts > attempt ) { rv = Tuple.of(endpoints.get(),determineInterval(attempt)); } } else { rv = Tuple.of(currentAddress,determineInterval(attempt)); } } return rv; } };
@Override protected void doAccept(Event<T> ev) { if (null == acc) { acc = (null != accumulators ? accumulators.get() : null); } acc = fn.apply(Tuple.of(ev.getData(), acc)); notifyValue(ev.copy(acc)); }