@InterfaceAudience.Private public class MaintenanceLoadBalancer extends Object implements LoadBalancer
Modifier and Type | Field and Description |
---|---|
private boolean |
stopped |
BOGUS_SERVER_NAME, SYSTEM_TABLES_ON_MASTER, TABLES_ON_MASTER
Constructor and Description |
---|
MaintenanceLoadBalancer() |
Modifier and Type | Method and Description |
---|---|
private Map<ServerName,List<RegionInfo>> |
assign(Collection<RegionInfo> regions,
List<ServerName> servers) |
List<RegionPlan> |
balanceCluster(Map<TableName,Map<ServerName,List<RegionInfo>>> loadOfAllTable)
Perform the major balance operation for cluster.
|
void |
initialize()
Initialize the load balancer.
|
boolean |
isStopped()
Returns True if
Stoppable.stop(String) has been closed. |
void |
onConfigurationChange(org.apache.hadoop.conf.Configuration conf)
This method would be called by the
ConfigurationManager object when the
Configuration object is reloaded from disk. |
void |
postMasterStartupInitialize()
If balancer needs to do initialization after Master has started up, lets do that here.
|
ServerName |
randomAssignment(RegionInfo regionInfo,
List<ServerName> servers)
Get a random region server from the list
|
void |
regionOffline(RegionInfo regionInfo)
Marks the region as offline at balancer.
|
void |
regionOnline(RegionInfo regionInfo,
ServerName sn)
Marks the region as online at balancer.
|
Map<ServerName,List<RegionInfo>> |
retainAssignment(Map<RegionInfo,ServerName> regions,
List<ServerName> servers)
Assign regions to the previously hosting region server nn * @return List of plans
|
Map<ServerName,List<RegionInfo>> |
roundRobinAssignment(List<RegionInfo> regions,
List<ServerName> servers)
Perform a Round Robin assignment of regions.
|
void |
setMasterServices(MasterServices masterServices)
Set the master service.
|
void |
stop(String why)
Stop this service.
|
void |
updateBalancerStatus(boolean status) |
void |
updateClusterMetrics(ClusterMetrics st)
Set the current cluster status.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isMasterCanHostUserRegions, isSystemTablesOnlyOnMaster, isTablesOnMaster, updateBalancerLoadInfo
private volatile boolean stopped
public MaintenanceLoadBalancer()
public void stop(String why)
Stoppable
public boolean isStopped()
Stoppable
Stoppable.stop(String)
has been closed.public void updateClusterMetrics(ClusterMetrics st)
LoadBalancer
updateClusterMetrics
in interface LoadBalancer
public void setMasterServices(MasterServices masterServices)
LoadBalancer
setMasterServices
in interface LoadBalancer
public List<RegionPlan> balanceCluster(Map<TableName,Map<ServerName,List<RegionInfo>>> loadOfAllTable) throws IOException
LoadBalancer
balanceCluster
in interface LoadBalancer
loadOfAllTable
- region load of servers for all tableIOException
private Map<ServerName,List<RegionInfo>> assign(Collection<RegionInfo> regions, List<ServerName> servers)
public Map<ServerName,List<RegionInfo>> roundRobinAssignment(List<RegionInfo> regions, List<ServerName> servers)
LoadBalancer
roundRobinAssignment
in interface LoadBalancer
public Map<ServerName,List<RegionInfo>> retainAssignment(Map<RegionInfo,ServerName> regions, List<ServerName> servers)
LoadBalancer
retainAssignment
in interface LoadBalancer
public ServerName randomAssignment(RegionInfo regionInfo, List<ServerName> servers)
LoadBalancer
randomAssignment
in interface LoadBalancer
regionInfo
- Region for which this selection is being done. nnpublic void initialize()
LoadBalancer
initialize
in interface LoadBalancer
public void regionOnline(RegionInfo regionInfo, ServerName sn)
LoadBalancer
regionOnline
in interface LoadBalancer
public void regionOffline(RegionInfo regionInfo)
LoadBalancer
regionOffline
in interface LoadBalancer
public void onConfigurationChange(org.apache.hadoop.conf.Configuration conf)
ConfigurationObserver
ConfigurationManager
object when the
Configuration
object is reloaded from disk.onConfigurationChange
in interface ConfigurationObserver
onConfigurationChange
in interface LoadBalancer
public void postMasterStartupInitialize()
LoadBalancer
postMasterStartupInitialize
in interface LoadBalancer
public void updateBalancerStatus(boolean status)
updateBalancerStatus
in interface LoadBalancer
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.