Skip to content

Commit

Permalink
targeted loggin
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellblazer committed Dec 26, 2023
1 parent 7295616 commit 918309d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
4 changes: 4 additions & 0 deletions model/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
<appender-ref ref="STDOUT"/>
</logger>

<logger name="com.salesforce.apollo.thoth.KerlSpace" level="warn" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>

<logger name="com.salesforce.apollo.archipelago" level="warn" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>
Expand Down
31 changes: 17 additions & 14 deletions thoth/src/main/java/com/salesforce/apollo/thoth/KerlDHT.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
public class KerlDHT implements ProtoKERLService {
private final static Logger log = LoggerFactory.getLogger(
KerlDHT.class);
private final static Logger reconcileLog = LoggerFactory.getLogger(
KerlSpace.class);
private final Ani ani;
private final CachingKERL cache;
private final JdbcConnectionPool connectionPool;
Expand Down Expand Up @@ -923,16 +925,15 @@ private void reconcile(Optional<Update> result,
if (!result.isEmpty()) {
try {
Update update = result.get();
log.trace("Received: {} events in interval reconciliation from: {} on: {}", update.getEventsCount(),
destination.member().getId(), member.getId());
kerlSpace.update(update.getEventsList(), kerl);
if (update.getEventsCount() > 0) {
reconcileLog.trace("Received: {} events in interval reconciliation from: {} on: {}",
update.getEventsCount(), destination.member().getId(), member.getId());
kerlSpace.update(update.getEventsList(), kerl);
}
} catch (NoSuchElementException e) {
log.debug("null interval reconciliation with {} : {} on: {}", destination.member().getId(),
member.getId(), e.getCause());
reconcileLog.debug("null interval reconciliation with {} : {} on: {}", destination.member().getId(),
member.getId(), e.getCause());
}
} else {
log.trace("Received no events in interval reconciliation from: {} on: {}", destination.member().getId(),
member.getId());
}
if (started.get()) {
scheduler.schedule(() -> reconcile(scheduler, duration), duration.toMillis(), TimeUnit.MILLISECONDS);
Expand All @@ -944,8 +945,8 @@ private Update reconcile(ReconciliationService link, Integer ring) {
return null;
}
CombinedIntervals keyIntervals = keyIntervals();
log.trace("Interval reconciliation on ring: {} with: {} on: {} intervals: {}", ring, link.getMember().getId(),
member.getId(), keyIntervals);
reconcileLog.trace("Interval reconciliation on ring: {} with: {} on: {} intervals: {}", ring,
link.getMember().getId(), member.getId(), keyIntervals);
return link.reconcile(Intervals.newBuilder()
.setRing(ring)
.addAllIntervals(keyIntervals.toIntervals())
Expand Down Expand Up @@ -1039,17 +1040,19 @@ private class Reconcile implements Reconciliation {
public Update reconcile(Intervals intervals, Digest from) {
var ring = intervals.getRing();
if (!valid(from, ring)) {
log.trace("Invalid reconcile from: {} ring: {} on: {}", from, ring, member.getId());
reconcileLog.trace("Invalid reconcile from: {} ring: {} on: {}", from, ring, member.getId());
return Update.getDefaultInstance();
}
log.trace("Reconcile from: {} ring: {} on: {}", from, ring, member.getId());
reconcileLog.trace("Reconcile from: {} ring: {} on: {}", from, ring, member.getId());
try (var k = kerlPool.create()) {
final var builder = KerlDHT.this.kerlSpace.reconcile(intervals, k);
CombinedIntervals keyIntervals = keyIntervals();
builder.addAllIntervals(keyIntervals.toIntervals())
.setHave(kerlSpace.populate(Entropy.nextBitsStreamLong(), keyIntervals, fpr));
log.trace("Reconcile for: {} ring: {} count: {} on: {}", from, ring, builder.getEventsCount(),
member.getId());
if (builder.getEventsCount() > 0) {
reconcileLog.trace("Reconcile for: {} ring: {} count: {} on: {}", from, ring,
builder.getEventsCount(), member.getId());
}
return builder.build();
} catch (IOException | SQLException e) {
throw new IllegalStateException("Cannot acquire KERL", e);
Expand Down

0 comments on commit 918309d

Please sign in to comment.