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;
}
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;
}
Aggregations