Class RegionReplicaUtil

java.lang.Object
org.apache.hadoop.hbase.client.RegionReplicaUtil
Direct Known Subclasses:
ServerRegionReplicaUtil

@Private public class RegionReplicaUtil extends Object
Utility methods which contain the logic for regions and replicas.
  • Field Details

    • REGION_REPLICA_WAIT_FOR_PRIMARY_FLUSH_CONF_KEY

      Whether or not the secondary region will wait for observing a flush / region open event from the primary region via async wal replication before enabling read requests. Since replayed edits from async wal replication from primary is not persisted in WAL, the memstore of the secondary region might be non-empty at the time of close or crash. For ensuring seqId's not "going back in time" in the secondary region replica, this should be enabled. However, in some cases the above semantics might be ok for some application classes. See HBASE-11580 for more context.
      See Also:
    • DEFAULT_REGION_REPLICA_WAIT_FOR_PRIMARY_FLUSH

      protected static final boolean DEFAULT_REGION_REPLICA_WAIT_FOR_PRIMARY_FLUSH
      See Also:
    • DEFAULT_REPLICA_ID

      static final int DEFAULT_REPLICA_ID
      The default replicaId for the region
      See Also:
  • Constructor Details

  • Method Details

    • getRegionInfoForReplica

      public static RegionInfo getRegionInfoForReplica(RegionInfo regionInfo, int replicaId)
      Returns the RegionInfo for the given replicaId. RegionInfo's correspond to a range of a table, but more than one "instance" of the same range can be deployed which are differentiated by the replicaId.
      Returns:
      an RegionInfo object corresponding to the same range (table, start and end key), but for the given replicaId.
    • getRegionInfoForDefaultReplica

      Returns the RegionInfo for the default replicaId (0). RegionInfo's correspond to a range of a table, but more than one "instance" of the same range can be deployed which are differentiated by the replicaId.
      Returns:
      an RegionInfo object corresponding to the same range (table, start and end key), but for the default replicaId.
    • isDefaultReplica

      public static boolean isDefaultReplica(int replicaId)
      Returns true if this replicaId corresponds to default replica for the region
    • isDefaultReplica

      public static boolean isDefaultReplica(RegionInfo hri)
      Returns true if this region is a default replica for the region
    • removeNonDefaultRegions

      public static void removeNonDefaultRegions(Collection<RegionInfo> regions)
      Removes the non-default replicas from the passed regions collection
    • isReplicasForSameRegion

      public static boolean isReplicasForSameRegion(RegionInfo regionInfoA, RegionInfo regionInfoB)
    • compareRegionInfosWithoutReplicaId

      private static int compareRegionInfosWithoutReplicaId(RegionInfo regionInfoA, RegionInfo regionInfoB)
    • addReplicas

      public static List<RegionInfo> addReplicas(List<RegionInfo> regions, int oldReplicaCount, int newReplicaCount)
      Create any replicas for the regions (the default replicas that was already created is passed to the method)
      Parameters:
      regions - existing regions
      oldReplicaCount - existing replica count
      newReplicaCount - updated replica count due to modify table
      Returns:
      the combined list of default and non-default replicas