Skip to content

Commit

Permalink
ignore self in gossip, better logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellblazer committed May 30, 2024
1 parent 1276eba commit b05b8db
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions fireflies/src/main/java/com/salesforce/apollo/fireflies/View.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public View(DynamicContext<Participant> context, ControlledIdentifierMember memb
EntranceClient.getCreate(metrics), Entrance.getLocalLoopback(node, service));
gossiper = new RingCommunications<>(context, node, comm);
gossiper.allowDuplicates();
gossiper.ignoreSelf();
this.validation = validation;
this.verifiers = verifiers;
}
Expand Down Expand Up @@ -807,6 +808,8 @@ private boolean add(NoteWrapper note) {
}

if (!isValidMask(note.getMask(), context)) {
log.debug("Invalid mask of: {} cardinality: {} on: {}", note.getId(), note.getMask().cardinality(),
node.getId());
if (metrics != null) {
metrics.filteredNotes().mark();
}
Expand Down Expand Up @@ -1373,11 +1376,11 @@ private Update updatesForDigests(Gossip gossip) {
private void validate(Digest from, final int ring, Digest requestView) {
if (shunned.contains(from)) {
log.trace("Member is shunned: {} on: {}", from, node.getId());
throw new StatusRuntimeException(Status.UNKNOWN.withDescription("Member is shunned: " + from));
throw new StatusRuntimeException(Status.UNKNOWN.withDescription("Member is shunned"));
}
if (!started.get()) {
log.trace("Currently offline, send unknown to: {} on: {}", from, node.getId());
throw new StatusRuntimeException(Status.UNKNOWN.withDescription("Member: " + node.getId() + " is offline"));
throw new StatusRuntimeException(Status.UNKNOWN.withDescription("Considered offline"));
}
if (!requestView.equals(currentView())) {
log.debug("Invalid view: {} current: {} ring: {} from: {} on: {}", requestView, currentView(), ring, from,
Expand All @@ -1389,7 +1392,7 @@ private void validate(Digest from, final int ring, Digest requestView) {

private void validate(Digest from, NoteWrapper note, Digest requestView, final int ring) {
if (!from.equals(note.getId())) {
throw new StatusRuntimeException(Status.UNAUTHENTICATED.withDescription("Member does not match: " + from));
throw new StatusRuntimeException(Status.UNAUTHENTICATED.withDescription("Note member does not match"));
}
validate(from, ring, requestView);
}
Expand Down Expand Up @@ -1860,16 +1863,14 @@ public void join(Join join, Digest from, StreamObserver<Gateway> responseObserve
@Override
public Gossip rumors(SayWhat request, Digest from) {
if (!introduced.get()) {
log.trace("Not introduced!, ring: {} on: {}", request.getRing(), node.getId());
throw new StatusRuntimeException(Status.FAILED_PRECONDITION.withDescription(
"Not introduced!, ring: %s from: %s on: %s".formatted(request.getRing(), from, node.getId())));
log.trace("Not introduced; ring: {} from: {}, on: {}", request.getRing(), from, node.getId());
throw new StatusRuntimeException(Status.FAILED_PRECONDITION.withDescription("Not introduced"));
}
return stable(() -> {
final var ring = request.getRing();
if (!context.validRing(ring)) {
log.debug("invalid ring: {} from: {} on: {}", ring, from, node.getId());
throw new StatusRuntimeException(Status.FAILED_PRECONDITION.withDescription(
"invalid ring: %s from: %s on: %s".formatted(ring, from, node.getId())));
throw new StatusRuntimeException(Status.FAILED_PRECONDITION.withDescription("invalid ring"));
}
validate(from, request);

Expand All @@ -1879,24 +1880,22 @@ public Gossip rumors(SayWhat request, Digest from) {
member = context.getActiveMember(from);
if (member == null) {
log.debug("Not active member: {} on: {}", from, node.getId());
throw new StatusRuntimeException(Status.PERMISSION_DENIED.withDescription(
"Not active member: %s on: %s".formatted(from, node.getId())));
throw new StatusRuntimeException(Status.PERMISSION_DENIED.withDescription("Not active member"));
}
}

Participant successor = context.successor(ring, member, m -> context.isActive(m.getId()));
if (successor == null) {
log.debug("No active successor on ring: {} from: {} on: {}", ring, from, node.getId());
throw new StatusRuntimeException(Status.FAILED_PRECONDITION.withDescription(
"No active successor on ring: %s from: %s on: %s".formatted(ring, from, node.getId())));
throw new StatusRuntimeException(Status.FAILED_PRECONDITION.withDescription("No active successor"));
}

Gossip g;
var builder = Gossip.newBuilder();
final var digests = request.getGossip();
if (!successor.equals(node)) {
builder.setRedirect(successor.getNote().getWrapped());
log.debug("Redirected: {} on: {}", member.getId(), node.getId());
log.debug("Redirected: {} to: {} on: {}", member.getId(), successor.id, node.getId());
}
g = builder.setNotes(processNotes(from, BloomFilter.from(digests.getNoteBff()), params.fpr()))
.setAccusations(
Expand Down Expand Up @@ -1941,15 +1940,13 @@ public void update(State request, Digest from) {
final var ring = request.getRing();
if (!context.validRing(ring)) {
log.debug("invalid ring: {} current: {} from: {} on: {}", ring, currentView(), from, node.getId());
throw new StatusRuntimeException(
Status.INVALID_ARGUMENT.withDescription("No successor of: " + from));
throw new StatusRuntimeException(Status.INVALID_ARGUMENT.withDescription("Invalid ring"));
}
Participant member = context.getActiveMember(from);
Participant successor = context.successor(ring, member, m -> context.isActive(m.getId()));
if (successor == null) {
log.debug("No successor, invalid update from: {} on ring: {} on: {}", from, ring, node.getId());
throw new StatusRuntimeException(
Status.FAILED_PRECONDITION.withDescription("No successor of: " + from));
throw new StatusRuntimeException(Status.FAILED_PRECONDITION.withDescription("No successor"));
}
if (!successor.equals(node)) {
return;
Expand Down

0 comments on commit b05b8db

Please sign in to comment.