HBASE-10743. Replica map update is problematic in RegionStates

git-svn-id: https://svn.apache.org/repos/asf/hbase/branches/hbase-10070@1577384 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Devaraj Das 2014-03-13 23:37:25 +00:00 committed by Enis Soztutar
parent 41116848e5
commit 72ba78667c
1 changed files with 7 additions and 0 deletions

View File

@ -404,6 +404,7 @@ public class RegionStates {
if (!serverName.equals(oldServerName)) {
LOG.info("Onlined " + hri.getShortNameToLog() + " on " + serverName);
addToServerHoldings(serverName, hri);
addToReplicaMapping(hri);
if (oldServerName != null) {
LOG.info("Offlined " + hri.getShortNameToLog() + " from " + oldServerName);
removeFromServerHoldings(oldServerName, hri);
@ -419,7 +420,9 @@ public class RegionStates {
serverHoldings.put(serverName, regions);
}
regions.add(hri);
}
private void addToReplicaMapping(HRegionInfo hri) {
HRegionInfo defaultReplica = RegionReplicaUtil.getRegionInfoForDefaultReplica(hri);
Set<HRegionInfo> replicas =
defaultReplicaToOtherReplicas.get(defaultReplica);
@ -436,6 +439,9 @@ public class RegionStates {
if (oldRegions.isEmpty()) {
serverHoldings.remove(serverName);
}
}
private void removeFromReplicaMapping(HRegionInfo hri) {
HRegionInfo defaultReplica = RegionReplicaUtil.getRegionInfoForDefaultReplica(hri);
Set<HRegionInfo> replicas = defaultReplicaToOtherReplicas.get(defaultReplica);
if (replicas != null) {
@ -525,6 +531,7 @@ public class RegionStates {
if (oldServerName != null && serverHoldings.containsKey(oldServerName)) {
LOG.info("Offlined " + hri.getShortNameToLog() + " from " + oldServerName);
removeFromServerHoldings(oldServerName, hri);
removeFromReplicaMapping(hri);
}
}
}