From 947ccdca33f0744d02512e077141e9ab5882c16f Mon Sep 17 00:00:00 2001 From: Hellblazer Date: Mon, 20 May 2024 20:48:30 -0700 Subject: [PATCH] parameterize aux population update duration. use different mechanism to determine if redirect --- .../salesforce/apollo/fireflies/Parameters.java | 14 ++++++++++++-- .../java/com/salesforce/apollo/fireflies/View.java | 4 ++-- .../apollo/fireflies/ViewManagement.java | 8 ++++---- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/fireflies/src/main/java/com/salesforce/apollo/fireflies/Parameters.java b/fireflies/src/main/java/com/salesforce/apollo/fireflies/Parameters.java index 803dcfa44..ec5aa1df1 100644 --- a/fireflies/src/main/java/com/salesforce/apollo/fireflies/Parameters.java +++ b/fireflies/src/main/java/com/salesforce/apollo/fireflies/Parameters.java @@ -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(); @@ -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() { @@ -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; } diff --git a/fireflies/src/main/java/com/salesforce/apollo/fireflies/View.java b/fireflies/src/main/java/com/salesforce/apollo/fireflies/View.java index 65346def8..1a32112fb 100644 --- a/fireflies/src/main/java/com/salesforce/apollo/fireflies/View.java +++ b/fireflies/src/main/java/com/salesforce/apollo/fireflies/View.java @@ -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; @@ -1060,7 +1060,7 @@ private void gossip(Optional result, RingCommunications.Destination redirect(member, gossip, destination.ring())); } else if (viewManagement.joined()) { try { diff --git a/fireflies/src/main/java/com/salesforce/apollo/fireflies/ViewManagement.java b/fireflies/src/main/java/com/salesforce/apollo/fireflies/ViewManagement.java index 7124e4fd3..5a62ea8d0 100644 --- a/fireflies/src/main/java/com/salesforce/apollo/fireflies/ViewManagement.java +++ b/fireflies/src/main/java/com/salesforce/apollo/fireflies/ViewManagement.java @@ -386,7 +386,7 @@ void populate(List 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 { @@ -396,10 +396,10 @@ void populate(List 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(); }