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,10 +836,16 @@ 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);
|
||||
// check if master is shutting down because above assignMeta could return even META isn't
|
||||
// check if master is shutting down because above assignMeta could return even META isn't
|
||||
// assigned when master is shutting down
|
||||
if(this.stopped) return;
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -974,7 +980,7 @@ MasterServices, Server {
|
|||
boolean beingExpired = false;
|
||||
|
||||
status.setStatus("Assigning META region");
|
||||
|
||||
|
||||
assignmentManager.getRegionStates().createRegionState(HRegionInfo.FIRST_META_REGIONINFO);
|
||||
boolean rit = this.assignmentManager
|
||||
.processRegionInTransitionAndBlockUntilAssigned(HRegionInfo.FIRST_META_REGIONINFO);
|
||||
|
@ -1217,11 +1223,11 @@ MasterServices, Server {
|
|||
public ActiveMasterManager getActiveMasterManager() {
|
||||
return this.activeMasterManager;
|
||||
}
|
||||
|
||||
|
||||
public MasterAddressTracker getMasterAddressManager() {
|
||||
return this.masterAddressManager;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Start up all services. If any of these threads gets an unhandled exception
|
||||
* then they just die with a logged message. This should be fine because
|
||||
|
@ -1785,14 +1791,14 @@ MasterServices, Server {
|
|||
if (getNamespaceDescriptor(namespace) == null) {
|
||||
throw new ConstraintException("Namespace " + namespace + " does not exist");
|
||||
}
|
||||
|
||||
|
||||
HRegionInfo[] newRegions = getHRegionInfos(hTableDescriptor, splitKeys);
|
||||
checkInitialized();
|
||||
checkCompression(hTableDescriptor);
|
||||
if (cpHost != null) {
|
||||
cpHost.preCreateTable(hTableDescriptor, newRegions);
|
||||
}
|
||||
|
||||
|
||||
this.executorService.submit(new CreateTableHandler(this,
|
||||
this.fileSystemManager, hTableDescriptor, conf,
|
||||
newRegions, this).prepare());
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue