HBASE-25872 Add documentation for LoadBalancer about synchronization (#3267)
Signed-off-by: Xin Sun <ddupgs@gmail.com>
This commit is contained in:
parent
d5d972f92e
commit
439fd4aff2
@ -33,18 +33,32 @@ import org.apache.hadoop.hbase.conf.ConfigurationObserver;
|
||||
import org.apache.yetus.audience.InterfaceAudience;
|
||||
|
||||
/**
|
||||
* Makes decisions about the placement and movement of Regions across
|
||||
* RegionServers.
|
||||
*
|
||||
* <p>Cluster-wide load balancing will occur only when there are no regions in
|
||||
* transition and according to a fixed period of a time using {@link #balanceCluster(Map)}.
|
||||
*
|
||||
* <p>On cluster startup, bulk assignment can be used to determine
|
||||
* locations for all Regions in a cluster.
|
||||
*
|
||||
* <p>This class produces plans for the
|
||||
* {@link org.apache.hadoop.hbase.master.assignment.AssignmentManager}
|
||||
* to execute.
|
||||
* Makes decisions about the placement and movement of Regions across RegionServers.
|
||||
* <p/>
|
||||
* Cluster-wide load balancing will occur only when there are no regions in transition and according
|
||||
* to a fixed period of a time using {@link #balanceCluster(Map)}.
|
||||
* <p/>
|
||||
* On cluster startup, bulk assignment can be used to determine locations for all Regions in a
|
||||
* cluster.
|
||||
* <p/>
|
||||
* This class produces plans for the {@code AssignmentManager} to execute.
|
||||
* <p/>
|
||||
* About locking:
|
||||
* <ul>
|
||||
* <li>We will first call {@link #setMasterServices(MasterServices)} and then
|
||||
* {@link #initialize()} to initialize the balancer, and before calling {@link #initialize()}, we
|
||||
* will never call any methods of this balancer. So these two methods do not need to be
|
||||
* synchronized.</li>
|
||||
* <li>The {@link #balanceCluster(Map)} method will use the {@link ClusterMetrics} which is set by
|
||||
* {@link #updateClusterMetrics(ClusterMetrics)}, and also lots of configurations, which could be
|
||||
* changed by {@link #onConfigurationChange(Configuration)}, so the easier way is to make these
|
||||
* three methods synchronized. And since there will be only one balancing thread, this will not
|
||||
* impact performance too much.</li>
|
||||
* <li>The {@link #roundRobinAssignment(List, List)}, {@link #retainAssignment(Map, List)} and
|
||||
* {@link #randomAssignment(RegionInfo, List)} could be called from multiple threads concurrently,
|
||||
* so these three methods should not be synchronized, the implementation classes need to make sure
|
||||
* that they are thread safe.</li>
|
||||
* </ul>
|
||||
*/
|
||||
@InterfaceAudience.Private
|
||||
public interface LoadBalancer extends Stoppable, ConfigurationObserver {
|
||||
|
Loading…
x
Reference in New Issue
Block a user