static ZlgBuilder forClass(Class<?> cls) { return forName(cls.getName()); }
default void c(String format, Consumer<LogChain> logChainConsumer) { level(LogLevel.CONF).format(format).flush(logChainConsumer); }
@Override public void onException(String summary, Throwable error) { zlgSupplier.get().w(summary, error); } }
try { entry.getValue().get(); zlg.d("Deleted consumer group %s", z -> z.arg(entry::getKey)); deleted.add(entry.getKey()); } catch (ExecutionException e) { if (e.getCause() instanceof GroupNotEmptyException) { zlg.d("Group %s not empty (will be deleted later)", z -> z.arg(entry::getKey)); deleted.add(entry.getKey()); } else if (e.getCause() instanceof GroupIdNotFoundException) { zlg.d("Group %s not found", z -> z.arg(entry::getKey)); } else { throw e;
private void decideBallot(PendingBallot ballot) { zlg.t("Decided ballot for %s: resolution: %s", z -> z.arg(ballot::getProposal).arg(ballot::getResolution)); final Proposal proposal = ballot.getProposal(); final String xid = proposal.getXid(); final Object metadata = metadataEnabled ? new OutcomeMetadata(proposal.getTimestamp()) : null; final Outcome outcome = new Outcome(xid, ballot.getResolution(), ballot.getAbortReason(), ballot.getResponses(), metadata) .inResponseTo(proposal).withSource(groupId); pending.remove(xid); if (trackingEnabled) { additions.add(outcome); } action.appendOutcome(outcome, (id, x) -> { if (x == null) { ballot.getConfirmation().confirm(); } else { zlg.w("Error appending to ledger [message: %s]", z -> z.arg(outcome).threw(x)); } }); }
public void onVote(MessageContext context, Vote vote) { synchronized (messageLock) { final PendingBallot ballot = pending.get(vote.getXid()); if (ballot != null) { zlg.t("Received %s", z -> z.arg(vote)); final boolean decided = ballot.castVote(zlg, vote); if (decided) { decideBallot(ballot); } } else { zlg.t("Missing pending ballot for vote %s", z -> z.arg(vote)); } } }
@Override public boolean isLoggable(Level level) { return zlg.isEnabled(JulMappings.mapLevel(level)); } }
static ZlgBuilder forDeclaringClass() { return forClass(Stacks.classForDepth(2)); }
public void onProposal(MessageContext context, Proposal proposal) { synchronized (messageLock) { final PendingBallot newBallot = new PendingBallot(proposal); final PendingBallot existingBallot = pending.put(proposal.getXid(), newBallot); if (existingBallot != null) { zlg.t("Skipping redundant %s (ballot already pending)", z -> z.arg(proposal)); pending.put(proposal.getXid(), existingBallot); return; } else { newBallot.setConfirmation(context.begin(proposal)); } } zlg.t("Initiating ballot for %s", z -> z.arg(proposal)); }
default void d(String format, Consumer<LogChain> logChainConsumer) { level(LogLevel.DEBUG).format(format).flush(logChainConsumer); }
public ZlgHandler() { this(Zlg.forName("").get()); }
private void append(Vote vote) { action.appendVote(vote, (id, x) -> { if (x != null) zlg.w("Error appending to ledger [message: %s]", z -> z.arg(vote).threw(x)); }); }
boolean castVote(Zlg zlg, Vote vote) { final Response response = vote.getResponse(); final Response existing = responses.put(response.getCohort(), response); if (existing != null) { zlg.t("Skipping redundant %s (already cast in current ballot)", z -> z.arg(vote)); responses.put(existing.getCohort(), existing); return false; } final Intent intent = response.getIntent(); if (intent == Intent.REJECT) { resolution = Resolution.ABORT; abortReason = AbortReason.REJECT; return true; } else if (intent == Intent.TIMEOUT) { resolution = Resolution.ABORT; abortReason = AbortReason.EXPLICIT_TIMEOUT; return true; } else if (hasLapsed(vote)) { resolution = Resolution.ABORT; abortReason = AbortReason.IMPLICIT_TIMEOUT; return true; } return allResponsesPresent(); }
default void i(String format, Consumer<LogChain> logChainConsumer) { level(LogLevel.INFO).format(format).flush(logChainConsumer); }
private void timeoutCohort(Proposal proposal, String cohort) { zlg.d("Timed out %s for cohort %s", z -> z.arg(proposal).arg(cohort)); append(new Vote(proposal.getXid(), new Response(cohort, Intent.TIMEOUT, null)) .inResponseTo(proposal).withSource(groupId)); }
@Override public ILogger createLogger(String name) { return new ZlgLogger(Zlg.forName(name).withConfigService(configService).get()); } }
final long safetyMargin = (long) (config.getStreamConfig().getHeapCapacity() * safetyMarginFrac); final long ffNextReadOffset = headSeq + safetyMargin; config.getZlg().w("Sequence %,d was stale (head already at %,d), fast-forwarding to %,d", z -> z.arg(nextReadOffset).arg(headSeq).arg(ffNextReadOffset)); nextReadOffset = ffNextReadOffset;
default void e(Object message) { level(LogLevel.ERROR).message(message).flush(entrypoint); }