Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-v committed Jul 8, 2024
1 parent f1a88ec commit d0f1f43
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public int doWork() {
workCount += pollMessage();
workCount += receiveMessage();
workCount += processTick();
workCount += callbackInvoker.doWork();
workCount += callbackInvoker != null ? callbackInvoker.doWork() : 0;

return workCount;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,12 @@ Member nextPingMember() {
return null;
}

final int i = index == size ? index = 0 : index++;
if (i == 0) {
final int i;
if (index >= size) {
i = index = 0;
shuffle();
} else {
i = index++;
}

return pingMembers.get(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,26 @@ void nextGossipMembers() {
return;
}

// for (int i = 0, limit = Math.min(gossipFanout, size); i < limit; ) {
// final Member member = remoteMembers.get(random.nextInt(remoteMembers.size()));
// if (!gossipMembers.contains(member)) {
// gossipMembers.add(member);
// i++;
// }
// }
if (size <= gossipFanout) {
shuffle();
for (int i = 0; i < size; i++) {
gossipMembers.add(remoteMembers.get(i));
}
return;
}

final int step = gossipFanout;
final int limit = step * (size / step);
final int nextLimit = index + step;

if (nextLimit >= limit) {
index = 0;
shuffle();
}

for (; index < nextLimit; index++) {
gossipMembers.add(remoteMembers.get(index));
}
}

void shuffle() {
Expand Down

0 comments on commit d0f1f43

Please sign in to comment.