Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
huanghaiping committed Jan 25, 2022
1 parent 4f02797 commit 67e3335
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions jraft-core/src/main/java/com/alipay/sofa/jraft/core/NodeImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1936,12 +1936,24 @@ public Message handleAppendEntriesRequest(final AppendEntriesRequest request, fi

updateLastLeaderTimestamp(Utils.monotonicMs());

if (entriesCount > 0 && this.snapshotExecutor != null && this.snapshotExecutor.isInstallingSnapshot()) {
LOG.warn("Node {} received AppendEntriesRequest while installing snapshot.", getNodeId());
return RpcFactoryHelper //
.responseFactory() //
.newResponse(AppendEntriesResponse.getDefaultInstance(), RaftError.EBUSY,
"Node %s:%s is installing snapshot.", this.groupId, this.serverId);
if (entriesCount > 0) {
if (this.snapshotExecutor != null && this.snapshotExecutor.isInstallingSnapshot()) {
LOG.warn("Node {} received AppendEntriesRequest while installing snapshot.", getNodeId());
return RpcFactoryHelper //
.responseFactory() //
.newResponse(AppendEntriesResponse.getDefaultInstance(), RaftError.EBUSY,
"Node %s:%s is installing snapshot.", this.groupId, this.serverId);
}
// Make sure applyQueue has enough space to hold logs that have not yet been applied
long remaining = this.applyQueue.getBufferSize()
- (this.logManager.getLastLogIndex() - this.fsmCaller.getLastAppliedIndex());
if (remaining < entriesCount) {
LOG.warn("Node {} received AppendEntriesRequest but applyQueue not enough", getNodeId());
return RpcFactoryHelper //
.responseFactory() //
.newResponse(AppendEntriesResponse.getDefaultInstance(), RaftError.EBUSY,
"Node %s:%s is busy.", this.groupId, this.serverId);
}
}

final long prevLogIndex = request.getPrevLogIndex();
Expand Down

0 comments on commit 67e3335

Please sign in to comment.