You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2014/10/31 19:33:40 UTC
git commit: HBASE-12219 Cache more efficiently getAll() and get() in
FSTableDescriptors (addendum)
Repository: hbase
Updated Branches:
refs/heads/branch-1 a46425b2a -> 1f18d706a
HBASE-12219 Cache more efficiently getAll() and get() in FSTableDescriptors (addendum)
Signed-off-by: stack <st...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/1f18d706
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/1f18d706
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/1f18d706
Branch: refs/heads/branch-1
Commit: 1f18d706a8da51641776c33a594391e69003da3a
Parents: a46425b
Author: Esteban Gutierrez <es...@cloudera.com>
Authored: Fri Oct 31 11:21:31 2014 -0700
Committer: stack <st...@apache.org>
Committed: Fri Oct 31 11:33:33 2014 -0700
----------------------------------------------------------------------
.../hadoop/hbase/util/FSTableDescriptors.java | 36 ++++++++++++++------
1 file changed, 26 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/1f18d706/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptors.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptors.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptors.java
index 37e2d21..30ebc7d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptors.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptors.java
@@ -186,17 +186,33 @@ public class FSTableDescriptors implements TableDescriptors {
public Map<String, HTableDescriptor> getAll()
throws IOException {
Map<String, HTableDescriptor> htds = new TreeMap<String, HTableDescriptor>();
- List<Path> tableDirs = FSUtils.getTableDirs(fs, rootdir);
- for (Path d: tableDirs) {
- HTableDescriptor htd = null;
- try {
- htd = get(FSUtils.getTableName(d));
- } catch (FileNotFoundException fnfe) {
- // inability of retrieving one HTD shouldn't stop getting the remaining
- LOG.warn("Trouble retrieving htd", fnfe);
+
+ if (fsvisited && usecache) {
+ for (Map.Entry<TableName, HTableDescriptor> entry: this.cache.entrySet()) {
+ htds.put(entry.getKey().toString(), entry.getValue());
+ }
+ // add hbase:meta to the response
+ htds.put(HTableDescriptor.META_TABLEDESC.getTableName().getNameAsString(),
+ HTableDescriptor.META_TABLEDESC);
+ } else {
+ LOG.debug("Fetching table descriptors from the filesystem.");
+ boolean allvisited = true;
+ for (Path d : FSUtils.getTableDirs(fs, rootdir)) {
+ HTableDescriptor htd = null;
+ try {
+ htd = get(FSUtils.getTableName(d));
+ } catch (FileNotFoundException fnfe) {
+ // inability of retrieving one HTD shouldn't stop getting the remaining
+ LOG.warn("Trouble retrieving htd", fnfe);
+ }
+ if (htd == null) {
+ allvisited = false;
+ continue;
+ } else {
+ htds.put(htd.getTableName().getNameAsString(), htd);
+ }
+ fsvisited = allvisited;
}
- if (htd == null) continue;
- htds.put(htd.getTableName().getNameAsString(), htd);
}
return htds;
}