From 940f4a43c0001fbece52980136cae0f5e0d7b74e Mon Sep 17 00:00:00 2001 From: Zhihong Yu Date: Tue, 5 Nov 2013 20:56:10 +0000 Subject: [PATCH] HBASE-9863 Intermittently TestZooKeeper#testRegionAssignmentAfterMasterRecoveryDueToZKExpiry hangs git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1539129 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/hadoop/hbase/master/HMaster.java | 22 +++---------------- .../hbase/master/TableNamespaceManager.java | 3 ++- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index 035a21a2a8a..cc183897653 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -3102,7 +3102,9 @@ MasterServices, Server { @Override public NamespaceDescriptor getNamespaceDescriptor(String name) throws IOException { - if (!isTableNamespaceManagerReady()) { + boolean ready = tableNamespaceManager != null && + tableNamespaceManager.isTableAvailableAndInitialized(); + if (!ready) { throw new IOException("Table Namespace Manager not ready yet, try again later"); } NamespaceDescriptor nsd = tableNamespaceManager.get(name); @@ -3114,17 +3116,11 @@ MasterServices, Server { @Override public List listNamespaceDescriptors() throws IOException { - if (!isTableNamespaceManagerReady()) { - return Lists.newArrayList(); - } return Lists.newArrayList(tableNamespaceManager.list()); } @Override public List listTableDescriptorsByNamespace(String name) throws IOException { - if (!isTableNamespaceManagerReady()) { - return Lists.newArrayList(); - } getNamespaceDescriptor(name); // check that namespace exists return Lists.newArrayList(tableDescriptors.getByNamespace(name).values()); } @@ -3132,9 +3128,6 @@ MasterServices, Server { @Override public List listTableNamesByNamespace(String name) throws IOException { List tableNames = Lists.newArrayList(); - if (!isTableNamespaceManagerReady()) { - return tableNames; - } getNamespaceDescriptor(name); // check that namespace exists for (HTableDescriptor descriptor: tableDescriptors.getByNamespace(name).values()) { tableNames.add(descriptor.getTableName()); @@ -3142,13 +3135,4 @@ MasterServices, Server { return tableNames; } - private boolean isTableNamespaceManagerReady() throws IOException { - boolean ready = tableNamespaceManager != null && - tableNamespaceManager.isTableAvailableAndInitialized(); - if (!ready) { - LOG.warn("Table Namespace Manager not ready yet"); - } - return ready; - } - } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java index e7b8080565a..c0d98273b44 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java @@ -115,7 +115,8 @@ public class TableNamespaceManager { public synchronized NamespaceDescriptor get(String name) throws IOException { - return get(getNamespaceTable(), name); + if (!isTableAvailableAndInitialized()) return null; + return zkNamespaceManager.get(name); } public synchronized void create(NamespaceDescriptor ns) throws IOException {