Skip to content

Commit

Permalink
parameterize aux population update duration.
Browse files Browse the repository at this point in the history
use different mechanism to determine if redirect
  • Loading branch information
Hellblazer committed May 21, 2024
1 parent ce9f397 commit 947ccdc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
public record Parameters(int joinRetries, int minimumBiffCardinality, int rebuttalTimeout, int viewChangeRounds,
int finalizeViewRounds, double fpr, int maximumTxfr, Duration retryDelay, int maxPending,
Duration seedingTimeout, int validationRetries, int crowns) {
Duration seedingTimeout, int validationRetries, int crowns, Duration populateDuration) {

public static Builder newBuilder() {
return new Builder();
Expand Down Expand Up @@ -68,11 +68,12 @@ public static class Builder {
* Minimum number of rounds to check for view change
*/
private int viewChangeRounds = 7;
private Duration populateDuration = Duration.ofMillis(20);

public Parameters build() {
return new Parameters(joinRetries, minimumBiffCardinality, rebuttalTimeout, viewChangeRounds,
finalizeViewRounds, fpr, maximumTxfr, retryDelay, maxPending, seedingTimout,
validationRetries, crowns);
validationRetries, crowns, populateDuration);
}

public int getCrowns() {
Expand Down Expand Up @@ -138,6 +139,15 @@ public Builder setMinimumBiffCardinality(int minimumBiffCardinality) {
return this;
}

public Duration getPopulateDuration() {
return populateDuration;
}

public Builder setPopulateDuration(Duration populateDuration) {
this.populateDuration = populateDuration;
return this;
}

public int getRebuttalTimeout() {
return rebuttalTimeout;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ void processUpdates(Gossip gossip) {
* @param ring
*/
boolean redirect(Participant member, Gossip gossip, int ring) {
if (!gossip.hasRedirect()) {
if (gossip.getRedirect().equals(SignedNote.getDefaultInstance())) {
log.warn("Redirect from: {} on ring: {} did not contain redirect member note on: {}", member.getId(), ring,
node.getId());
return false;
Expand Down Expand Up @@ -1060,7 +1060,7 @@ private void gossip(Optional<Gossip> result, RingCommunications.Destination<Part
final var member = destination.member();
try {
Gossip gossip = result.get();
if (gossip.hasRedirect()) {
if (!gossip.getRedirect().equals(SignedNote.getDefaultInstance())) {
stable(() -> redirect(member, gossip, destination.ring()));
} else if (viewManagement.joined()) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ void populate(List<Participant> sample) {
return view.gossip(link, 0);
}, (futureSailor, link, m) -> {
futureSailor.ifPresent(g -> {
if (g.hasRedirect()) {
if (!g.getRedirect().equals(SignedNote.getDefaultInstance())) {
final Participant member = (Participant) link.getMember();
view.stable(() -> view.redirect(member, g, 0));
} else {
Expand All @@ -396,10 +396,10 @@ void populate(List<Participant> sample) {
return !joined();
}, () -> {
if (!joined()) {
scheduler.schedule(() -> Thread.ofVirtual().start(Utils.wrapped(repopulate.get(), log)), 500,
TimeUnit.MILLISECONDS);
scheduler.schedule(() -> Thread.ofVirtual().start(Utils.wrapped(repopulate.get(), log)),
params.populateDuration().toNanos(), TimeUnit.NANOSECONDS);
}
}, Duration.ofMillis(500)));
}, params.populateDuration()));
repopulate.get().run();
}

Expand Down

0 comments on commit 947ccdc

Please sign in to comment.