code: private void blockUntilOpenShardsAtMost(int maxOpenShards, @Nullable TransferKey permittedKey)
              throws IOException, InterruptedException {
          blockUntilOpenShardsAtMost(maxOpenShards, permittedKey, Instant.MAX);
      }
docs: Blocks until the number of open shards is equal to or less than the provided threshold.