Search in sources :

Example 1 with TableSpanBuilder

use of org.apache.hadoop.hbase.client.trace.TableSpanBuilder in project hbase by apache.

the class AsyncRegionLocator method getRegionLocation.

CompletableFuture<HRegionLocation> getRegionLocation(TableName tableName, byte[] row, int replicaId, RegionLocateType type, boolean reload, long timeoutNs) {
    final Supplier<Span> supplier = new TableSpanBuilder(conn).setName("AsyncRegionLocator.getRegionLocation").setTableName(tableName);
    return tracedLocationFuture(() -> {
        // meta region can not be split right now so we always call the same method.
        // Change it later if the meta table can have more than one regions.
        CompletableFuture<HRegionLocation> future = new CompletableFuture<>();
        CompletableFuture<RegionLocations> locsFuture = isMeta(tableName) ? metaRegionLocator.getRegionLocations(replicaId, reload) : nonMetaRegionLocator.getRegionLocations(tableName, row, replicaId, type, reload);
        addListener(locsFuture, (locs, error) -> {
            if (error != null) {
                future.completeExceptionally(error);
                return;
            }
            HRegionLocation loc = locs.getRegionLocation(replicaId);
            if (loc == null) {
                future.completeExceptionally(new RegionOfflineException("No location for " + tableName + ", row='" + Bytes.toStringBinary(row) + "', locateType=" + type + ", replicaId=" + replicaId));
            } else if (loc.getServerName() == null) {
                future.completeExceptionally(new RegionOfflineException("No server address listed for region '" + loc.getRegion().getRegionNameAsString() + ", row='" + Bytes.toStringBinary(row) + "', locateType=" + type + ", replicaId=" + replicaId));
            } else {
                future.complete(loc);
            }
        });
        return withTimeout(future, timeoutNs, () -> "Timeout(" + TimeUnit.NANOSECONDS.toMillis(timeoutNs) + "ms) waiting for region location for " + tableName + ", row='" + Bytes.toStringBinary(row) + "', replicaId=" + replicaId);
    }, AsyncRegionLocator::getRegionNames, supplier);
}
Also used : RegionLocations(org.apache.hadoop.hbase.RegionLocations) CompletableFuture(java.util.concurrent.CompletableFuture) HRegionLocation(org.apache.hadoop.hbase.HRegionLocation) TableSpanBuilder(org.apache.hadoop.hbase.client.trace.TableSpanBuilder) Span(io.opentelemetry.api.trace.Span)

Aggregations

Span (io.opentelemetry.api.trace.Span)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 HRegionLocation (org.apache.hadoop.hbase.HRegionLocation)1 RegionLocations (org.apache.hadoop.hbase.RegionLocations)1 TableSpanBuilder (org.apache.hadoop.hbase.client.trace.TableSpanBuilder)1