From 18d5502d6db298b0a1dc344a69cb49e45d0c33a4 Mon Sep 17 00:00:00 2001 From: Howard Gao Date: Tue, 18 Jun 2019 17:36:29 +0800 Subject: [PATCH] ARTEMIS-1825 Live-backup topology not correctly displayed on console Second commit. The topology shown on backup's console is not yet correct. This fixes the problem. --- .../main/webapp/plugin/js/brokerDiagram.js | 67 ++++++++++++++----- 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/brokerDiagram.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/brokerDiagram.js index 180c22fde8..dc7f35d4a6 100644 --- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/brokerDiagram.js +++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/brokerDiagram.js @@ -448,32 +448,69 @@ var ARTEMIS = (function(ARTEMIS) { ARTEMISService.artemisConsole.getRemoteBrokers(mBean, containerJolokia, onSuccess(function (properties) { remoteBrokers = properties.value; - ARTEMIS.log.info("remoteBrokers=" + angular.toJson(remoteBrokers)) - angular.forEach(angular.fromJson(remoteBrokers), function (remoteBroker) { - if (remoteBroker) { - ARTEMIS.log.info("remote=" + angular.toJson(remoteBroker)) - if (broker.nodeId != remoteBroker.nodeID) { - getOrAddBroker(true, "\"" + remoteBroker.live + "\"", remoteBroker.nodeID, "remote", null, properties); - addLinkIds("broker:" + broker.brokerId, "broker:" + "\"" + remoteBroker.live + "\"", "network"); + var remoteBrokersObj = angular.fromJson(remoteBrokers); - var backup = remoteBroker.backup; - if (backup) { - getOrAddBroker(false, "\"" + backup + "\"", remoteBroker.nodeID, "remote", null, properties); - addLinkIds("broker:" + "\"" + remoteBroker.live + "\"", "broker:" + "\"" + backup + "\"", "network"); + var newBackReq = ARTEMISService.artemisConsole.isBackup(jolokia, mBean); + var newBackup = newBackReq.value; + + angular.forEach(remoteBrokersObj, function (remoteBroker) { + if (broker.nodeId != remoteBroker.nodeID) { + if (remoteBroker.live) { + getOrAddBroker(true, "\"" + remoteBroker.live + "\"", remoteBroker.nodeID, "remote", null, properties); + } + if (remoteBroker.backup) { + getOrAddBroker(false, "\"" + remoteBroker.backup + "\"", remoteBroker.nodeID, "remote", null, properties); + } + } else { + if (!newBackup) { + getOrAddBroker(false, "\"" + remoteBroker.backup + "\"", remoteBroker.nodeID, "remote", null, properties); + } else { + getOrAddBroker(true, "\"" + remoteBroker.live + "\"", remoteBroker.nodeID, "remote", null, properties); + } + } + }); + + var processedLiveBrokers = []; + angular.forEach(remoteBrokersObj, function (remoteBroker) { + if (remoteBroker) { + if (remoteBroker.live) { + angular.forEach(processedLiveBrokers, function(livebroker) { + //because the local broker has a different id format we need to identify it + if (broker.nodeId == livebroker.nodeID) { + if (!newBackup) { + addLinkIds("broker:" + broker.brokerId, "broker:" + "\"" + remoteBroker.live + "\"", "network"); + } else { + //I am backup + addLinkIds("broker:" + "\"" + livebroker.live + "\"", "broker:" + "\"" + remoteBroker.live + "\"", "network"); + } + } else if (broker.nodeId == remoteBroker.nodeID) { + if (!newBackup) { + addLinkIds("broker:" + broker.brokerId, "broker:" + "\"" + livebroker.live + "\"", "network"); + } else { + //I am backup + addLinkIds("broker:" + "\"" + livebroker.live + "\"", "broker:" + "\"" + remoteBroker.live + "\"", "network"); + } + } else { + addLinkIds("broker:" + "\"" + livebroker.live + "\"", "broker:" + "\"" + remoteBroker.live + "\"", "network"); + } + }); + processedLiveBrokers.push(remoteBroker); + } + + //now backups + if (broker.nodeId != remoteBroker.nodeID) { + if (remoteBroker.backup) { + addLinkIds("broker:" + "\"" + remoteBroker.live + "\"", "broker:" + "\"" + remoteBroker.backup + "\"", "network"); } } else { - var newBackReq = ARTEMISService.artemisConsole.isBackup(jolokia, mBean); - var newBackup = newBackReq.value; if (!newBackup) { if (remoteBroker.backup) { - getOrAddBroker(false, "\"" + remoteBroker.backup + "\"", remoteBroker.nodeID, "remote", null, properties); addLinkIds("broker:" + broker.brokerId, "broker:" + "\"" + remoteBroker.backup + "\"", "network"); } } else { //I am backup - getOrAddBroker(true, "\"" + remoteBroker.live + "\"", remoteBroker.nodeID, "remote", null, properties); addLinkIds("broker:" + broker.brokerId, "broker:" + "\"" + remoteBroker.live + "\"", "network"); } }