This is an automated email from the ASF dual-hosted git repository.
szetszwo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ratis.git
The following commit(s) were added to refs/heads/master by this push:
new e08f2d1 Revert "RATIS-601. Fix NotLeaderException handling.
Contributed by Mukul Kumar Singh"
e08f2d1 is described below
commit e08f2d13e44befd136655f4936a01dca704dc3b1
Author: Tsz Wo Nicholas Sze <[email protected]>
AuthorDate: Tue Jun 25 11:28:06 2019 +0800
Revert "RATIS-601. Fix NotLeaderException handling. Contributed by Mukul
Kumar Singh"
This reverts commit 6d7afecf4ec547815e283602f6ba2bac73b165cc.
---
.../src/main/java/org/apache/ratis/client/impl/OrderedAsync.java | 7 +------
.../src/main/java/org/apache/ratis/client/impl/RaftClientImpl.java | 6 ++----
.../src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java | 5 +++--
3 files changed, 6 insertions(+), 12 deletions(-)
diff --git
a/ratis-client/src/main/java/org/apache/ratis/client/impl/OrderedAsync.java
b/ratis-client/src/main/java/org/apache/ratis/client/impl/OrderedAsync.java
index 35681b8..2ad393e 100644
--- a/ratis-client/src/main/java/org/apache/ratis/client/impl/OrderedAsync.java
+++ b/ratis-client/src/main/java/org/apache/ratis/client/impl/OrderedAsync.java
@@ -229,12 +229,7 @@ class OrderedAsync {
if (!retryPolicy.shouldRetry(attemptCount, request)) {
handleAsyncRetryFailure(request, attemptCount, e);
} else {
- if (e instanceof NotLeaderException) {
- NotLeaderException nle = (NotLeaderException)e;
- client.handleNotLeaderException(request, nle,
this::resetSlidingWindow);
- } else {
- client.handleIOException(request, (IOException) e, null,
this::resetSlidingWindow);
- }
+ client.handleIOException(request, (IOException) e, null,
this::resetSlidingWindow);
}
if (e instanceof NotLeaderException) {
throw new CompletionException(e);
diff --git
a/ratis-client/src/main/java/org/apache/ratis/client/impl/RaftClientImpl.java
b/ratis-client/src/main/java/org/apache/ratis/client/impl/RaftClientImpl.java
index feed9d0..65c84a2 100644
---
a/ratis-client/src/main/java/org/apache/ratis/client/impl/RaftClientImpl.java
+++
b/ratis-client/src/main/java/org/apache/ratis/client/impl/RaftClientImpl.java
@@ -361,13 +361,11 @@ final class RaftClientImpl implements RaftClient {
}
LOG.debug("{}: oldLeader={}, curLeader={}, newLeader={}", clientId,
oldLeader, curLeader, newLeader);
- final boolean changeLeader = !(ioe instanceof AlreadyClosedException ||
ioe instanceof TimeoutIOException)
- && newLeader != null && stillLeader;
+ final boolean changeLeader = newLeader != null && stillLeader;
final boolean reconnect = changeLeader || clientRpc.shouldReconnect(ioe);
if (reconnect) {
if (changeLeader && oldLeader.equals(leaderId)) {
- LOG.debug("{} {}: client change Leader from {} to {} ex={}", groupId,
- clientId, oldLeader, newLeader, ioe.getClass().getName());
+ LOG.debug("{}: change Leader from {} to {}", clientId, oldLeader,
newLeader);
this.leaderId = newLeader;
}
clientRpc.handleException(oldLeader, ioe, reconnect);
diff --git
a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
index ec21a17..ecd790d 100644
---
a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
+++
b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
@@ -451,8 +451,9 @@ public class RaftServerImpl implements RaftServerProtocol,
RaftServerAsynchronou
RaftPeerId leaderId = state.getLeaderId();
if (leaderId == null || leaderId.equals(state.getSelfId())) {
// No idea about who is the current leader. Or the peer is the current
- // leader, but it is about to step down. set the suggested leader as
null.
- leaderId = null;
+ // leader, but it is about to step down
+ RaftPeer suggestedLeader =
getRaftConf().getRandomPeer(state.getSelfId());
+ leaderId = suggestedLeader == null ? null : suggestedLeader.getId();
}
RaftConfiguration conf = getRaftConf();
Collection<RaftPeer> peers = conf.getPeers();