AcquireTask(Promise<Channel> promise) { super(promise); // We need to create a new promise as we need to ensure the AcquireListener runs in the correct // EventLoop. this.promise = executor.<Channel>newPromise().addListener(this); } }
public AcquireTask(Promise<Channel> promise) { super(promise); // We need to create a new promise as we need to ensure the AcquireListener runs in the correct // EventLoop. this.promise = executor.<Channel>newPromise().addListener(this); } }
@Override public Future<T> resolve(String inetHost) { return resolve(inetHost, executor.<T>newPromise()); }
@Override public Future<List<T>> resolveAll(String inetHost) { return resolveAll(inetHost, executor.<List<T>>newPromise()); }
public AcquireTask(Promise<Channel> promise) { super(promise); // We need to create a new promise as we need to ensure the AcquireListener runs in the correct // EventLoop. this.promise = executor.<Channel>newPromise().addListener(this); } }
@Override public final Future<List<T>> resolveAll(String inetHost) { final Promise<List<T>> promise = executor().newPromise(); return resolveAll(inetHost, promise); }
/** * Creates a promise backed by this RPC's event loop. */ public <T> Promise<T> createPromise() { return egroup.next().newPromise(); }
@Override public final Future<T> resolve(String inetHost) { final Promise<T> promise = executor().newPromise(); return resolve(inetHost, promise); }
/** * Performs TLS renegotiation. */ public Future<Channel> renegotiate() { ChannelHandlerContext ctx = this.ctx; if (ctx == null) { throw new IllegalStateException(); } return renegotiate(ctx.executor().<Channel>newPromise()); }
/** * The default implementation will simply call {@link AsyncMapping#map(Object, Promise)} but * users can override this method to implement custom behavior. * * @see AsyncMapping#map(Object, Promise) */ @Override protected Future<SslContext> lookup(ChannelHandlerContext ctx, String hostname) throws Exception { return mapping.map(hostname, ctx.executor().<SslContext>newPromise()); }
@Override public final Future<T> resolve(String inetHost) { final Promise<T> promise = executor().newPromise(); return resolve(inetHost, promise); }
@Override public final Future<List<T>> resolveAll(String inetHost) { final Promise<List<T>> promise = executor().newPromise(); return resolveAll(inetHost, promise); }
/** * Performs TLS renegotiation. */ public Future<Channel> renegotiate() { ChannelHandlerContext ctx = this.ctx; if (ctx == null) { throw new IllegalStateException(); } return renegotiate(ctx.executor().<Channel>newPromise()); }
/** * The default implementation will simply call {@link AsyncMapping#map(Object, Promise)} but * users can override this method to implement custom behavior. * * @see AsyncMapping#map(Object, Promise) */ @Override protected Future<SslContext> lookup(ChannelHandlerContext ctx, String hostname) throws Exception { return mapping.map(hostname, ctx.executor().<SslContext>newPromise()); }
@Override public final Future<List<T>> resolveAll(String inetHost) { final Promise<List<T>> promise = executor().newPromise(); return resolveAll(inetHost, promise); }
@Override public final Future<T> resolve(String inetHost) { final Promise<T> promise = executor().newPromise(); return resolve(inetHost, promise); }
@Override public Future<Void> release(final Channel channel, final Promise<Void> promise) { ObjectUtil.checkNotNull(promise, "promise"); final Promise<Void> p = executor.newPromise(); super.release(channel, p.addListener(new FutureListener<Void>() { @Override public void operationComplete(Future<Void> future) throws Exception { assert executor.inEventLoop(); if (closed) { // Since the pool is closed, we have no choice but to close the channel channel.close(); promise.setFailure(POOL_CLOSED_ON_RELEASE_EXCEPTION); return; } if (future.isSuccess()) { decrementAndRunTaskQueue(); promise.setSuccess(null); } else { Throwable cause = future.cause(); // Check if the exception was not because of we passed the Channel to the wrong pool. if (!(cause instanceof IllegalArgumentException)) { decrementAndRunTaskQueue(); } promise.setFailure(future.cause()); } } })); return promise; }
Promise<Channel> p = executor.newPromise(); AcquireListener l = new AcquireListener(promise); l.acquired();
@Override public final Future<List<T>> resolveAll(SocketAddress address) { if (!isSupported(checkNotNull(address, "address"))) { // Address type not supported by the resolver return executor().newFailedFuture(new UnsupportedAddressTypeException()); } if (isResolved(address)) { // Resolved already; no need to perform a lookup @SuppressWarnings("unchecked") final T cast = (T) address; return executor.newSucceededFuture(Collections.singletonList(cast)); } try { @SuppressWarnings("unchecked") final T cast = (T) address; final Promise<List<T>> promise = executor().newPromise(); doResolveAll(cast, promise); return promise; } catch (Exception e) { return executor().newFailedFuture(e); } }
@Override public final Future<T> resolve(SocketAddress address) { if (!isSupported(checkNotNull(address, "address"))) { // Address type not supported by the resolver return executor().newFailedFuture(new UnsupportedAddressTypeException()); } if (isResolved(address)) { // Resolved already; no need to perform a lookup @SuppressWarnings("unchecked") final T cast = (T) address; return executor.newSucceededFuture(cast); } try { @SuppressWarnings("unchecked") final T cast = (T) address; final Promise<T> promise = executor().newPromise(); doResolve(cast, promise); return promise; } catch (Exception e) { return executor().newFailedFuture(e); } }