@@ -211,9 +211,9 @@ public Join handleStartJoin(StartJoinRequest startJoinRequest) {
211
211
}
212
212
213
213
/**
214
- * May be called on receipt of a Join.
214
+ * May be called on receipt of a {@link Join}, which is effectively a vote for the receiving node to be the elected master .
215
215
*
216
- * @param join The Join received.
216
+ * @param join The {@link Join} received.
217
217
* @return true iff this instance does not already have a join vote from the given source node for this term
218
218
* @throws CoordinationStateRejectedException if the arguments were incompatible with the current state of this object.
219
219
*/
@@ -234,6 +234,9 @@ public boolean handleJoin(Join join) {
234
234
235
235
final long lastAcceptedTerm = getLastAcceptedTerm ();
236
236
if (join .lastAcceptedTerm () > lastAcceptedTerm ) {
237
+ // Note that this is running on the receiving node, so it must reject joins from nodes with fresher state. This is unlike a
238
+ // real-world election where candidates will accept every vote they receive and it's the voter's responsibility to be selective
239
+ // about the votes they cast.
237
240
logger .debug (
238
241
"handleJoin: ignored join as joiner has a better last accepted term (expected: <=[{}], actual: [{}])" ,
239
242
lastAcceptedTerm ,
@@ -248,6 +251,9 @@ public boolean handleJoin(Join join) {
248
251
}
249
252
250
253
if (join .lastAcceptedTerm () == lastAcceptedTerm && join .lastAcceptedVersion () > getLastAcceptedVersion ()) {
254
+ // Note that this is running on the receiving node, so it must reject joins from nodes with fresher state. This is unlike a
255
+ // real-world election where candidates will accept every vote they receive and it's the voter's responsibility to be selective
256
+ // about the votes they cast.
251
257
logger .debug (
252
258
"handleJoin: ignored join as joiner has a better last accepted version (expected: <=[{}], actual: [{}]) in term {}" ,
253
259
getLastAcceptedVersion (),
0 commit comments