This is an automated email from the ASF dual-hosted git repository.
caogaofei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 251b89dfa4 Make the transferLeader api available for
MultiLeaderConsensus (#7449)
251b89dfa4 is described below
commit 251b89dfa42beb228759ecc563c568fa1e9e2283
Author: Zhang.Jinrui <[email protected]>
AuthorDate: Tue Sep 27 18:19:23 2022 +0800
Make the transferLeader api available for MultiLeaderConsensus (#7449)
---
.../consensus/multileader/MultiLeaderConsensus.java | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git
a/consensus/src/main/java/org/apache/iotdb/consensus/multileader/MultiLeaderConsensus.java
b/consensus/src/main/java/org/apache/iotdb/consensus/multileader/MultiLeaderConsensus.java
index 2a9da3a1a6..2a8792db7a 100644
---
a/consensus/src/main/java/org/apache/iotdb/consensus/multileader/MultiLeaderConsensus.java
+++
b/consensus/src/main/java/org/apache/iotdb/consensus/multileader/MultiLeaderConsensus.java
@@ -309,12 +309,26 @@ public class MultiLeaderConsensus implements IConsensus {
@Override
public ConsensusGenericResponse transferLeader(ConsensusGroupId groupId,
Peer newLeader) {
- return ConsensusGenericResponse.newBuilder().setSuccess(false).build();
+ return ConsensusGenericResponse.newBuilder().setSuccess(true).build();
}
@Override
public ConsensusGenericResponse triggerSnapshot(ConsensusGroupId groupId) {
- return ConsensusGenericResponse.newBuilder().setSuccess(false).build();
+ MultiLeaderServerImpl impl = stateMachineMap.get(groupId);
+ if (impl == null) {
+ return ConsensusGenericResponse.newBuilder()
+ .setException(new ConsensusGroupNotExistException(groupId))
+ .build();
+ }
+ try {
+ impl.takeSnapshot();
+ } catch (ConsensusGroupAddPeerException e) {
+ return ConsensusGenericResponse.newBuilder()
+ .setSuccess(false)
+ .setException(new ConsensusException(e.getMessage()))
+ .build();
+ }
+ return ConsensusGenericResponse.newBuilder().setSuccess(true).build();
}
@Override