|
@@ -60,6 +60,7 @@ import org.apache.hadoop.io.retry.RetryProxy;
|
|
|
import org.apache.hadoop.ipc.Client.ConnectionId;
|
|
|
import org.apache.hadoop.ipc.RPC.RpcKind;
|
|
|
import org.apache.hadoop.ipc.Server.Connection;
|
|
|
+import org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcResponseHeaderProto;
|
|
|
import org.apache.hadoop.net.ConnectTimeoutException;
|
|
|
import org.apache.hadoop.net.NetUtils;
|
|
|
import org.apache.hadoop.util.StringUtils;
|
|
@@ -708,33 +709,45 @@ public class TestIPC {
|
|
|
assertRetriesOnSocketTimeouts(conf, 4);
|
|
|
}
|
|
|
|
|
|
- private static class CallId {
|
|
|
+ private static class CallInfo {
|
|
|
int id = RpcConstants.INVALID_CALL_ID;
|
|
|
+ int retry = RpcConstants.INVALID_RETRY_COUNT;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Test if the rpc server uses the call id generated by the rpc client.
|
|
|
+ * Test if
|
|
|
+ * (1) the rpc server uses the call id/retry provided by the rpc client, and
|
|
|
+ * (2) the rpc client receives the same call id/retry from the rpc server.
|
|
|
*/
|
|
|
@Test
|
|
|
- public void testCallIds() throws Exception {
|
|
|
- final CallId callId = new CallId();
|
|
|
+ public void testCallIdAndRetry() throws Exception {
|
|
|
+ final CallInfo info = new CallInfo();
|
|
|
|
|
|
- // Override client to store the call id
|
|
|
+ // Override client to store the call info and check response
|
|
|
final Client client = new Client(LongWritable.class, conf) {
|
|
|
@Override
|
|
|
Call createCall(RpcKind rpcKind, Writable rpcRequest) {
|
|
|
final Call call = super.createCall(rpcKind, rpcRequest);
|
|
|
- callId.id = call.id;
|
|
|
+ info.id = call.id;
|
|
|
+ info.retry = call.retry;
|
|
|
return call;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ void checkResponse(RpcResponseHeaderProto header) throws IOException {
|
|
|
+ super.checkResponse(header);
|
|
|
+ Assert.assertEquals(info.id, header.getCallId());
|
|
|
+ Assert.assertEquals(info.retry, header.getRetryCount());
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
- // Attach a listener that tracks every call ID received by the server.
|
|
|
+ // Attach a listener that tracks every call received by the server.
|
|
|
final TestServer server = new TestServer(1, false);
|
|
|
server.callListener = new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- Assert.assertEquals(callId.id, Server.getCallId());
|
|
|
+ Assert.assertEquals(info.id, Server.getCallId());
|
|
|
+ Assert.assertEquals(info.retry, Server.getCallRetryCount());
|
|
|
}
|
|
|
};
|
|
|
|