You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by te...@apache.org on 2012/04/07 01:37:01 UTC

svn commit: r1310634 - in /hbase/trunk/src: main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java

Author: tedyu
Date: Fri Apr  6 23:37:01 2012
New Revision: 1310634

URL: http://svn.apache.org/viewvc?rev=1310634&view=rev
Log:
HBASE-5736 ThriftServerRunner.HbaseHandler.mutateRow() does not use ByteBuffer correctly (Scott Chen)

Modified:
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java?rev=1310634&r1=1310633&r2=1310634&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java Fri Apr  6 23:37:01 2012
@@ -974,11 +974,11 @@ public class ThriftServerRunner implemen
           } else {
             if(famAndQf.length == 1) {
               put.add(famAndQf[0], HConstants.EMPTY_BYTE_ARRAY,
-                  m.value != null ? m.value.array()
+                  m.value != null ? getBytes(m.value)
                       : HConstants.EMPTY_BYTE_ARRAY);
             } else {
               put.add(famAndQf[0], famAndQf[1],
-                  m.value != null ? m.value.array()
+                  m.value != null ? getBytes(m.value)
                       : HConstants.EMPTY_BYTE_ARRAY);
             }
             put.setWriteToWAL(m.writeToWAL);
@@ -1032,11 +1032,11 @@ public class ThriftServerRunner implemen
           } else {
             if(famAndQf.length == 1) {
               put.add(famAndQf[0], HConstants.EMPTY_BYTE_ARRAY,
-                  m.value != null ? m.value.array()
+                  m.value != null ? getBytes(m.value)
                       : HConstants.EMPTY_BYTE_ARRAY);
             } else {
               put.add(famAndQf[0], famAndQf[1],
-                  m.value != null ? m.value.array()
+                  m.value != null ? getBytes(m.value)
                       : HConstants.EMPTY_BYTE_ARRAY);
             }
             put.setWriteToWAL(m.writeToWAL);
@@ -1401,8 +1401,8 @@ public class ThriftServerRunner implemen
       return;
     }
     for (Map.Entry<ByteBuffer, ByteBuffer> entry : attributes.entrySet()) {
-      String name = Bytes.toStringBinary(entry.getKey());
-      byte[] value =  Bytes.toBytes(entry.getValue());
+      String name = Bytes.toStringBinary(getBytes(entry.getKey()));
+      byte[] value =  getBytes(entry.getValue());
       op.setAttribute(name, value);
     }
   }

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java?rev=1310634&r1=1310633&r2=1310634&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java Fri Apr  6 23:37:01 2012
@@ -209,9 +209,13 @@ public class TestThriftServer {
    * @throws Exception
    */
   public void doTestTableMutations() throws Exception {
-    // Setup
     ThriftServerRunner.HBaseHandler handler =
       new ThriftServerRunner.HBaseHandler(UTIL.getConfiguration());
+    doTestTableMutations(handler);
+  }
+
+  public static void doTestTableMutations(Hbase.Iface handler) throws Exception {
+    // Setup
     handler.createTable(tableAname, getColumnDescriptors());
 
     // Apply a few Mutations to rowA
@@ -267,7 +271,7 @@ public class TestThriftServer {
     handler.mutateRow(tableAname, rowAname, mutations, null);
     TRowResult rowResult3 = handler.getRow(tableAname, rowAname, null).get(0);
     assertEquals(rowAname, rowResult3.row);
-    assertEquals(0, rowResult3.columns.get(columnAname).value.array().length);
+    assertEquals(0, rowResult3.columns.get(columnAname).value.remaining());
 
     // Teardown
     handler.disableTable(tableAname);
@@ -540,7 +544,7 @@ public class TestThriftServer {
    * (rowB, columnA): place valueC
    * (rowB, columnB): place valueD
    */
-  private List<BatchMutation> getBatchMutations() {
+  private static List<BatchMutation> getBatchMutations() {
     List<BatchMutation> batchMutations = new ArrayList<BatchMutation>();
 
     // Mutations to rowA.  You can't mix delete and put anymore.

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java?rev=1310634&r1=1310633&r2=1310634&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java Fri Apr  6 23:37:01 2012
@@ -58,7 +58,7 @@ import com.google.common.base.Joiner;
 @RunWith(Parameterized.class)
 public class TestThriftServerCmdLine {
 
-  public static final Log LOG = 
+  public static final Log LOG =
       LogFactory.getLog(TestThriftServerCmdLine.class);
 
   private final ImplType implType;
@@ -71,7 +71,7 @@ public class TestThriftServerCmdLine {
 
   private Thread cmdLineThread;
   private volatile Exception cmdLineException;
-  
+
   private Exception clientSideException;
 
   private ThriftServer thriftServer;
@@ -142,7 +142,7 @@ public class TestThriftServerCmdLine {
     cmdLineThread.start();
   }
 
-  @Test(timeout=30 * 1000)
+  @Test(timeout=60 * 1000)
   public void testRunThriftServer() throws Exception {
     List<String> args = new ArrayList<String>();
     if (implType != null) {
@@ -209,6 +209,7 @@ public class TestThriftServerCmdLine {
       TestThriftServer.doTestTableCreateDrop(client);
       TestThriftServer.doTestGetRegionInfo(client);
       TestThriftServer.doTestGetTableRegions(client);
+      TestThriftServer.doTestTableMutations(client);
     } finally {
       sock.close();
     }