Skip to content

Commit

Permalink
HBASE-25290 Remove table on master related code in balancer implement…
Browse files Browse the repository at this point in the history
…ation (#3162)

Signed-off-by: Yulin Niu <niuyulin@apache.org>
  • Loading branch information
Apache9 authored Apr 20, 2021
1 parent 33e886c commit 781da18
Show file tree
Hide file tree
Showing 32 changed files with 56 additions and 740 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@
import java.io.FileWriter;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer;
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker;
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.apache.hadoop.hbase.zookeeper.ZNodePaths;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.zookeeper.KeeperException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -145,21 +141,6 @@ public static String parseMasterServerName(String rsZnodePath) {
return masterServerName;
}

/**
* @return true if cluster is configured with master-rs collocation
* @deprecated since 2.4.0, will be removed in 3.0.0.
* @see <a href="https://issues.apache.org/jira/browse/HBASE-15549">HBASE-15549</a>
*/
@Deprecated
private static boolean tablesOnMaster(Configuration conf) {
boolean tablesOnMaster = true;
String confValue = conf.get(BaseLoadBalancer.TABLES_ON_MASTER);
if (confValue != null && confValue.equalsIgnoreCase("none")) {
tablesOnMaster = false;
}
return tablesOnMaster;
}

/**
* Delete the master znode if its content (ServerName string) is the same
* as the one in the znode file. (env: HBASE_ZNODE_FILE). I case of master-rs
Expand All @@ -185,25 +166,14 @@ public static boolean clear(Configuration conf) {
String znodeFileContent;
try {
znodeFileContent = ZNodeClearer.readMyEphemeralNodeOnDisk();
if (ZNodeClearer.tablesOnMaster(conf)) {
// In case of master crash also remove rsZnode since master is also regionserver
ZKUtil.deleteNodeFailSilent(zkw,
ZNodePaths.joinZNode(zkw.getZNodePaths().rsZNode, znodeFileContent));
return MasterAddressTracker.deleteIfEquals(zkw,
ZNodeClearer.parseMasterServerName(znodeFileContent));
} else {
return MasterAddressTracker.deleteIfEquals(zkw, znodeFileContent);
}
return MasterAddressTracker.deleteIfEquals(zkw, znodeFileContent);
} catch (FileNotFoundException fnfe) {
// If no file, just keep going -- return success.
LOG.warn("Can't find the znode file; presume non-fatal", fnfe);
return true;
} catch (IOException e) {
LOG.warn("Can't read the content of the znode file", e);
return false;
} catch (KeeperException e) {
LOG.warn("ZooKeeper exception deleting znode", e);
return false;
} finally {
zkw.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,17 +605,14 @@ protected void login(UserProvider user, String host) throws IOException {
}

/**
* If configured to put regions on active master,
* wait till a backup master becomes active.
* Otherwise, loop till the server is stopped or aborted.
* Loop till the server is stopped or aborted.
*/
@Override
protected void waitForMasterActive(){
protected void waitForMasterActive() {
if (maintenanceMode) {
return;
}
boolean tablesOnMaster = LoadBalancer.isTablesOnMaster(conf);
while (!(tablesOnMaster && activeMaster) && !isStopped() && !isAborted()) {
while (!isStopped() && !isAborted()) {
sleeper.sleep();
}
}
Expand Down Expand Up @@ -658,7 +655,7 @@ protected RSRpcServices createRpcServices() throws IOException {
protected void configureInfoServer() {
infoServer.addUnprivilegedServlet("master-status", "/master-status", MasterStatusServlet.class);
infoServer.setAttribute(MASTER, this);
if (LoadBalancer.isTablesOnMaster(conf)) {
if (maintenanceMode) {
super.configureInfoServer();
}
}
Expand Down Expand Up @@ -3703,7 +3700,7 @@ public SyncReplicationReplayWALManager getSyncReplicationReplayWALManager() {

@Override
public Map<String, ReplicationStatus> getWalGroupsReplicationStatus() {
if (!this.isOnline() || !LoadBalancer.isMasterCanHostUserRegions(conf)) {
if (!this.isOnline() || !maintenanceMode) {
return new HashMap<>();
}
return super.getWalGroupsReplicationStatus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,6 @@
*/
@InterfaceAudience.Private
public interface LoadBalancer extends Configurable, Stoppable, ConfigurationObserver {
/**
* Master can carry regions as of hbase-2.0.0.
* By default, it carries no tables.
* TODO: Add any | system as flags to indicate what it can do.
*
* @deprecated since 2.4.0, will be removed in 3.0.0.
* @see <a href="https://issues.apache.org/jira/browse/HBASE-15549">HBASE-15549</a>
*/
@Deprecated
String TABLES_ON_MASTER = "hbase.balancer.tablesOnMaster";

/**
* Master carries system tables.
*
* @deprecated since 2.4.0, will be removed in 3.0.0.
* @see <a href="https://issues.apache.org/jira/browse/HBASE-15549">HBASE-15549</a>
*/
@Deprecated
String SYSTEM_TABLES_ON_MASTER = "hbase.balancer.tablesOnMaster.systemTablesOnly";

// Used to signal to the caller that the region(s) cannot be assigned
// We deliberately use 'localhost' so the operation will fail fast
Expand Down Expand Up @@ -164,32 +145,4 @@ Map<ServerName, List<RegionInfo>> retainAssignment(Map<RegionInfo, ServerName> r

/*Updates balancer status tag reported to JMX*/
void updateBalancerStatus(boolean status);

/**
* @return true if Master carries regions
* @deprecated since 2.4.0, will be removed in 3.0.0.
* @see <a href="https://issues.apache.org/jira/browse/HBASE-15549">HBASE-15549</a>
*/
@Deprecated
static boolean isTablesOnMaster(Configuration conf) {
return conf.getBoolean(TABLES_ON_MASTER, false);
}

/**
* @deprecated since 2.4.0, will be removed in 3.0.0.
* @see <a href="https://issues.apache.org/jira/browse/HBASE-15549">HBASE-15549</a>
*/
@Deprecated
static boolean isSystemTablesOnlyOnMaster(Configuration conf) {
return conf.getBoolean(SYSTEM_TABLES_ON_MASTER, false);
}

/**
* @deprecated since 2.4.0, will be removed in 3.0.0.
* @see <a href="https://issues.apache.org/jira/browse/HBASE-15549">HBASE-15549</a>
*/
@Deprecated
static boolean isMasterCanHostUserRegions(Configuration conf) {
return isTablesOnMaster(conf) && !isSystemTablesOnlyOnMaster(conf);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,7 @@ protected RpcServerInterface createRpcServer(final Server server,
final String name) throws IOException {
final Configuration conf = regionServer.getConfiguration();
// RpcServer at HM by default enable ByteBufferPool iff HM having user table region in it
boolean reservoirEnabled = conf.getBoolean(ByteBuffAllocator.ALLOCATOR_POOL_ENABLED_KEY,
LoadBalancer.isMasterCanHostUserRegions(conf));
boolean reservoirEnabled = conf.getBoolean(ByteBuffAllocator.ALLOCATOR_POOL_ENABLED_KEY, false);
try {
return RpcServerFactory.createRpcServer(server, name, getServices(),
bindAddress, // use final bindAddress for this server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import org.apache.hadoop.hbase.RegionMetrics;
import org.apache.hadoop.hbase.ScheduledChore;
import org.apache.hadoop.hbase.ServerMetrics;
import org.apache.hadoop.hbase.ServerMetricsBuilder;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.YouAreDeadException;
import org.apache.hadoop.hbase.client.AsyncClusterConnection;
Expand Down Expand Up @@ -736,13 +735,6 @@ private int getMinToStart() {
}

int minimumRequired = 1;
if (LoadBalancer.isTablesOnMaster(master.getConfiguration()) &&
LoadBalancer.isSystemTablesOnlyOnMaster(master.getConfiguration())) {
// If Master is carrying regions it will show up as a 'server', but is not handling user-
// space regions, so we need a second server.
minimumRequired = 2;
}

int minToStart = this.master.getConfiguration().getInt(WAIT_ON_REGIONSERVERS_MINTOSTART, -1);
// Ensure we are never less than minimumRequired else stuff won't work.
return Math.max(minToStart, minimumRequired);
Expand Down
Loading

0 comments on commit 781da18

Please sign in to comment.