This is an automated email from the ASF dual-hosted git repository.
mmiller pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push:
new db22fdd Improve fetching scans and compactions in Monitor (#2294)
db22fdd is described below
commit db22fdd03db44a44ae87c6ae8add23edc63c21e8
Author: Mike Miller
AuthorDate: Fri Oct 1 11:17:21 2021 -0400
Improve fetching scans and compactions in Monitor (#2294)
* Drop fetchScans and fetchCompactions threads and just let the page
refresh get the data as needed. Created constant to prevent fetching
more than once a minute. Created time constant for age off
* Replace active scans table with datatables and add fetched column
* Add fetched column to Active compactions table
* Refactored fetch methods to catch thrift error and log.
* Made entry point methods getCompactions and getScans synchronized to
allow removal of synchronized code blocks.
---
.../java/org/apache/accumulo/monitor/Monitor.java | 78 ++
.../monitor/rest/compactions/CompactionInfo.java | 16 ++---
.../rest/compactions/CompactionsResource.java | 2 +-
.../monitor/rest/scans/ScanInformation.java| 16 ++---
.../accumulo/monitor/rest/scans/ScansResource.java | 4 +-
.../accumulo/monitor/resources/js/compactions.js | 11 ++-
.../apache/accumulo/monitor/resources/js/scans.js | 77 ++---
.../accumulo/monitor/templates/compactions.ftl | 1 +
.../apache/accumulo/monitor/templates/scans.ftl| 13 ++--
9 files changed, 108 insertions(+), 110 deletions(-)
diff --git
a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
index 6217347..9e48e9d 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
@@ -474,28 +474,6 @@ public class Monitor extends AbstractServer implements
HighlyAvailableService {
}
}).start();
-Threads.createThread("Scan scanner", () -> {
- while (true) {
-try {
- fetchScans();
-} catch (Exception e) {
- log.warn("{}", e.getMessage(), e);
-}
-sleepUninterruptibly(5, TimeUnit.SECONDS);
- }
-}).start();
-
-Threads.createThread("Compaction fetcher", () -> {
- while (true) {
-try {
- fetchCompactions();
-} catch (Exception e) {
- log.warn("{}", e.getMessage(), e);
-}
-sleepUninterruptibly(5, TimeUnit.SECONDS);
- }
-}).start();
-
monitorInitialized.set(true);
}
@@ -561,6 +539,7 @@ public class Monitor extends AbstractServer implements
HighlyAvailableService {
oldest = Math.max(oldest, scan.age);
}
this.oldestScan = oldest < 0 ? null : oldest;
+ // use clock time for date friendly display
this.fetched = System.currentTimeMillis();
}
}
@@ -577,6 +556,7 @@ public class Monitor extends AbstractServer implements
HighlyAvailableService {
oldest = Math.max(oldest, a.age);
}
this.oldest = oldest < 0 ? null : oldest;
+ // use clock time for date friendly display
this.fetched = System.currentTimeMillis();
}
}
@@ -584,56 +564,71 @@ public class Monitor extends AbstractServer implements
HighlyAvailableService {
private final Map allScans = new HashMap<>();
private final Map allCompactions = new
HashMap<>();
private final RecentLogs recentLogs = new RecentLogs();
+ private long scansFetchedNanos = 0L;
+ private long compactsFetchedNanos = 0L;
+ private final long fetchTimeNanos = TimeUnit.MINUTES.toNanos(1);
+ private final long ageOffEntriesMillis = TimeUnit.MINUTES.toMillis(15);
- public Map getScans() {
-synchronized (allScans) {
- return new HashMap<>(allScans);
+ /**
+ * Fetch the active scans but only if fetchTimeNanos has elapsed.
+ */
+ public synchronized Map getScans() {
+if (System.nanoTime() - scansFetchedNanos > fetchTimeNanos) {
+ log.info("User initiated fetch of Active Scans");
+ fetchScans();
}
+return Map.copyOf(allScans);
}
- public Map getCompactions() {
-synchronized (allCompactions) {
- return new HashMap<>(allCompactions);
+ /**
+ * Fetch the active compactions but only if fetchTimeNanos has elapsed.
+ */
+ public synchronized Map getCompactions() {
+if (System.nanoTime() - compactsFetchedNanos > fetchTimeNanos) {
+ log.info("User initiated fetch of Active Compactions");
+ fetchCompactions();
}
+return Map.copyOf(allCompactions);
}
- private void fetchScans() throws Exception {
+ private void fetchScans() {
ServerContext context = getContext();
for (String server : context.instanceOperations().getTabletServers()) {
final