DomGarguilo commented on code in PR #4380:
URL: https://github.com/apache/accumulo/pull/4380#discussion_r1934659302
##########
server/base/src/main/java/org/apache/accumulo/server/mem/LowMemoryDetector.java:
##########
@@ -173,25 +176,24 @@ public void logGCInfo(AccumuloConfiguration conf) {
LOG.debug(sb.toString());
}
- final long keepAliveTimeout =
conf.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT);
- if (lastMemoryCheckTime > 0 && lastMemoryCheckTime < now) {
- final long diff = now - lastMemoryCheckTime;
- if (diff > keepAliveTimeout + 1000) {
+ final Duration keepAliveTimeout =
conf.getDuration(Property.INSTANCE_ZK_TIMEOUT);
+ if (lastMemoryCheckTime != null &&
lastMemoryCheckTime.hasElapsed(keepAliveTimeout)) {
+ if
(currentTimer.hasElapsed(keepAliveTimeout.plus(Duration.ofSeconds(1)))) {
LOG.warn(String.format(
"GC pause checker not called in a timely"
+ " fashion. Expected every %.1f seconds but was %.1f
seconds since last check",
- keepAliveTimeout / 1000., diff / 1000.));
+ keepAliveTimeout.toMillis() / 1000.,
currentTimer.elapsed(MILLISECONDS) / 1000.));
}
- lastMemoryCheckTime = now;
+ lastMemoryCheckTime = currentTimer;
return;
}
- if (maxIncreaseInCollectionTime > keepAliveTimeout) {
+ if (maxIncreaseInCollectionTime > keepAliveTimeout.toMillis()) {
Halt.halt("Garbage collection may be interfering with lock keep-alive.
Halting.", -1);
}
lastMemorySize = freeMemory;
- lastMemoryCheckTime = now;
+ lastMemoryCheckTime = currentTimer;
Review Comment:
`Timer lastMemoryCheckTime` is initialized as null and then the code checks
if its null in places to see if the check has happened yet. We could probably
achieve the same with one Timer and a boolean flag that indicates if the check
has happened yet but this seemed like this best way to do things from what I
can tell.
--
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]