Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CD983B80A for ; Sat, 7 Jan 2012 00:09:23 +0000 (UTC) Received: (qmail 44264 invoked by uid 500); 7 Jan 2012 00:09:23 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 44199 invoked by uid 500); 7 Jan 2012 00:09:23 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 44192 invoked by uid 99); 7 Jan 2012 00:09:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 Jan 2012 00:09:22 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 Jan 2012 00:09:19 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 3C76B23888E4 for ; Sat, 7 Jan 2012 00:08:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1228506 - in /hbase/branches/0.92: CHANGES.txt src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java Date: Sat, 07 Jan 2012 00:08:58 -0000 To: commits@hbase.apache.org From: tedyu@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120107000858.3C76B23888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tedyu Date: Sat Jan 7 00:08:57 2012 New Revision: 1228506 URL: http://svn.apache.org/viewvc?rev=1228506&view=rev Log: HBASE-5041 Major compaction on non existing table does not throw error (Shrijeet) Modified: hbase/branches/0.92/CHANGES.txt hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java Modified: hbase/branches/0.92/CHANGES.txt URL: http://svn.apache.org/viewvc/hbase/branches/0.92/CHANGES.txt?rev=1228506&r1=1228505&r2=1228506&view=diff ============================================================================== --- hbase/branches/0.92/CHANGES.txt (original) +++ hbase/branches/0.92/CHANGES.txt Sat Jan 7 00:08:57 2012 @@ -917,6 +917,7 @@ Release 0.90.6 - Unreleased HBASE-4970 Add a parameter so that keepAliveTime of Htable thread pool can be changed (gaojinchao) HBASE-5060 HBase client is blocked forever (Jinchao) HBASE-5009 Failure of creating split dir if it already exists prevents splits from happening further + HBASE-5041 Major compaction on non existing table does not throw error (Shrijeet) Release 0.90.5 - Unreleased Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java?rev=1228506&r1=1228505&r2=1228506&view=diff ============================================================================== --- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (original) +++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java Sat Jan 7 00:08:57 2012 @@ -1113,8 +1113,8 @@ public class HBaseAdmin implements Abort */ public void flush(final byte [] tableNameOrRegionName) throws IOException, InterruptedException { - boolean isRegionName = isRegionName(tableNameOrRegionName); CatalogTracker ct = getCatalogTracker(); + boolean isRegionName = isRegionName(tableNameOrRegionName, ct); try { if (isRegionName) { Pair pair = @@ -1126,9 +1126,10 @@ public class HBaseAdmin implements Abort flush(pair.getSecond(), pair.getFirst()); } } else { + final String tableName = tableNameString(tableNameOrRegionName, ct); List> pairs = MetaReader.getTableRegionsAndLocations(ct, - Bytes.toString(tableNameOrRegionName)); + tableName); for (Pair pair: pairs) { if (pair.getFirst().isOffline()) continue; if (pair.getSecond() == null) continue; @@ -1219,7 +1220,7 @@ public class HBaseAdmin implements Abort throws IOException, InterruptedException { CatalogTracker ct = getCatalogTracker(); try { - if (isRegionName(tableNameOrRegionName)) { + if (isRegionName(tableNameOrRegionName, ct)) { Pair pair = MetaReader.getRegion(ct, tableNameOrRegionName); if (pair == null || pair.getSecond() == null) { @@ -1229,9 +1230,10 @@ public class HBaseAdmin implements Abort compact(pair.getSecond(), pair.getFirst(), major); } } else { + final String tableName = tableNameString(tableNameOrRegionName, ct); List> pairs = MetaReader.getTableRegionsAndLocations(ct, - Bytes.toString(tableNameOrRegionName)); + tableName); for (Pair pair: pairs) { if (pair.getFirst().isOffline()) continue; if (pair.getSecond() == null) continue; @@ -1375,7 +1377,7 @@ public class HBaseAdmin implements Abort final byte [] splitPoint) throws IOException, InterruptedException { CatalogTracker ct = getCatalogTracker(); try { - if (isRegionName(tableNameOrRegionName)) { + if (isRegionName(tableNameOrRegionName, ct)) { // Its a possible region name. Pair pair = MetaReader.getRegion(ct, tableNameOrRegionName); @@ -1386,9 +1388,10 @@ public class HBaseAdmin implements Abort split(pair.getSecond(), pair.getFirst(), splitPoint); } } else { + final String tableName = tableNameString(tableNameOrRegionName, ct); List> pairs = MetaReader.getTableRegionsAndLocations(ct, - Bytes.toString(tableNameOrRegionName)); + tableName); for (Pair pair: pairs) { // May not be a server for a particular row if (pair.getSecond() == null) continue; @@ -1436,17 +1439,38 @@ public class HBaseAdmin implements Abort /** * @param tableNameOrRegionName Name of a table or name of a region. - * @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. + * @param ct A {@link #CatalogTracker} instance (caller of this method usually has one). + * @return True if tableNameOrRegionName is a verified region + * name (we call {@link #MetaReader.getRegion(CatalogTracker catalogTracker, + * byte [] regionName)};) else false. + * Throw an exception if tableNameOrRegionName is null. * @throws IOException */ - private boolean isRegionName(final byte [] tableNameOrRegionName) + private boolean isRegionName(final byte[] tableNameOrRegionName, + CatalogTracker ct) throws IOException { if (tableNameOrRegionName == null) { throw new IllegalArgumentException("Pass a table name or region name"); } - return !tableExists(tableNameOrRegionName); + return (MetaReader.getRegion(ct, tableNameOrRegionName) != null); + } + + /** + * Convert the table name byte array into a table name string and check if table + * exists or not. + * @param tableNameBytes Name of a table. + * @param ct A {@link #CatalogTracker} instance (caller of this method usually has one). + * @return tableName in string form. + * @throws IOException if a remote or network exception occurs. + * @throws TableNotFoundException if table does not exist. + */ + private String tableNameString(final byte[] tableNameBytes, CatalogTracker ct) + throws IOException { + String tableNameString = Bytes.toString(tableNameBytes); + if (!MetaReader.tableExists(ct, tableNameString)) { + throw new TableNotFoundException(tableNameString); + } + return tableNameString; } /** Modified: hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java?rev=1228506&r1=1228505&r2=1228506&view=diff ============================================================================== --- hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java (original) +++ hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java Sat Jan 7 00:08:57 2012 @@ -106,6 +106,34 @@ public class TestAdmin { } @Test + public void testSplitFlushCompactUnknownTable() throws InterruptedException { + final String unknowntable = "fubar"; + Exception exception = null; + try { + this.admin.compact(unknowntable); + } catch (IOException e) { + exception = e; + } + assertTrue(exception instanceof TableNotFoundException); + + exception = null; + try { + this.admin.flush(unknowntable); + } catch (IOException e) { + exception = e; + } + assertTrue(exception instanceof TableNotFoundException); + + exception = null; + try { + this.admin.split(unknowntable); + } catch (IOException e) { + exception = e; + } + assertTrue(exception instanceof TableNotFoundException); + } + + @Test public void testDeleteEditUnknownColumnFamilyAndOrTable() throws IOException { // Test we get exception if we try to final String nonexistent = "nonexistent";