Skip to content

Commit

Permalink
fix: missing count down handler
Browse files Browse the repository at this point in the history
  • Loading branch information
elblasco committed Aug 6, 2024
1 parent 332a103 commit 71e23dc
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/main/java/it/unitn/disi/ds1/qtop/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ private void becomeReceiver() {
private Receive voterBehaviour() {
return receiveBuilder().match(
CountDown.class,
this::onCountDown
this::voterOnCountDown
).match(
CrashRequest.class,
this::onCrashRequest
Expand Down Expand Up @@ -430,14 +430,12 @@ private void onHeartBeat(HeartBeat msg) {
}

/**
* General purpose handler for the countdown which a Receiver can support
* Receiver handler for the countdown which a Receiver can support
*
* @param msg Genre of countdown
*/
private void onCountDown(@NotNull CountDown msg) {
int countDownIndex =
(msg.reason() == TimeOutReason.HEARTBEAT || msg.reason() == TimeOutReason.ELECTION) ? 0 : msg.epoch()
.i();
int countDownIndex = (msg.reason() == TimeOutReason.HEARTBEAT) ? 0 : msg.epoch().i();
this.timeOutManager.handleCountDown(
msg.reason(),
countDownIndex,
Expand Down Expand Up @@ -1209,4 +1207,21 @@ private void voterOnTimeOut(TimeOut msg) {
break;
}
}

/**
* Voter handler for the countdown which a Receiver can support
*
* @param msg Genre of countdown
*/
private void voterOnCountDown(@NotNull CountDown msg) {
int countDownIndex =
(msg.reason() == TimeOutReason.ELECTION || msg.reason() == TimeOutReason.ELECTION_GLOBAL) ? 0 :
msg.epoch()
.i();
this.timeOutManager.handleCountDown(
msg.reason(),
countDownIndex,
this.getSelf()
);
}
}

0 comments on commit 71e23dc

Please sign in to comment.