HBASE-21288 HostingServer in UnassignProcedure is not accurate
Signed-off-by: Allan Yang <allan163@apache.org>
This commit is contained in:
parent
fffd9b9b6d
commit
b3c3393c19
|
@ -74,6 +74,7 @@ import org.apache.hadoop.hbase.MetaTableAccessor;
|
||||||
import org.apache.hadoop.hbase.NamespaceDescriptor;
|
import org.apache.hadoop.hbase.NamespaceDescriptor;
|
||||||
import org.apache.hadoop.hbase.PleaseHoldException;
|
import org.apache.hadoop.hbase.PleaseHoldException;
|
||||||
import org.apache.hadoop.hbase.ReplicationPeerNotFoundException;
|
import org.apache.hadoop.hbase.ReplicationPeerNotFoundException;
|
||||||
|
import org.apache.hadoop.hbase.ServerMetrics;
|
||||||
import org.apache.hadoop.hbase.ServerName;
|
import org.apache.hadoop.hbase.ServerName;
|
||||||
import org.apache.hadoop.hbase.TableDescriptors;
|
import org.apache.hadoop.hbase.TableDescriptors;
|
||||||
import org.apache.hadoop.hbase.TableName;
|
import org.apache.hadoop.hbase.TableName;
|
||||||
|
@ -1587,6 +1588,20 @@ public class HMaster extends HRegionServer implements MasterServices {
|
||||||
this.serverManager.getDeadServers());
|
this.serverManager.getDeadServers());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Map<ServerName, ServerMetrics> onlineServers = serverManager.getOnlineServers();
|
||||||
|
int regionNotOnOnlineServer = 0;
|
||||||
|
for (RegionState regionState : assignmentManager.getRegionStates().getRegionStates()) {
|
||||||
|
if (regionState.isOpened() && !onlineServers
|
||||||
|
.containsKey(regionState.getServerName())) {
|
||||||
|
LOG.warn("{} 's server is not in the online server list.", regionState);
|
||||||
|
regionNotOnOnlineServer++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (regionNotOnOnlineServer > 0) {
|
||||||
|
LOG.info("Not running balancer because {} regions found not on an online server",
|
||||||
|
regionNotOnOnlineServer);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.cpHost != null) {
|
if (this.cpHost != null) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -77,6 +77,8 @@ public class UnassignProcedure extends RegionTransitionProcedure {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Where to send the unassign RPC.
|
* Where to send the unassign RPC.
|
||||||
|
* this one may not accurate since another RTP may change this location for
|
||||||
|
* the region. The hostingServer will be updated in updateTransition
|
||||||
*/
|
*/
|
||||||
protected volatile ServerName hostingServer;
|
protected volatile ServerName hostingServer;
|
||||||
/**
|
/**
|
||||||
|
@ -198,6 +200,13 @@ public class UnassignProcedure extends RegionTransitionProcedure {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (regionNode.getRegionLocation() != null && !regionNode
|
||||||
|
.getRegionLocation().equals(hostingServer)) {
|
||||||
|
LOG.info("HostingServer changed from {} to {} for {}", hostingServer,
|
||||||
|
regionNode.getRegionLocation(), this);
|
||||||
|
this.hostingServer = regionNode.getRegionLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Mark the region as CLOSING.
|
// Mark the region as CLOSING.
|
||||||
env.getAssignmentManager().markRegionAsClosing(regionNode);
|
env.getAssignmentManager().markRegionAsClosing(regionNode);
|
||||||
|
@ -357,7 +366,12 @@ public class UnassignProcedure extends RegionTransitionProcedure {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerName getServer(final MasterProcedureEnv env) {
|
public ServerName getServer(final MasterProcedureEnv env) {
|
||||||
return this.hostingServer;
|
RegionStateNode node =
|
||||||
|
env.getAssignmentManager().getRegionStates().getRegionStateNode(this.getRegionInfo());
|
||||||
|
if (node == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return node.getRegionLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue