io.netty.util.concurrent.Promise.isDone()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(250)

本文整理了Java中io.netty.util.concurrent.Promise.isDone()方法的一些代码示例,展示了Promise.isDone()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Promise.isDone()方法的具体详情如下:
包路径:io.netty.util.concurrent.Promise
类名称:Promise
方法名:isDone

Promise.isDone介绍

暂无

代码示例

代码示例来源:origin: redisson/redisson

@Override
  public void run() {
    if (promise.isDone()) {
      // Received a response before the query times out.
      return;
    }
    setFailure("query timed out after " + queryTimeoutMillis + " milliseconds", null);
  }
}, queryTimeoutMillis, TimeUnit.MILLISECONDS);

代码示例来源:origin: redisson/redisson

@Override
public boolean isDone() {
  return promise.isDone();
}

代码示例来源:origin: redisson/redisson

@Override
public boolean isDone() {
  return promise.isDone();
}

代码示例来源:origin: wildfly/wildfly

@Override
  public void run() {
    if (promise.isDone()) {
      // Received a response before the query times out.
      return;
    }
    setFailure("query timed out after " + queryTimeoutMillis + " milliseconds", null);
  }
}, queryTimeoutMillis, TimeUnit.MILLISECONDS);

代码示例来源:origin: apache/hive

@Override
 public void operationComplete(Promise<T> p) {
  if (jobId != null) {
   jobs.remove(jobId);
  }
  if (p.isCancelled() && !rpc.isDone()) {
   rpc.cancel(true);
  }
 }
});

代码示例来源:origin: apache/hive

@Override
public boolean isDone() {
 return promise.isDone();
}

代码示例来源:origin: line/armeria

@Override
public boolean isDone() {
  return delegate.isDone();
}

代码示例来源:origin: redisson/redisson

@Override
public void read(ChannelHandlerContext ctx) throws Exception {
  if (!handshakePromise.isDone()) {
    readDuringHandshake = true;
  }
  ctx.read();
}

代码示例来源:origin: redisson/redisson

/**
 * Works around some Android {@link SSLEngine} implementations that skip {@link HandshakeStatus#FINISHED} and
 * go straight into {@link HandshakeStatus#NOT_HANDSHAKING} when handshake is finished.
 *
 * @return {@code true} if and only if the workaround has been applied and thus {@link #handshakeFuture} has been
 *         marked as success by this method
 */
private boolean setHandshakeSuccessIfStillHandshaking() {
  if (!handshakePromise.isDone()) {
    setHandshakeSuccess();
    return true;
  }
  return false;
}

代码示例来源:origin: wildfly/wildfly

@Override
public void read(ChannelHandlerContext ctx) throws Exception {
  if (!handshakePromise.isDone()) {
    readDuringHandshake = true;
  }
  ctx.read();
}

代码示例来源:origin: wildfly/wildfly

/**
 * Works around some Android {@link SSLEngine} implementations that skip {@link HandshakeStatus#FINISHED} and
 * go straight into {@link HandshakeStatus#NOT_HANDSHAKING} when handshake is finished.
 *
 * @return {@code true} if and only if the workaround has been applied and thus {@link #handshakeFuture} has been
 *         marked as success by this method
 */
private boolean setHandshakeSuccessIfStillHandshaking() {
  if (!handshakePromise.isDone()) {
    setHandshakeSuccess();
    return true;
  }
  return false;
}

代码示例来源:origin: redisson/redisson

private void readIfNeeded(ChannelHandlerContext ctx) {
  // If handshake is not finished yet, we need more data.
  if (!ctx.channel().config().isAutoRead() && (!firedChannelRead || !handshakePromise.isDone())) {
    // No auto-read used and no message passed through the ChannelPipeline or the handshake was not complete
    // yet, which means we need to trigger the read to ensure we not encounter any stalls.
    ctx.read();
  }
}

代码示例来源:origin: redisson/redisson

@Override
  public void run() {
    if (localHandshakePromise.isDone()) {
      return;
    }
    try {
      if (localHandshakePromise.tryFailure(HANDSHAKE_TIMED_OUT)) {
        SslUtils.handleHandshakeFailure(ctx, HANDSHAKE_TIMED_OUT, true);
      }
    } finally {
      releaseAndFailAll(HANDSHAKE_TIMED_OUT);
    }
  }
}, handshakeTimeoutMillis, TimeUnit.MILLISECONDS);

代码示例来源:origin: apache/hive

@Override
  public void operationComplete(ChannelFuture cf) {
   if (!cf.isSuccess() && !promise.isDone()) {
    LOG.warn("Failed to send message '" + msg + "', closing Remote Spark Driver - " +
        "HiveServer2 connection.", cf.cause());
    promise.setFailure(cf.cause());
    dispatcher.discardRpc(id);
    close();
   }
  }
};

代码示例来源:origin: apache/hive

@Override
protected void onError(Throwable error) {
 timeout.cancel(true);
 if (!promise.isDone()) {
  promise.setFailure(error);
 }
}

代码示例来源:origin: wildfly/wildfly

@Override
  public void run() {
    if (promise.isDone()) {
      return;
    }
    try {
      if (handshakePromise.tryFailure(HANDSHAKE_TIMED_OUT)) {
        SslUtils.handleHandshakeFailure(ctx, HANDSHAKE_TIMED_OUT, true);
      }
    } finally {
      releaseAndFailAll(HANDSHAKE_TIMED_OUT);
    }
  }
}, handshakeTimeoutMillis, TimeUnit.MILLISECONDS);

代码示例来源:origin: wildfly/wildfly

private void readIfNeeded(ChannelHandlerContext ctx) {
  // If handshake is not finished yet, we need more data.
  if (!ctx.channel().config().isAutoRead() && (!firedChannelRead || !handshakePromise.isDone())) {
    // No auto-read used and no message passed through the ChannelPipeline or the handshake was not complete
    // yet, which means we need to trigger the read to ensure we not encounter any stalls.
    ctx.read();
  }
}

代码示例来源:origin: redisson/redisson

private void renegotiateOnEventLoop(final Promise<Channel> newHandshakePromise) {
  final Promise<Channel> oldHandshakePromise = handshakePromise;
  if (!oldHandshakePromise.isDone()) {
    // There's no need to handshake because handshake is in progress already.
    // Merge the new promise into the old one.
    oldHandshakePromise.addListener(new PromiseNotifier<Channel, Future<Channel>>(newHandshakePromise));
  } else {
    handshakePromise = newHandshakePromise;
    handshake();
    applyHandshakeTimeout();
  }
}

代码示例来源:origin: apache/hive

@Override
protected void onError(Throwable error) {
 cancelTask.cancel(true);
 if (client != null) {
  client.timeoutFuture.cancel(true);
  if (!client.promise.isDone()) {
   client.promise.setFailure(error);
  }
 }
}

代码示例来源:origin: redisson/redisson

private void wrapAndFlush(ChannelHandlerContext ctx) throws SSLException {
  if (pendingUnencryptedWrites.isEmpty()) {
    // It's important to NOT use a voidPromise here as the user
    // may want to add a ChannelFutureListener to the ChannelPromise later.
    //
    // See https://github.com/netty/netty/issues/3364
    pendingUnencryptedWrites.add(Unpooled.EMPTY_BUFFER, ctx.newPromise());
  }
  if (!handshakePromise.isDone()) {
    flushedBeforeHandshake = true;
  }
  try {
    wrap(ctx, false);
  } finally {
    // We may have written some parts of data before an exception was thrown so ensure we always flush.
    // See https://github.com/netty/netty/issues/3900#issuecomment-172481830
    forceFlush(ctx);
  }
}

相关文章