CompletableFuture<HRegionLocation> getRegionLocation(byte[] regionNameOrEncodedRegionName) {
    if (regionNameOrEncodedRegionName == null) {
      return failedFuture(new IllegalArgumentException("Passed region name can't be null"));
    }

    CompletableFuture<Optional<HRegionLocation>> future;
    if (RegionInfo.isEncodedRegionName(regionNameOrEncodedRegionName)) {
      String encodedName = Bytes.toString(regionNameOrEncodedRegionName);
      if (encodedName.length() < RegionInfo.MD5_HEX_LENGTH) {
        // old format encodedName, should be meta region
        future = connection.registry.getMetaRegionLocations()
          .thenApply(locs -> Stream.of(locs.getRegionLocations())
            .filter(loc -> loc.getRegion().getEncodedName().equals(encodedName)).findFirst());
      } else {
        future = ClientMetaTableAccessor.getRegionLocationWithEncodedName(metaTable,
          regionNameOrEncodedRegionName);
      }
    } else {
      // Not all regionNameOrEncodedRegionName here is going to be a valid region name,
      // it needs to throw out IllegalArgumentException in case tableName is passed in.
      RegionInfo regionInfo;
      try {
        regionInfo =
          CatalogFamilyFormat.parseRegionInfoFromRegionName(regionNameOrEncodedRegionName);
      } catch (IOException ioe) {
        return failedFuture(new IllegalArgumentException(ioe.getMessage()));
      }

      if (regionInfo.isMetaRegion()) {
        future = connection.registry.getMetaRegionLocations()
          .thenApply(locs -> Stream.of(locs.getRegionLocations())
            .filter(loc -> loc.getRegion().getReplicaId() == regionInfo.getReplicaId())
            .findFirst());
      } else {
        future =
          ClientMetaTableAccessor.getRegionLocation(metaTable, regionNameOrEncodedRegionName);
      }
    }

    CompletableFuture<HRegionLocation> returnedFuture = new CompletableFuture<>();
    addListener(future, (location, err) -> {
      if (err != null) {
        returnedFuture.completeExceptionally(err);
        return;
      }
      if (!location.isPresent() || location.get().getRegion() == null) {
        returnedFuture.completeExceptionally(
          new UnknownRegionException("Invalid region name or encoded region name: "
            + Bytes.toStringBinary(regionNameOrEncodedRegionName)));
      } else {
        returnedFuture.complete(location.get());
      }
    });
    return returnedFuture;
  }
Get the region location for the passed region name. The region name may be a full region name
or encoded region name. If the region does not found, then it'll throw an
UnknownRegionException wrapped by a {@link CompletableFuture}
@param regionNameOrEncodedRegionName region name or encoded region name
@return region location, wrapped by a {@link CompletableFuture}
hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java