private void waitUntilTableIsActive()

in iep-spring-leader-dynamodb/src/main/java/com/netflix/iep/leader/dynamodb/DynamoDbLeaderDatabase.java [326:353]


  private void waitUntilTableIsActive(
      DynamoDbClient db,
      String tableName,
      Duration tableActiveTimeout
  ) {
    final Instant timeoutInstant = Instant.now().plus(tableActiveTimeout);
    final Duration waitDuration = Duration.ofSeconds(20L);
    while (Instant.now().isBefore(timeoutInstant)) {
      logger.debug("Checking if table '{}' is active", tableName);

      if (tableIsActive(db, tableName)) return;

      logger.debug("Table '{}' is not yet active, waiting ${waitDuration}", tableName);
      try {
        Thread.sleep(waitDuration.toMillis());
      } catch (InterruptedException e) {
        logger.warn("Interrupted while waiting for table '{}' to become active", tableName);
        Thread.currentThread().interrupt();
      }
    }

    final String message = String.format(
        "Table '%s' did not transition to active within: %s",
        tableName, tableActiveTimeout
    );
    logger.error(message);
    throw new TableActiveTimeoutException(message);
  }