Return-Path: Delivered-To: apmail-hadoop-hbase-commits-archive@minotaur.apache.org Received: (qmail 87099 invoked from network); 26 Feb 2009 06:07:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Feb 2009 06:07:57 -0000 Received: (qmail 67146 invoked by uid 500); 26 Feb 2009 06:07:57 -0000 Delivered-To: apmail-hadoop-hbase-commits-archive@hadoop.apache.org Received: (qmail 67133 invoked by uid 500); 26 Feb 2009 06:07:57 -0000 Mailing-List: contact hbase-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hbase-dev@hadoop.apache.org Delivered-To: mailing list hbase-commits@hadoop.apache.org Received: (qmail 67124 invoked by uid 99); 26 Feb 2009 06:07:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Feb 2009 22:07:57 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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; Thu, 26 Feb 2009 06:07:55 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4466123888A5; Thu, 26 Feb 2009 06:07:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r748029 - in /hadoop/hbase/branches/0.19: CHANGES.txt src/java/org/apache/hadoop/hbase/thrift/ThriftServer.java src/java/org/apache/hadoop/hbase/thrift/ThriftUtilities.java Date: Thu, 26 Feb 2009 06:07:35 -0000 To: hbase-commits@hadoop.apache.org From: stack@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090226060735.4466123888A5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: stack Date: Thu Feb 26 06:07:34 2009 New Revision: 748029 URL: http://svn.apache.org/viewvc?rev=748029&view=rev Log: HBASE-1142 Cleanup thrift server; remove Text and profuse DEBUG messaging Modified: hadoop/hbase/branches/0.19/CHANGES.txt hadoop/hbase/branches/0.19/src/java/org/apache/hadoop/hbase/thrift/ThriftServer.java hadoop/hbase/branches/0.19/src/java/org/apache/hadoop/hbase/thrift/ThriftUtilities.java Modified: hadoop/hbase/branches/0.19/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.19/CHANGES.txt?rev=748029&r1=748028&r2=748029&view=diff ============================================================================== --- hadoop/hbase/branches/0.19/CHANGES.txt (original) +++ hadoop/hbase/branches/0.19/CHANGES.txt Thu Feb 26 06:07:34 2009 @@ -12,6 +12,8 @@ HBASE-1198 OOME in IPC server does not trigger abort behavior HBASE-1224 Scanner returns values from before startrow (Ben Maurer via Stack) + HBASE-1142 Cleanup thrift server; remove Text and profuse DEBUG messaging + (Tim Sell via Stack) IMPROVEMENTS HBASE-845 HCM.isTableEnabled doesn't really tell if it is, or not Modified: hadoop/hbase/branches/0.19/src/java/org/apache/hadoop/hbase/thrift/ThriftServer.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.19/src/java/org/apache/hadoop/hbase/thrift/ThriftServer.java?rev=748029&r1=748028&r2=748029&view=diff ============================================================================== --- hadoop/hbase/branches/0.19/src/java/org/apache/hadoop/hbase/thrift/ThriftServer.java (original) +++ hadoop/hbase/branches/0.19/src/java/org/apache/hadoop/hbase/thrift/ThriftServer.java Thu Feb 26 06:07:34 2009 @@ -19,7 +19,6 @@ package org.apache.hadoop.hbase.thrift; import java.io.IOException; -import java.nio.charset.MalformedInputException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -53,7 +52,6 @@ import org.apache.hadoop.hbase.thrift.generated.TCell; import org.apache.hadoop.hbase.thrift.generated.TRowResult; import org.apache.hadoop.hbase.util.Bytes; -import org.apache.hadoop.io.Text; import com.facebook.thrift.TException; import com.facebook.thrift.protocol.TBinaryProtocol; @@ -93,7 +91,7 @@ */ protected HTable getTable(final byte[] tableName) throws IOError, IOException { - return new HTable(this.conf, getText(tableName)); + return new HTable(this.conf, tableName); } /** @@ -141,33 +139,7 @@ scannerMap = new HashMap(); } - /** - * Converts a byte array to a Text object after validating the UTF-8 - * encoding. - * - * @param buf - * UTF-8 encoded bytes - * @return Text object - * @throws IllegalArgument - * @throws IOError - */ - byte [] getText(byte[] buf) throws IOError { - try { - Text.validateUTF8(buf); - } catch (MalformedInputException e) { - throw new IOError("invalid UTF-8 encoding in row or column name"); - } - return buf; - } - - // - // The Thrift Hbase.Iface interface is implemented below. - // Documentation for the methods and datastructures is the Hbase.thrift file - // used to generate the interface. - // - public void enableTable(final byte[] tableName) throws IOError { - LOG.debug("enableTable"); try{ admin.enableTable(tableName); } catch (IOException e) { @@ -176,7 +148,6 @@ } public void disableTable(final byte[] tableName) throws IOError{ - LOG.debug("disableTable"); try{ admin.disableTable(tableName); } catch (IOException e) { @@ -185,7 +156,6 @@ } public boolean isTableEnabled(final byte[] tableName) throws IOError { - LOG.debug("isTableEnabled"); try { return HTable.isTableEnabled(tableName); } catch (IOException e) { @@ -194,7 +164,6 @@ } public List getTableNames() throws IOError { - LOG.debug("getTableNames"); try { HTableDescriptor[] tables = this.admin.listTables(); ArrayList list = new ArrayList(tables.length); @@ -210,8 +179,6 @@ public List getTableRegions(byte[] tableName) throws IOError { try{ - LOG.debug("getTableRegions: " + new String(tableName)); - HTable table = getTable(tableName); Map regionsInfo = table.getRegionsInfo(); List regions = new ArrayList(); @@ -233,13 +200,9 @@ public TCell get(byte[] tableName, byte[] row, byte[] column) throws NotFound, IOError { - if (LOG.isDebugEnabled()) { - LOG.debug("get: table=" + new String(tableName) + ", row=" - + new String(row) + ", col=" + new String(column)); - } try { HTable table = getTable(tableName); - Cell cell = table.get(getText(row), getText(column)); + Cell cell = table.get(row, column); if (cell == null) { throw new NotFound(); } @@ -251,15 +214,10 @@ public List getVer(byte[] tableName, byte[] row, byte[] column, int numVersions) throws IOError, NotFound { - if (LOG.isDebugEnabled()) { - LOG.debug("getVer: table=" + new String(tableName) + ", row=" - + new String(row) + ", col=" + new String(column) + ", numVers=" - + numVersions); - } try { HTable table = getTable(tableName); Cell[] cells = - table.get(getText(row), getText(column), numVersions); + table.get(row, column, numVersions); if (cells == null) { throw new NotFound(); } @@ -276,15 +234,9 @@ public List getVerTs(byte[] tableName, byte[] row, byte[] column, long timestamp, int numVersions) throws IOError, NotFound { - if (LOG.isDebugEnabled()) { - LOG.debug("getVerTs: table=" + new String(tableName) + ", row=" - + new String(row) + ", col=" + new String(column) + ", ts=" - + timestamp + ", numVers=" + numVersions); - } try { HTable table = getTable(tableName); - Cell[] cells = table.get(getText(row), - getText(column), timestamp, numVersions); + Cell[] cells = table.get(row, column, timestamp, numVersions); if (cells == null) { throw new NotFound(); } @@ -318,18 +270,14 @@ public TRowResult getRowWithColumnsTs(byte[] tableName, byte[] row, List columns, long timestamp) throws IOError { - if (LOG.isDebugEnabled()) { - LOG.debug("getRowTs: table=" + new String(tableName) + ", row=" - + new String(row) + ", ts=" + timestamp); - } try { HTable table = getTable(tableName); if (columns == null) { - return ThriftUtilities.rowResultFromHBase(table.getRow(getText(row), + return ThriftUtilities.rowResultFromHBase(table.getRow(row, timestamp)); } else { byte[][] columnArr = columns.toArray(new byte[columns.size()][]); - return ThriftUtilities.rowResultFromHBase(table.getRow(getText(row), + return ThriftUtilities.rowResultFromHBase(table.getRow(row, columnArr, timestamp)); } } catch (IOException e) { @@ -344,14 +292,9 @@ public void deleteAllTs(byte[] tableName, byte[] row, byte[] column, long timestamp) throws IOError { - if (LOG.isDebugEnabled()) { - LOG.debug("deleteAllTs: table=" + new String(tableName) + ", row=" - + new String(row) + ", col=" + new String(column) + ", ts=" - + timestamp); - } try { HTable table = getTable(tableName); - table.deleteAll(getText(row), getText(column), timestamp); + table.deleteAll(row, column, timestamp); } catch (IOException e) { throw new IOError(e.getMessage()); } @@ -363,13 +306,9 @@ public void deleteAllRowTs(byte[] tableName, byte[] row, long timestamp) throws IOError { - if (LOG.isDebugEnabled()) { - LOG.debug("deleteAllRowTs: table=" + new String(tableName) + ", row=" - + new String(row) + ", ts=" + timestamp); - } try { HTable table = getTable(tableName); - table.deleteAll(getText(row), timestamp); + table.deleteAll(row, timestamp); } catch (IOException e) { throw new IOError(e.getMessage()); } @@ -378,21 +317,14 @@ public void createTable(byte[] tableName, List columnFamilies) throws IOError, IllegalArgument, AlreadyExists { - if (LOG.isDebugEnabled()) { - LOG.debug("createTable: table=" + new String(tableName)); - } try { - byte [] tableStr = getText(tableName); - if (admin.tableExists(tableStr)) { + if (admin.tableExists(tableName)) { throw new AlreadyExists("table name already in use"); } - HTableDescriptor desc = new HTableDescriptor(tableStr); + HTableDescriptor desc = new HTableDescriptor(tableName); for (ColumnDescriptor col : columnFamilies) { HColumnDescriptor colDesc = ThriftUtilities.colDescFromThrift(col); desc.addFamily(colDesc); - if (LOG.isDebugEnabled()) { - LOG.debug("createTable: col=" + new String(colDesc.getName())); - } } admin.createTable(desc); } catch (IOException e) { @@ -407,11 +339,10 @@ LOG.debug("deleteTable: table=" + new String(tableName)); } try { - byte [] tableStr = getText(tableName); - if (!admin.tableExists(tableStr)) { + if (!admin.tableExists(tableName)) { throw new NotFound(); } - admin.deleteTable(tableStr); + admin.deleteTable(tableName); } catch (IOException e) { throw new IOError(e.getMessage()); } @@ -424,29 +355,15 @@ public void mutateRowTs(byte[] tableName, byte[] row, List mutations, long timestamp) throws IOError, IllegalArgument { - if (LOG.isDebugEnabled()) { - LOG.debug("mutateRowTs: table=" + new String(tableName) + ", row=" - + new String(row) + ", ts=" + timestamp + " mutations=" - + mutations.size()); - for (Mutation m : mutations) { - if (m.isDelete) { - LOG.debug("mutateRowTs: : delete - " + new String(getText(m.column))); - } else { - LOG.debug("mutateRowTs: : put - " + new String(getText(m.column)) + " => " - + new String(m.value)); - } - } - } - HTable table = null; try { table = getTable(tableName); - BatchUpdate batchUpdate = new BatchUpdate(getText(row), timestamp); + BatchUpdate batchUpdate = new BatchUpdate(row, timestamp); for (Mutation m : mutations) { if (m.isDelete) { - batchUpdate.delete(getText(m.column)); + batchUpdate.delete(m.column); } else { - batchUpdate.put(getText(m.column), m.value); + batchUpdate.put(m.column, m.value); } } table.commit(batchUpdate); @@ -466,30 +383,15 @@ throws IOError, IllegalArgument, TException { List batchUpdates = new ArrayList(); - if (LOG.isDebugEnabled()) { - LOG.debug("mutateRowsTs: table=" + new String(tableName) + ", rows=" - + rowBatches.size() + ", ts=" + timestamp); - } for (BatchMutation batch : rowBatches) { byte[] row = batch.row; List mutations = batch.mutations; - if (LOG.isDebugEnabled()) { - LOG.debug("mutateRowsTs: : row=" + new String(row) + " mutations=" + mutations.size()); - for (Mutation m : mutations) { - if (m.isDelete) { - LOG.debug("mutateRowsTs: : delete - " + new String(getText(m.column))); - } else { - LOG.debug("mutateRowsTs: : put - " + new String(getText(m.column)) + " => " - + new String(m.value)); - } - } - } - BatchUpdate batchUpdate = new BatchUpdate(getText(row), timestamp); + BatchUpdate batchUpdate = new BatchUpdate(row, timestamp); for (Mutation m : mutations) { if (m.isDelete) { - batchUpdate.delete(getText(m.column)); + batchUpdate.delete(m.column); } else { - batchUpdate.put(getText(m.column), m.value); + batchUpdate.put(m.column, m.value); } } batchUpdates.add(batchUpdate); @@ -539,18 +441,10 @@ public int scannerOpen(byte[] tableName, byte[] startRow, List columns) throws IOError { - if (LOG.isDebugEnabled()) { - LOG.debug("scannerOpen: table=" + new String(getText(tableName)) + ", start=" - + new String(getText(startRow)) + ", columns=" + columns.toString()); - } try { HTable table = getTable(tableName); - byte [][] columnsText = new byte[columns.size()][]; - for (int i = 0; i < columns.size(); ++i) { - columnsText[i] = getText(columns.get(i)); - } - Scanner scanner = table.getScanner(columnsText, - getText(startRow)); + Scanner scanner = table.getScanner(columns.toArray(new byte[0][]), + startRow); return addScanner(scanner); } catch (IOException e) { throw new IOError(e.getMessage()); @@ -559,19 +453,10 @@ public int scannerOpenWithStop(byte[] tableName, byte[] startRow, byte[] stopRow, List columns) throws IOError, TException { - if (LOG.isDebugEnabled()) { - LOG.debug("scannerOpen: table=" + new String(getText(tableName)) + ", start=" - + new String(getText(startRow)) + ", stop=" + new String(getText(stopRow)) + ", columns=" - + columns.toString()); - } try { HTable table = getTable(tableName); - byte [][] columnsText = new byte[columns.size()][]; - for (int i = 0; i < columns.size(); ++i) { - columnsText[i] = getText(columns.get(i)); - } - Scanner scanner = table.getScanner(columnsText, - getText(startRow), getText(stopRow)); + Scanner scanner = table.getScanner(columns.toArray(new byte[0][]), + startRow, stopRow); return addScanner(scanner); } catch (IOException e) { throw new IOError(e.getMessage()); @@ -580,19 +465,10 @@ public int scannerOpenTs(byte[] tableName, byte[] startRow, List columns, long timestamp) throws IOError, TException { - if (LOG.isDebugEnabled()) { - LOG.debug("scannerOpen: table=" + new String(getText(tableName)) + ", start=" - + new String(getText(startRow)) + ", columns=" + columns.toString() - + ", timestamp=" + timestamp); - } try { HTable table = getTable(tableName); - byte [][] columnsText = new byte[columns.size()][]; - for (int i = 0; i < columns.size(); ++i) { - columnsText[i] = getText(columns.get(i)); - } - Scanner scanner = table.getScanner(columnsText, - getText(startRow), timestamp); + Scanner scanner = table.getScanner(columns.toArray(new byte[0][]), + startRow, timestamp); return addScanner(scanner); } catch (IOException e) { throw new IOError(e.getMessage()); @@ -602,19 +478,10 @@ public int scannerOpenWithStopTs(byte[] tableName, byte[] startRow, byte[] stopRow, List columns, long timestamp) throws IOError, TException { - if (LOG.isDebugEnabled()) { - LOG.debug("scannerOpen: table=" + new String(getText(tableName)) + ", start=" - + new String(getText(startRow)) + ", stop=" + new String(getText(stopRow)) + ", columns=" - + columns.toString() + ", timestamp=" + timestamp); - } try { HTable table = getTable(tableName); - byte [][] columnsText = new byte[columns.size()][]; - for (int i = 0; i < columns.size(); ++i) { - columnsText[i] = getText(columns.get(i)); - } - Scanner scanner = table.getScanner(columnsText, - getText(startRow), getText(stopRow), timestamp); + Scanner scanner = table.getScanner(columns.toArray(new byte[0][]), + startRow, stopRow, timestamp); return addScanner(scanner); } catch (IOException e) { throw new IOError(e.getMessage()); @@ -623,9 +490,6 @@ public Map getColumnDescriptors( byte[] tableName) throws IOError, TException { - if (LOG.isDebugEnabled()) { - LOG.debug("getColumnDescriptors: table=" + new String(tableName)); - } try { TreeMap columns = new TreeMap(Bytes.BYTES_COMPARATOR); @@ -669,7 +533,7 @@ } /* - * Start up the REST servlet in standalone mode. + * Start up the Thrift server. * @param args */ protected static void doMain(final String [] args) throws Exception { Modified: hadoop/hbase/branches/0.19/src/java/org/apache/hadoop/hbase/thrift/ThriftUtilities.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.19/src/java/org/apache/hadoop/hbase/thrift/ThriftUtilities.java?rev=748029&r1=748028&r2=748029&view=diff ============================================================================== --- hadoop/hbase/branches/0.19/src/java/org/apache/hadoop/hbase/thrift/ThriftUtilities.java (original) +++ hadoop/hbase/branches/0.19/src/java/org/apache/hadoop/hbase/thrift/ThriftUtilities.java Thu Feb 26 06:07:34 2009 @@ -18,7 +18,6 @@ package org.apache.hadoop.hbase.thrift; -import java.io.IOException; import java.util.Map; import java.util.TreeMap; @@ -27,9 +26,7 @@ import org.apache.hadoop.hbase.io.Cell; import org.apache.hadoop.hbase.io.RowResult; import org.apache.hadoop.hbase.thrift.generated.ColumnDescriptor; -import org.apache.hadoop.hbase.thrift.generated.IOError; import org.apache.hadoop.hbase.thrift.generated.IllegalArgument; -import org.apache.hadoop.hbase.thrift.generated.NotFound; import org.apache.hadoop.hbase.thrift.generated.TCell; import org.apache.hadoop.hbase.thrift.generated.TRowResult; import org.apache.hadoop.hbase.util.Bytes;