From 5980e5705d8469ed7a53050f785e8b278831b2ab Mon Sep 17 00:00:00 2001 From: Guus der Kinderen Date: Thu, 23 Dec 2021 15:04:34 +0100 Subject: [PATCH] for #162: Show warning for mismatched plugin on cluster When running in a cluster, and not all servers in the cluster have the same version of the Monitoring plugin loaded, behavior will be broken. This commit detects version mismatches, and displays a warning on the admin console. --- pom.xml | 2 +- src/i18n/monitoring_i18n.properties | 1 + src/web/archive-search.jsp | 16 ++++++++++++---- src/web/archiving-settings.jsp | 16 ++++++++++++++-- src/web/conversations.jsp | 12 ++++++++++++ src/web/stats-dashboard.jsp | 13 +++++++++++++ src/web/stats-reporter.jsp | 12 ++++++++++++ 7 files changed, 65 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 342f03e60..071af7145 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ plugins org.igniterealtime.openfire - 4.7.0-beta + 4.7.0-SNAPSHOT org.igniterealtime.openfire.plugins monitoring diff --git a/src/i18n/monitoring_i18n.properties b/src/i18n/monitoring_i18n.properties index f924c16e7..d9314f2e2 100644 --- a/src/i18n/monitoring_i18n.properties +++ b/src/i18n/monitoring_i18n.properties @@ -244,5 +244,6 @@ muc.conversation.joined={0} ({1}) has joined the room muc.conversation.left={0} ({1}) has left the room warning.httpbinding.disabled=The HTTP Binding service appears to be disabled! Web-based logs will not be accessible without this service. {0}Please enable the HTTP Binding service here!{1} +warning.clustering.versions=This Openfire server is part of a cluster. Not all servers in the cluster are running (the same version of) the Monitoring plugin. This will result in inconsistent behavior, possibly even errors. Please review {0}the version of the Monitoring plugin that is installed on each cluster node.{1} monitoring.search.allow-unrecognized-fields=If 'true', silently ignores unrecognized search filters in queries, which otherwise result in error responses. diff --git a/src/web/archive-search.jsp b/src/web/archive-search.jsp index ca3ded154..c64702052 100644 --- a/src/web/archive-search.jsp +++ b/src/web/archive-search.jsp @@ -1,9 +1,5 @@ <%@ page contentType="text/html; charset=UTF-8" %> <%@ page errorPage="/error.jsp" import="org.jivesoftware.openfire.plugin.MonitoringPlugin"%> -<%@ page import="org.jivesoftware.openfire.archive.ArchiveSearch" %> -<%@ page import="org.jivesoftware.openfire.archive.ArchiveSearcher" %> -<%@ page import="org.jivesoftware.openfire.archive.Conversation" %> -<%@ page import="org.jivesoftware.openfire.archive.ConversationManager" %> <%@ page import="org.jivesoftware.openfire.XMPPServer" %> <%@ page import="org.jivesoftware.openfire.user.UserNameManager" %> <%@ page import="org.jivesoftware.openfire.user.UserNotFoundException" %> @@ -15,6 +11,8 @@ <%@ page import="org.slf4j.Logger" %> <%@ page import="org.slf4j.LoggerFactory" %> <%@ page import="com.reucon.openfire.plugin.archive.xep.AbstractXepSupport" %> +<%@ page import="org.jivesoftware.openfire.archive.*" %> +<%@ page import="org.jivesoftware.openfire.cluster.ClusterManager" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> @@ -499,6 +497,16 @@ +<% if (!ClusterManager.findRemotePluginsWithDifferentVersion(MonitoringConstants.PLUGIN_NAME).isEmpty()) { %> +
+ + + + +
+
+<% } %> + " style="display:none;">
diff --git a/src/web/archiving-settings.jsp b/src/web/archiving-settings.jsp index 4af584ddc..f062d57e8 100644 --- a/src/web/archiving-settings.jsp +++ b/src/web/archiving-settings.jsp @@ -12,9 +12,10 @@ <%@ page import="java.util.Map" %> <%@ page import="com.reucon.openfire.plugin.archive.impl.MucIndexer" %> <%@ page import="org.jivesoftware.openfire.plugin.service.LogAPI" %> -<%@ page import="org.jivesoftware.util.*" %> <%@ page import="org.jivesoftware.openfire.http.HttpBindManager" %> <%@ page import="com.reucon.openfire.plugin.archive.impl.MessageIndexer" %> +<%@ page import="org.jivesoftware.openfire.archive.MonitoringConstants" %> +<%@ page import="org.jivesoftware.openfire.cluster.ClusterManager" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> @@ -310,7 +311,8 @@
"> -

+
+ <% if (errors.size() > 0) { %>
@@ -319,6 +321,16 @@
<% } %> +<% if (!ClusterManager.findRemotePluginsWithDifferentVersion(MonitoringConstants.PLUGIN_NAME).isEmpty()) { %> +
+ + + + +
+
+<% } %> +

diff --git a/src/web/conversations.jsp b/src/web/conversations.jsp index 826870320..6a8682b07 100644 --- a/src/web/conversations.jsp +++ b/src/web/conversations.jsp @@ -10,6 +10,8 @@ <%@ page import="org.jivesoftware.openfire.user.UserManager"%> <%@ page import="java.net.URLEncoder" %> <%@ page import="org.jivesoftware.util.StringUtils" %> +<%@ page import="org.jivesoftware.openfire.archive.MonitoringConstants" %> +<%@ page import="org.jivesoftware.openfire.cluster.ClusterManager" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> @@ -139,6 +141,16 @@ function updateConversations(data) { //# sourceURL=conversations.jsp +<% if (!ClusterManager.findRemotePluginsWithDifferentVersion(MonitoringConstants.PLUGIN_NAME).isEmpty()) { %> +
+ + + + +
+
+<% } %> +

diff --git a/src/web/stats-dashboard.jsp b/src/web/stats-dashboard.jsp index cb4d8940b..bad8c627f 100644 --- a/src/web/stats-dashboard.jsp +++ b/src/web/stats-dashboard.jsp @@ -16,6 +16,8 @@ <%@ page import="java.util.*"%> <%@ page import="org.jivesoftware.openfire.XMPPServer" %> <%@ page import="org.jivesoftware.openfire.plugin.MonitoringPlugin" %> +<%@ page import="org.jivesoftware.openfire.cluster.ClusterManager" %> +<%@ page import="org.jivesoftware.openfire.archive.MonitoringConstants" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> @@ -380,6 +382,17 @@ function createCookie(name,value,days) {

+ + <% if (!ClusterManager.findRemotePluginsWithDifferentVersion(MonitoringConstants.PLUGIN_NAME).isEmpty()) { %> +
+ + + + +
+
+ <% } %> +
diff --git a/src/web/stats-reporter.jsp b/src/web/stats-reporter.jsp index 7790c647d..3d7d40f52 100644 --- a/src/web/stats-reporter.jsp +++ b/src/web/stats-reporter.jsp @@ -11,6 +11,8 @@ <%@ page import="java.util.List"%> <%@ page import="org.jivesoftware.openfire.plugin.MonitoringPlugin" %> <%@ page import="org.jivesoftware.openfire.XMPPServer" %> +<%@ page import="org.jivesoftware.openfire.cluster.ClusterManager" %> +<%@ page import="org.jivesoftware.openfire.archive.MonitoringConstants" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> @@ -281,6 +283,16 @@ +<% if (!ClusterManager.findRemotePluginsWithDifferentVersion(MonitoringConstants.PLUGIN_NAME).isEmpty()) { %> +
+ + + + +
+
+<% } %> +