/** * 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(); } }
@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)); }