You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/02/01 18:52:57 UTC

[58/71] [abbrv] brooklyn-ui git commit: misc cleanups for HA and shutdown

misc cleanups for HA and shutdown

* HA list in GUI reports if data is stale (makes it obvious is some servers are likely dead)
* On "Clear HA nodes" false masters are removed (fix bug where lots of masters, including stale, aren't cleared)
* On shutdown, RebindManager.waitForPending wasn't doing the right thing when invoked by stop, meaning state wasn't being written (really bad if you click "stop all apps", as the final deletion isn't actually persisted!)


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/86fdc10e
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/86fdc10e
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/86fdc10e

Branch: refs/heads/0.7.0-incubating
Commit: 86fdc10e344a258133a8d9823465b21bdbeb2e66
Parents: 7680018
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Sat May 9 12:58:29 2015 +0100
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Sun May 10 10:02:33 2015 -0700

----------------------------------------------------------------------
 .../main/webapp/assets/js/view/ha-summary.js    | 98 ++++++++++++--------
 1 file changed, 60 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/86fdc10e/usage/jsgui/src/main/webapp/assets/js/view/ha-summary.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/view/ha-summary.js b/usage/jsgui/src/main/webapp/assets/js/view/ha-summary.js
index 2032d1d..250977e 100644
--- a/usage/jsgui/src/main/webapp/assets/js/view/ha-summary.js
+++ b/usage/jsgui/src/main/webapp/assets/js/view/ha-summary.js
@@ -29,10 +29,11 @@ define([
                 "<% if (nodeUri && !isTerminated) { %><a href='<%= nodeUri %>'><%= nodeId %></a><% } else { %><%= nodeId %><%    } %>" +
                 "<% if (isSelf) { %><span class='pull-right badge badge-success'>this</span><% } %>" +
             "</td>" +
-            "<td><%= status %></td>" +
+            "<td><% if (isPretendMaster) {%>EX-MASTER<%} else {%><%= status %><%} if (isStale) { %> (stale)<% } %></td>" +
             "<td><%= timestampDisplayPrefix %><span class='timestamp' data-timestamp='<%= timestamp %>'><%= timestampDisplay %><span><%= timestampDisplaySuffix %></td>" +
         "</tr>");
-    var noServers = "<tr><td colspan='3'><i>Failed to load servers!</i></td></tr>";
+    var noServers = "<tr><td colspan='3'><i>Failed to load data of servers</i></td></tr>";
+    var waitingServers = "<tr><td colspan='3'><i>Waiting on detail for servers...</i></td></tr>";
 
     var HASummaryView = Backbone.View.extend({
         initialize: function() {
@@ -49,53 +50,74 @@ define([
         },
         render: function() {
             this.$el.html(template());
-            if (serverStatus.loaded) {
-                this.renderNodeStatus();
-            }
+            this.renderNodeStatus();
             return this;
         },
         renderNodeStatus: function() {
+            var $target = this.$(".ha-summary-table-body");
+            if (!serverStatus.loaded) {
+                $target.html(waitingServers);
+                return;
+            }
+            
             var serverHa = serverStatus.get("ha") || {};
             var master = serverHa.masterId,
                 self = serverHa.ownId,
-                nodes = serverHa.nodes,
-                $target = this.$(".ha-summary-table-body");
-            $target.empty();
+                nodes = serverHa.nodes;
+                
             // undefined check just in case server returns something odd
             if (nodes == undefined || _.isEmpty(nodes)) {
                 $target.html(noServers);
-            } else {
-                _.each(nodes, function (n) {
-                    var node = _.clone(n);
-                    node.timestampDisplayPrefix = "";
-                    node.timestampDisplaySuffix = "";
-                    if (node['remoteTimestamp']) {
-                        node.timestamp = node.remoteTimestamp;
-                    } else {
-                        node.timestamp = node.localTimestamp;
-                        node.timestampDisplaySuffix = " (local)";
-                    }
-                    if (node.timestamp >= moment().utc() + 10*1000) {
-                        // if server reports time significantly in future, report this, with no timestampe
-                        node.timestampDisplayPrefix = "server clock in future by "+
-                            moment.duration(moment(node.timestamp).diff(moment())).humanize();
-                        node.timestamp = "";
-                        node.timestampDisplay = "";
-                    } else {
-                        // else use timestamp
-                        if (node.timestamp >= moment().utc()) {
-                            // but if just a little bit in future, backdate to show "a few seconds ago"
-                            node.timestamp = moment().utc()-1;
-                        }
-                        node.timestampDisplay = moment(node.timestamp).fromNow();
+                return;
+            }
+            
+            $target.empty();
+            var masterTimestamp;
+            _.each(nodes, function (n) {
+                    if (n.nodeId == master && n.remoteTimestamp) {
+                        masterTimestamp = n.remoteTimestamp;
                     }
-                    
-                    node.isSelf = node.nodeId == self;
-                    node.isMaster = self == master;
-                    node.isTerminated = node.status == "TERMINATED";
-                    $target.append(nodeRowTemplate(node));
                 });
-            }
+            
+            _.each(nodes, function (n) {
+                var node = _.clone(n);
+                node.timestampDisplayPrefix = "";
+                node.timestampDisplaySuffix = "";
+                if (node['remoteTimestamp']) {
+                    node.timestamp = node.remoteTimestamp;
+                } else {
+                    node.timestamp = node.localTimestamp;
+                    node.timestampDisplaySuffix = " (local)";
+                }
+                if (node.timestamp >= moment().utc() + 10*1000) {
+                    // if server reports time significantly in future, report this, with no timestampe
+                    node.timestampDisplayPrefix = "server clock in future by "+
+                        moment.duration(moment(node.timestamp).diff(moment())).humanize();
+                    node.timestamp = "";
+                    node.timestampDisplay = "";
+                } else {
+                    // else use timestamp
+                    if (node.timestamp >= moment().utc()) {
+                        // but if just a little bit in future, backdate to show "a few seconds ago"
+                        node.timestamp = moment().utc()-1;
+                    }
+                    node.timestampDisplay = moment(node.timestamp).fromNow();
+                }
+                
+                node.isSelf = node.nodeId == self;
+                node.isMaster = self == master;
+                if (node.status == "TERMINATED") {
+                    node.isTerminated = true;
+                    node.isPretendMaster = false;
+                    node.isStale = false;
+                } else {
+                    node.isTerminated = false;
+                    node.isPretendMaster = (!node.isMaster && node.status == "MASTER" && master != node.nodeId);
+                    node.isStale = (masterTimestamp && node.timestamp + 30*1000 < masterTimestamp);
+                }
+                 
+                $target.append(nodeRowTemplate(node));
+            });
         },
         updateTimestamps: function() {
             this.$(".timestamp").each(function(index, t) {