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/12 01:36:23 UTC
svn commit: r1325067 - in /hbase/branches/0.94/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: Wed Apr 11 23:36:22 2012
New Revision: 1325067
URL: http://svn.apache.org/viewvc?rev=1325067&view=rev
Log:
HBASE-5736 ThriftServerRunner.HbaseHandler.mutateRow() does not use ByteBuffer correctly (Scott Chen)
Modified:
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java
hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java
hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java
Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java?rev=1325067&r1=1325066&r2=1325067&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java Wed Apr 11 23:36:22 2012
@@ -971,11 +971,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);
@@ -1029,11 +1029,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);
@@ -1398,8 +1398,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/branches/0.94/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java?rev=1325067&r1=1325066&r2=1325067&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java (original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java Wed Apr 11 23:36:22 2012
@@ -203,9 +203,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
@@ -261,7 +265,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);
@@ -497,7 +501,7 @@ public class TestThriftServer {
* @return a List of Mutations for a row, with columnA having valueA
* and columnB having valueB
*/
- private List<Mutation> getMutations() {
+ private static List<Mutation> getMutations() {
List<Mutation> mutations = new ArrayList<Mutation>();
mutations.add(new Mutation(false, columnAname, valueAname, true));
mutations.add(new Mutation(false, columnBname, valueBname, true));
@@ -512,7 +516,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/branches/0.94/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java?rev=1325067&r1=1325066&r2=1325067&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java (original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java Wed Apr 11 23:36:22 2012
@@ -59,7 +59,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;
@@ -72,7 +72,7 @@ public class TestThriftServerCmdLine {
private Thread cmdLineThread;
private volatile Exception cmdLineException;
-
+
private Exception clientSideException;
private ThriftServer thriftServer;
@@ -139,7 +139,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) {
@@ -204,6 +204,7 @@ public class TestThriftServerCmdLine {
Hbase.Client client = new Hbase.Client(prot);
TestThriftServer.doTestTableCreateDrop(client);
TestThriftServer.doTestGetTableRegions(client);
+ TestThriftServer.doTestTableMutations(client);
} finally {
sock.close();
}