diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestIPC.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestIPC.java index 28b863e..1a1f07f 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestIPC.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestIPC.java @@ -30,8 +30,6 @@ import java.io.IOException; import java.lang.reflect.Method; import java.net.InetSocketAddress; import java.net.Socket; -import java.util.ArrayList; -import java.util.List; import javax.net.SocketFactory; @@ -42,10 +40,17 @@ import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.IpcProtocol; import org.apache.hadoop.hbase.KeyValue; +import org.apache.hadoop.hbase.KeyValueUtil; import org.apache.hadoop.hbase.SmallTests; +import org.apache.hadoop.hbase.client.Put; +import org.apache.hadoop.hbase.client.RowMutations; import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler; +import org.apache.hadoop.hbase.protobuf.RequestConverter; +import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MultiRequest; import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.RpcRequestBody; +import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.RpcResponseBody; import org.apache.hadoop.hbase.security.User; +import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.net.NetUtils; import org.apache.hadoop.util.StringUtils; import org.junit.Test; @@ -70,7 +75,7 @@ public class TestIPC { public Message call(Class protocol, RpcRequestBody param, long receiveTime, MonitoredRPCHandler status) throws IOException { - return param; + return RpcResponseBody.newBuilder().build(); } } @@ -107,11 +112,11 @@ public class TestIPC { * A nothing protocol used in test below. */ interface NothingProtocol extends IpcProtocol { - void doNothing(); + RpcResponseBody doNothing(); } public static class DoNothing implements NothingProtocol { - public void doNothing() {} + public RpcResponseBody doNothing() {return RpcResponseBody.newBuilder().build();} } public static void main(String[] args) @@ -127,19 +132,15 @@ public class TestIPC { Configuration conf = HBaseConfiguration.create(); TestRpcServer rpcServer = new TestRpcServer(); HBaseClient client = new HBaseClient(conf, HConstants.CLUSTER_ID_DEFAULT); - RpcRequestBody.Builder builder = RpcRequestBody.newBuilder(); - byte [] xyz = new byte [] {'x', 'y', 'z'}; - KeyValue kv = new KeyValue(xyz, xyz, xyz, xyz); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DataOutputStream dos = new DataOutputStream(baos); - for (int i = 0; i < cellcount; i++) { - KeyValue.write(kv, dos); - } - dos.close(); - byte [] bytes = baos.toByteArray(); - builder.setMethodName("nothing"); - builder.setRequest(ByteString.copyFrom(bytes)); - RpcRequestBody body = builder.build(); + final byte [] CELL_BYTES = Bytes.toBytes("xyz"); + final KeyValue kv = new KeyValue(CELL_BYTES, CELL_BYTES, CELL_BYTES, CELL_BYTES); + Put p = new Put(kv.getRow()); + for (int i = 0; i < cellcount; i++) p.add(kv); + RowMutations rm = new RowMutations(kv.getRow()); + rm.add(p); + MultiRequest mr = RequestConverter.buildMultiRequest(HConstants.EMPTY_BYTE_ARRAY, rm); + Method m = NothingProtocol.class.getMethod("doNothing", null); + try { rpcServer.start(); InetSocketAddress address = rpcServer.getListenerAddress(); @@ -153,6 +154,10 @@ public class TestIPC { // ReflectionUtils.printThreadInfo(new PrintWriter(System.out), // "Thread dump " + Thread.currentThread().getName()); } + RpcRequestBody.Builder builder = RpcRequestBody.newBuilder(); + builder.setRequest(mr.toByteString()); + builder.setMethodName(m.getName()); + RpcRequestBody body = builder.build(); Message response = client.call(body, address, NothingProtocol.class, user, 0); /* int count = 0;