hbase git commit: HBASE-20697 Can't cache All region locations of the specify table by calling table.getRegionLocator().getAllRegionLocations()
Repository: hbase Updated Branches: refs/heads/master d7561cee5 -> 1e0650955 HBASE-20697 Can't cache All region locations of the specify table by calling table.getRegionLocator().getAllRegionLocations() Signed-off-by: Guanghao Zhang Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/1e065095 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/1e065095 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/1e065095 Branch: refs/heads/master Commit: 1e0650955a58bfaf28e8075353f894141226a844 Parents: d7561ce Author: zhaoyuan Authored: Tue Jul 10 15:03:05 2018 +0800 Committer: Guanghao Zhang Committed: Wed Jul 11 10:52:06 2018 +0800 -- .../org/apache/hadoop/hbase/RegionLocations.java| 11 ++- .../apache/hadoop/hbase/client/HRegionLocator.java | 16 ++-- .../hadoop/hbase/client/TestFromClientSide.java | 7 +++ 3 files changed, 19 insertions(+), 15 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/1e065095/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java index 8889dc2..fd6f3c7 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java @@ -56,9 +56,6 @@ public class RegionLocations { int index = 0; for (HRegionLocation loc : locations) { if (loc != null) { -if (loc.getServerName() != null) { - numNonNullElements++; -} if (loc.getRegionInfo().getReplicaId() >= maxReplicaId) { maxReplicaId = loc.getRegionInfo().getReplicaId(); maxReplicaIdIndex = index; @@ -66,8 +63,6 @@ public class RegionLocations { } index++; } -this.numNonNullElements = numNonNullElements; - // account for the null elements in the array after maxReplicaIdIndex maxReplicaId = maxReplicaId + (locations.length - (maxReplicaIdIndex + 1) ); @@ -81,6 +76,12 @@ public class RegionLocations { } } } +for (HRegionLocation loc : this.locations) { + if (loc != null && loc.getServerName() != null){ +numNonNullElements++; + } +} +this.numNonNullElements = numNonNullElements; } public RegionLocations(Collection locations) { http://git-wip-us.apache.org/repos/asf/hbase/blob/1e065095/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java index 0231370..2559114 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java @@ -27,7 +27,6 @@ import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionLocation; import org.apache.hadoop.hbase.MetaTableAccessor; import org.apache.hadoop.hbase.RegionLocations; -import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.util.Pair; import org.apache.yetus.audience.InterfaceAudience; @@ -85,15 +84,12 @@ public class HRegionLocator implements RegionLocator { @Override public List getAllRegionLocations() throws IOException { TableName tableName = getName(); -List> locations = -MetaTableAccessor.getTableRegionsAndLocations(this.connection, tableName); -ArrayList regions = new ArrayList<>(locations.size()); -for (Pair entry : locations) { - regions.add(new HRegionLocation(entry.getFirst(), entry.getSecond())); - -} -if (regions.size() > 0) { - connection.cacheLocation(tableName, new RegionLocations(regions)); +ArrayList regions = new ArrayList<>(); +for (RegionLocations locations : listRegionLocations()) { + for (HRegionLocation location : locations.getRegionLocations()) { +regions.add(location); + } + connection.cacheLocation(tableName, locations); } return regions; } http://git-wip-us.apache.org/repos/asf/hbase/blob/1e065095/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java index 13fa59f..c4285b4 100644 --
hbase git commit: HBASE-20697 Can't cache All region locations of the specify table by calling table.getRegionLocator().getAllRegionLocations()
Repository: hbase Updated Branches: refs/heads/branch-2 573fa74cb -> 7990283d5 HBASE-20697 Can't cache All region locations of the specify table by calling table.getRegionLocator().getAllRegionLocations() Signed-off-by: Guanghao Zhang Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/7990283d Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/7990283d Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/7990283d Branch: refs/heads/branch-2 Commit: 7990283d5070ebee1ff18401dd2186e9317ba054 Parents: 573fa74 Author: zhaoyuan Authored: Tue Jul 10 15:03:05 2018 +0800 Committer: Guanghao Zhang Committed: Wed Jul 11 11:07:04 2018 +0800 -- .../org/apache/hadoop/hbase/RegionLocations.java| 11 ++- .../apache/hadoop/hbase/client/HRegionLocator.java | 16 ++-- .../hadoop/hbase/client/TestFromClientSide.java | 7 +++ 3 files changed, 19 insertions(+), 15 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/7990283d/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java index 8889dc2..fd6f3c7 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java @@ -56,9 +56,6 @@ public class RegionLocations { int index = 0; for (HRegionLocation loc : locations) { if (loc != null) { -if (loc.getServerName() != null) { - numNonNullElements++; -} if (loc.getRegionInfo().getReplicaId() >= maxReplicaId) { maxReplicaId = loc.getRegionInfo().getReplicaId(); maxReplicaIdIndex = index; @@ -66,8 +63,6 @@ public class RegionLocations { } index++; } -this.numNonNullElements = numNonNullElements; - // account for the null elements in the array after maxReplicaIdIndex maxReplicaId = maxReplicaId + (locations.length - (maxReplicaIdIndex + 1) ); @@ -81,6 +76,12 @@ public class RegionLocations { } } } +for (HRegionLocation loc : this.locations) { + if (loc != null && loc.getServerName() != null){ +numNonNullElements++; + } +} +this.numNonNullElements = numNonNullElements; } public RegionLocations(Collection locations) { http://git-wip-us.apache.org/repos/asf/hbase/blob/7990283d/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java index 0231370..2559114 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java @@ -27,7 +27,6 @@ import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionLocation; import org.apache.hadoop.hbase.MetaTableAccessor; import org.apache.hadoop.hbase.RegionLocations; -import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.util.Pair; import org.apache.yetus.audience.InterfaceAudience; @@ -85,15 +84,12 @@ public class HRegionLocator implements RegionLocator { @Override public List getAllRegionLocations() throws IOException { TableName tableName = getName(); -List> locations = -MetaTableAccessor.getTableRegionsAndLocations(this.connection, tableName); -ArrayList regions = new ArrayList<>(locations.size()); -for (Pair entry : locations) { - regions.add(new HRegionLocation(entry.getFirst(), entry.getSecond())); - -} -if (regions.size() > 0) { - connection.cacheLocation(tableName, new RegionLocations(regions)); +ArrayList regions = new ArrayList<>(); +for (RegionLocations locations : listRegionLocations()) { + for (HRegionLocation location : locations.getRegionLocations()) { +regions.add(location); + } + connection.cacheLocation(tableName, locations); } return regions; } http://git-wip-us.apache.org/repos/asf/hbase/blob/7990283d/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java index 13fa59f..c4285b4 10064
hbase git commit: HBASE-20697 Can't cache All region locations of the specify table by calling table.getRegionLocator().getAllRegionLocations()
Repository: hbase Updated Branches: refs/heads/branch-2.1 e1673bb0b -> 8de69db14 HBASE-20697 Can't cache All region locations of the specify table by calling table.getRegionLocator().getAllRegionLocations() Signed-off-by: Guanghao Zhang Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/8de69db1 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/8de69db1 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/8de69db1 Branch: refs/heads/branch-2.1 Commit: 8de69db1438d78ec63f83bfff7fda92d5799ee44 Parents: e1673bb Author: zhaoyuan Authored: Tue Jul 10 15:03:05 2018 +0800 Committer: Guanghao Zhang Committed: Wed Jul 11 11:17:41 2018 +0800 -- .../org/apache/hadoop/hbase/RegionLocations.java| 11 ++- .../apache/hadoop/hbase/client/HRegionLocator.java | 16 ++-- .../hadoop/hbase/client/TestFromClientSide.java | 7 +++ 3 files changed, 19 insertions(+), 15 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/8de69db1/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java index 8889dc2..fd6f3c7 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java @@ -56,9 +56,6 @@ public class RegionLocations { int index = 0; for (HRegionLocation loc : locations) { if (loc != null) { -if (loc.getServerName() != null) { - numNonNullElements++; -} if (loc.getRegionInfo().getReplicaId() >= maxReplicaId) { maxReplicaId = loc.getRegionInfo().getReplicaId(); maxReplicaIdIndex = index; @@ -66,8 +63,6 @@ public class RegionLocations { } index++; } -this.numNonNullElements = numNonNullElements; - // account for the null elements in the array after maxReplicaIdIndex maxReplicaId = maxReplicaId + (locations.length - (maxReplicaIdIndex + 1) ); @@ -81,6 +76,12 @@ public class RegionLocations { } } } +for (HRegionLocation loc : this.locations) { + if (loc != null && loc.getServerName() != null){ +numNonNullElements++; + } +} +this.numNonNullElements = numNonNullElements; } public RegionLocations(Collection locations) { http://git-wip-us.apache.org/repos/asf/hbase/blob/8de69db1/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java index 0231370..2559114 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java @@ -27,7 +27,6 @@ import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionLocation; import org.apache.hadoop.hbase.MetaTableAccessor; import org.apache.hadoop.hbase.RegionLocations; -import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.util.Pair; import org.apache.yetus.audience.InterfaceAudience; @@ -85,15 +84,12 @@ public class HRegionLocator implements RegionLocator { @Override public List getAllRegionLocations() throws IOException { TableName tableName = getName(); -List> locations = -MetaTableAccessor.getTableRegionsAndLocations(this.connection, tableName); -ArrayList regions = new ArrayList<>(locations.size()); -for (Pair entry : locations) { - regions.add(new HRegionLocation(entry.getFirst(), entry.getSecond())); - -} -if (regions.size() > 0) { - connection.cacheLocation(tableName, new RegionLocations(regions)); +ArrayList regions = new ArrayList<>(); +for (RegionLocations locations : listRegionLocations()) { + for (HRegionLocation location : locations.getRegionLocations()) { +regions.add(location); + } + connection.cacheLocation(tableName, locations); } return regions; } http://git-wip-us.apache.org/repos/asf/hbase/blob/8de69db1/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java index 13fa59f..c4285b4 1
hbase git commit: HBASE-20697 Can't cache All region locations of the specify table by calling table.getRegionLocator().getAllRegionLocations()
Repository: hbase Updated Branches: refs/heads/branch-1 f2dc754aa -> 6edb27e1e HBASE-20697 Can't cache All region locations of the specify table by calling table.getRegionLocator().getAllRegionLocations() Signed-off-by: Guanghao Zhang Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/6edb27e1 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/6edb27e1 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/6edb27e1 Branch: refs/heads/branch-1 Commit: 6edb27e1e6ac86b2b9bc2ac9592e4d847eb2763f Parents: f2dc754 Author: zhaoyuan Authored: Wed Jun 13 14:49:48 2018 +0800 Committer: Guanghao Zhang Committed: Wed Jul 11 11:33:32 2018 +0800 -- .../apache/hadoop/hbase/client/HRegionLocator.java| 14 ++ .../java/org/apache/hadoop/hbase/client/TestHCM.java | 10 ++ 2 files changed, 16 insertions(+), 8 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/6edb27e1/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java index d270607..fadab46 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java @@ -86,14 +86,12 @@ public class HRegionLocator implements RegionLocator { @Override public List getAllRegionLocations() throws IOException { TableName tableName = getName(); -NavigableMap locations = -MetaScanner.allTableRegions(this.connection, tableName); -ArrayList regions = new ArrayList<>(locations.size()); -for (Entry entry : locations.entrySet()) { - regions.add(new HRegionLocation(entry.getKey(), entry.getValue())); -} -if (regions.size() > 0) { - connection.cacheLocation(tableName, new RegionLocations(regions)); +ArrayList regions = new ArrayList<>(); +for (RegionLocations locations : listRegionLocations()) { + for (HRegionLocation location : locations.getRegionLocations()) { +regions.add(location); + } + connection.cacheLocation(tableName, locations); } return regions; } http://git-wip-us.apache.org/repos/asf/hbase/blob/6edb27e1/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java index a5e3a65..3ffaa43 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java @@ -18,6 +18,7 @@ */ package org.apache.hadoop.hbase.client; +import static org.apache.hadoop.hbase.HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -995,6 +996,15 @@ public class TestHCM { RegionLocations rl = conn.getCachedLocation(TABLE_NAME, ROW); assertNull("What is this location?? " + rl, rl); +// We're now going to test getAllRegionLocations() whether or not cache all region locations +conn.clearRegionCache(TABLE_NAME); +conn.getRegionLocator(TABLE_NAME).getAllRegionLocations(); +assertNotNull("Can't get cached location for row aaa", +conn.getCachedLocation(TABLE_NAME,Bytes.toBytes("aaa"))); +for(byte[] startKey:KEYS_FOR_HBA_CREATE_TABLE){ + assertNotNull("Can't get cached location for row "+ + Bytes.toString(startKey),conn.getCachedLocation(TABLE_NAME,startKey)); +} // We're now going to move the region and check that it works for the client // First a new put to add the location in the cache conn.clearRegionCache(TABLE_NAME);
hbase git commit: HBASE-20697 Can't cache All region locations of the specify table by calling table.getRegionLocator().getAllRegionLocations()
Repository: hbase Updated Branches: refs/heads/branch-1.4 89605929a -> 43dc18450 HBASE-20697 Can't cache All region locations of the specify table by calling table.getRegionLocator().getAllRegionLocations() Signed-off-by: Guanghao Zhang Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/43dc1845 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/43dc1845 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/43dc1845 Branch: refs/heads/branch-1.4 Commit: 43dc1845015d4e2c379f424ee51ca3a940274f57 Parents: 8960592 Author: zhaoyuan Authored: Wed Jun 13 14:49:48 2018 +0800 Committer: Guanghao Zhang Committed: Wed Jul 11 13:14:12 2018 +0800 -- .../apache/hadoop/hbase/client/HRegionLocator.java| 14 ++ .../java/org/apache/hadoop/hbase/client/TestHCM.java | 10 ++ 2 files changed, 16 insertions(+), 8 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/43dc1845/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java index d270607..fadab46 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java @@ -86,14 +86,12 @@ public class HRegionLocator implements RegionLocator { @Override public List getAllRegionLocations() throws IOException { TableName tableName = getName(); -NavigableMap locations = -MetaScanner.allTableRegions(this.connection, tableName); -ArrayList regions = new ArrayList<>(locations.size()); -for (Entry entry : locations.entrySet()) { - regions.add(new HRegionLocation(entry.getKey(), entry.getValue())); -} -if (regions.size() > 0) { - connection.cacheLocation(tableName, new RegionLocations(regions)); +ArrayList regions = new ArrayList<>(); +for (RegionLocations locations : listRegionLocations()) { + for (HRegionLocation location : locations.getRegionLocations()) { +regions.add(location); + } + connection.cacheLocation(tableName, locations); } return regions; } http://git-wip-us.apache.org/repos/asf/hbase/blob/43dc1845/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java index a5e3a65..3ffaa43 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java @@ -18,6 +18,7 @@ */ package org.apache.hadoop.hbase.client; +import static org.apache.hadoop.hbase.HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -995,6 +996,15 @@ public class TestHCM { RegionLocations rl = conn.getCachedLocation(TABLE_NAME, ROW); assertNull("What is this location?? " + rl, rl); +// We're now going to test getAllRegionLocations() whether or not cache all region locations +conn.clearRegionCache(TABLE_NAME); +conn.getRegionLocator(TABLE_NAME).getAllRegionLocations(); +assertNotNull("Can't get cached location for row aaa", +conn.getCachedLocation(TABLE_NAME,Bytes.toBytes("aaa"))); +for(byte[] startKey:KEYS_FOR_HBA_CREATE_TABLE){ + assertNotNull("Can't get cached location for row "+ + Bytes.toString(startKey),conn.getCachedLocation(TABLE_NAME,startKey)); +} // We're now going to move the region and check that it works for the client // First a new put to add the location in the cache conn.clearRegionCache(TABLE_NAME);
hbase git commit: HBASE-20697 Can't cache All region locations of the specify table by calling table.getRegionLocator().getAllRegionLocations()
Repository: hbase Updated Branches: refs/heads/branch-2.0 e3a67493c -> a532cb500 HBASE-20697 Can't cache All region locations of the specify table by calling table.getRegionLocator().getAllRegionLocations() Signed-off-by: Guanghao Zhang Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/a532cb50 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/a532cb50 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/a532cb50 Branch: refs/heads/branch-2.0 Commit: a532cb500a5e8df4bdc179177614944feef10d1e Parents: e3a6749 Author: zhaoyuan Authored: Tue Jul 10 15:03:05 2018 +0800 Committer: Guanghao Zhang Committed: Thu Jul 12 11:30:13 2018 +0800 -- .../org/apache/hadoop/hbase/RegionLocations.java| 11 ++- .../apache/hadoop/hbase/client/HRegionLocator.java | 16 ++-- .../hadoop/hbase/client/TestFromClientSide.java | 7 +++ 3 files changed, 19 insertions(+), 15 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/a532cb50/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java index 8889dc2..fd6f3c7 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java @@ -56,9 +56,6 @@ public class RegionLocations { int index = 0; for (HRegionLocation loc : locations) { if (loc != null) { -if (loc.getServerName() != null) { - numNonNullElements++; -} if (loc.getRegionInfo().getReplicaId() >= maxReplicaId) { maxReplicaId = loc.getRegionInfo().getReplicaId(); maxReplicaIdIndex = index; @@ -66,8 +63,6 @@ public class RegionLocations { } index++; } -this.numNonNullElements = numNonNullElements; - // account for the null elements in the array after maxReplicaIdIndex maxReplicaId = maxReplicaId + (locations.length - (maxReplicaIdIndex + 1) ); @@ -81,6 +76,12 @@ public class RegionLocations { } } } +for (HRegionLocation loc : this.locations) { + if (loc != null && loc.getServerName() != null){ +numNonNullElements++; + } +} +this.numNonNullElements = numNonNullElements; } public RegionLocations(Collection locations) { http://git-wip-us.apache.org/repos/asf/hbase/blob/a532cb50/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java index 0231370..2559114 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java @@ -27,7 +27,6 @@ import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionLocation; import org.apache.hadoop.hbase.MetaTableAccessor; import org.apache.hadoop.hbase.RegionLocations; -import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.util.Pair; import org.apache.yetus.audience.InterfaceAudience; @@ -85,15 +84,12 @@ public class HRegionLocator implements RegionLocator { @Override public List getAllRegionLocations() throws IOException { TableName tableName = getName(); -List> locations = -MetaTableAccessor.getTableRegionsAndLocations(this.connection, tableName); -ArrayList regions = new ArrayList<>(locations.size()); -for (Pair entry : locations) { - regions.add(new HRegionLocation(entry.getFirst(), entry.getSecond())); - -} -if (regions.size() > 0) { - connection.cacheLocation(tableName, new RegionLocations(regions)); +ArrayList regions = new ArrayList<>(); +for (RegionLocations locations : listRegionLocations()) { + for (HRegionLocation location : locations.getRegionLocations()) { +regions.add(location); + } + connection.cacheLocation(tableName, locations); } return regions; } http://git-wip-us.apache.org/repos/asf/hbase/blob/a532cb50/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java index 100df38..663cb7f 1
hbase git commit: HBASE-20697 Can't cache All region locations of the specify table by calling table.getRegionLocator().getAllRegionLocations()
Repository: hbase Updated Branches: refs/heads/branch-1.3 53dba694d -> 0981cd0a6 HBASE-20697 Can't cache All region locations of the specify table by calling table.getRegionLocator().getAllRegionLocations() Signed-off-by: Guanghao Zhang Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/0981cd0a Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/0981cd0a Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/0981cd0a Branch: refs/heads/branch-1.3 Commit: 0981cd0a60fa701f4bf058caabc956ff5e6cdac2 Parents: 53dba69 Author: zhaoyuan Authored: Wed Jun 13 14:49:48 2018 +0800 Committer: Guanghao Zhang Committed: Mon Jul 23 17:15:16 2018 +0800 -- .../apache/hadoop/hbase/client/HRegionLocator.java | 17 ++--- .../org/apache/hadoop/hbase/client/TestHCM.java| 10 ++ 2 files changed, 16 insertions(+), 11 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/0981cd0a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java index d270607..d585b46 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java @@ -21,14 +21,11 @@ package org.apache.hadoop.hbase.client; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import java.util.NavigableMap; -import java.util.Map.Entry; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionLocation; import org.apache.hadoop.hbase.RegionLocations; -import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceStability; @@ -86,14 +83,12 @@ public class HRegionLocator implements RegionLocator { @Override public List getAllRegionLocations() throws IOException { TableName tableName = getName(); -NavigableMap locations = -MetaScanner.allTableRegions(this.connection, tableName); -ArrayList regions = new ArrayList<>(locations.size()); -for (Entry entry : locations.entrySet()) { - regions.add(new HRegionLocation(entry.getKey(), entry.getValue())); -} -if (regions.size() > 0) { - connection.cacheLocation(tableName, new RegionLocations(regions)); +ArrayList regions = new ArrayList<>(); +for (RegionLocations locations : listRegionLocations()) { + for (HRegionLocation location : locations.getRegionLocations()) { +regions.add(location); + } + connection.cacheLocation(tableName, locations); } return regions; } http://git-wip-us.apache.org/repos/asf/hbase/blob/0981cd0a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java index c6482fe..25b744e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java @@ -18,6 +18,7 @@ */ package org.apache.hadoop.hbase.client; +import static org.apache.hadoop.hbase.HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -922,6 +923,15 @@ public class TestHCM { RegionLocations rl = conn.getCachedLocation(TABLE_NAME, ROW); assertNull("What is this location?? " + rl, rl); +// We're now going to test getAllRegionLocations() whether or not cache all region locations +conn.clearRegionCache(TABLE_NAME); +conn.getRegionLocator(TABLE_NAME).getAllRegionLocations(); +assertNotNull("Can't get cached location for row aaa", +conn.getCachedLocation(TABLE_NAME,Bytes.toBytes("aaa"))); +for(byte[] startKey:KEYS_FOR_HBA_CREATE_TABLE){ + assertNotNull("Can't get cached location for row "+ + Bytes.toString(startKey),conn.getCachedLocation(TABLE_NAME,startKey)); +} // We're now going to move the region and check that it works for the client // First a new put to add the location in the cache conn.clearRegionCache(TABLE_NAME);
hbase git commit: HBASE-20697 Can't cache All region locations of the specify table by calling table.getRegionLocator().getAllRegionLocations()
Repository: hbase Updated Branches: refs/heads/branch-1.2 34a9b272d -> 79d716476 HBASE-20697 Can't cache All region locations of the specify table by calling table.getRegionLocator().getAllRegionLocations() Signed-off-by: Guanghao Zhang Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/79d71647 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/79d71647 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/79d71647 Branch: refs/heads/branch-1.2 Commit: 79d716476f4461047c7971ff130ae9c6e72e3636 Parents: 34a9b27 Author: zhaoyuan Authored: Wed Jun 13 14:49:48 2018 +0800 Committer: Guanghao Zhang Committed: Mon Jul 23 17:19:18 2018 +0800 -- .../apache/hadoop/hbase/client/HRegionLocator.java | 17 ++--- .../org/apache/hadoop/hbase/client/TestHCM.java| 10 ++ 2 files changed, 16 insertions(+), 11 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/79d71647/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java index d270607..d585b46 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java @@ -21,14 +21,11 @@ package org.apache.hadoop.hbase.client; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import java.util.NavigableMap; -import java.util.Map.Entry; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionLocation; import org.apache.hadoop.hbase.RegionLocations; -import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceStability; @@ -86,14 +83,12 @@ public class HRegionLocator implements RegionLocator { @Override public List getAllRegionLocations() throws IOException { TableName tableName = getName(); -NavigableMap locations = -MetaScanner.allTableRegions(this.connection, tableName); -ArrayList regions = new ArrayList<>(locations.size()); -for (Entry entry : locations.entrySet()) { - regions.add(new HRegionLocation(entry.getKey(), entry.getValue())); -} -if (regions.size() > 0) { - connection.cacheLocation(tableName, new RegionLocations(regions)); +ArrayList regions = new ArrayList<>(); +for (RegionLocations locations : listRegionLocations()) { + for (HRegionLocation location : locations.getRegionLocations()) { +regions.add(location); + } + connection.cacheLocation(tableName, locations); } return regions; } http://git-wip-us.apache.org/repos/asf/hbase/blob/79d71647/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java index e592fa8..f86a841 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java @@ -18,6 +18,7 @@ */ package org.apache.hadoop.hbase.client; +import static org.apache.hadoop.hbase.HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -739,6 +740,15 @@ public class TestHCM { RegionLocations rl = conn.getCachedLocation(TABLE_NAME, ROW); assertNull("What is this location?? " + rl, rl); +// We're now going to test getAllRegionLocations() whether or not cache all region locations +conn.clearRegionCache(TABLE_NAME); +conn.getRegionLocator(TABLE_NAME).getAllRegionLocations(); +assertNotNull("Can't get cached location for row aaa", +conn.getCachedLocation(TABLE_NAME,Bytes.toBytes("aaa"))); +for(byte[] startKey:KEYS_FOR_HBA_CREATE_TABLE){ + assertNotNull("Can't get cached location for row "+ + Bytes.toString(startKey),conn.getCachedLocation(TABLE_NAME,startKey)); +} // We're now going to move the region and check that it works for the client // First a new put to add the location in the cache conn.clearRegionCache(TABLE_NAME);
[03/29] hbase git commit: HBASE-20697 Can't cache All region locations of the specify table by calling table.getRegionLocator().getAllRegionLocations()
HBASE-20697 Can't cache All region locations of the specify table by calling table.getRegionLocator().getAllRegionLocations() Signed-off-by: Guanghao Zhang Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/1e065095 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/1e065095 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/1e065095 Branch: refs/heads/HBASE-20749 Commit: 1e0650955a58bfaf28e8075353f894141226a844 Parents: d7561ce Author: zhaoyuan Authored: Tue Jul 10 15:03:05 2018 +0800 Committer: Guanghao Zhang Committed: Wed Jul 11 10:52:06 2018 +0800 -- .../org/apache/hadoop/hbase/RegionLocations.java| 11 ++- .../apache/hadoop/hbase/client/HRegionLocator.java | 16 ++-- .../hadoop/hbase/client/TestFromClientSide.java | 7 +++ 3 files changed, 19 insertions(+), 15 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/1e065095/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java index 8889dc2..fd6f3c7 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLocations.java @@ -56,9 +56,6 @@ public class RegionLocations { int index = 0; for (HRegionLocation loc : locations) { if (loc != null) { -if (loc.getServerName() != null) { - numNonNullElements++; -} if (loc.getRegionInfo().getReplicaId() >= maxReplicaId) { maxReplicaId = loc.getRegionInfo().getReplicaId(); maxReplicaIdIndex = index; @@ -66,8 +63,6 @@ public class RegionLocations { } index++; } -this.numNonNullElements = numNonNullElements; - // account for the null elements in the array after maxReplicaIdIndex maxReplicaId = maxReplicaId + (locations.length - (maxReplicaIdIndex + 1) ); @@ -81,6 +76,12 @@ public class RegionLocations { } } } +for (HRegionLocation loc : this.locations) { + if (loc != null && loc.getServerName() != null){ +numNonNullElements++; + } +} +this.numNonNullElements = numNonNullElements; } public RegionLocations(Collection locations) { http://git-wip-us.apache.org/repos/asf/hbase/blob/1e065095/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java -- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java index 0231370..2559114 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java @@ -27,7 +27,6 @@ import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionLocation; import org.apache.hadoop.hbase.MetaTableAccessor; import org.apache.hadoop.hbase.RegionLocations; -import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.util.Pair; import org.apache.yetus.audience.InterfaceAudience; @@ -85,15 +84,12 @@ public class HRegionLocator implements RegionLocator { @Override public List getAllRegionLocations() throws IOException { TableName tableName = getName(); -List> locations = -MetaTableAccessor.getTableRegionsAndLocations(this.connection, tableName); -ArrayList regions = new ArrayList<>(locations.size()); -for (Pair entry : locations) { - regions.add(new HRegionLocation(entry.getFirst(), entry.getSecond())); - -} -if (regions.size() > 0) { - connection.cacheLocation(tableName, new RegionLocations(regions)); +ArrayList regions = new ArrayList<>(); +for (RegionLocations locations : listRegionLocations()) { + for (HRegionLocation location : locations.getRegionLocations()) { +regions.add(location); + } + connection.cacheLocation(tableName, locations); } return regions; } http://git-wip-us.apache.org/repos/asf/hbase/blob/1e065095/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java index 13fa59f..c4285b4 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClien