Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBASE-25872 Add documentation for LoadBalancer about synchronization #3267

Merged
merged 1 commit into from
May 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@
* cluster.
* <p/>
* This class produces plans for the {@code AssignmentManager} to execute.
* <p/>
* About locking:
* <ul>
* <li>We will first call {@link #setClusterInfoProvider(ClusterInfoProvider)} 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 {
Expand Down