dcapwell commented on code in PR #2104:
URL: https://github.com/apache/cassandra/pull/2104#discussion_r1136180197
##########
src/java/org/apache/cassandra/streaming/StreamManager.java:
##########
@@ -252,18 +255,36 @@ public void onRegister(StreamResultFuture result)
}
};
+ protected void addStreamingStateAgain(StreamingState state)
+ {
+ if (!DatabaseDescriptor.getStreamingStatsEnabled())
+ return;
+ states.put(state.id(), state);
+ }
+
public StreamManager()
{
DurationSpec.LongNanosecondsBound duration =
DatabaseDescriptor.getStreamingStateExpires();
long sizeBytes = DatabaseDescriptor.getStreamingStateSize().toBytes();
- long numElements = sizeBytes / StreamingState.ELEMENT_SIZE;
- logger.info("Storing streaming state for {} or for {} elements",
duration, numElements);
+ logger.info("Storing streaming state for {} or for weight {}",
duration, sizeBytes);
states = CacheBuilder.newBuilder()
.expireAfterWrite(duration.quantity(),
duration.unit())
- .maximumSize(numElements)
+ .maximumWeight(sizeBytes)
+ .weigher(new StreamingStateWeigher())
.build();
}
+ private static class StreamingStateWeigher implements
Weigher<TimeUUID,StreamingState>
+ {
+ @Override
+ public int weigh(TimeUUID key, StreamingState val)
+ {
+ long costOfStreamingState = val.unsharedHeapSize() +
TimeUUID.sizeInBytes();
+ int finalWeight = Math.toIntExact(costOfStreamingState);
Review Comment:
marked this comment as unresolved as the variable still exists
##########
src/java/org/apache/cassandra/streaming/StreamSession.java:
##########
@@ -1352,27 +1351,19 @@ public static StringBuilder boundStackTrace(Throwable
e, int limit, int counter,
return out;
if (!visited.add(e))
- return out.append("[CIRCULAR REFERENCE:
").append(e.getClass().getName()).append(":
").append(e.getMessage()).append("]");
+ return out.append("[CIRCULAR REFERENCE:
").append(e.getClass().getName() + ": " +
e.getMessage()).append("]").append('\n');
Review Comment:
don't do string concat, use the builder. the compiler will replace
`e.getClass().getName() + ": " + e.getMessage()` with a brand new
StringBuilder, so is slightly more costly than what you had before
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]