DonalEvans commented on a change in pull request #7358:
URL: https://github.com/apache/geode/pull/7358#discussion_r808345559
##########
File path:
geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/RedisStats.java
##########
@@ -222,28 +221,25 @@ private void stopRollingAverageUpdater() {
}
private void doRollingAverageUpdates() {
- updateNetworkKilobytesReadLastSecond(rollingAverageTick);
- updateOpsPerformedOverLastSecond(rollingAverageTick);
+ networkKiloBytesReadOverLastSecond = networkKiloBytesReadRollingAverageStat
+ .calculate(getTotalNetworkBytesRead(), rollingAverageTick) / 1024.0;
+ opsPerformedOverLastSecond =
+ opsPerformedRollingAverageStat.calculate(getCommandsProcessed(),
rollingAverageTick);
rollingAverageTick++;
- if (rollingAverageTick >= rollingAverageSamplesPerSecond) {
+ if (rollingAverageTick >= ROLLING_AVERAGE_SAMPLES_PER_SECOND) {
rollingAverageTick = 0;
}
}
- private void updateNetworkKilobytesReadLastSecond(int tickNumber) {
- final long totalNetworkBytesRead = getTotalNetworkBytesRead();
- long deltaNetworkBytesRead = totalNetworkBytesRead -
totalNetworkBytesReadLastTick;
- networkBytesReadOverLastNSamples[tickNumber] = deltaNetworkBytesRead;
- networkKiloBytesReadOverLastSecond =
- Arrays.stream(networkBytesReadOverLastNSamples).sum() / 1024.0;
- totalNetworkBytesReadLastTick = totalNetworkBytesRead;
- }
+ private static class RollingUpgradeStat {
Review comment:
Yes, I was apparently on auto-pilot when I typed that, thanks for
catching it
##########
File path:
geode-for-redis/src/main/java/org/apache/geode/redis/internal/statistics/RedisStats.java
##########
@@ -39,15 +39,14 @@
private final AtomicLong uniqueChannelSubscriptions = new AtomicLong();
private final AtomicLong uniquePatternSubscriptions = new AtomicLong();
- private final int rollingAverageSamplesPerSecond = 16;
+ private static final int ROLLING_AVERAGE_SAMPLES_PER_SECOND = 16;
private final ScheduledExecutorService rollingAverageExecutor;
- private volatile double networkKiloBytesReadOverLastSecond;
- private final long[] networkBytesReadOverLastNSamples = new
long[rollingAverageSamplesPerSecond];
- private long totalNetworkBytesReadLastTick;
- private double opsPerformedOverLastSecond;
- private volatile long totalOpsPerformedLastTick;
- private final long[] opsPerformedOverLastNSamples = new
long[rollingAverageSamplesPerSecond];
private int rollingAverageTick = 0;
+ private final RollingUpgradeStat networkKiloBytesReadRollingAverageStat =
Review comment:
Good call
--
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]