diff options
author | Harald Musum <musum@yahooinc.com> | 2024-04-04 09:18:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-04 09:18:20 +0200 |
commit | e380bdd2a1b0eb6d2fea79ffde6ae1d5b7377857 (patch) | |
tree | 645c47a6276ec19ba6248b667cb454adffc00589 | |
parent | c6decc1fd2a5878388be3d26bec7c392aa361a0d (diff) | |
parent | 6fd4c3ed1594b50ad4b6de95c80624192e8b1ccf (diff) |
Merge pull request #30806 from vespa-engine/balder/log-correct-value
- No need for final on locals and params.
3 files changed, 26 insertions, 57 deletions
diff --git a/container-messagebus/src/main/java/com/yahoo/container/jdisc/messagebus/SessionCache.java b/container-messagebus/src/main/java/com/yahoo/container/jdisc/messagebus/SessionCache.java index 2464a272ed1..3d500c85df1 100644 --- a/container-messagebus/src/main/java/com/yahoo/container/jdisc/messagebus/SessionCache.java +++ b/container-messagebus/src/main/java/com/yahoo/container/jdisc/messagebus/SessionCache.java @@ -106,11 +106,11 @@ public final class SessionCache extends AbstractComponent { return new SharedMessageBus(bus); } - ReferencedResource<SharedIntermediateSession> retainIntermediate(final IntermediateSessionParams p) { + ReferencedResource<SharedIntermediateSession> retainIntermediate(IntermediateSessionParams p) { return intermediatesCreator.retain(intermediateLock, intermediates, p); } - public ReferencedResource<SharedSourceSession> retainSource(final SourceSessionParams p) { + public ReferencedResource<SharedSourceSession> retainSource(SourceSessionParams p) { return sourcesCreator.retain(sourceLock, sources, p); } @@ -137,7 +137,7 @@ public final class SessionCache extends AbstractComponent { try { sessionReference = session.refer(this); logReuse(session); - } catch (final IllegalStateException e) { + } catch (IllegalStateException e) { session = createAndStore(registry, p, key); sessionReference = References.fromResource(session); } @@ -169,7 +169,7 @@ public final class SessionCache extends AbstractComponent { } @Override - void logReuse(final SharedSourceSession session) { + void logReuse(SharedSourceSession session) { log.log(Level.FINE, "Reusing source session."); } } @@ -179,7 +179,7 @@ public final class SessionCache extends AbstractComponent { @Override SharedIntermediateSession create(IntermediateSessionParams p) { - log.log(Level.FINE, "Creating new intermediate session " + p.getName() + ""); + log.log(Level.FINE, "Creating new intermediate session " + p.getName()); return bus().newIntermediateSession(p); } @@ -190,7 +190,7 @@ public final class SessionCache extends AbstractComponent { @Override void logReuse(SharedIntermediateSession session) { - log.log(Level.FINE, "Reusing intermediate session " + session.name() + ""); + log.log(Level.FINE, "Reusing intermediate session " + session.name()); } } @@ -203,12 +203,12 @@ public final class SessionCache extends AbstractComponent { } - static class StaticThrottlePolicySignature extends ThrottlePolicySignature { + static final class StaticThrottlePolicySignature extends ThrottlePolicySignature { private final int maxPendingCount; private final long maxPendingSize; - StaticThrottlePolicySignature(final StaticThrottlePolicy policy) { + StaticThrottlePolicySignature(StaticThrottlePolicy policy) { maxPendingCount = policy.getMaxPendingCount(); maxPendingSize = policy.getMaxPendingSize(); } @@ -224,26 +224,15 @@ public final class SessionCache extends AbstractComponent { } @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (getClass() != obj.getClass()) { - return false; - } - final StaticThrottlePolicySignature other = (StaticThrottlePolicySignature) obj; - if (maxPendingCount != other.maxPendingCount) { - return false; - } - if (maxPendingSize != other.maxPendingSize) { - return false; - } - return true; + public boolean equals(Object obj) { + if (this == obj) return true; + if (! (obj instanceof StaticThrottlePolicySignature other)) return false; + return (maxPendingCount == other.maxPendingCount) && (maxPendingSize == other.maxPendingSize); } } - static class DynamicThrottlePolicySignature extends ThrottlePolicySignature { + static final class DynamicThrottlePolicySignature extends ThrottlePolicySignature { private final int maxPending; private final double maxWindowSize; @@ -251,7 +240,7 @@ public final class SessionCache extends AbstractComponent { private final double windowSizeBackoff; private final double windowSizeIncrement; - DynamicThrottlePolicySignature(final DynamicThrottlePolicy policy) { + DynamicThrottlePolicySignature(DynamicThrottlePolicy policy) { maxPending = policy.getMaxPendingCount(); maxWindowSize = policy.getMaxWindowSize(); minWindowSize = policy.getMinWindowSize(); @@ -278,29 +267,13 @@ public final class SessionCache extends AbstractComponent { @Override public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (getClass() != obj.getClass()) { - return false; - } - DynamicThrottlePolicySignature other = (DynamicThrottlePolicySignature) obj; - if (maxPending != other.maxPending) { - return false; - } - if (Double.doubleToLongBits(maxWindowSize) != Double.doubleToLongBits(other.maxWindowSize)) { - return false; - } - if (Double.doubleToLongBits(minWindowSize) != Double - .doubleToLongBits(other.minWindowSize)) { - return false; - } - if (Double.doubleToLongBits(windowSizeBackoff) != Double.doubleToLongBits(other.windowSizeBackoff)) { - return false; - } - if (Double.doubleToLongBits(windowSizeIncrement) != Double.doubleToLongBits(other.windowSizeIncrement)) { - return false; - } + if (this == obj) return true; + if (! (obj instanceof DynamicThrottlePolicySignature other)) return false; + if (maxPending != other.maxPending) return false; + if (Double.doubleToLongBits(maxWindowSize) != Double.doubleToLongBits(other.maxWindowSize)) return false; + if (Double.doubleToLongBits(minWindowSize) != Double.doubleToLongBits(other.minWindowSize)) return false; + if (Double.doubleToLongBits(windowSizeBackoff) != Double.doubleToLongBits(other.windowSizeBackoff)) return false; + if (Double.doubleToLongBits(windowSizeIncrement) != Double.doubleToLongBits(other.windowSizeIncrement)) return false; return true; } diff --git a/indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/expressions/BusyWaitExpression.java b/indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/expressions/BusyWaitExpression.java index 068aa1421f7..8ae77aad1b1 100644 --- a/indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/expressions/BusyWaitExpression.java +++ b/indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/expressions/BusyWaitExpression.java @@ -5,7 +5,7 @@ import com.yahoo.document.datatypes.FieldValue; import com.yahoo.document.datatypes.NumericFieldValue; /** - * Utility expression that will sleep the amount of time given in the numeric field. + * Utility expression that will busy-wait the amount of time given in the numeric field. * Non-numeric fields will be ignored * @author baldersheim */ @@ -37,7 +37,7 @@ public final class BusyWaitExpression extends Expression { @Override protected void doVerify(VerificationContext context) { } @Override public DataType createdOutputType() { return null; } - @Override public String toString() { return "sleep"; } + @Override public String toString() { return "busy_wait"; } @Override public boolean equals(Object obj) { return obj instanceof BusyWaitExpression; } @Override public int hashCode() { return getClass().hashCode(); } } diff --git a/messagebus/src/main/java/com/yahoo/messagebus/DynamicThrottlePolicy.java b/messagebus/src/main/java/com/yahoo/messagebus/DynamicThrottlePolicy.java index 76287d949b7..97f681404e9 100644 --- a/messagebus/src/main/java/com/yahoo/messagebus/DynamicThrottlePolicy.java +++ b/messagebus/src/main/java/com/yahoo/messagebus/DynamicThrottlePolicy.java @@ -133,11 +133,9 @@ public class DynamicThrottlePolicy extends StaticThrottlePolicy { // No need to increase window when we're this close to max. // TODO jonmv: Not so sure — what if we're too high, and should back off? } else if (throughput > localMaxThroughput) { - localMaxThroughput = throughput; windowSize += weight * windowSizeIncrement; - if (log.isLoggable(Level.FINE)) { - log.log(Level.FINE, "windowSize " + windowSize + " throughput " + throughput + " local max " + localMaxThroughput); - } + log.log(Level.FINE, () -> "windowSize " + windowSize + " throughput " + throughput + " local max " + localMaxThroughput); + localMaxThroughput = throughput; } else { // scale up/down throughput for comparing to window size double period = 1; @@ -154,9 +152,7 @@ public class DynamicThrottlePolicy extends StaticThrottlePolicy { } else { windowSize += weight * windowSizeIncrement; } - if (log.isLoggable(Level.FINE)) { - log.log(Level.FINE, "windowSize " + windowSize + " throughput " + throughput + " local max " + localMaxThroughput + " efficiency " + efficiency); - } + log.log(Level.FINE, () ->"windowSize " + windowSize + " throughput " + throughput + " local max " + localMaxThroughput + " efficiency " + efficiency); } windowSize = Math.max(minWindowSize, windowSize); windowSize = Math.min(maxWindowSize, windowSize); |