HBASE-9263 Add initialize method to load balancer interface

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1516310 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2013-08-21 21:42:03 +00:00
parent ed864807e3
commit 1be8cd2c63
3 changed files with 37 additions and 8 deletions

View File

@ -836,6 +836,12 @@ MasterServices, Server {
Set<ServerName> previouslyFailedMetaRSs = getPreviouselyFailedMetaServersFromZK();
this.initializationBeforeMetaAssignment = true;
//initialize load balancer
this.balancer.setClusterStatus(getClusterStatus());
this.balancer.setMasterServices(this);
this.balancer.initialize();
// Make sure meta assigned before proceeding.
status.setStatus("Assigning Meta Region");
assignMeta(status);
@ -877,11 +883,11 @@ MasterServices, Server {
org.apache.hadoop.hbase.catalog.MetaMigrationConvertingToPB
.updateMetaIfNecessary(this);
this.balancer.setMasterServices(this);
// Fix up assignment manager status
status.setStatus("Starting assignment manager");
this.assignmentManager.joinCluster();
//set cluster status again after user regions are assigned
this.balancer.setClusterStatus(getClusterStatus());
if (!masterRecovery) {

View File

@ -27,6 +27,7 @@ import org.apache.hadoop.hbase.ClusterStatus;
import org.apache.hadoop.hbase.HBaseIOException;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.Stoppable;
/**
* Makes decisions about the placement and movement of Regions across
@ -45,7 +46,7 @@ import org.apache.hadoop.hbase.ServerName;
* <p>This classes produces plans for the {@link AssignmentManager} to execute.
*/
@InterfaceAudience.Public
public interface LoadBalancer extends Configurable {
public interface LoadBalancer extends Configurable, Stoppable {
/**
* Set the current cluster status. This allows a LoadBalancer to map host name to a server
@ -110,4 +111,10 @@ public interface LoadBalancer extends Configurable {
ServerName randomAssignment(
HRegionInfo regionInfo, List<ServerName> servers
) throws HBaseIOException;
/**
* Initialize the load balancer. Must be called after setters.
* @throws HBaseIOException
*/
void initialize() throws HBaseIOException;
}

View File

@ -33,6 +33,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.ClusterStatus;
import org.apache.hadoop.hbase.HBaseIOException;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.RegionLoad;
import org.apache.hadoop.hbase.ServerName;
@ -51,6 +52,7 @@ import com.google.common.collect.Sets;
*
*/
public abstract class BaseLoadBalancer implements LoadBalancer {
private volatile boolean stopped = false;
/**
* An efficient array based implementation similar to ClusterState for keeping
@ -566,4 +568,18 @@ public abstract class BaseLoadBalancer implements LoadBalancer {
return assignments;
}
@Override
public void initialize() throws HBaseIOException{
}
@Override
public boolean isStopped() {
return stopped;
}
@Override
public void stop(String why) {
LOG.info("Load Balancer stop requested: "+why);
stopped = true;
}
}