Skip to content

Commit

Permalink
reduce beacon publishing logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellblazer committed May 26, 2024
1 parent ad4b01d commit 6f51664
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
16 changes: 11 additions & 5 deletions choam/src/main/java/com/salesforce/apollo/choam/CHOAM.java
Original file line number Diff line number Diff line change
Expand Up @@ -542,10 +542,16 @@ public Block produce(ULong height, Digest prev, Executions executions, HashedBlo
}

@Override
public void publish(Digest hash, CertifiedBlock cb) {
log.info("Publishing: {} hash: {} height: {} certifications: {} on: {}", cb.getBlock().getBodyCase(),
hash, ULong.valueOf(cb.getBlock().getHeader().getHeight()), cb.getCertificationsCount(),
params.member().getId());
public void publish(Digest hash, CertifiedBlock cb, boolean beacon) {
if (beacon) {
log.trace("Publishing beacon: {} hash: {} height: {} certifications: {} on: {}",
cb.getBlock().getBodyCase(), hash, ULong.valueOf(cb.getBlock().getHeader().getHeight()),
cb.getCertificationsCount(), params.member().getId());
} else {
log.info("Publishing: {} hash: {} height: {} certifications: {} on: {}",
cb.getBlock().getBodyCase(), hash, ULong.valueOf(cb.getBlock().getHeader().getHeight()),
cb.getCertificationsCount(), params.member().getId());
}
combine.publish(cb, true);
}

Expand Down Expand Up @@ -1022,7 +1028,7 @@ public interface BlockProducer {

Block produce(ULong height, Digest prev, Executions executions, HashedBlock checkpoint);

void publish(Digest hash, CertifiedBlock cb);
void publish(Digest hash, CertifiedBlock cb, boolean beacon);

Block reconfigure(Map<Digest, Join> joining, Digest nextViewId, HashedBlock previous, HashedBlock checkpoint);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public void publish() {
.sorted(Comparator.comparing(e -> e.getKey().getId()))
.map(Map.Entry::getValue)
.forEach(v -> b.addCertifications(v.getWitness()));
view.publish(new HashedCertifiedBlock(params().digestAlgorithm(), b.build()));
view.publish(new HashedCertifiedBlock(params().digestAlgorithm(), b.build()), false);
controller.completeIt();
log.info("Genesis block: {} published with {} witnesses for: {} on: {}", reconfiguration.hash, witnesses.size(),
view.context().getId(), params().member().getId());
Expand Down
8 changes: 4 additions & 4 deletions choam/src/main/java/com/salesforce/apollo/choam/Producer.java
Original file line number Diff line number Diff line change
Expand Up @@ -312,23 +312,23 @@ private void publish(PendingBlock p) {
this.publish(p, false);
}

private void publish(PendingBlock p, boolean force) {
private void publish(PendingBlock p, boolean beacon) {
assert p.witnesses.size() >= params().majority() : "Publishing non majority block";
var publish = p.published.compareAndSet(false, true);
if (!publish && !force) {
if (!publish && !beacon) {
log.trace("Already published: {} hash: {} height: {} witnesses: {} on: {}", p.block.block.getBodyCase(),
p.block.hash, p.block.height(), p.witnesses.values().size(), params().member().getId());
return;
}
log.trace("Publishing {}pending: {} hash: {} height: {} witnesses: {} on: {}", force ? "(forced) " : "",
log.trace("Publishing {}pending: {} hash: {} height: {} witnesses: {} on: {}", beacon ? "(beacon) " : "",
p.block.block.getBodyCase(), p.block.hash, p.block.height(), p.witnesses.values().size(),
params().member().getId());
final var cb = CertifiedBlock.newBuilder()
.setBlock(p.block.block)
.addAllCertifications(
p.witnesses.values().stream().map(Validate::getWitness).toList())
.build();
view.publish(new HashedCertifiedBlock(params().digestAlgorithm(), cb));
view.publish(new HashedCertifiedBlock(params().digestAlgorithm(), cb), beacon);
}

private void reconfigure() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ public Block produce(ULong height, Digest prev, Assemble assemble, HashedBlock c
return blockProducer.produce(height, prev, assemble, checkpoint);
}

public void publish(HashedCertifiedBlock block) {
blockProducer.publish(block.hash, block.certifiedBlock);
public void publish(HashedCertifiedBlock block, boolean beacon) {
blockProducer.publish(block.hash, block.certifiedBlock, beacon);
}

public Block reconfigure(Map<Digest, Join> aggregate, Digest nextViewId, HashedBlock lastBlock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public Block produce(ULong height, Digest prev, Executions executions, HashedBlo
}

@Override
public void publish(Digest hash, CertifiedBlock cb) {
public void publish(Digest hash, CertifiedBlock cb, boolean beacon) {
complete.countDown();
}

Expand Down

0 comments on commit 6f51664

Please sign in to comment.