Class CatalogReplicaLoadBalanceSimpleSelector

java.lang.Object
org.apache.hadoop.hbase.client.CatalogReplicaLoadBalanceSimpleSelector
All Implemented Interfaces:
CatalogReplicaLoadBalanceSelector, Stoppable

CatalogReplicaLoadBalanceReplicaSimpleSelector implements a simple catalog replica load balancing algorithm. It maintains a stale location cache for each table. Whenever client looks up location, it first check if the row is the stale location cache. If yes, the location from catalog replica is stale, it will go to the primary region to look up update-to-date location; otherwise, it will randomly pick up a replica region or primary region for lookup. When clients receive RegionNotServedException from region servers, it will add these region locations to the stale location cache. The stale cache will be cleaned up periodically by a chore.

It follows a simple algorithm to choose a meta replica region (including primary meta) to go:
  1. If there is no stale location entry for rows it looks up, it will randomly pick a meta replica region (including primary meta) to do lookup.
  2. If the location from the replica region is stale, client gets RegionNotServedException from region server, in this case, it will create StaleLocationCacheEntry in CatalogReplicaLoadBalanceReplicaSimpleSelector.
  3. When client tries to do location lookup, it checks StaleLocationCache first for rows it tries to lookup, if entry exists, it will go with primary meta region to do lookup; otherwise, it will follow step 1.
  4. A chore will periodically run to clean up cache entries in the StaleLocationCache.