Skip to content

Commit

Permalink
Remove "startupWithoutServing" and simplify the process in syncWithLe…
Browse files Browse the repository at this point in the history
…ader.
  • Loading branch information
AlphaCanisMajoris committed Aug 28, 2024
1 parent f95a261 commit d2ee4dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -793,19 +793,6 @@ public void startdata() throws IOException, InterruptedException {
}

public synchronized void startup() {
startupWithServerState(State.RUNNING);
}

public synchronized void startupWithoutServing() {
startupWithServerState(State.INITIAL);
}

public synchronized void startServing() {
setState(State.RUNNING);
notifyAll();
}

private void startupWithServerState(State state) {
if (sessionTracker == null) {
createSessionTracker();
}
Expand All @@ -820,7 +807,7 @@ private void startupWithServerState(State state) {

registerMetrics();

setState(state);
setState(State.RUNNING);

requestPathMetricsCollector.start();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -798,13 +798,6 @@ protected void syncWithLeader(long newLeaderZxid) throws Exception {
self.setCurrentEpoch(newEpoch);
LOG.info("Set the current epoch to {}", newEpoch);

// Now we almost complete the synchronization phase. Start RequestProcessors
// to asynchronously process the pending txns in "packetsNotLogged" and
// "packetsCommitted" later.
sock.setSoTimeout(self.tickTime * self.syncLimit);
self.setSyncMode(QuorumPeer.SyncMode.NONE);
zk.startupWithoutServing();

// send NEWLEADER ack after the committed txns are persisted
writePacket(new QuorumPacket(Leader.ACK, newLeaderZxid, null, null), true);
LOG.info("Sent NEWLEADER ack to leader with zxid {}", Long.toHexString(newLeaderZxid));
Expand All @@ -814,7 +807,9 @@ protected void syncWithLeader(long newLeaderZxid) throws Exception {
}
ack.setZxid(ZxidUtils.makeZxid(newEpoch, 0));
writePacket(ack, true);
zk.startServing();
sock.setSoTimeout(self.tickTime * self.syncLimit);
self.setSyncMode(QuorumPeer.SyncMode.NONE);
zk.startup();
/*
* Update the election vote here to ensure that all members of the
* ensemble report the same vote to new servers that start up and
Expand Down

0 comments on commit d2ee4dd

Please sign in to comment.