From 96c64712e655ca456a3d3b0104d6c09e5f64074b Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Thu, 28 Jun 2007 22:29:07 +0000 Subject: [PATCH] HADOOP-1543 [base] Add HClient.tableExists M src/java/org/apache/hadoop/hbase/HClient.java (tableExists): Added M CHANGES.txt M src/java/org/apache/hadoop/hbase/package.html Fix javadoc. git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@551725 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 2 +- src/java/org/apache/hadoop/hbase/HClient.java | 17 +++++++++++++++++ src/java/org/apache/hadoop/hbase/package.html | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index d876d66dd85..99ce05964e5 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -42,4 +42,4 @@ Trunk (unreleased changes) 24. HADOOP-1534. [hbase] Memcache scanner fails if start key not present 25. HADOOP-1537. Catch exceptions in testCleanRegionServerExit so we can see what is failing. - + 26. HADOOP-1543 [hbase] Add HClient.tableExists diff --git a/src/java/org/apache/hadoop/hbase/HClient.java b/src/java/org/apache/hadoop/hbase/HClient.java index eba0fd9f926..c683bab9b04 100644 --- a/src/java/org/apache/hadoop/hbase/HClient.java +++ b/src/java/org/apache/hadoop/hbase/HClient.java @@ -125,6 +125,23 @@ public class HClient implements HConstants { this.currentServer = null; this.rand = new Random(); } + + /** + * @param tableName Table to check. + * @return True if table exists already. + * @throws IOException + */ + public boolean tableExists(final Text tableName) throws IOException { + HTableDescriptor [] tables = listTables(); + boolean result = false; + for (int i = 0; i < tables.length; i++) { + if (tables[i].getName().equals(tableName)) { + result = true; + break; + } + } + return result; + } protected void handleRemoteException(RemoteException e) throws IOException { String msg = e.getMessage(); diff --git a/src/java/org/apache/hadoop/hbase/package.html b/src/java/org/apache/hadoop/hbase/package.html index 9d1d838d4d4..77ab48ab4f7 100644 --- a/src/java/org/apache/hadoop/hbase/package.html +++ b/src/java/org/apache/hadoop/hbase/package.html @@ -18,7 +18,7 @@ Set JAVA_HOME to the root of your Java installation

First, you need a working instance of Hadoop. Download a recent release from Hadoop downloads. Unpack the release and connect to its top-level directory. Let this be -${HADOOP_HOME}. Edit the file ${HADOOP_HOME}/conf/hadoop-env.sh +${HADOOP_HOME}. Edit the file ${HADOOP_HOME}/conf/hadoop-env.sh to define at least JAVA_HOME. Also, add site-particular customizations to the file ${HADOOP_HOME}/conf/hadoop-site.xml. Try the following command:

bin/hadoop