org.apache.hadoop.hbase.master
Interface LoadBalancer

All Superinterfaces:
org.apache.hadoop.conf.Configurable, Stoppable
All Known Implementing Classes:
BaseLoadBalancer, FavoredNodeLoadBalancer, SimpleLoadBalancer, StochasticLoadBalancer

@InterfaceAudience.Private
public interface LoadBalancer
extends org.apache.hadoop.conf.Configurable, Stoppable

Makes decisions about the placement and movement of Regions across RegionServers.

Cluster-wide load balancing will occur only when there are no regions in transition and according to a fixed period of a time using balanceCluster(Map).

Inline region placement with immediateAssignment(java.util.List, java.util.List) can be used when the Master needs to handle closed regions that it currently does not have a destination set for. This can happen during master failover.

On cluster startup, bulk assignment can be used to determine locations for all Regions in a cluster.

This classes produces plans for the AssignmentManager to execute.


Method Summary
 List<RegionPlan> balanceCluster(Map<ServerName,List<HRegionInfo>> clusterState)
          Perform the major balance operation
 Map<HRegionInfo,ServerName> immediateAssignment(List<HRegionInfo> regions, List<ServerName> servers)
          Sync assign a region
 void initialize()
          Initialize the load balancer.
 ServerName randomAssignment(HRegionInfo regionInfo, List<ServerName> servers)
          Get a random region server from the list
 void regionOffline(HRegionInfo regionInfo)
          Marks the region as offline at balancer.
 void regionOnline(HRegionInfo regionInfo, ServerName sn)
          Marks the region as online at balancer.
 Map<ServerName,List<HRegionInfo>> retainAssignment(Map<HRegionInfo,ServerName> regions, List<ServerName> servers)
          Assign regions to the previously hosting region server
 Map<ServerName,List<HRegionInfo>> roundRobinAssignment(List<HRegionInfo> regions, List<ServerName> servers)
          Perform a Round Robin assignment of regions.
 void setClusterStatus(ClusterStatus st)
          Set the current cluster status.
 void setMasterServices(MasterServices masterServices)
          Set the master service.
 
Methods inherited from interface org.apache.hadoop.conf.Configurable
getConf, setConf
 
Methods inherited from interface org.apache.hadoop.hbase.Stoppable
isStopped, stop
 

Method Detail

setClusterStatus

void setClusterStatus(ClusterStatus st)
Set the current cluster status. This allows a LoadBalancer to map host name to a server

Parameters:
st -

setMasterServices

void setMasterServices(MasterServices masterServices)
Set the master service.

Parameters:
masterServices -

balanceCluster

List<RegionPlan> balanceCluster(Map<ServerName,List<HRegionInfo>> clusterState)
                                throws HBaseIOException
Perform the major balance operation

Parameters:
clusterState -
Returns:
List of plans
Throws:
HBaseIOException

roundRobinAssignment

Map<ServerName,List<HRegionInfo>> roundRobinAssignment(List<HRegionInfo> regions,
                                                       List<ServerName> servers)
                                                       throws HBaseIOException
Perform a Round Robin assignment of regions.

Parameters:
regions -
servers -
Returns:
Map of servername to regioninfos
Throws:
HBaseIOException

retainAssignment

Map<ServerName,List<HRegionInfo>> retainAssignment(Map<HRegionInfo,ServerName> regions,
                                                   List<ServerName> servers)
                                                   throws HBaseIOException
Assign regions to the previously hosting region server

Parameters:
regions -
servers -
Returns:
List of plans
Throws:
HBaseIOException

immediateAssignment

Map<HRegionInfo,ServerName> immediateAssignment(List<HRegionInfo> regions,
                                                List<ServerName> servers)
                                                throws HBaseIOException
Sync assign a region

Parameters:
regions -
servers -
Returns:
Map regioninfos to servernames
Throws:
HBaseIOException

randomAssignment

ServerName randomAssignment(HRegionInfo regionInfo,
                            List<ServerName> servers)
                            throws HBaseIOException
Get a random region server from the list

Parameters:
regionInfo - Region for which this selection is being done.
servers -
Returns:
Servername
Throws:
HBaseIOException

initialize

void initialize()
                throws HBaseIOException
Initialize the load balancer. Must be called after setters.

Throws:
HBaseIOException

regionOnline

void regionOnline(HRegionInfo regionInfo,
                  ServerName sn)
Marks the region as online at balancer.

Parameters:
regionInfo -
sn -

regionOffline

void regionOffline(HRegionInfo regionInfo)
Marks the region as offline at balancer.

Parameters:
regionInfo -


Copyright © 2015 The Apache Software Foundation. All rights reserved.