HBASE-10734. Fix RegionStates.getRegionAssignments to not add duplicate regions

git-svn-id: https://svn.apache.org/repos/asf/hbase/branches/hbase-10070@1577001 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Devaraj Das 2014-03-12 23:26:17 +00:00 committed by Enis Soztutar
parent fa68470fe6
commit a0a4744556
1 changed files with 2 additions and 12 deletions

View File

@ -159,22 +159,12 @@ public class RegionStates {
Map<ServerName, List<HRegionInfo>> map = new HashMap<ServerName, List<HRegionInfo>>(); Map<ServerName, List<HRegionInfo>> map = new HashMap<ServerName, List<HRegionInfo>>();
for (HRegionInfo region : regions) { for (HRegionInfo region : regions) {
HRegionInfo defaultReplica = RegionReplicaUtil.getRegionInfoForDefaultReplica(region); HRegionInfo defaultReplica = RegionReplicaUtil.getRegionInfoForDefaultReplica(region);
ServerName server = regionAssignments.get(defaultReplica);
List<HRegionInfo> regionsOnServer;
if (server != null) {
regionsOnServer = map.get(server);
if (regionsOnServer == null) {
regionsOnServer = new ArrayList<HRegionInfo>(1);
map.put(server, regionsOnServer);
}
regionsOnServer.add(defaultReplica);
}
Set<HRegionInfo> allReplicas = defaultReplicaToOtherReplicas.get(defaultReplica); Set<HRegionInfo> allReplicas = defaultReplicaToOtherReplicas.get(defaultReplica);
if (allReplicas != null) { if (allReplicas != null) {
for (HRegionInfo hri : allReplicas) { for (HRegionInfo hri : allReplicas) {
server = regionAssignments.get(hri); ServerName server = regionAssignments.get(hri);
if (server != null) { if (server != null) {
regionsOnServer = map.get(server); List<HRegionInfo> regionsOnServer = map.get(server);
if (regionsOnServer == null) { if (regionsOnServer == null) {
regionsOnServer = new ArrayList<HRegionInfo>(1); regionsOnServer = new ArrayList<HRegionInfo>(1);
map.put(server, regionsOnServer); map.put(server, regionsOnServer);