Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize the debug log that affects performance, and unify the style #13498

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Optimize the debug log that affects performance, and unify the style
liudezhi2098 committed Dec 25, 2021
commit ab130a190783868e68e8e9d3a72ff86da02e8162
Original file line number Diff line number Diff line change
@@ -182,8 +182,10 @@ public synchronized CompletableFuture<Void> disconnect(boolean failIfHasBacklog)
if (failIfHasBacklog && getNumberOfEntriesInBacklog() > 0) {
CompletableFuture<Void> disconnectFuture = new CompletableFuture<>();
disconnectFuture.completeExceptionally(new TopicBusyException("Cannot close a replicator with backlog"));
log.debug("[{}][{} -> {}] Replicator disconnect failed since topic has backlog", topicName, localCluster,
remoteCluster);
if (log.isDebugEnabled()) {
log.debug("[{}][{} -> {}] Replicator disconnect failed since topic has backlog", topicName, localCluster,
remoteCluster);
}
return disconnectFuture;
}

Original file line number Diff line number Diff line change
@@ -105,7 +105,9 @@ public void add(T event, long ts, Record<?> record) {
public void add(Event<T> windowEvent) {
// watermark events are not added to the queue.
if (windowEvent.isWatermark()) {
log.debug(String.format("Got watermark event with ts %d", windowEvent.getTimestamp()));
if (log.isDebugEnabled()) {
log.debug(String.format("Got watermark event with ts %d", windowEvent.getTimestamp()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to use String.format, just
log.debug("Got watermark event with ts {}", windowEvent.getTimestamp());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes , I will delete

}
} else {
queue.add(windowEvent);
}
@@ -145,8 +147,10 @@ public boolean onTrigger() {
prevWindowEvents.clear();
if (!events.isEmpty()) {
prevWindowEvents.addAll(windowEvents);
log.debug(String.format("invoking windowLifecycleListener onActivation, [%d] events in "
+ "window.", events.size()));
if (log.isDebugEnabled()) {
log.debug(String.format("invoking windowLifecycleListener onActivation, [%d] events in "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

+ "window.", events.size()));
}
windowLifecycleListener.onActivation(events, newEvents, expired,
evictionPolicy.getContext().getReferenceTime());
} else {
@@ -216,7 +220,9 @@ private List<Event<T>> scanEvents(boolean fullScan) {
lock.unlock();
}
eventsSinceLastExpiry.set(0);
log.debug(String.format("[%d] events expired from window.", eventsToExpire.size()));
if (log.isDebugEnabled()) {
log.debug(String.format("[%d] events expired from window.", eventsToExpire.size()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

}
if (!eventsToExpire.isEmpty()) {
log.debug("invoking windowLifecycleListener.onExpiry");
windowLifecycleListener.onExpiry(eventsToExpire);
Original file line number Diff line number Diff line change
@@ -413,8 +413,9 @@ synchronized boolean processDeregister(String tenant, String namespace,
String functionName, long version) throws IllegalArgumentException {

boolean needsScheduling = false;

log.debug("Process deregister request: {}/{}/{}/{}", tenant, namespace, functionName, version);
if (log.isDebugEnabled()) {
log.debug("Process deregister request: {}/{}/{}/{}", tenant, namespace, functionName, version);
}

// Check if we still have this function. Maybe already deleted by someone else
if (this.containsFunctionMetaData(tenant, namespace, functionName)) {
Original file line number Diff line number Diff line change
@@ -437,7 +437,9 @@ public boolean hasFinished() {

@Override
public void readEntriesFailed(ManagedLedgerException exception, Object ctx) {
log.debug(exception, "Failed to read entries from topic %s", topicName.toString());
if (log.isDebugEnabled()) {
log.debug(exception, "Failed to read entries from topic %s", topicName.toString());
}
outstandingReadsRequests.incrementAndGet();

//set read latency stats for failed