Search in sources :

Example 6 with RegionSpecifierType

use of org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType in project hbase by apache.

the class ProtobufUtil method getRegionEncodedName.

/**
   * Find the HRegion encoded name based on a region specifier
   *
   * @param regionSpecifier the region specifier
   * @return the corresponding region's encoded name
   * @throws DoNotRetryIOException if the specifier type is unsupported
   */
public static String getRegionEncodedName(final RegionSpecifier regionSpecifier) throws DoNotRetryIOException {
    ByteString value = regionSpecifier.getValue();
    RegionSpecifierType type = regionSpecifier.getType();
    switch(type) {
        case REGION_NAME:
            return HRegionInfo.encodeRegionName(value.toByteArray());
        case ENCODED_REGION_NAME:
            return value.toStringUtf8();
        default:
            throw new DoNotRetryIOException("Unsupported region specifier type: " + type);
    }
}
Also used : RegionSpecifierType(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) ByteString(org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString)

Aggregations

DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)6 RegionSpecifierType (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType)6 IOException (java.io.IOException)4 ServiceException (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)4 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)3 UnknownRegionException (org.apache.hadoop.hbase.UnknownRegionException)3 ServerName (org.apache.hadoop.hbase.ServerName)2 ByteString (org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 AssignRegionResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.AssignRegionResponse)1 MoveRegionResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MoveRegionResponse)1 UnassignRegionResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.UnassignRegionResponse)1