Search in sources :

Example 1 with Call

use of org.apache.hadoop.hbase.ipc.RpcServer.Call in project hbase by apache.

the class TestSimpleRpcScheduler method getMockedCallRunner.

// Get mocked call that has the CallRunner sleep for a while so that the fast
// path isn't hit.
private CallRunner getMockedCallRunner(long timestamp, final long sleepTime) throws IOException {
    final RpcServer.Call putCall = mock(RpcServer.Call.class);
    putCall.timestamp = timestamp;
    putCall.param = RequestConverter.buildMutateRequest(Bytes.toBytes("abc"), new Put(Bytes.toBytes("row")));
    RPCProtos.RequestHeader putHead = RPCProtos.RequestHeader.newBuilder().setMethodName("mutate").build();
    when(putCall.getSize()).thenReturn(9L);
    when(putCall.getHeader()).thenReturn(putHead);
    when(putCall.getReceiveTime()).thenReturn(putCall.timestamp);
    when(putCall.getParam()).thenReturn(putCall.param);
    CallRunner cr = new CallRunner(null, putCall) {

        public void run() {
            if (sleepTime <= 0)
                return;
            try {
                LOG.warn("Sleeping for " + sleepTime);
                Thread.sleep(sleepTime);
                LOG.warn("Done Sleeping for " + sleepTime);
            } catch (InterruptedException e) {
            }
        }

        public RpcCall getRpcCall() {
            return putCall;
        }

        public void drop() {
        }
    };
    return cr;
}
Also used : RPCProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos) Call(org.apache.hadoop.hbase.ipc.RpcServer.Call) Put(org.apache.hadoop.hbase.client.Put) RequestHeader(org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.RequestHeader)

Example 2 with Call

use of org.apache.hadoop.hbase.ipc.RpcServer.Call in project hbase by apache.

the class TestSimpleRpcScheduler method createMockTask.

private CallRunner createMockTask() {
    Call call = mock(Call.class);
    CallRunner task = mock(CallRunner.class);
    when(task.getRpcCall()).thenReturn(call);
    return task;
}
Also used : Call(org.apache.hadoop.hbase.ipc.RpcServer.Call)

Aggregations

Call (org.apache.hadoop.hbase.ipc.RpcServer.Call)2 Put (org.apache.hadoop.hbase.client.Put)1 RPCProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos)1 RequestHeader (org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.RequestHeader)1