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:
parent
ed864807e3
commit
1be8cd2c63
|
@ -836,6 +836,12 @@ MasterServices, Server {
|
||||||
Set<ServerName> previouslyFailedMetaRSs = getPreviouselyFailedMetaServersFromZK();
|
Set<ServerName> previouslyFailedMetaRSs = getPreviouselyFailedMetaServersFromZK();
|
||||||
|
|
||||||
this.initializationBeforeMetaAssignment = true;
|
this.initializationBeforeMetaAssignment = true;
|
||||||
|
|
||||||
|
//initialize load balancer
|
||||||
|
this.balancer.setClusterStatus(getClusterStatus());
|
||||||
|
this.balancer.setMasterServices(this);
|
||||||
|
this.balancer.initialize();
|
||||||
|
|
||||||
// Make sure meta assigned before proceeding.
|
// Make sure meta assigned before proceeding.
|
||||||
status.setStatus("Assigning Meta Region");
|
status.setStatus("Assigning Meta Region");
|
||||||
assignMeta(status);
|
assignMeta(status);
|
||||||
|
@ -877,11 +883,11 @@ MasterServices, Server {
|
||||||
org.apache.hadoop.hbase.catalog.MetaMigrationConvertingToPB
|
org.apache.hadoop.hbase.catalog.MetaMigrationConvertingToPB
|
||||||
.updateMetaIfNecessary(this);
|
.updateMetaIfNecessary(this);
|
||||||
|
|
||||||
this.balancer.setMasterServices(this);
|
|
||||||
// Fix up assignment manager status
|
// Fix up assignment manager status
|
||||||
status.setStatus("Starting assignment manager");
|
status.setStatus("Starting assignment manager");
|
||||||
this.assignmentManager.joinCluster();
|
this.assignmentManager.joinCluster();
|
||||||
|
|
||||||
|
//set cluster status again after user regions are assigned
|
||||||
this.balancer.setClusterStatus(getClusterStatus());
|
this.balancer.setClusterStatus(getClusterStatus());
|
||||||
|
|
||||||
if (!masterRecovery) {
|
if (!masterRecovery) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.hadoop.hbase.ClusterStatus;
|
||||||
import org.apache.hadoop.hbase.HBaseIOException;
|
import org.apache.hadoop.hbase.HBaseIOException;
|
||||||
import org.apache.hadoop.hbase.HRegionInfo;
|
import org.apache.hadoop.hbase.HRegionInfo;
|
||||||
import org.apache.hadoop.hbase.ServerName;
|
import org.apache.hadoop.hbase.ServerName;
|
||||||
|
import org.apache.hadoop.hbase.Stoppable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes decisions about the placement and movement of Regions across
|
* 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.
|
* <p>This classes produces plans for the {@link AssignmentManager} to execute.
|
||||||
*/
|
*/
|
||||||
@InterfaceAudience.Public
|
@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
|
* 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(
|
ServerName randomAssignment(
|
||||||
HRegionInfo regionInfo, List<ServerName> servers
|
HRegionInfo regionInfo, List<ServerName> servers
|
||||||
) throws HBaseIOException;
|
) throws HBaseIOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the load balancer. Must be called after setters.
|
||||||
|
* @throws HBaseIOException
|
||||||
|
*/
|
||||||
|
void initialize() throws HBaseIOException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.hbase.ClusterStatus;
|
import org.apache.hadoop.hbase.ClusterStatus;
|
||||||
|
import org.apache.hadoop.hbase.HBaseIOException;
|
||||||
import org.apache.hadoop.hbase.HRegionInfo;
|
import org.apache.hadoop.hbase.HRegionInfo;
|
||||||
import org.apache.hadoop.hbase.RegionLoad;
|
import org.apache.hadoop.hbase.RegionLoad;
|
||||||
import org.apache.hadoop.hbase.ServerName;
|
import org.apache.hadoop.hbase.ServerName;
|
||||||
|
@ -51,6 +52,7 @@ import com.google.common.collect.Sets;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class BaseLoadBalancer implements LoadBalancer {
|
public abstract class BaseLoadBalancer implements LoadBalancer {
|
||||||
|
private volatile boolean stopped = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An efficient array based implementation similar to ClusterState for keeping
|
* An efficient array based implementation similar to ClusterState for keeping
|
||||||
|
@ -566,4 +568,18 @@ public abstract class BaseLoadBalancer implements LoadBalancer {
|
||||||
return assignments;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue