You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2022/05/10 15:07:17 UTC

[GitHub] [accumulo] DomGarguilo commented on a diff in pull request #2685: Convert deadTServers and badTServers tables to DataTables

DomGarguilo commented on code in PR #2685:
URL: https://github.com/apache/accumulo/pull/2685#discussion_r869356499


##########
server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/tservers.js:
##########
@@ -183,29 +112,155 @@ function refreshDeadTServersTable() {
  * @param {string} server Dead TServer to clear
  */
 function clearDeadTServers(server) {
-  clearDeadServers(server);
-  refreshTServers();
-  refreshNavBar();
+    clearDeadServers(server);
+    refreshTServers();
+    refreshNavBar();
 }
 
 /**
- * Generates the tserver table
+ * Creates initial tables
  */
-function refreshTServersTable() {
-  if (tserversTable) tserversTable.ajax.reload(null, false); // user paging is not reset on reload
-}
+$(document).ready(function () {
 
-/**
- * Refreshes the list of recovering tservers used to highlight rows
- */
-function refreshRecoveryList() {
-  $('#recovery-caption').hide(); // Hide the caption about highlighted rows on each refresh
-  getRecoveryList().then(function () {
-    recoveryList = []
-    var data = sessionStorage.recoveryList === undefined ?
-      [] : JSON.parse(sessionStorage.recoveryList);
-    data.recoveryList.forEach(entry => {
-      recoveryList.push(entry.server);
+    refreshRecoveryList();
+
+    // Create a table for tserver list
+    tserversTable = $('#tservers').DataTable({
+        "ajax": {
+            "url": '/rest/tservers',
+            "dataSrc": "servers"
+        },
+        "stateSave": true,
+        "columnDefs": [
+            {
+                "targets": "big-num",
+                "render": function (data, type) {
+                    if (type === 'display') {
+                        data = bigNumberForQuantity(data);
+                    }
+                    return data;
+                }
+            },
+            {
+                "targets": "duration",
+                "render": function (data, type) {
+                    if (type === 'display') {
+                        data = timeDuration(data);
+                    }
+                    return data;
+                }
+            },
+            {
+                "targets": "percent",
+                "render": function (data, type) {
+                    if (type === 'display') {
+                        data = Math.round(data * 100) + '%';
+                    }
+                    return data;
+                }
+            }
+        ],
+        "columns": [
+            {
+                "data": "hostname",
+                "type": "html",
+                "render": function (data, type, row) {
+                    if (type === 'display') {
+                        data = '<a href="/tservers?s=' + row.id + '">' + row.hostname + '</a>';
+                    }
+                    return data;
+                }
+            },
+            { "data": "tablets" },
+            { "data": "lastContact" },
+            { "data": "responseTime" },
+            { "data": "entries" },
+            { "data": "ingest" },
+            { "data": "query" },
+            { "data": "holdtime" },
+            { "data": "scansCombo" },
+            { "data": "minorCombo" },
+            { "data": "majorCombo" },
+            { "data": "indexCacheHitRate" },
+            { "data": "dataCacheHitRate" },
+            { "data": "osload" }
+        ],
+        "rowCallback": function (row, data, index) {
+            // reset background of each row
+            $(row).css('background-color', '');
+
+            // return if the current row's tserver is not recovering
+            if (!recoveryList.includes(data.hostname)) {
+                return;
+            }
+
+            // only show the caption if we know there are rows in the tservers table
+            $('#recovery-caption').show();

Review Comment:
   Looks like jslint doesn't complain about the changes made in [086031e](https://github.com/apache/accumulo/pull/2685/commits/086031ecff58f4c089efb9eaa257218723a1553a)



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org