From d86e7e1c1820546f75788ebc02d705ffbcf0be12 Mon Sep 17 00:00:00 2001 From: Andrew Kyle Purtell Date: Thu, 10 Mar 2011 23:41:28 +0000 Subject: [PATCH] HBASE-3612 HBaseAdmin::isTableAvailable returns true when the table does not exit git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1080397 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 2 ++ .../org/apache/hadoop/hbase/client/HConnectionManager.java | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 7806d27aa7a..b0cceee4b46 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -62,6 +62,8 @@ Release 0.91.0 - Unreleased on OOME HBASE-1960 Master should wait for DFS to come up when creating hbase.version; use alternate strategy for waiting for DNs + HBASE-3612 HBaseAdmin::isTableAvailable returns true when the table does + not exit IMPROVEMENTS HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack) diff --git a/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java b/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java index df947cc37c0..3d2c5ea8b89 100644 --- a/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java +++ b/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java @@ -31,6 +31,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -443,6 +444,7 @@ public class HConnectionManager { public boolean isTableAvailable(final byte[] tableName) throws IOException { final AtomicBoolean available = new AtomicBoolean(true); + final AtomicInteger regionCount = new AtomicInteger(0); MetaScannerVisitor visitor = new MetaScannerVisitor() { @Override public boolean processRow(Result row) throws IOException { @@ -457,13 +459,14 @@ public class HConnectionManager { available.set(false); return false; } + regionCount.incrementAndGet(); } } return true; } }; MetaScanner.metaScan(conf, visitor); - return available.get(); + return available.get() && (regionCount.get() > 0); } /*