@@ -211,9 +211,9 @@ public Join handleStartJoin(StartJoinRequest startJoinRequest) {
211211 }
212212
213213 /**
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 .
215215 *
216- * @param join The Join received.
216+ * @param join The {@link Join} received.
217217 * @return true iff this instance does not already have a join vote from the given source node for this term
218218 * @throws CoordinationStateRejectedException if the arguments were incompatible with the current state of this object.
219219 */
@@ -234,6 +234,9 @@ public boolean handleJoin(Join join) {
234234
235235 final long lastAcceptedTerm = getLastAcceptedTerm ();
236236 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.
237240 logger .debug (
238241 "handleJoin: ignored join as joiner has a better last accepted term (expected: <=[{}], actual: [{}])" ,
239242 lastAcceptedTerm ,
@@ -248,6 +251,9 @@ public boolean handleJoin(Join join) {
248251 }
249252
250253 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.
251257 logger .debug (
252258 "handleJoin: ignored join as joiner has a better last accepted version (expected: <=[{}], actual: [{}]) in term {}" ,
253259 getLastAcceptedVersion (),
0 commit comments