2929import org .apache .ratis .proto .RaftProtos .ServerRpcProto ;
3030import org .apache .ratis .protocol .RaftGroupId ;
3131import org .apache .ratis .protocol .RaftGroupMemberId ;
32- import org .apache .ratis .protocol .RaftPeer ;
3332import org .apache .ratis .protocol .RaftPeerId ;
3433import org .apache .ratis .server .RaftServerConfigKeys ;
35- import org .apache .ratis .server .protocol .RaftServerProtocol ;
34+ import org .apache .ratis .server .impl .FollowerState .UpdateType ;
35+ import org .apache .ratis .server .protocol .RaftServerProtocol .Op ;
3636import org .apache .ratis .server .protocol .TermIndex ;
3737import org .apache .ratis .server .raftlog .LogProtoUtils ;
3838import org .apache .ratis .server .util .ServerStringUtils ;
@@ -173,16 +173,16 @@ private CompletableFuture<InstallSnapshotReplyProto> checkAndInstallSnapshot(Ins
173173 final long lastIncludedIndex = lastIncluded .getIndex ();
174174 final CompletableFuture <Void > future ;
175175 synchronized (server ) {
176- final boolean recognized = state .recognizeLeader (RaftServerProtocol . Op .INSTALL_SNAPSHOT , leaderId , leaderTerm );
176+ final boolean recognized = state .recognizeLeader (Op .INSTALL_SNAPSHOT , leaderId , leaderTerm );
177177 currentTerm = state .getCurrentTerm ();
178178 if (!recognized ) {
179179 return CompletableFuture .completedFuture (toInstallSnapshotReplyProto (leaderId , getMemberId (),
180180 currentTerm , snapshotChunkRequest .getRequestIndex (), InstallSnapshotResult .NOT_LEADER ));
181181 }
182- future = server .changeToFollowerAndPersistMetadata (leaderTerm , true , "installSnapshot" );
183- state .setLeader (leaderId , "installSnapshot" );
182+ future = server .changeToFollowerAndPersistMetadata (leaderTerm , true , Op . INSTALL_SNAPSHOT );
183+ state .setLeader (leaderId , Op . INSTALL_SNAPSHOT );
184184
185- server .updateLastRpcTime (FollowerState . UpdateType .INSTALL_SNAPSHOT_START );
185+ server .updateLastRpcTime (UpdateType .INSTALL_SNAPSHOT_START );
186186 long callId = chunk0CallId .get ();
187187 // 1. leaderTerm < currentTerm will never come here
188188 // 2. leaderTerm == currentTerm && callId == request.getCallId()
@@ -229,7 +229,7 @@ private CompletableFuture<InstallSnapshotReplyProto> checkAndInstallSnapshot(Ins
229229 chunk0CallId .set (-1 );
230230 }
231231 } finally {
232- server .updateLastRpcTime (FollowerState . UpdateType .INSTALL_SNAPSHOT_COMPLETE );
232+ server .updateLastRpcTime (UpdateType .INSTALL_SNAPSHOT_COMPLETE );
233233 }
234234 }
235235 if (snapshotChunkRequest .getDone ()) {
@@ -249,15 +249,15 @@ private CompletableFuture<InstallSnapshotReplyProto> notifyStateMachineToInstall
249249 final long firstAvailableLogIndex = firstAvailableLogTermIndex .getIndex ();
250250 final CompletableFuture <Void > future ;
251251 synchronized (server ) {
252- final boolean recognized = state .recognizeLeader ("notifyInstallSnapshot" , leaderId , leaderTerm );
252+ final boolean recognized = state .recognizeLeader (UpdateType . INSTALL_SNAPSHOT_NOTIFICATION , leaderId , leaderTerm );
253253 currentTerm = state .getCurrentTerm ();
254254 if (!recognized ) {
255255 return CompletableFuture .completedFuture (toInstallSnapshotReplyProto (leaderId , getMemberId (),
256256 currentTerm , InstallSnapshotResult .NOT_LEADER ));
257257 }
258- future = server .changeToFollowerAndPersistMetadata (leaderTerm , true , "installSnapshot" );
259- state .setLeader (leaderId , "installSnapshot" );
260- server .updateLastRpcTime (FollowerState . UpdateType .INSTALL_SNAPSHOT_NOTIFICATION );
258+ future = server .changeToFollowerAndPersistMetadata (leaderTerm , true , UpdateType . INSTALL_SNAPSHOT_NOTIFICATION );
259+ state .setLeader (leaderId , UpdateType . INSTALL_SNAPSHOT_NOTIFICATION );
260+ server .updateLastRpcTime (UpdateType .INSTALL_SNAPSHOT_NOTIFICATION );
261261
262262 if (inProgressInstallSnapshotIndex .compareAndSet (INVALID_LOG_INDEX , firstAvailableLogIndex )) {
263263 LOG .info ("{}: Received notification to install snapshot at index {}" , getMemberId (), firstAvailableLogIndex );
@@ -292,7 +292,7 @@ private CompletableFuture<InstallSnapshotReplyProto> notifyStateMachineToInstall
292292 // For the cases where RaftConf is empty on newly started peer with empty peer list,
293293 // we retrieve leader info from installSnapShotRequestProto.
294294 final RoleInfoProto proto = leaderProto == null || server .getRaftConf ().getPeer (state .getLeaderId ()) != null ?
295- server .getRoleInfoProto (): getRoleInfoProto (ProtoUtils . toRaftPeer ( leaderProto ) );
295+ server .getRoleInfoProto (): getRoleInfoProto (leaderProto );
296296 // This is the first installSnapshot notify request for this term and
297297 // index. Notify the state machine to install the snapshot.
298298 LOG .info ("{}: notifyInstallSnapshot: nextIndex is {} but the leader's first available index is {}." ,
@@ -386,7 +386,7 @@ private CompletableFuture<InstallSnapshotReplyProto> notifyStateMachineToInstall
386386 }
387387 }
388388
389- private RoleInfoProto getRoleInfoProto (RaftPeer leader ) {
389+ private RoleInfoProto getRoleInfoProto (RaftPeerProto leader ) {
390390 final RoleInfo role = server .getRole ();
391391 final Optional <FollowerState > fs = role .getFollowerState ();
392392 final ServerRpcProto leaderInfo = toServerRpcProto (leader ,
0 commit comments