runzhiwang commented on pull request #373:
URL: https://github.com/apache/incubator-ratis/pull/373#issuecomment-750736393
@szetszwo If want to support timeout when transfer leadership, I need the
following change in grpc call, otherwise request will timeout by
requestTimeoutDuration, default 3 seconds. So if without following change, even
though I set timeout to 10 seconds, the call will timeout after 3 seconds. If
you agree with this change, I will also change the netty call.
```
RaftClientReplyProto transferLeadership(
TransferLeadershipRequestProto request) throws IOException {
+ TimeDuration duration = TimeDuration.valueOf(
+ requestTimeoutDuration.getDuration(),
requestTimeoutDuration.getUnit());
+ TimeDuration durationInMs = duration.to(TimeUnit.MILLISECONDS);
return blockingCall(() -> blockingStub
- .withDeadlineAfter(requestTimeoutDuration.getDuration(),
requestTimeoutDuration.getUnit())
+ .withDeadlineAfter(durationInMs.getDuration() +
request.getTimeoutInMs(), TimeUnit.MILLISECONDS)
.transferLeadership(request));
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]