Index: src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
===================================================================
--- src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (revision 991708)
+++ src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (working copy)
@@ -61,7 +61,6 @@
import org.apache.hadoop.hbase.ipc.HMasterInterface;
import org.apache.hadoop.hbase.ipc.HRegionInterface;
import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.hbase.util.MetaUtils;
import org.apache.hadoop.hbase.util.SoftValueSortedMap;
import org.apache.hadoop.hbase.util.Writables;
import org.apache.hadoop.hbase.zookeeper.ZKTableDisable;
@@ -370,38 +369,6 @@
throw new MasterNotRunningException();
}
- public boolean tableExists(final byte [] tableName)
- throws MasterNotRunningException, ZooKeeperConnectionException {
- getMaster();
- if (tableName == null) {
- throw new IllegalArgumentException("Table name cannot be null");
- }
- if (isMetaTableName(tableName)) {
- return true;
- }
- boolean exists = false;
- try {
- HTableDescriptor[] tables = listTables();
- for (HTableDescriptor table : tables) {
- if (Bytes.equals(table.getName(), tableName)) {
- exists = true;
- }
- }
- } catch (IOException e) {
- LOG.warn("Testing for table existence threw exception", e);
- }
- return exists;
- }
-
- /*
- * @param n
- * @return Truen if passed tablename n is equal to the name
- * of a catalog table.
- */
- private static boolean isMetaTableName(final byte [] n) {
- return MetaUtils.isMetaTableName(n);
- }
-
public HRegionLocation getRegionLocation(final byte [] name,
final byte [] row, boolean reload)
throws IOException {
@@ -409,7 +376,6 @@
}
public HTableDescriptor[] listTables() throws IOException {
- getMaster();
final TreeSet uniqueTables =
new TreeSet();
MetaScannerVisitor visitor = new MetaScannerVisitor() {
@@ -433,7 +399,6 @@
}
};
MetaScanner.metaScan(conf, visitor);
-
return uniqueTables.toArray(new HTableDescriptor[uniqueTables.size()]);
}
@@ -475,10 +440,6 @@
*/
private boolean testTableOnlineState(byte[] tableName, boolean online)
throws IOException {
- // TODO: Replace w/ CatalogTracker-based tableExists test.
- if (!tableExists(tableName)) {
- throw new TableNotFoundException(Bytes.toString(tableName));
- }
if (Bytes.equals(tableName, HConstants.ROOT_TABLE_NAME)) {
// The root region is always enabled
return true;
Index: src/main/java/org/apache/hadoop/hbase/client/HConnection.java
===================================================================
--- src/main/java/org/apache/hadoop/hbase/client/HConnection.java (revision 991708)
+++ src/main/java/org/apache/hadoop/hbase/client/HConnection.java (working copy)
@@ -60,16 +60,6 @@
throws MasterNotRunningException, ZooKeeperConnectionException;
/**
- * Checks if tableName exists.
- * @param tableName Table to check.
- * @return True if table exists already.
- * @throws MasterNotRunningException if the master is not running
- * @throws ZooKeeperConnectionException if unable to connect to zookeeper
- */
- public boolean tableExists(final byte [] tableName)
- throws MasterNotRunningException, ZooKeeperConnectionException;
-
- /**
* A table that isTableEnabled == false and isTableDisabled == false
* is possible. This happens when a table has a lot of regions
* that must be processed.
Index: src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
===================================================================
--- src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (revision 991708)
+++ src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (working copy)
@@ -138,24 +138,21 @@
/**
* @param tableName Table to check.
* @return True if table exists already.
- * @throws MasterNotRunningException if the master is not running
- * @throws ZooKeeperConnectionException if unable to connect to zookeeper
+ * @throws IOException
*/
public boolean tableExists(final String tableName)
- throws MasterNotRunningException, ZooKeeperConnectionException {
- return tableExists(Bytes.toBytes(tableName));
+ throws IOException {
+ return MetaReader.tableExists(getCatalogTracker(), tableName);
}
/**
* @param tableName Table to check.
* @return True if table exists already.
- * @throws MasterNotRunningException if the master is not running
- * @throws ZooKeeperConnectionException if unable to connect to zookeeper
+ * @throws IOException
*/
public boolean tableExists(final byte [] tableName)
- throws MasterNotRunningException, ZooKeeperConnectionException {
- connection.isMasterRunning();
- return connection.tableExists(tableName);
+ throws IOException {
+ return tableExists(Bytes.toString(tableName));
}
/**
@@ -945,11 +942,10 @@
* @return True if tableNameOrRegionName is *possibly* a region
* name else false if a verified tablename (we call {@link #tableExists(byte[])};
* else we throw an exception.
- * @throws ZooKeeperConnectionException
- * @throws MasterNotRunningException
+ * @throws IOException
*/
private boolean isRegionName(final byte [] tableNameOrRegionName)
- throws MasterNotRunningException, ZooKeeperConnectionException {
+ throws IOException {
if (tableNameOrRegionName == null) {
throw new IllegalArgumentException("Pass a table name or region name");
}