Class MaintenanceLoadBalancer
java.lang.Object
org.apache.hadoop.hbase.master.balancer.MaintenanceLoadBalancer
- All Implemented Interfaces:
ConfigurationObserver
,LoadBalancer
,Stoppable
a balancer which is only used in maintenance mode.
-
Field Summary
Fields inherited from interface org.apache.hadoop.hbase.master.LoadBalancer
BOGUS_SERVER_NAME, HBASE_RSGROUP_LOADBALANCER_CLASS
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate Map<ServerName,
List<RegionInfo>> assign
(Collection<RegionInfo> regions, List<ServerName> servers) balanceCluster
(Map<TableName, Map<ServerName, List<RegionInfo>>> loadOfAllTable) Perform the major balance operation for cluster.void
Initialize the load balancer.boolean
Returns True ifStoppable.stop(String)
has been closed.void
onConfigurationChange
(org.apache.hadoop.conf.Configuration conf) Notification that config has changedvoid
If balancer needs to do initialization after Master has started up, lets do that here.randomAssignment
(RegionInfo regionInfo, List<ServerName> servers) Get a random region server from the listvoid
regionOffline
(RegionInfo regionInfo) Marks the region as offline at balancer.void
regionOnline
(RegionInfo regionInfo, ServerName sn) Marks the region as online at balancer.retainAssignment
(Map<RegionInfo, ServerName> regions, List<ServerName> servers) Assign regions to the previously hosting region serverroundRobinAssignment
(List<RegionInfo> regions, List<ServerName> servers) Perform a Round Robin assignment of regions.void
setClusterInfoProvider
(ClusterInfoProvider provider) Set the cluster info provider.void
Stop this service.void
updateBalancerStatus
(boolean status) void
Set the current cluster status.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.hadoop.hbase.master.LoadBalancer
updateBalancerLoadInfo
-
Field Details
-
stopped
-
-
Constructor Details
-
MaintenanceLoadBalancer
public MaintenanceLoadBalancer()
-
-
Method Details
-
stop
Description copied from interface:Stoppable
Stop this service. Implementers should favor logging errors over throwing RuntimeExceptions. -
isStopped
Description copied from interface:Stoppable
Returns True ifStoppable.stop(String)
has been closed. -
updateClusterMetrics
Description copied from interface:LoadBalancer
Set the current cluster status. This allows a LoadBalancer to map host name to a server- Specified by:
updateClusterMetrics
in interfaceLoadBalancer
-
setClusterInfoProvider
Description copied from interface:LoadBalancer
Set the cluster info provider. Usually it is just a wrapper of master.- Specified by:
setClusterInfoProvider
in interfaceLoadBalancer
-
balanceCluster
public List<RegionPlan> balanceCluster(Map<TableName, Map<ServerName, throws IOExceptionList<RegionInfo>>> loadOfAllTable) Description copied from interface:LoadBalancer
Perform the major balance operation for cluster.- Specified by:
balanceCluster
in interfaceLoadBalancer
- Parameters:
loadOfAllTable
- region load of servers for all table- Returns:
- a list of regions to be moved, including source and destination, or null if cluster is already balanced
- Throws:
IOException
-
assign
private Map<ServerName,List<RegionInfo>> assign(Collection<RegionInfo> regions, List<ServerName> servers) -
roundRobinAssignment
public Map<ServerName,List<RegionInfo>> roundRobinAssignment(List<RegionInfo> regions, List<ServerName> servers) throws IOException Description copied from interface:LoadBalancer
Perform a Round Robin assignment of regions.- Specified by:
roundRobinAssignment
in interfaceLoadBalancer
- Returns:
- Map of servername to regioninfos
- Throws:
IOException
-
retainAssignment
public Map<ServerName,List<RegionInfo>> retainAssignment(Map<RegionInfo, ServerName> regions, List<ServerName> servers) throws IOExceptionDescription copied from interface:LoadBalancer
Assign regions to the previously hosting region server- Specified by:
retainAssignment
in interfaceLoadBalancer
- Returns:
- List of plans
- Throws:
IOException
-
randomAssignment
public ServerName randomAssignment(RegionInfo regionInfo, List<ServerName> servers) throws IOException Description copied from interface:LoadBalancer
Get a random region server from the list- Specified by:
randomAssignment
in interfaceLoadBalancer
- Parameters:
regionInfo
- Region for which this selection is being done.- Throws:
IOException
-
initialize
Description copied from interface:LoadBalancer
Initialize the load balancer. Must be called after setters.- Specified by:
initialize
in interfaceLoadBalancer
-
regionOnline
Description copied from interface:LoadBalancer
Marks the region as online at balancer.- Specified by:
regionOnline
in interfaceLoadBalancer
-
regionOffline
Description copied from interface:LoadBalancer
Marks the region as offline at balancer.- Specified by:
regionOffline
in interfaceLoadBalancer
-
onConfigurationChange
Description copied from interface:LoadBalancer
Notification that config has changed- Specified by:
onConfigurationChange
in interfaceConfigurationObserver
- Specified by:
onConfigurationChange
in interfaceLoadBalancer
-
postMasterStartupInitialize
Description copied from interface:LoadBalancer
If balancer needs to do initialization after Master has started up, lets do that here.- Specified by:
postMasterStartupInitialize
in interfaceLoadBalancer
-
updateBalancerStatus
- Specified by:
updateBalancerStatus
in interfaceLoadBalancer
-