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 {