Package org.apache.hadoop.hbase.client
Class RegionReplicaUtil
java.lang.Object
org.apache.hadoop.hbase.client.RegionReplicaUtil
- Direct Known Subclasses:
ServerRegionReplicaUtil
Utility methods which contain the logic for regions and replicas.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final boolean(package private) static final intThe default replicaId for the regionstatic final StringWhether 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. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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)private static intcompareRegionInfosWithoutReplicaId(RegionInfo regionInfoA, RegionInfo regionInfoB) static RegionInfogetRegionInfoForDefaultReplica(RegionInfo regionInfo) Returns the RegionInfo for the default replicaId (0).static RegionInfogetRegionInfoForReplica(RegionInfo regionInfo, int replicaId) Returns the RegionInfo for the given replicaId.static booleanisDefaultReplica(int replicaId) Returns true if this replicaId corresponds to default replica for the regionstatic booleanReturns true if this region is a default replica for the regionstatic booleanisReplicasForSameRegion(RegionInfo regionInfoA, RegionInfo regionInfoB) static voidremoveNonDefaultRegions(Collection<RegionInfo> regions) Removes the non-default replicas from the passed regions collection
-
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
- See Also:
-
DEFAULT_REPLICA_ID
The default replicaId for the region- See Also:
-
-
Constructor Details
-
RegionReplicaUtil
public RegionReplicaUtil()
-
-
Method Details
-
getRegionInfoForReplica
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
Returns true if this replicaId corresponds to default replica for the region -
isDefaultReplica
Returns true if this region is a default replica for the region -
removeNonDefaultRegions
Removes the non-default replicas from the passed regions collection -
isReplicasForSameRegion
-
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 regionsoldReplicaCount- existing replica countnewReplicaCount- updated replica count due to modify table- Returns:
- the combined list of default and non-default replicas
-