dcapwell commented on code in PR #2104:
URL: https://github.com/apache/cassandra/pull/2104#discussion_r1119272700
##########
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();
Review Comment:
`TimeUUID.sizeInBytes()` this is the serialized size and not the object
overhead. Please compute this like we do `EMPTY` for other types
--
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]