Skip to content

Commit

Permalink
allow dups in view gossip
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellblazer committed May 22, 2024
1 parent 947ccdc commit 0b14641
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public View(DynamicContext<Participant> context, ControlledIdentifierMember memb
r -> new EntranceServer(gateway.getClientIdentityProvider(), r, metrics),
EntranceClient.getCreate(metrics), Entrance.getLocalLoopback(node, service));
gossiper = new RingCommunications<>(context, node, comm);
gossiper.allowDuplicates();
this.validation = validation;
this.verifiers = verifiers;
}
Expand Down Expand Up @@ -615,6 +616,7 @@ protected Gossip gossip(Fireflies link, int ring) {
.setRing(ring)
.setGossip(commonDigests())
.build());
log.info("gossiping with: {} on: {}", link.getMember().getId(), node.getId());
try {
return link.gossip(gossip);
} catch (Throwable e) {
Expand Down Expand Up @@ -1330,7 +1332,7 @@ private Gossip redirectTo(Participant member, int ring, Participant successor, D
.setObservations(processObservations(BloomFilter.from(digests.getObservationBff())))
.setJoins(viewManagement.processJoins(BloomFilter.from(digests.getJoinBiff())))
.build();
log.trace("Redirecting: {} to: {} on ring: {} notes: {} acc: {} obv: {} joins: {} on: {}", member.getId(),
log.trace("Redirect: {} to: {} on ring: {} notes: {} acc: {} obv: {} joins: {} on: {}", member.getId(),
successor.getId(), ring, gossip.getNotes().getUpdatesCount(),
gossip.getAccusations().getUpdatesCount(), gossip.getObservations().getUpdatesCount(),
gossip.getJoins().getUpdatesCount(), node.getId());
Expand Down Expand Up @@ -1928,6 +1930,7 @@ public Gossip rumors(SayWhat request, Digest from) {
final var digests = request.getGossip();
if (!successor.equals(node)) {
g = redirectTo(member, ring, successor, digests);
log.info("Redirected: {} on: {}", member.getId(), node.getId());
} else {
g = Gossip.newBuilder()
.setNotes(processNotes(from, BloomFilter.from(digests.getNoteBff()), params.fpr()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,17 @@ public void swarm() throws Exception {
}
assertTrue(testGraph.isSC());
}

var ringRef = views.get(0).getContext().rings().toList();
for (var v : views) {
var tested = v.getContext().rings().toList();
for (int i = 0; i < ringRef.size(); i++) {
var r = ringRef.get(i);
var t = tested.get(i);
assertEquals(r.getRing(), t.getRing());
assertEquals(r.getRing(), t.getRing());
}
}
}
communications.forEach(e -> e.close(Duration.ofSeconds(1)));
views.forEach(view -> view.stop());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import java.util.function.Predicate;
Expand All @@ -41,7 +42,7 @@ public class DynamicContextImpl<T extends Member> implements DynamicContext<T> {
private final Map<Digest, Tracked<T>> members = new ConcurrentSkipListMap<>();
private final Map<UUID, MembershipListener<T>> membershipListeners = new ConcurrentHashMap<>();
private final double pByz;
private final List<Ring<T>> rings = new ArrayList<>();
private final List<Ring<T>> rings = new CopyOnWriteArrayList<>();
private volatile int cardinality;

public DynamicContextImpl(Digest id, int cardinality, double pbyz, int bias) {
Expand Down Expand Up @@ -526,7 +527,7 @@ public void rebalance(int newCardinality) {
});
}
assert rings.size() == ringCount : "Ring count: " + rings.size() + " does not match: " + ringCount;
log.debug("Rebalanced: {} from: {} to: {} tolerance: {}", id, currentCount, rings.size(), toleranceLevel());
log.info("Rebalanced: {} from: {} to: {} tolerance: {}", id, currentCount, rings.size(), toleranceLevel());
}

@Override
Expand Down

0 comments on commit 0b14641

Please sign in to comment.