Repository: ignite
Updated Branches:
  refs/heads/master 4e6727fe4 -> 08fff5e71


IGNITE-9807 Web Agent: Added support for cluster ID.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/08fff5e7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/08fff5e7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/08fff5e7

Branch: refs/heads/master
Commit: 08fff5e71309d4c6bdf295f0d6bc041a30753de5
Parents: 4e6727f
Author: Andrey Novikov <[email protected]>
Authored: Mon Oct 8 09:47:00 2018 +0700
Committer: Alexey Kuznetsov <[email protected]>
Committed: Mon Oct 8 09:47:00 2018 +0700

----------------------------------------------------------------------
 .../web-console/backend/app/agentsHandler.js    |  3 ++-
 .../app/modules/agent/AgentManager.service.js   |  4 ----
 .../console/agent/handlers/ClusterListener.java | 20 ++++++++++++++++++--
 3 files changed, 20 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/08fff5e7/modules/web-console/backend/app/agentsHandler.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/app/agentsHandler.js 
b/modules/web-console/backend/app/agentsHandler.js
index 6d8c621..8d72ded 100644
--- a/modules/web-console/backend/app/agentsHandler.js
+++ b/modules/web-console/backend/app/agentsHandler.js
@@ -87,7 +87,8 @@ module.exports.factory = function(settings, mongo, 
AgentSocket) {
         constructor(top) {
             const clusterName = top.clusterName;
 
-            this.id = _.isEmpty(clusterName) ? `Cluster ${uuid().substring(0, 
8).toUpperCase()}` : clusterName;
+            this.id = _.isEmpty(top.clusterId) ? uuid() : top.clusterId;
+            this.name = _.isEmpty(clusterName) ? `Cluster 
${this.id.substring(0, 8).toUpperCase()}` : clusterName;
             this.nids = top.nids;
             this.addresses = top.addresses;
             this.clients = top.clients;

http://git-wip-us.apache.org/repos/asf/ignite/blob/08fff5e7/modules/web-console/frontend/app/modules/agent/AgentManager.service.js
----------------------------------------------------------------------
diff --git 
a/modules/web-console/frontend/app/modules/agent/AgentManager.service.js 
b/modules/web-console/frontend/app/modules/agent/AgentManager.service.js
index f667374..aeb5f2b 100644
--- a/modules/web-console/frontend/app/modules/agent/AgentManager.service.js
+++ b/modules/web-console/frontend/app/modules/agent/AgentManager.service.js
@@ -73,10 +73,6 @@ class ConnectionState {
     }
 
     update(demo, count, clusters) {
-        _.forEach(clusters, (cluster) => {
-            cluster.name = cluster.id;
-        });
-
         this.clusters = clusters;
 
         if (_.isEmpty(this.clusters))

http://git-wip-us.apache.org/repos/asf/ignite/blob/08fff5e7/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/ClusterListener.java
----------------------------------------------------------------------
diff --git 
a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/ClusterListener.java
 
b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/ClusterListener.java
index 1c93798..98a7d0f 100644
--- 
a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/ClusterListener.java
+++ 
b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/ClusterListener.java
@@ -74,6 +74,9 @@ public class ClusterListener implements AutoCloseable {
     /** */
     private static final IgniteProductVersion IGNITE_2_3 = 
IgniteProductVersion.fromString("2.3.0");
 
+    /** Optional Ignite cluster ID. */
+    public static final String IGNITE_CLUSTER_ID = "IGNITE_CLUSTER_ID";
+
     /** Unique Visor key to get events last order. */
     private static final String EVT_LAST_ORDER_KEY = "WEB_AGENT_" + 
UUID.randomUUID().toString();
 
@@ -189,6 +192,9 @@ public class ClusterListener implements AutoCloseable {
     /** */
     private static class TopologySnapshot {
         /** */
+        private String clusterId;
+
+        /** */
         private String clusterName;
 
         /** */
@@ -242,6 +248,9 @@ public class ClusterListener implements AutoCloseable {
 
                 Map<String, Object> attrs = node.getAttributes();
 
+                if (F.isEmpty(clusterId))
+                    clusterId = attribute(attrs, IGNITE_CLUSTER_ID);
+
                 if (F.isEmpty(clusterName))
                     clusterName = attribute(attrs, IGNITE_CLUSTER_NAME);
 
@@ -269,6 +278,13 @@ public class ClusterListener implements AutoCloseable {
         }
 
         /**
+         * @return Cluster id.
+         */
+        public String getClusterId() {
+            return clusterId;
+        }
+
+        /**
          * @return Cluster name.
          */
         public String getClusterName() {
@@ -384,11 +400,11 @@ public class ClusterListener implements AutoCloseable {
                     sesTok = res.getSessionToken();
 
                     return res;
-                    
+
                 case STATUS_FAILED:
                     if (res.getError().startsWith(EXPIRED_SES_ERROR_MSG)) {
                         sesTok = null;
-                        
+
                         params.remove("sessionToken");
 
                         return restCommand(params);

Reply via email to