Skip to content
Closed
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,14 @@ public void init(Configuration conf) {
@Override
public boolean acquirePermit(String nsId) {
try {
LOG.debug("Taking lock for nameservice {}", nsId);
if (LOG.isDebugEnabled()) {
LOG.debug("Taking lock for nameservice {}", nsId);
Copy link
Member

Choose a reason for hiding this comment

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

We have gone through this in the past.
LOG.debug with {} should already be equivalent to adding the safeguard.

Do you have some instrumentation showing that LOG.isDebugEnabled() is cheaper than just calling LOG.debug()?

Copy link
Member Author

Choose a reason for hiding this comment

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

i.m sorry, @goiri , here does not need if condition statement exactlly. i will close this pr.

}
return this.permits.get(nsId).tryAcquire(acquireTimeoutMs, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
LOG.debug("Cannot get a permit for nameservice {}", nsId);
if (LOG.isDebugEnabled()) {
LOG.debug("Cannot get a permit for nameservice {}", nsId);
}
}
return false;
}
Expand All @@ -78,7 +82,9 @@ public void releasePermit(String nsId) {

@Override
public void shutdown() {
LOG.debug("Shutting down router fairness policy controller");
if (LOG.isDebugEnabled()) {
LOG.debug("Shutting down router fairness policy controller");
}
// drain all semaphores
for (Semaphore sema: this.permits.values()) {
sema.drainPermits();
Expand Down