From ba5c74887c2a5cd7ee407662ed8f48614a266820 Mon Sep 17 00:00:00 2001 From: Kevin Rathbun Date: Thu, 18 Sep 2025 16:30:38 -0400 Subject: [PATCH 1/6] Manager info on Monitor `rest/manager` -> `rest-v2/manager` Manager info on the Monitor (displayed on homepage (`/`) and Manager page (`/manager`)) now obtains and displays info from the existing (but unused) `rest-v2/manager` endpoint. * Updated the homepage to display table data corresponding to the `rest-v2/manager` endpoint. * Updated the manager page to display table data corresponding to the `rest-v2/manager` endpoint. * Created new endpoint `rest-v2/manager/metrics` which returns the Manager metrics as json. This is linked in the Manager table in both the homepage and the manager page. * Server navigation bar now only considers the Manager status (as obtained from `rest/status`) (ERROR, WARN, OK). Previously took into account the manager state (e.g., if the state or goal state was SAFE_MODE or CLEAN_STOP), but this info was only included in the `rest/manager` endpoint. * Deleted the `rest/manager` endpoint and associated code used to gather data for this endpoint. * Deleted `systemAlert.js` and `systemAlert.ftl` as this alert was entirely based on Manager info included in `rest/manager` (manager state being SAFE_MODE or CLEAN_STOP). No longer applicable with `rest-v2/manager`. --- .../accumulo/monitor/next/Endpoints.java | 12 + .../monitor/rest/SummaryInformation.java | 34 +-- .../apache/accumulo/monitor/rest/Totals.java | 48 --- .../accumulo/monitor/rest/XMLResource.java | 5 +- .../monitor/rest/logs/DeadLoggerList.java | 42 --- .../rest/manager/ManagerInformation.java | 131 --------- .../monitor/rest/manager/ManagerResource.java | 271 ----------------- .../tservers/BadTabletServerInformation.java | 49 ---- .../rest/tservers/BadTabletServers.java | 43 --- .../rest/tservers/DeadServerInformation.java | 54 ---- .../monitor/rest/tservers/DeadServerList.java | 42 --- .../ServerShuttingDownInformation.java | 44 --- .../rest/tservers/ServersShuttingDown.java | 42 --- .../rest/tservers/TabletServerResource.java | 3 - .../TabletServerWithTableInformation.java | 47 --- .../monitor/rest/tservers/TabletServers.java | 14 - .../monitor/resources/js/functions.js | 2 +- .../accumulo/monitor/resources/js/manager.js | 275 +++++++----------- .../accumulo/monitor/resources/js/navbar.js | 88 +++--- .../accumulo/monitor/resources/js/overview.js | 44 ++- .../monitor/resources/js/systemAlert.js | 172 ----------- .../accumulo/monitor/resources/js/tservers.js | 110 +------ .../accumulo/monitor/templates/default.ftl | 2 - .../accumulo/monitor/templates/manager.ftl | 21 +- .../accumulo/monitor/templates/overview.ftl | 20 +- .../monitor/templates/systemAlert.ftl | 31 -- .../accumulo/monitor/templates/tservers.ftl | 28 -- 27 files changed, 189 insertions(+), 1485 deletions(-) delete mode 100644 server/monitor/src/main/java/org/apache/accumulo/monitor/rest/Totals.java delete mode 100644 server/monitor/src/main/java/org/apache/accumulo/monitor/rest/logs/DeadLoggerList.java delete mode 100644 server/monitor/src/main/java/org/apache/accumulo/monitor/rest/manager/ManagerInformation.java delete mode 100644 server/monitor/src/main/java/org/apache/accumulo/monitor/rest/manager/ManagerResource.java delete mode 100644 server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/BadTabletServerInformation.java delete mode 100644 server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/BadTabletServers.java delete mode 100644 server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/DeadServerInformation.java delete mode 100644 server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/DeadServerList.java delete mode 100644 server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/ServerShuttingDownInformation.java delete mode 100644 server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/ServersShuttingDown.java delete mode 100644 server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/TabletServerWithTableInformation.java delete mode 100644 server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/systemAlert.js delete mode 100644 server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/systemAlert.ftl diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/next/Endpoints.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/next/Endpoints.java index c0eb1b2e1d1..fdd89507956 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/next/Endpoints.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/next/Endpoints.java @@ -151,6 +151,18 @@ public MetricResponse getManager() { return monitor.getInformationFetcher().getAllMetrics().asMap().get(s); } + @GET + @Path("manager/metrics") + @Produces(MediaType.APPLICATION_JSON) + @Description("Returns the metrics for the Manager") + public List getManagerMetrics() { + if (getManager().getMetrics() != null) { + return getManager().getMetrics().stream().map(FMetric::getRootAsFMetric) + .collect(Collectors.toList()); + } + return List.of(); + } + @GET @Path("gc") @Produces(MediaType.APPLICATION_JSON) diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/SummaryInformation.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/SummaryInformation.java index 3880c2e79f4..f468819df3e 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/SummaryInformation.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/SummaryInformation.java @@ -23,12 +23,7 @@ import jakarta.xml.bind.annotation.XmlRootElement; -import org.apache.accumulo.monitor.rest.logs.DeadLoggerList; -import org.apache.accumulo.monitor.rest.manager.ManagerInformation; import org.apache.accumulo.monitor.rest.tables.TableInformationList; -import org.apache.accumulo.monitor.rest.tservers.BadTabletServers; -import org.apache.accumulo.monitor.rest.tservers.DeadServerList; -import org.apache.accumulo.monitor.rest.tservers.ServersShuttingDown; import org.apache.accumulo.monitor.rest.tservers.TabletServer; /** @@ -40,46 +35,23 @@ public class SummaryInformation { // Variable names become JSON keys - public List servers = new ArrayList<>(); - - public String managerGoalState; - public String managerState; - - public BadTabletServers badTabletServers; - public ServersShuttingDown tabletServersShuttingDown; - public Integer unassignedTablets; - public DeadServerList deadTabletServers; - - public DeadLoggerList deadLoggers; + public List servers; public TableInformationList tables; - public Totals totals; - + // do not remove public SummaryInformation() {} /** * Stores Monitor information as XML or JSON * * @param size Number of tservers - * @param info Manager information * @param tablesList Table list */ - public SummaryInformation(int size, ManagerInformation info, TableInformationList tablesList) { + public SummaryInformation(int size, TableInformationList tablesList) { this.servers = new ArrayList<>(size); - this.managerGoalState = info.managerGoalState; - this.managerState = info.managerState; - - this.badTabletServers = info.badTabletServers; - this.tabletServersShuttingDown = info.tabletServersShuttingDown; - this.unassignedTablets = info.unassignedTablets; - this.deadTabletServers = info.deadTabletServers; - this.deadLoggers = info.deadLoggers; - this.tables = tablesList; - - this.totals = new Totals(info.ingestrate, info.queryrate, info.numentries); } /** diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/Totals.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/Totals.java deleted file mode 100644 index 1697f1885bc..00000000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/Totals.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.accumulo.monitor.rest; - -/** - * Generates the totals for XML summary - * - * @since 2.0.0 - */ -public class Totals { - - // Variable names become JSON keys - public double ingestrate = 0.0; - public double queryrate = 0.0; - public double diskrate = 0.0; - public long numentries = 0L; - - public Totals() {} - - /** - * Initializes totals - * - * @param ingestrate Total ingest rate - * @param queryrate Total query rate - * @param numentries Total number of entries - */ - public Totals(double ingestrate, double queryrate, long numentries) { - this.ingestrate = ingestrate; - this.queryrate = queryrate; - this.numentries = numentries; - } -} diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/XMLResource.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/XMLResource.java index 33ab3654c04..cb52c0174c3 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/XMLResource.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/XMLResource.java @@ -29,7 +29,6 @@ import org.apache.accumulo.core.manager.thrift.ManagerMonitorInfo; import org.apache.accumulo.core.manager.thrift.TabletServerStatus; import org.apache.accumulo.monitor.Monitor; -import org.apache.accumulo.monitor.rest.manager.ManagerResource; import org.apache.accumulo.monitor.rest.tables.TablesResource; import org.apache.accumulo.monitor.rest.tservers.TabletServer; @@ -58,8 +57,8 @@ public SummaryInformation getInformation() { } // Add Monitor information - SummaryInformation xml = new SummaryInformation(mmi.tServerInfo.size(), - ManagerResource.getTables(monitor), TablesResource.getTables(monitor)); + SummaryInformation xml = + new SummaryInformation(mmi.tServerInfo.size(), TablesResource.getTables(monitor)); // Add tserver information for (TabletServerStatus status : mmi.tServerInfo) { diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/logs/DeadLoggerList.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/logs/DeadLoggerList.java deleted file mode 100644 index 2cdec7750e3..00000000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/logs/DeadLoggerList.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.accumulo.monitor.rest.logs; - -import java.util.ArrayList; -import java.util.List; - -/** - * Stores a new dead logger object - * - * @since 2.0.0 - */ -public class DeadLoggerList { - - // Variable names become JSON keys - public List deadLogger = new ArrayList<>(); - - /** - * Adds a new dead logger to the list - * - * @param deadLogger dead logger to add - */ - public void addDeadLogger(DeadLoggerInformation deadLogger) { - this.deadLogger.add(deadLogger); - } -} diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/manager/ManagerInformation.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/manager/ManagerInformation.java deleted file mode 100644 index c202f076d99..00000000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/manager/ManagerInformation.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.accumulo.monitor.rest.manager; - -import org.apache.accumulo.monitor.rest.logs.DeadLoggerList; -import org.apache.accumulo.monitor.rest.tservers.BadTabletServers; -import org.apache.accumulo.monitor.rest.tservers.DeadServerList; -import org.apache.accumulo.monitor.rest.tservers.ServersShuttingDown; - -/** - * Responsible for storing manager information as a JSON object - * - * @since 2.0.0 - */ -public class ManagerInformation { - - // Variable names become JSON keys - public String manager = "No Managers running"; - public String lastGC = "0"; - public String gcStatus; - public String managerGoalState; - public String managerState; - - public Integer onlineTabletServers = 0; - public Integer totalTabletServers = 0; - public Integer tablets = 0; - public Integer unassignedTablets = 0; - - public long numentries = 0L; - public double osload = 0L; - public double ingestrate = 0d; - public double entriesRead = 0d; - public double queryrate = 0d; // entriesReturned same as queryrate - - public long holdTime = 0L; - - public int tables; - public int deadTabletServersCount; - public long lookups; - public long uptime; - - public BadTabletServers badTabletServers; - public ServersShuttingDown tabletServersShuttingDown; - public DeadServerList deadTabletServers; - public DeadLoggerList deadLoggers; - - /** - * Creates an empty manager JSON object - */ - public ManagerInformation() {} - - public ManagerInformation(String manager) { - this.manager = manager; - } - - /** - * Stores a new manager JSON object - * - * @param manager Manager location - * @param onlineTabletServers Number of online tservers - * @param totalTabletServers Total number of tservers - * @param lastGC Time of the last gc - * @param tablets Number of tablet - * @param unassignedTablets Number of unassigned tablets - * @param entries Number of entries - * @param ingest Number of ingest - * @param entriesRead Number of queries - * @param entriesReturned Number of returned queries - * @param holdTime Amount of hold time - * @param osLoad Amount of load to the OS - * @param tables Number of tables - * @param deadTabletServersCount Number of dead tservers - * @param lookups Number of lookups - * @param uptime Time the Monitor has been running - * @param gcStatus Status of the garbage collector - * @param managerGoalState Goal state of the manager - * @param managerState Current state of the manager - * @param badTabletServers Number of bad tservers - * @param tabletServersShuttingDown Number of tservers shutting down - * @param deadTabletServers Number of dead tservers - * @param deadLoggers Number of dead loggers - */ - public ManagerInformation(String manager, int onlineTabletServers, int totalTabletServers, - String lastGC, int tablets, int unassignedTablets, long entries, double ingest, - double entriesRead, double entriesReturned, long holdTime, double osLoad, int tables, - int deadTabletServersCount, long lookups, long uptime, String gcStatus, - String managerGoalState, String managerState, BadTabletServers badTabletServers, - ServersShuttingDown tabletServersShuttingDown, DeadServerList deadTabletServers, - DeadLoggerList deadLoggers) { - - this.manager = manager; - this.onlineTabletServers = onlineTabletServers; - this.totalTabletServers = totalTabletServers; - this.lastGC = lastGC; - this.tablets = tablets; - this.unassignedTablets = unassignedTablets; - this.numentries = entries; - this.ingestrate = ingest; - this.entriesRead = entriesRead; - this.queryrate = entriesReturned; - this.holdTime = holdTime; - this.osload = osLoad; - this.tables = tables; - this.deadTabletServersCount = deadTabletServersCount; - this.lookups = lookups; - this.uptime = uptime; - this.gcStatus = gcStatus; - this.managerGoalState = managerGoalState; - this.managerState = managerState; - this.badTabletServers = badTabletServers; - this.tabletServersShuttingDown = tabletServersShuttingDown; - this.deadTabletServers = deadTabletServers; - this.deadLoggers = deadLoggers; - } -} diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/manager/ManagerResource.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/manager/ManagerResource.java deleted file mode 100644 index eab9eee7e93..00000000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/manager/ManagerResource.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.accumulo.monitor.rest.manager; - -import java.lang.management.ManagementFactory; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import jakarta.inject.Inject; -import jakarta.ws.rs.GET; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.Produces; -import jakarta.ws.rs.core.MediaType; - -import org.apache.accumulo.core.client.admin.servers.ServerId; -import org.apache.accumulo.core.conf.Property; -import org.apache.accumulo.core.gc.thrift.GCStatus; -import org.apache.accumulo.core.manager.thrift.DeadServer; -import org.apache.accumulo.core.manager.thrift.ManagerMonitorInfo; -import org.apache.accumulo.core.manager.thrift.TabletServerStatus; -import org.apache.accumulo.monitor.Monitor; -import org.apache.accumulo.monitor.rest.logs.DeadLoggerInformation; -import org.apache.accumulo.monitor.rest.logs.DeadLoggerList; -import org.apache.accumulo.monitor.rest.tservers.BadTabletServerInformation; -import org.apache.accumulo.monitor.rest.tservers.BadTabletServers; -import org.apache.accumulo.monitor.rest.tservers.DeadServerInformation; -import org.apache.accumulo.monitor.rest.tservers.DeadServerList; -import org.apache.accumulo.monitor.rest.tservers.ServerShuttingDownInformation; -import org.apache.accumulo.monitor.rest.tservers.ServersShuttingDown; -import org.apache.accumulo.server.manager.state.TabletServerState; -import org.apache.commons.lang3.StringUtils; - -/** - * Responsible for generating a new Manager information JSON object - * - * @since 2.0.0 - */ -@Path("/manager") -@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) -public class ManagerResource { - public static final String NO_MANAGERS = "No Managers running"; - - @Inject - private Monitor monitor; - - /** - * Generates a manager information JSON object - * - * @return manager JSON object - */ - @GET - public ManagerInformation getTables() { - return getTables(monitor); - } - - public static ManagerInformation getTables(Monitor monitor) { - ManagerInformation managerInformation; - ManagerMonitorInfo mmi = monitor.getMmi(); - - if (mmi != null) { - GCStatus gcStatusObj = monitor.getGcStatus(); - String gcStatus = "Waiting"; - String label = ""; - if (gcStatusObj != null) { - long start = 0; - if (gcStatusObj.current.started != 0 || gcStatusObj.currentLog.started != 0) { - start = Math.max(gcStatusObj.current.started, gcStatusObj.currentLog.started); - label = "Running"; - } else if (gcStatusObj.lastLog.finished != 0) { - start = gcStatusObj.lastLog.finished; - } - if (start != 0) { - gcStatus = String.valueOf(start); - } - } else { - gcStatus = "Down"; - } - - List tservers = new ArrayList<>(); - for (TabletServerStatus up : mmi.tServerInfo) { - tservers.add(up.name); - } - for (DeadServer down : mmi.deadTabletServers) { - tservers.add(down.server); - } - - Set managers = - monitor.getContext().instanceOperations().getServers(ServerId.Type.MANAGER); - String manager = "Down"; - if (managers != null && !managers.isEmpty()) { - manager = managers.iterator().next().getHost(); - } - - int onlineTabletServers = mmi.tServerInfo.size(); - int totalTabletServers = tservers.size(); - int tablets = monitor.getTotalTabletCount(); - int unassignedTablets = mmi.unassignedTablets; - long entries = monitor.getTotalEntries(); - double ingest = monitor.getTotalIngestRate(); - double entriesRead = monitor.getTotalScanRate(); - double entriesReturned = monitor.getTotalQueryRate(); - long holdTime = monitor.getTotalHoldTime(); - double osLoad = ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage(); - - int tables = monitor.getTotalTables(); - int deadTabletServers = mmi.deadTabletServers.size(); - long lookups = monitor.getTotalLookups(); - long uptime = System.currentTimeMillis() - monitor.getStartTime(); - - managerInformation = new ManagerInformation(manager, onlineTabletServers, totalTabletServers, - gcStatus, tablets, unassignedTablets, entries, ingest, entriesRead, entriesReturned, - holdTime, osLoad, tables, deadTabletServers, lookups, uptime, label, - getGoalState(monitor), getState(monitor), getNumBadTservers(monitor), - getServersShuttingDown(monitor), getDeadTservers(monitor), getDeadLoggers(monitor)); - } else { - managerInformation = new ManagerInformation(); - } - return managerInformation; - } - - /** - * Returns the current state of the manager - * - * @return manager state - */ - public static String getState(Monitor monitor) { - ManagerMonitorInfo mmi = monitor.getMmi(); - if (mmi == null) { - return NO_MANAGERS; - } - return mmi.state.toString(); - } - - /** - * Returns the goal state of the manager - * - * @return manager goal state - */ - public static String getGoalState(Monitor monitor) { - ManagerMonitorInfo mmi = monitor.getMmi(); - if (mmi == null) { - return NO_MANAGERS; - } - return mmi.goalState.name(); - } - - /** - * Generates a dead server list as a JSON object - * - * @return dead server list - */ - public static DeadServerList getDeadTservers(Monitor monitor) { - ManagerMonitorInfo mmi = monitor.getMmi(); - if (mmi == null) { - return new DeadServerList(); - } - - DeadServerList deadServers = new DeadServerList(); - - String prop = monitor.getConfiguration().get(Property.MONITOR_DEAD_LIST_RG_EXCLUSIONS); - Set exclusions = null; - if (StringUtils.isNotBlank(prop)) { - String[] rgs = prop.split(","); - exclusions = new HashSet<>(rgs.length); - for (String s : rgs) { - exclusions.add(s.trim()); - } - } - - // Add new dead servers to the list - for (DeadServer dead : mmi.deadTabletServers) { - if (exclusions == null || !exclusions.contains(dead.getResourceGroup())) { - deadServers - .addDeadServer(new DeadServerInformation(dead.server, dead.lastStatus, dead.status)); - } - } - return deadServers; - } - - /** - * Generates a dead logger list as a JSON object - * - * @return dead logger list - */ - public static DeadLoggerList getDeadLoggers(Monitor monitor) { - ManagerMonitorInfo mmi = monitor.getMmi(); - if (mmi == null) { - return new DeadLoggerList(); - } - - DeadLoggerList deadLoggers = new DeadLoggerList(); - // Add new dead loggers to the list - for (DeadServer dead : mmi.deadTabletServers) { - deadLoggers - .addDeadLogger(new DeadLoggerInformation(dead.server, dead.lastStatus, dead.status)); - } - return deadLoggers; - } - - /** - * Generates bad tserver lists as a JSON object - * - * @return bad tserver list - */ - public static BadTabletServers getNumBadTservers(Monitor monitor) { - ManagerMonitorInfo mmi = monitor.getMmi(); - if (mmi == null) { - return new BadTabletServers(); - } - - Map badServers = mmi.getBadTServers(); - - if (badServers == null || badServers.isEmpty()) { - return new BadTabletServers(); - } - - BadTabletServers readableBadServers = new BadTabletServers(); - // Add new bad tservers to the list - for (Entry badServer : badServers.entrySet()) { - try { - TabletServerState state = TabletServerState.getStateById(badServer.getValue()); - readableBadServers - .addBadServer(new BadTabletServerInformation(badServer.getKey(), state.name())); - } catch (IndexOutOfBoundsException e) { - readableBadServers - .addBadServer(new BadTabletServerInformation(badServer.getKey(), "Unknown state")); - } - } - return readableBadServers; - } - - /** - * Generates a JSON object of a list of servers shutting down - * - * @return servers shutting down list - */ - public static ServersShuttingDown getServersShuttingDown(Monitor monitor) { - ManagerMonitorInfo mmi = monitor.getMmi(); - ServersShuttingDown servers = new ServersShuttingDown(); - if (mmi == null) { - return servers; - } - - // Add new servers to the list - for (String server : mmi.serversShuttingDown) { - servers.addServerShuttingDown(new ServerShuttingDownInformation(server)); - } - return servers; - } - -} diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/BadTabletServerInformation.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/BadTabletServerInformation.java deleted file mode 100644 index 5a398943356..00000000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/BadTabletServerInformation.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.accumulo.monitor.rest.tservers; - -import jakarta.xml.bind.annotation.XmlAttribute; - -/** - * Generates a bad tserver information - * - * @since 2.0.0 - */ -public class BadTabletServerInformation { - - // Variable names become JSON keys - @XmlAttribute - public String id; - - @XmlAttribute - public String status; - - public BadTabletServerInformation() {} - - /** - * Stores a bad tserver - * - * @param id ID of the tserver - * @param status Status of the tserver - */ - public BadTabletServerInformation(String id, String status) { - this.id = id; - this.status = status; - } -} diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/BadTabletServers.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/BadTabletServers.java deleted file mode 100644 index c3654b9c2a1..00000000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/BadTabletServers.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.accumulo.monitor.rest.tservers; - -import java.util.ArrayList; -import java.util.List; - -/** - * Generates a list of bad tservers - * - * @since 2.0.0 - */ -public class BadTabletServers { - - // Variable names become JSON keys - public List badTabletServer = new ArrayList<>(); - - /** - * Adds a new bad tserver to the list - * - * @param badTabletServer Bad tserver to add - */ - public void addBadServer(BadTabletServerInformation badTabletServer) { - this.badTabletServer.add(badTabletServer); - } - -} diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/DeadServerInformation.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/DeadServerInformation.java deleted file mode 100644 index 6b78187976b..00000000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/DeadServerInformation.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.accumulo.monitor.rest.tservers; - -import jakarta.xml.bind.annotation.XmlAttribute; - -/** - * Generates a dead tserver information - * - * @since 2.0.0 - */ -public class DeadServerInformation { - - // Variable names become JSON keys - @XmlAttribute - public String server; - - @XmlAttribute - public long lastStatus; - - @XmlAttribute - public String status; - - public DeadServerInformation() {} - - /** - * Stores a new dead tserver - * - * @param server Location of the tserver - * @param lastStatus Last know status of the tserver - * @param status Current status of the tserver - */ - public DeadServerInformation(String server, long lastStatus, String status) { - this.server = server; - this.lastStatus = lastStatus; - this.status = status; - } -} diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/DeadServerList.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/DeadServerList.java deleted file mode 100644 index 64f930f1f6f..00000000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/DeadServerList.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.accumulo.monitor.rest.tservers; - -import java.util.ArrayList; -import java.util.List; - -/** - * Generates a list of dead tservers - * - * @since 2.0.0 - */ -public class DeadServerList { - - // Variable names become JSON keys - public List deadTabletServer = new ArrayList<>(); - - /** - * Adds a new dead tserver to the list - * - * @param deadTabletServer Dead tserver to add - */ - public void addDeadServer(DeadServerInformation deadTabletServer) { - this.deadTabletServer.add(deadTabletServer); - } -} diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/ServerShuttingDownInformation.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/ServerShuttingDownInformation.java deleted file mode 100644 index 4b6165696b0..00000000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/ServerShuttingDownInformation.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.accumulo.monitor.rest.tservers; - -import jakarta.xml.bind.annotation.XmlAttribute; - -/** - * Generates a tserver shutting down - * - * @since 2.0.0 - */ -public class ServerShuttingDownInformation { - - // Variable names become JSON keys - @XmlAttribute - public String id; - - public ServerShuttingDownInformation() {} - - /** - * Stores ID of the tserver shutting down - * - * @param id ID of the tserver shutting down - */ - public ServerShuttingDownInformation(String id) { - this.id = id; - } -} diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/ServersShuttingDown.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/ServersShuttingDown.java deleted file mode 100644 index ed00f3a9817..00000000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/ServersShuttingDown.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.accumulo.monitor.rest.tservers; - -import java.util.ArrayList; -import java.util.List; - -/** - * Generates a list of servers shutting down - * - * @since 2.0.0 - */ -public class ServersShuttingDown { - - // Variable names become JSON keys - public List server = new ArrayList<>(); - - /** - * Adds a new tserver to the list - * - * @param server TServer to add - */ - public void addServerShuttingDown(ServerShuttingDownInformation server) { - this.server.add(server); - } -} diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/TabletServerResource.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/TabletServerResource.java index b21407049c7..c96cd611c37 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/TabletServerResource.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/TabletServerResource.java @@ -50,7 +50,6 @@ import org.apache.accumulo.core.trace.TraceUtil; import org.apache.accumulo.core.util.AddressUtil; import org.apache.accumulo.monitor.Monitor; -import org.apache.accumulo.monitor.rest.manager.ManagerResource; import org.apache.accumulo.server.manager.state.DeadServerList; import org.apache.accumulo.server.util.ActionStatsUpdator; @@ -89,8 +88,6 @@ public TabletServers getTserverSummary() { tserverInfo.addTablet(new TabletServer(monitor, status)); } - tserverInfo.addBadTabletServer(ManagerResource.getTables(monitor)); - return tserverInfo; } diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/TabletServerWithTableInformation.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/TabletServerWithTableInformation.java deleted file mode 100644 index 30c8eb932f0..00000000000 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/TabletServerWithTableInformation.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.accumulo.monitor.rest.tservers; - -import org.apache.accumulo.monitor.rest.tables.TableInformation; - -/** - * Generates a tserver with table information - * - * @since 2.0.0 - */ -public class TabletServerWithTableInformation { - - // Variable names become JSON keys - public TabletServerInformation tserver; - public TableInformation table; - - public TabletServerWithTableInformation() {} - - /** - * Stores a new tserver - * - * @param tserverInfo Tserver to add - * @param tableInfo Table information - */ - public TabletServerWithTableInformation(TabletServerInformation tserverInfo, - TableInformation tableInfo) { - this.tserver = tserverInfo; - this.table = tableInfo; - } -} diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/TabletServers.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/TabletServers.java index 4b794b7899e..231ca61e513 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/TabletServers.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/TabletServers.java @@ -21,8 +21,6 @@ import java.util.ArrayList; import java.util.List; -import org.apache.accumulo.monitor.rest.manager.ManagerInformation; - import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; /** @@ -36,8 +34,6 @@ public class TabletServers { // Variable names become JSON keys public List servers = new ArrayList<>(); - public List badServers = new ArrayList<>(); - public List deadServers = new ArrayList<>(); public TabletServers() {} @@ -45,16 +41,6 @@ public TabletServers(int size) { servers = new ArrayList<>(size); } - /** - * Adds bad and dead servers to the list - * - * @param info Manager information to get bad and dead server information - */ - public void addBadTabletServer(ManagerInformation info) { - badServers = info.badTabletServers.badTabletServer; - deadServers = info.deadTabletServers.deadTabletServer; - } - /** * Adds new tservers to the list * diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/functions.js b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/functions.js index 7795ec4b0f5..0b1e5d4033c 100644 --- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/functions.js +++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/functions.js @@ -339,7 +339,7 @@ function doLoggedPostCall(call, callback, shouldSanitize) { * stores it on a sessionStorage variable */ function getManager() { - return getJSONForTable(contextPath + 'rest/manager', 'manager'); + return getJSONForTable(REST_V2_PREFIX + '/manager', 'manager'); } /** diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/manager.js b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/manager.js index 11a966e205e..f048fc666d0 100644 --- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/manager.js +++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/manager.js @@ -23,56 +23,29 @@ */ "use strict"; -var managerStatusTable, recoveryListTable; +var managerStatusTable, recoveryListTable, managerStatus; function refreshManagerBanners() { - getStatus().then(function () { - const managerStatus = JSON.parse(sessionStorage.status).managerStatus; - - // If manager status is error - if (managerStatus === 'ERROR') { - // show the manager error banner and hide table - $('#managerRunningBanner').show(); - $('#managerStatus_wrapper').hide(); - } else { - // otherwise, hide the error banner and show manager table - $('#managerRunningBanner').hide(); - $('#managerStatus_wrapper').show(); - } - }); - - getManager().then(function () { - const managerData = JSON.parse(sessionStorage.manager); - const managerState = managerData.managerState; - const managerGoalState = managerData.managerGoalState; - - const isStateGoalSame = managerState === managerGoalState; - - // if the manager state is normal and the goal state is the same as the current state, - // or of the manager is not running, hide the state banner and return early - if ((managerState === 'NORMAL' && isStateGoalSame) || managerState === null) { - $('#managerStateBanner').hide(); - return; - } - - // update the manager state banner message and show it - let bannerMessage = 'Manager state: ' + managerState; - if (!isStateGoalSame) { - // only show the goal state if it differs from the manager's current state - bannerMessage += '. Manager goal state: ' + managerGoalState; - } - $('#manager-banner-message').text(bannerMessage); - $('#managerStateBanner').show(); - }); - + // If manager status is error + if (managerStatus === 'ERROR') { + // show the manager error banner and hide manager table + $('#managerRunningBanner').show(); + $('#managerStatusTable').hide(); + } else { + // otherwise, hide the error banner and show manager table + $('#managerRunningBanner').hide(); + $('#managerStatusTable').show(); + } } /** * Populates tables with the new information */ function refreshManagerTables() { - ajaxReloadTable(managerStatusTable); refreshManagerBanners(); + if (managerStatus !== 'ERROR') { + ajaxReloadTable(managerStatusTable); + } ajaxReloadTable(recoveryListTable); } @@ -92,146 +65,106 @@ function refreshManagerTables() { */ $(function () { - // Generates the manager table - managerStatusTable = $('#managerStatus').DataTable({ - "ajax": { - "url": contextPath + 'rest/manager', - "dataSrc": function (json) { - // the data needs to be in an array to work with DataTables - var arr = [json]; - return arr; - } - }, - "stateSave": true, - "searching": false, - "paging": false, - "info": false, - "columnDefs": [{ - "targets": "big-num", - "render": function (data, type) { - if (type === 'display') { - data = bigNumberForQuantity(data); + getStatus().then(function () { + managerStatus = JSON.parse(sessionStorage.status).managerStatus; + if (managerStatus !== 'ERROR') { + // Generates the manager table + managerStatusTable = $('#managerStatusTable').DataTable({ + "ajax": { + "url": contextPath + 'rest-v2/manager', + "dataSrc": function (json) { + // the data needs to be in an array to work with DataTables + var arr = [json]; + return arr; } - return data; - } - }, - { - "targets": "big-num-rounded", - "render": function (data, type) { - if (type === 'display') { - data = bigNumberForQuantity(Math.round(data)); + }, + "stateSave": true, + "searching": false, + "paging": false, + "info": false, + "columnDefs": [{ + "targets": "timestamp", + "render": function (data, type) { + if (type === 'display') { + data = dateFormat(data); + } + return data; + } + }, + { + "targets": "metrics", + "orderable": false, + "render": function () { + return "Metrics"; + } } - return data; - } - }, - { - "targets": "duration", - "render": function (data, type) { - if (type === 'display') { - data = timeDuration(parseInt(data, 10)); + ], + "columns": [{ + "data": "host" + }, + { + "data": "resourceGroup" + }, + { + "data": "timestamp" + }, + { + "data": "metrics" + } + ] + }); + } + + // Generates the recovery table + recoveryListTable = $('#recoveryList').DataTable({ + "ajax": { + "url": contextPath + 'rest/tservers/recovery', + "dataSrc": function (data) { + data = data.recoveryList; + if (data.length === 0) { + console.info('Recovery list is empty, hiding recovery table'); + $('#recoveryList_wrapper').hide(); + } else { + $('#recoveryList_wrapper').show(); } return data; } - } - ], - "columns": [{ - "data": "manager" - }, - { - "data": "onlineTabletServers" }, - { - "data": "totalTabletServers" - }, - { - "data": "lastGC", - "type": "html", - "render": function (data, type) { - if (type === 'display') { - if (data !== 'Waiting') { - data = dateFormat(parseInt(data, 10)); + "columnDefs": [{ + "targets": "duration", + "render": function (data, type) { + if (type === 'display') { + data = timeDuration(parseInt(data, 10)); } - data = '' + data + ''; + return data; } - return data; - } - }, - { - "data": "tablets" - }, - { - "data": "unassignedTablets" - }, - { - "data": "numentries" - }, - { - "data": "ingestrate" - }, - { - "data": "entriesRead" - }, - { - "data": "queryrate" - }, - { - "data": "holdTime" - }, - { - "data": "osload" - }, - ] - }); - - // Generates the recovery table - recoveryListTable = $('#recoveryList').DataTable({ - "ajax": { - "url": contextPath + 'rest/tservers/recovery', - "dataSrc": function (data) { - data = data.recoveryList; - if (data.length === 0) { - console.info('Recovery list is empty, hiding recovery table'); - $('#recoveryList_wrapper').hide(); - } else { - $('#recoveryList_wrapper').show(); - } - return data; - } - }, - "columnDefs": [{ - "targets": "duration", - "render": function (data, type) { - if (type === 'display') { - data = timeDuration(parseInt(data, 10)); + }, + { + "targets": "percent", + "render": function (data, type) { + if (type === 'display') { + data = (data * 100).toFixed(2) + '%'; + } + return data; } - return data; } - }, - { - "targets": "percent", - "render": function (data, type) { - if (type === 'display') { - data = (data * 100).toFixed(2) + '%'; - } - return data; + ], + "stateSave": true, + "columns": [{ + "data": "server" + }, + { + "data": "log" + }, + { + "data": "time" + }, + { + "data": "progress" } - } - ], - "stateSave": true, - "columns": [{ - "data": "server" - }, - { - "data": "log" - }, - { - "data": "time" - }, - { - "data": "progress" - } - ] - }); + ] + }); - refreshManagerTables(); + refreshManagerTables(); + }); }); diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/navbar.js b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/navbar.js index 75593783369..fe6228566e3 100644 --- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/navbar.js +++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/navbar.js @@ -64,59 +64,47 @@ function updateElementStatus(elementId, status) { * @param {JSON} statusData object containing the status info for the servers */ function updateServerNotifications(statusData) { - getManager().then(function () { - - // gather information about the manager - const managerData = JSON.parse(sessionStorage.manager); - const managerState = managerData.managerState; - const managerGoalState = managerData.managerGoalState; - - const isSafeMode = managerState === 'SAFE_MODE' || managerGoalState === 'SAFE_MODE'; - const isCleanStop = managerState === 'CLEAN_STOP' || managerGoalState === 'CLEAN_STOP'; - - // setting manager status notification - if (statusData.managerStatus === STATUS.ERROR || isCleanStop) { - updateElementStatus('managerStatusNotification', STATUS.ERROR); - } else if (statusData.managerStatus === STATUS.WARN || isSafeMode) { - updateElementStatus('managerStatusNotification', STATUS.WARN); - } else if (statusData.managerStatus === STATUS.OK) { - updateElementStatus('managerStatusNotification', STATUS.OK); - } else { - console.error('Unrecognized manager state: ' + statusData.managerStatus + '. Could not properly set manager status notification.'); - } - - // setting tserver status notification - if (statusData.tServerStatus === STATUS.OK) { - updateElementStatus('serverStatusNotification', STATUS.OK); - } else if (statusData.tServerStatus === STATUS.WARN) { - updateElementStatus('serverStatusNotification', STATUS.WARN); - } else { - updateElementStatus('serverStatusNotification', STATUS.ERROR); - } + // setting manager status notification + if (statusData.managerStatus === STATUS.ERROR) { + updateElementStatus('managerStatusNotification', STATUS.ERROR); + } else if (statusData.managerStatus === STATUS.WARN) { + updateElementStatus('managerStatusNotification', STATUS.WARN); + } else if (statusData.managerStatus === STATUS.OK) { + updateElementStatus('managerStatusNotification', STATUS.OK); + } else { + console.error('Unrecognized manager state: ' + statusData.managerStatus + '. Could not properly set manager status notification.'); + } - // setting gc status notification - if (statusData.gcStatus === STATUS.OK) { - updateElementStatus('gcStatusNotification', STATUS.OK); - } else { - updateElementStatus('gcStatusNotification', STATUS.ERROR); - } + // setting tserver status notification + if (statusData.tServerStatus === STATUS.OK) { + updateElementStatus('serverStatusNotification', STATUS.OK); + } else if (statusData.tServerStatus === STATUS.WARN) { + updateElementStatus('serverStatusNotification', STATUS.WARN); + } else { + updateElementStatus('serverStatusNotification', STATUS.ERROR); + } - // Setting overall servers status notification - if ((statusData.managerStatus === STATUS.OK && !isSafeMode && !isCleanStop) && - statusData.tServerStatus === STATUS.OK && - statusData.gcStatus === STATUS.OK) { - updateElementStatus('statusNotification', STATUS.OK); - } else if (statusData.managerStatus === STATUS.ERROR || isCleanStop || - statusData.tServerStatus === STATUS.ERROR || - statusData.gcStatus === STATUS.ERROR) { - updateElementStatus('statusNotification', STATUS.ERROR); - } else if (statusData.managerStatus === STATUS.WARN || isSafeMode || - statusData.tServerStatus === STATUS.WARN || - statusData.gcStatus === STATUS.WARN) { - updateElementStatus('statusNotification', STATUS.WARN); - } + // setting gc status notification + if (statusData.gcStatus === STATUS.OK) { + updateElementStatus('gcStatusNotification', STATUS.OK); + } else { + updateElementStatus('gcStatusNotification', STATUS.ERROR); + } - }); + // Setting overall servers status notification + if (statusData.managerStatus === STATUS.OK && + statusData.tServerStatus === STATUS.OK && + statusData.gcStatus === STATUS.OK) { + updateElementStatus('statusNotification', STATUS.OK); + } else if (statusData.managerStatus === STATUS.ERROR || + statusData.tServerStatus === STATUS.ERROR || + statusData.gcStatus === STATUS.ERROR) { + updateElementStatus('statusNotification', STATUS.ERROR); + } else if (statusData.managerStatus === STATUS.WARN || + statusData.tServerStatus === STATUS.WARN || + statusData.gcStatus === STATUS.WARN) { + updateElementStatus('statusNotification', STATUS.WARN); + } } /** diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/overview.js b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/overview.js index f4a9b196793..c375d2e2b56 100644 --- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/overview.js +++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/overview.js @@ -29,40 +29,30 @@ $(function () { * Makes the REST calls, generates the table with the new information */ function refreshOverview() { - getManager().then(function () { - refreshManagerTable(); + getStatus().then(function () { + var managerStatus = JSON.parse(sessionStorage.status).managerStatus; + // If the manager is down, show only the first row, otherwise refresh old values + $('#manager tr td').hide(); + if (managerStatus === 'ERROR') { + $('#manager tr td:first').show(); + } else { + $('#manager tr td:not(:first)').show(); + refreshManagerTable(); + } }); } -/** - * Used to redraw the page - */ -function refresh() { - refreshOverview(); -} - /** * Refreshes the manager table */ function refreshManagerTable() { - var data = sessionStorage.manager === undefined ? [] : JSON.parse(sessionStorage.manager); - - $('#manager tr td:first').hide(); - $('#manager tr td').hide(); - - // If the manager is down, show the first row, otherwise refresh old values - if (data.length === 0 || data.manager === 'No Managers running') { - $('#manager tr td:first').show(); - } else { - $('#manager tr td:not(:first)').show(); + getManager().then(function () { + var data = JSON.parse(sessionStorage.manager); var table = $('#manager td.right'); - table.eq(0).html(bigNumberForQuantity(data.tables)); - table.eq(1).html(bigNumberForQuantity(data.totalTabletServers)); - table.eq(2).html(bigNumberForQuantity(data.deadTabletServersCount)); - table.eq(3).html(bigNumberForQuantity(data.tablets)); - table.eq(4).html(bigNumberForQuantity(data.numentries)); - table.eq(5).html(bigNumberForQuantity(data.lookups)); - table.eq(6).html(timeDuration(data.uptime)); - } + table.eq(0).html(data.host); + table.eq(1).html(data.resourceGroup); + table.eq(2).html(dateFormat(data.timestamp)); + table.eq(3).html('Metrics'); + }); } diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/systemAlert.js b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/systemAlert.js deleted file mode 100644 index 1aa876a6886..00000000000 --- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/systemAlert.js +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -"use strict"; - -/** - * Add new system-wide messages to this object. - */ -const alertMap = { - /** - * @property {string} message - The message to display within the alert banner. - * @property {string} id - Short string used to identify the message. - * @property {string} alertClass - The bootstrap class for which alert style to apply. - * @property {string} notificationClass - The color class to apply to the status notification in the navbar. - */ - CLEAN_STOP: { - message: "The manager state is CLEAN_STOP.", - id: "cleanStop", - alertClass: "alert-danger", - notificationClass: "error-inv" - }, - SAFE_MODE: { - message: "The manager state is SAFE_MODE.", - id: "safeMode", - alertClass: "alert-warning", - notificationClass: "warning-inv" - } -}; - -/** - * Idempotently append an alert message - */ -function appendAlertMessage(alertInfo) { - if (alertInfo && $('#' + alertInfo.id).length === 0) { - const li = $('
  • ').text(alertInfo.message).attr('id', alertInfo.id); - $("#alertMessages").append(li); - } -} - -function removeAlertMessage(alertInfo) { - if (alertInfo) { - $('#' + alertInfo.id).remove(); - } -} - -/** - * Set the class for system alert. - * - * @param {string} alertClass - Class to be applied to system alert. - */ -function setAlertClass(alertClass) { - $("#systemAlert").removeClass("alert-warning alert-danger").addClass(alertClass); -} - -/** - * Set the class for notification status. - * - * @param {string} notificationClass - Class to be applied to notification status. - */ -function setNotificationClass(notificationClass) { - $("#alertStatus").removeClass("warning error").addClass(notificationClass); -} - -function updateAlertVisibility() { - if ($("#alertMessages").children().length === 0) { - $("#systemAlert").hide(); - $("#alertStatus").hide(); - } else if (localStorage.getItem('alertDismissed') === 'true') { - $("#systemAlert").hide(); - } else { - $("#systemAlert").show(); - } -} - -/** - * Appends or removes an alert message based on the provided parameters. - * - * @param {string} alertType - Type of alert (e.g., 'CLEAN_STOP', 'SAFE_MODE'). - * @param {string} operation - Operation to perform ('apply' or 'remove'). - */ -function handleAlert(alertType, operation) { - const alertInfo = alertMap[alertType]; - switch (operation) { - case 'apply': - appendAlertMessage(alertInfo); - setAlertClass(alertInfo.alertClass); - setNotificationClass(alertInfo.notificationClass); - $("#alertStatus").show(); - break; - case 'remove': - removeAlertMessage(alertInfo); - break; - default: - console.error('Alert operation not recognized: ' + operation); - return; - } - - updateAlertVisibility(); -} - -function updateManagerAlerts() { - getManager().then(function () { - - // gather information about the manager - const managerData = JSON.parse(sessionStorage.manager); - const managerState = managerData.managerState; - const managerGoalState = managerData.managerGoalState; - - const isSafeMode = managerState === 'SAFE_MODE' || managerGoalState === 'SAFE_MODE'; - const isCleanStop = managerState === 'CLEAN_STOP' || managerGoalState === 'CLEAN_STOP'; - - const currentState = isCleanStop ? 'CLEAN_STOP' : isSafeMode ? 'SAFE_MODE' : null; - const prevStoredState = localStorage.getItem('currentState'); - - if (currentState !== prevStoredState) { - localStorage.removeItem('alertDismissed'); - localStorage.setItem('currentState', currentState); - } - - if (isCleanStop) { - handleAlert('SAFE_MODE', 'remove'); - handleAlert('CLEAN_STOP', 'apply'); - } else if (isSafeMode) { - handleAlert('CLEAN_STOP', 'remove'); - handleAlert('SAFE_MODE', 'apply'); - } else { - handleAlert('CLEAN_STOP', 'remove'); - handleAlert('SAFE_MODE', 'remove'); - } - }).catch(function () { - console.error('Failed to retrieve manager data'); - }) -} - -/** - * Pulls the neccesarry data then refreshes the system wide alert banner and status notification - */ -function updateSystemAlerts() { - updateManagerAlerts(); -} - -$(function () { - - // dismiss the alert when clicked - $('#systemAlertCloseButton').click(function () { - $("#systemAlert").hide(); - localStorage.setItem('alertDismissed', 'true'); - }); - - // when clicked, the status icon will bring the alert back up - $('#alertStatus').click(function () { - $("#systemAlert").show(); - localStorage.removeItem('alertDismissed'); - }); - - updateSystemAlerts(); -}); diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/tservers.js b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/tservers.js index 1d9b11384d1..d879c2d02b1 100644 --- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/tservers.js +++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/tservers.js @@ -18,12 +18,12 @@ */ /* JSLint global definitions */ /*global - $, document, sessionStorage, getTServers, clearDeadServers, refreshNavBar, - getRecoveryList, bigNumberForQuantity, timeDuration, dateFormat, ajaxReloadTable + $, sessionStorage, getTServers, getRecoveryList, bigNumberForQuantity, timeDuration, + ajaxReloadTable */ "use strict"; -var tserversTable, deadTServersTable, badTServersTable; +var tserversTable; var recoveryList = []; /** @@ -69,41 +69,11 @@ function refreshTServersTable() { ajaxReloadTable(tserversTable); } -/** - * Refreshes data in the deadtservers table - */ -function refreshDeadTServersTable() { - ajaxReloadTable(deadTServersTable); - - // Only show the table if there are non-empty rows - if ($('#deadtservers tbody .dataTables_empty').length) { - $('#deadtservers_wrapper').hide(); - } else { - $('#deadtservers_wrapper').show(); - } -} - -/** - * Refreshes data in the badtservers table - */ -function refreshBadTServersTable() { - ajaxReloadTable(badTServersTable); - - // Only show the table if there are non-empty rows - if ($('#badtservers tbody .dataTables_empty').length) { - $('#badtservers_wrapper').hide(); - } else { - $('#badtservers_wrapper').show(); - } -} - /** * Makes the REST calls, generates the tables with the new information */ function refreshTServers() { getTServers().then(function () { - refreshBadTServersTable(); - refreshDeadTServersTable(); refreshTServersTable(); }); } @@ -115,17 +85,6 @@ function refresh() { refreshTServers(); } -/** - * Makes the REST POST call to clear dead table server - * - * @param {string} server Dead TServer to clear - */ -function clearDeadTServers(server) { - clearDeadServers(server); - refreshTServers(); - refreshNavBar(); -} - /** * Creates initial tables */ @@ -260,68 +219,5 @@ $(function () { } }); - // Create a table for deadServers list - deadTServersTable = $('#deadtservers').DataTable({ - "ajax": { - "url": contextPath + 'rest/tservers', - "dataSrc": "deadServers" - }, - "stateSave": true, - "columnDefs": [{ - "targets": "date", - "render": function (data, type) { - if (type === 'display' && data > 0) { - data = dateFormat(data); - } - return data; - } - }], - "columns": [{ - "data": "server" - }, - { - "data": "lastStatus" - }, - { - "data": "status" - }, - { - "data": "server", - "type": "html", - "render": function (data, type) { - if (type === 'display') { - data = 'clear'; - } - return data; - } - } - ] - }); - - // Create a table for badServers list - badTServersTable = $('#badtservers').DataTable({ - "ajax": { - "url": contextPath + 'rest/tservers', - "dataSrc": "badServers" - }, - "stateSave": true, - "columnDefs": [{ - "targets": "date", - "render": function (data, type) { - if (type === 'display' && data > 0) { - data = dateFormat(data); - } - return data; - } - }], - "columns": [{ - "data": "id" - }, - { - "data": "status" - } - ] - }); - refreshTServers(); }); diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/default.ftl b/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/default.ftl index 3d802c533c9..24cf215268b 100644 --- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/default.ftl +++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/default.ftl @@ -58,7 +58,6 @@ - @@ -66,7 +65,6 @@ <#include "navbar.ftl">
    - <#include "systemAlert.ftl"> <#include "${template}">
    diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/manager.ftl b/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/manager.ftl index a26b3b4616a..1fae7a5931b 100644 --- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/manager.ftl +++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/manager.ftl @@ -26,25 +26,14 @@ - - +
    - - - - - - - - - - - - + + + + diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/overview.ftl b/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/overview.ftl index 1763c3f2a51..55a6f2cad55 100644 --- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/overview.ftl +++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/overview.ftl @@ -34,31 +34,19 @@ - + - + - + - - - - - - - - - - - - - + diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/systemAlert.ftl b/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/systemAlert.ftl deleted file mode 100644 index 94adc19a443..00000000000 --- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/systemAlert.ftl +++ /dev/null @@ -1,31 +0,0 @@ -<#-- - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - ---> - \ No newline at end of file diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/tservers.ftl b/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/tservers.ftl index 290fc0ce789..0a5904b102f 100644 --- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/tservers.ftl +++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/tservers.ftl @@ -49,33 +49,5 @@
    ${title}
    HostnameOnline TServers TotalTServers Last GCTabletsUnassigned Tablets EntriesIngestEntries ReadEntries ReturnedHold TimeOS LoadServerResource GroupLast ContactMetrics
    TablesServer
    Total Known Tablet ServersResource Group
    Dead Tablet ServersLast Contact
    Tablets
    Entries
    Lookups
    UptimeMetrics
    -
    - - - - - - - - - -
    Non-Functioning Tablet Servers
    - The following tablet servers reported a status other than Online.
    -
    ServerStatus
    -
    - - - - - - - - - - - -
    Dead Tablet Servers
    - The following tablet servers are no longer reachable.
    -
    ServerLast UpdatedEventClear
    From ceeab753f165abb13c8d54b1db4788b5bdae62aa Mon Sep 17 00:00:00 2001 From: Kevin Rathbun Date: Thu, 18 Sep 2025 16:47:06 -0400 Subject: [PATCH 2/6] removed unused declared dependency --- server/monitor/pom.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/server/monitor/pom.xml b/server/monitor/pom.xml index d92c06d8b12..4458c497480 100644 --- a/server/monitor/pom.xml +++ b/server/monitor/pom.xml @@ -100,10 +100,6 @@ org.apache.accumulo accumulo-start - - org.apache.commons - commons-lang3 - org.apache.logging.log4j log4j-web From 341963538ef1015f8ba070a92cb4fd4448a946a0 Mon Sep 17 00:00:00 2001 From: Kevin Rathbun Date: Tue, 7 Oct 2025 13:14:29 -0400 Subject: [PATCH 3/6] Minor fixes: - Fix error on using auto-refresh - Move REST_V2_PREFIX to top of script --- .../org/apache/accumulo/monitor/resources/js/functions.js | 3 +-- .../org/apache/accumulo/monitor/resources/js/navbar.js | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/functions.js b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/functions.js index 0b1e5d4033c..4ef7090ff85 100644 --- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/functions.js +++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/functions.js @@ -26,6 +26,7 @@ var QUANTITY_SUFFIX = ['', 'K', 'M', 'B', 'T', 'e15', 'e18', 'e21']; // Suffixes for size var SIZE_SUFFIX = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB']; +const REST_V2_PREFIX = contextPath + 'rest-v2'; /** * Initializes Auto Refresh to false if it is not set, @@ -462,8 +463,6 @@ function clearAllTableCells(tableId) { // NEW REST CALLS -const REST_V2_PREFIX = contextPath + 'rest-v2'; - /** * REST GET call for /problems, * stores it on a sessionStorage variable diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/navbar.js b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/navbar.js index fe6228566e3..2070a320659 100644 --- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/navbar.js +++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/navbar.js @@ -128,7 +128,6 @@ function refreshSidebar() { */ function refreshNavBar() { refreshSidebar(); - updateSystemAlerts(); } /** From d1c8630c9a5e8286a8e6d687c0a4daf9d12ad0c3 Mon Sep 17 00:00:00 2001 From: Kevin Rathbun Date: Thu, 16 Oct 2025 15:57:35 -0400 Subject: [PATCH 4/6] fixes issue with auto-refresh: Did not properly auto-refresh "/manager" and "/" pages when the manager was killed after the page was already loaded --- .../apache/accumulo/monitor/resources/js/manager.js | 13 ++++++++----- .../accumulo/monitor/resources/js/overview.js | 7 +++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/manager.js b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/manager.js index f048fc666d0..097de76cb7e 100644 --- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/manager.js +++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/manager.js @@ -42,11 +42,14 @@ function refreshManagerBanners() { * Populates tables with the new information */ function refreshManagerTables() { - refreshManagerBanners(); - if (managerStatus !== 'ERROR') { - ajaxReloadTable(managerStatusTable); - } - ajaxReloadTable(recoveryListTable); + getStatus().then(function () { + managerStatus = JSON.parse(sessionStorage.status).managerStatus; + refreshManagerBanners(); + if (managerStatus !== 'ERROR') { + ajaxReloadTable(managerStatusTable); + } + ajaxReloadTable(recoveryListTable); + }); } /* diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/overview.js b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/overview.js index c375d2e2b56..a0255e32c95 100644 --- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/overview.js +++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/overview.js @@ -42,6 +42,13 @@ function refreshOverview() { }); } +/** + * Used to redraw the page + */ +function refresh() { + refreshOverview(); +} + /** * Refreshes the manager table */ From 331c9d2d60559603dc141e162b4080ea3ef6a2ce Mon Sep 17 00:00:00 2001 From: Kevin Rathbun Date: Thu, 16 Oct 2025 16:03:43 -0400 Subject: [PATCH 5/6] trivial: avoid repeated call --- .../java/org/apache/accumulo/monitor/next/Endpoints.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/next/Endpoints.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/next/Endpoints.java index fdd89507956..58f45b55427 100644 --- a/server/monitor/src/main/java/org/apache/accumulo/monitor/next/Endpoints.java +++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/next/Endpoints.java @@ -156,9 +156,9 @@ public MetricResponse getManager() { @Produces(MediaType.APPLICATION_JSON) @Description("Returns the metrics for the Manager") public List getManagerMetrics() { - if (getManager().getMetrics() != null) { - return getManager().getMetrics().stream().map(FMetric::getRootAsFMetric) - .collect(Collectors.toList()); + var managerMetrics = getManager().getMetrics(); + if (managerMetrics != null) { + return managerMetrics.stream().map(FMetric::getRootAsFMetric).collect(Collectors.toList()); } return List.of(); } From a630f14a47f4d866ecec540a620af60a727de9cd Mon Sep 17 00:00:00 2001 From: Kevin Rathbun Date: Wed, 19 Nov 2025 12:42:49 -0500 Subject: [PATCH 6/6] Handle a couple edge cases: Handles a couple edge cases for /manager endpoint: - If manager is dead on first loading the page (in this case, no manager table is created), but later comes online and we are using the auto-refresh feature, previously would never create the manager table. auto-refresh will now create the table if it does not yet exist. - There was a case where /manager could result in a DataTables alert/error. If the manager was up but the endpoint used to get the table data was not yet available (small window where this could occur), a DataTables alert would occur. Handle this instead as a console log and populate the table with no data. --- .../accumulo/monitor/resources/js/manager.js | 109 ++++++++++-------- 1 file changed, 63 insertions(+), 46 deletions(-) diff --git a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/manager.js b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/manager.js index 097de76cb7e..b6519757394 100644 --- a/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/manager.js +++ b/server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/manager.js @@ -25,6 +25,63 @@ var managerStatusTable, recoveryListTable, managerStatus; +function createManagerTable() { + // Generates the manager table + managerStatusTable = $('#managerStatusTable').DataTable({ + "ajax": function (data, callback, settings) { + $.ajax({ + url: contextPath + 'rest-v2/manager', + method: 'GET' + }).done(function (json) { + callback({ + "data": [json] + }); + }).fail(function (jqXHR, textStatus, errorThrown) { + // This is needed if the url is not yet available, but the manager is up. E.g., Short + // window where a 404 could occur, which would lead to DataTables error/alert w/out fail() + console.error("DataTables Ajax error :", errorThrown); + callback({ + "data": [] + }); + }); + }, + "stateSave": true, + "searching": false, + "paging": false, + "info": false, + "columnDefs": [{ + "targets": "timestamp", + "render": function (data, type) { + if (type === 'display') { + data = dateFormat(data); + } + return data; + } + }, + { + "targets": "metrics", + "orderable": false, + "render": function () { + return "Metrics"; + } + } + ], + "columns": [{ + "data": "host" + }, + { + "data": "resourceGroup" + }, + { + "data": "timestamp" + }, + { + "data": "metrics" + } + ] + }); +} + function refreshManagerBanners() { // If manager status is error if (managerStatus === 'ERROR') { @@ -45,7 +102,11 @@ function refreshManagerTables() { getStatus().then(function () { managerStatus = JSON.parse(sessionStorage.status).managerStatus; refreshManagerBanners(); - if (managerStatus !== 'ERROR') { + if (managerStatusTable === undefined && managerStatus !== 'ERROR') { + // Can happen if the manager is dead on first loading the page, but later comes back online + // while using auto-refresh + createManagerTable(); + } else if (managerStatus !== 'ERROR') { ajaxReloadTable(managerStatusTable); } ajaxReloadTable(recoveryListTable); @@ -71,51 +132,7 @@ $(function () { getStatus().then(function () { managerStatus = JSON.parse(sessionStorage.status).managerStatus; if (managerStatus !== 'ERROR') { - // Generates the manager table - managerStatusTable = $('#managerStatusTable').DataTable({ - "ajax": { - "url": contextPath + 'rest-v2/manager', - "dataSrc": function (json) { - // the data needs to be in an array to work with DataTables - var arr = [json]; - return arr; - } - }, - "stateSave": true, - "searching": false, - "paging": false, - "info": false, - "columnDefs": [{ - "targets": "timestamp", - "render": function (data, type) { - if (type === 'display') { - data = dateFormat(data); - } - return data; - } - }, - { - "targets": "metrics", - "orderable": false, - "render": function () { - return "Metrics"; - } - } - ], - "columns": [{ - "data": "host" - }, - { - "data": "resourceGroup" - }, - { - "data": "timestamp" - }, - { - "data": "metrics" - } - ] - }); + createManagerTable(); } // Generates the recovery table