dlmarion commented on code in PR #6433:
URL: https://github.com/apache/accumulo/pull/6433#discussion_r3437485469
##########
server/monitor/src/main/java/org/apache/accumulo/monitor/next/InformationFetcher.java:
##########
@@ -792,26 +792,53 @@ private void fetchTabletInformation(SystemInformation
summary, UpdateTasks futur
public void run() {
long lastRunTime = 0;
+ final Timer noConnectionTimer = Timer.startNew();
+ final int clearStateMins = 10;
+ final Duration clearStateDuration = Duration.ofMinutes(clearStateMins);
Review Comment:
I'm going to leave as-is for now. I'm wondering if this value might be more
useful as a property.
##########
server/monitor/src/main/java/org/apache/accumulo/monitor/next/InformationFetcher.java:
##########
@@ -792,26 +792,53 @@ private void fetchTabletInformation(SystemInformation
summary, UpdateTasks futur
public void run() {
long lastRunTime = 0;
+ final Timer noConnectionTimer = Timer.startNew();
+ final int clearStateMins = 10;
+ final Duration clearStateDuration = Duration.ofMinutes(clearStateMins);
+ final long minimumRefreshTimeMs = 5000;
while (true) {
+ // Only refresh internal data structure every 5s (old monitor logic).
+ while (NanoTime.millisElapsed(lastRunTime, NanoTime.now()) <
minimumRefreshTimeMs) {
+ LOG.trace("Waiting for the 5s refresh interval");
+ try {
+ Thread.sleep(250);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new IllegalStateException(
+ "Thread " + Thread.currentThread().getName() + " interrupted",
e);
+ }
+ }
+
// Don't fetch new data if there are no connections.
- // On an initial connection, no data may be displayed.
- // If a connection has not been made in a while, stale data may be
displayed.
- // Only refresh every 5s (old monitor logic).
- while (!newConnectionEvent.get() && connectionCount.get() == 0
- && NanoTime.millisElapsed(lastRunTime, NanoTime.now()) > 5000) {
+ // When summaryRef is not set, then the REST endpoint will wait
+ // until data is retrieved. summaryRef is not set on initial
+ // connection or when there has been no connection for 5 minutes
+ noConnectionTimer.restart();
+ while (!newConnectionEvent.get() && connectionCount.get() == 0) {
+ LOG.trace("Waiting for a connection, connections: {}",
connectionCount.get());
try {
- Thread.sleep(100);
+ Thread.sleep(250);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalStateException(
"Thread " + Thread.currentThread().getName() + " interrupted",
e);
}
+ // If a connection has not been made in 5 minutes,
+ // then clear the summaryRef so that stale data is not displayed.
+ if (this.summaryRef.get() != null &&
noConnectionTimer.hasElapsed(clearStateDuration)) {
Review Comment:
With the check there we will only enter the code block once, instead of
every `clearStateDuration` minutes.
--
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]