code: public TableDescription waitForActive() throws InterruptedException {
          final Table table = getTable();
          final String tableName = table.getTableName();
          final String indexName = getIndexName();
          retry: for (;;) {
              TableDescription desc = table.waitForActive();
              final List<GlobalSecondaryIndexDescription> list = desc.getGlobalSecondaryIndexes();
              if (list != null) {
                  for (GlobalSecondaryIndexDescription d: list) {
                      if (d.getIndexName().equals(indexName)) {
                          final String status = d.getIndexStatus();
                          switch(IndexStatus.fromValue(status)) {
                              case ACTIVE:
                                  return desc;
                              case CREATING:
                              case UPDATING:
                                  Thread.sleep(SLEEP_TIME_MILLIS);
                                  continue retry;
                              default:
                                  throw new IllegalArgumentException(
                                      "Global Secondary Index "
                                      + indexName
                                      + " is not being created or updated (with status="
                                      + status + ")");
                          }
                      }
                  }
              }
              throw new IllegalArgumentException("Global Secondary Index "
                      + indexName + " does not exist in Table " + tableName + ")");
          }
      }
docs: A convenient blocking call that can be used, typically during index
  creation, to wait for the index to become active by polling the table
  every 5 seconds.
  <p>
  Currently online index creation is only supported for Global Secondary
  Index (GSI). Calling this method on a Local Secondary Index (LSI) would
  result in <code>IllegalArgumentException</code>.
  
  @return the table description when the index has become active
  
  @throws IllegalArgumentException if the table is being deleted, or if
  the GSI is not being created or updated, or if the GSI doesn't exist
  @throws ResourceNotFoundException if the table doesn't exist