google-api-services-common/src/main/java/bio/terra/cloudres/google/api/services/common/OperationUtils.java
/**
   * Poll an operation until it completes, the operation get errors, or the timeout is reached.
   *
   * <p>Note that this does not throw an error if the operation executes "successfully" but returns
   * an error.
   */
Poll an operation until it completes, the operation get errors, or the timeout is reached.
Note that this does not throw an error if the operation executes "successfully" but returns
an error.
Poll an operation until it completes the operation get errors or the timeout is reached . Note that this does not throw an error if the operation executes " successfully " but returns an error .
@CheckReturnValue
  public static <T> OperationCow<T> pollUntilComplete(
      OperationCow<T> operation, Duration pollingInterval, Duration timeout)
      throws IOException, InterruptedException {
    Instant deadline = Instant.now().plus(timeout);
    while (!isDone(operation.getOperationAdapter())
        && operation.getOperationAdapter().getError() == null) {
      if (Instant.now().plus(pollingInterval).isAfter(deadline)) {
        throw new InterruptedException(
            "Timeout during pollUntilComplete for operation "
                + operation.getOperationAdapter().getName());
      }
      Thread.sleep(pollingInterval.toMillis());
      operation = operation.executeGet();
    }
    return operation;
  }
@ CheckReturnValue public static < T > OperationCow < T > pollUntilComplete ( OperationCow < T > operation , Duration pollingInterval , Duration timeout ) throws IOException , InterruptedException { Instant deadline = Instant . now ( ) . plus ( timeout ) ; while ( ! isDone ( operation . getOperationAdapter ( ) ) && operation . getOperationAdapter ( ) . getError ( ) == null ) { if ( Instant . now ( ) . plus ( pollingInterval ) . isAfter ( deadline ) ) { throw new InterruptedException ( "Timeout during pollUntilComplete for operation " + operation . getOperationAdapter ( ) . getName ( ) ) ; } Thread . sleep ( pollingInterval . toMillis ( ) ) ; operation = operation . executeGet ( ) ; } return operation ; }
Poll an operation until it completes, the operation get errors, or the timeout is reached.
Poll an operation until it completes the operation get errors or the timeout is reached .