You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by do...@apache.org on 2022/12/12 20:41:07 UTC

[accumulo] branch main updated: Fix bug in external compactions page (#3104)

This is an automated email from the ASF dual-hosted git repository.

domgarguilo 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 5c3a010cbb Fix bug in external compactions page (#3104)
5c3a010cbb is described below

commit 5c3a010cbb41a669b1eb2a03d88749289df582a5
Author: Dom G <do...@apache.org>
AuthorDate: Mon Dec 12 15:41:00 2022 -0500

    Fix bug in external compactions page (#3104)
    
    * move hide/show logic for compaction page in monitor into javascript
---
 .../monitor/rest/status/StatusInformation.java     |  5 ++-
 .../monitor/rest/status/StatusResource.java        |  4 ++-
 .../org/apache/accumulo/monitor/view/WebViews.java |  8 ++---
 .../org/apache/accumulo/monitor/resources/js/ec.js | 37 +++++++++++++++++++---
 .../org/apache/accumulo/monitor/templates/ec.ftl   |  8 ++---
 5 files changed, 44 insertions(+), 18 deletions(-)

diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/status/StatusInformation.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/status/StatusInformation.java
index 25d4c74e82..c55e2876b7 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/status/StatusInformation.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/status/StatusInformation.java
@@ -29,6 +29,7 @@ public class StatusInformation {
   public String managerStatus = null;
   public String gcStatus = null;
   public String tServerStatus = null;
+  public String coordinatorStatus = null;
 
   public Integer logNumber = 0;
   public boolean logsHaveError = false;
@@ -42,15 +43,17 @@ public class StatusInformation {
    * @param managerStatus Status for the manager
    * @param gcStatus Status for the GC
    * @param tServerStatus Status for the tserver
+   * @param coordinatorStatus Status for the Compaction Coordinator
    * @param logNumber Number of log reports
    * @param logsHaveError Check if log reports include errors
    * @param problemNumber Number of problems per table
    */
   public StatusInformation(String managerStatus, String gcStatus, String tServerStatus,
-      Integer logNumber, boolean logsHaveError, Integer problemNumber) {
+      String coordinatorStatus, Integer logNumber, boolean logsHaveError, Integer problemNumber) {
     this.managerStatus = managerStatus;
     this.gcStatus = gcStatus;
     this.tServerStatus = tServerStatus;
+    this.coordinatorStatus = coordinatorStatus;
     this.logNumber = logNumber;
     this.logsHaveError = logsHaveError;
     this.problemNumber = problemNumber;
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/status/StatusResource.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/status/StatusResource.java
index aeb88f7648..775f612a61 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/status/StatusResource.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/status/StatusResource.java
@@ -56,6 +56,8 @@ public class StatusResource {
     Status managerStatus;
     Status gcStatus;
     Status tServerStatus = Status.ERROR;
+    Status coordinatorStatus = monitor.getCoordinatorHost().isPresent() ? Status.OK : Status.ERROR;
+
     ManagerMonitorInfo mmi = monitor.getMmi();
 
     if (mmi != null) {
@@ -95,7 +97,7 @@ public class StatusResource {
     }
 
     return new StatusInformation(managerStatus.toString(), gcStatus.toString(),
-        tServerStatus.toString(), monitor.recentLogs().numEvents(),
+        tServerStatus.toString(), coordinatorStatus.toString(), monitor.recentLogs().numEvents(),
         monitor.recentLogs().eventsIncludeErrors(), monitor.getProblemSummary().entrySet().size());
   }
 }
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/view/WebViews.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/view/WebViews.java
index 25578fd596..d508e09c53 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/view/WebViews.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/view/WebViews.java
@@ -216,12 +216,8 @@ public class WebViews {
     model.put("title", "External Compactions");
     model.put("template", "ec.ftl");
 
-    if (ccHost.isPresent()) {
-      model.put("coordinatorRunning", true);
-      model.put("js", "ec.js");
-    } else {
-      model.put("coordinatorRunning", false);
-    }
+    model.put("coordinatorRunning", ccHost.isPresent());
+    model.put("js", "ec.js");
 
     return model;
   }
diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/ec.js b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/ec.js
index d32180a453..e0c8759e6a 100644
--- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/ec.js
+++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/ec.js
@@ -238,12 +238,41 @@ function refresh() {
  * Refreshes the compaction tables
  */
 function refreshECTables() {
-  // user paging is not reset on reload
-  ajaxReloadTable(compactorsTable);
-  ajaxReloadTable(runningTable);
-  ajaxReloadTable(coordinatorTable);
+  refreshCoordinatorStatus().then(function (coordinatorStatus) {
+
+    // tables will not be shown, avoid reloading
+    if (coordinatorStatus === 'ERROR') {
+      return;
+    }
+
+    // user paging is not reset on reload
+    refreshCompactors();
+    refreshRunning();
+    ajaxReloadTable(coordinatorTable);
+  });
 }
 
+/**
+ * Updates session storage then checks if the coordinator is running. If it is,
+ * show the tables and hide the 'coordinator not running' banner. Else, vise-versa.
+ * 
+ * returns the coordinator status
+ */
+async function refreshCoordinatorStatus() {
+  return getStatus().then(function () {
+    var coordinatorStatus = JSON.parse(sessionStorage.status).coordinatorStatus;
+    if (coordinatorStatus === 'ERROR') {
+      // show banner and hide tables
+      $('#ccBanner').show();
+      $('#ecDiv').hide();
+    } else {
+      // otherwise, hide banner and show tables
+      $('#ccBanner').hide();
+      $('#ecDiv').show();
+    }
+    return coordinatorStatus;
+  });
+}
 
 function getRunningDetails(ecid, idSuffix) {
   var ajaxUrl = '/rest/ec/details?ecid=' + ecid;
diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/ec.ftl b/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/ec.ftl
index e9b194b5e4..5ea573cf43 100644
--- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/ec.ftl
+++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/ec.ftl
@@ -23,8 +23,7 @@
           <h3>${title}</h3>
         </div>
       </div>
-    <#if coordinatorRunning == true>
-      <div id="ecDiv">
+      <div id="ecDiv" style="display: none;">
         <div class="row">
           <div class="col-xs-12">
             <table id="coordinatorTable" class="table caption-top table-bordered table-striped table-condensed">
@@ -83,9 +82,6 @@
           </div>
         </div>
       </div>
-   <#else>
-    <div id="ccBanner">
+    <div id="ccBanner" style="display: none;">
       <div class="alert alert-danger" role="alert">Compaction Coordinator Not Running</div>
     </div>
-   </#if>
-