Repository: qpid-broker-j
Updated Branches:
  refs/heads/master efb35e571 -> 67aa48fd5


QPID-7881: [Java Broker] [WMC] Expose broker restart operation


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/67aa48fd
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/67aa48fd
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/67aa48fd

Branch: refs/heads/master
Commit: 67aa48fd5069778c3dff86443eda47d75e852974
Parents: efb35e5
Author: Keith Wall <keith.w...@gmail.com>
Authored: Wed Aug 9 07:49:06 2017 +0100
Committer: Keith Wall <keith.w...@gmail.com>
Committed: Wed Aug 9 07:49:06 2017 +0100

----------------------------------------------------------------------
 .../java/resources/js/qpid/common/updater.js    |  9 ++-
 .../java/resources/js/qpid/management/Broker.js | 41 ++++++++++
 .../resources/js/qpid/management/Management.js  | 12 +--
 .../src/main/java/resources/showBroker.html     | 83 +++++++++++---------
 4 files changed, 99 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/67aa48fd/broker-plugins/management-http/src/main/java/resources/js/qpid/common/updater.js
----------------------------------------------------------------------
diff --git 
a/broker-plugins/management-http/src/main/java/resources/js/qpid/common/updater.js
 
b/broker-plugins/management-http/src/main/java/resources/js/qpid/common/updater.js
index aa71540..8c84ace 100644
--- 
a/broker-plugins/management-http/src/main/java/resources/js/qpid/common/updater.js
+++ 
b/broker-plugins/management-http/src/main/java/resources/js/qpid/common/updater.js
@@ -20,7 +20,7 @@
  */
 define([], function ()
 {
-    var updateList = new Array();
+    var updateList = [];
 
     function invokeUpdates()
     {
@@ -56,7 +56,6 @@ define([], function ()
         {
             updateList.push(obj);
         },
-
         remove: function (obj)
         {
             for (var i = 0; i < updateList.length; i++)
@@ -68,12 +67,16 @@ define([], function ()
                 }
             }
         },
-
         restartTimer: function()
         {
             clearInterval(timer);
             invokeUpdates();
             timer = setInterval(invokeUpdates, 1000 * updatePeriod);
+        },
+        cancel: function()
+        {
+            updateList = [];
+            clearInterval(timer);
         }
     };
 });

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/67aa48fd/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js
----------------------------------------------------------------------
diff --git 
a/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js
 
b/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js
index cda12be..b7dfa23 100644
--- 
a/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js
+++ 
b/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js
@@ -22,14 +22,17 @@ define(["dojo/parser",
         "dojo/query",
         "dojo/json",
         "dojo/_base/lang",
+        "dojo/_base/event",
         "dojo/_base/connect",
         "dojo/store/Memory",
         "dojo/promise/all",
+        "dojo/request/xhr",
         "qpid/common/properties",
         "qpid/common/updater",
         "qpid/common/util",
         "qpid/common/UpdatableStore",
         "dojox/grid/EnhancedGrid",
+        "dojox/widget/Standby",
         "dijit/registry",
         "dojox/html/entities",
         "qpid/management/addAuthenticationProvider",
@@ -59,14 +62,17 @@ define(["dojo/parser",
               query,
               json,
               lang,
+              event,
               connect,
               memory,
               all,
+              xhr,
               properties,
               updater,
               util,
               UpdatableStore,
               EnhancedGrid,
+              Standby,
               registry,
               entities,
               addAuthenticationProvider,
@@ -85,6 +91,7 @@ define(["dojo/parser",
                                     "operatingSystem",
                                     "platform",
                                     "productVersion",
+                                    "processPid",
                                     "modelVersion",
                                     "statisticsReportingPeriod",
                                     "statisticsReportingResetEnabled",
@@ -185,6 +192,12 @@ define(["dojo/parser",
                         {
                             editBroker.show(that.management, 
that.brokerUpdater.brokerData);
                         });
+                        var restartButton = query(".restartBroker", 
contentPane.containerNode)[0];
+                        connect.connect(registry.byNode(restartButton), 
"onClick", function (evt)
+                        {
+                            that.restartBroker();
+                            event.stop(evt);
+                        });
 
                         var addKeystoreButton = query(".addKeystore", 
contentPane.containerNode)[0];
                         connect.connect(registry.byNode(addKeystoreButton), 
"onClick", function (evt)
@@ -304,6 +317,34 @@ define(["dojo/parser",
             }
         };
 
+        Broker.prototype.restartBroker = function ()
+        {
+            if (confirm("Warning! Restart will disconnect all applications and 
logoff all users, including you."
+                        + " All messaging operations will be interrupted until 
applications reconnect."
+                        + " Are you certain you wish to proceed?"))
+            {
+                this.management.post({url: 
this.management.objectToURL(this.modelObj) + "/restart"}, {})
+                    .then(lang.hitch(this, function ()
+                    {
+                        updater.cancel();
+                        var standby = new Standby({target: dojo.body()});
+                        document.body.appendChild(standby.domNode);
+                        standby.startup();
+                        standby.show();
+                        var pollUrl = this.management.getFullUrl("/");
+                        var logout = function ()
+                        {
+                            window.location = "logout";
+                        };
+                        var ping = function ()
+                        {
+                            xhr(pollUrl, {method: "GET"}).then(logout, ping);
+                        };
+                        var timer = setInterval(lang.hitch(this, ping), 5000);
+                    }));
+            }
+        };
+
         Broker.prototype.close = function ()
         {
             updater.remove(this.brokerUpdater);

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/67aa48fd/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Management.js
----------------------------------------------------------------------
diff --git 
a/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Management.js
 
b/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Management.js
index 4471f52..703525b 100644
--- 
a/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Management.js
+++ 
b/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Management.js
@@ -344,7 +344,7 @@ define(["dojo/_base/lang",
             {
                 window.location = url;
             }, 100);
-        }
+        };
 
         // summary:
         //  Downloads current JSON for object specified as modelObj argument 
into iframe
@@ -356,7 +356,7 @@ define(["dojo/_base/lang",
             document.body.appendChild(iframe);
             iframe.src = url;
             // It seems there is no way to remove this iframe in a manner that 
is cross browser compatible.
-        }
+        };
 
         // summary:
         //  Builds relative REST url (excluding schema, host and port) for the 
object representing CO hierarchy
@@ -377,9 +377,9 @@ define(["dojo/_base/lang",
         Management.prototype.objectToURL = function (modelObj)
         {
             var url = null;
-            if (modelObj.type == "broker")
+            if (modelObj.type === "broker")
             {
-                url = "broker"
+                url = "broker";
             }
             else
             {
@@ -392,7 +392,7 @@ define(["dojo/_base/lang",
 
                 if (modelObj.name)
                 {
-                    if (url.substring(url.length - 1) != "/")
+                    if (url.substring(url.length - 1) !== "/")
                     {
                         url = url + "/";
                     }
@@ -468,7 +468,7 @@ define(["dojo/_base/lang",
                 url = url + "?" + ioQuery.objectToQuery(parameters);
             }
             return this.getFullUrl(url);
-        }
+        };
 
         // summary:
         //  Returns full REST url for the relative REST url

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/67aa48fd/broker-plugins/management-http/src/main/java/resources/showBroker.html
----------------------------------------------------------------------
diff --git 
a/broker-plugins/management-http/src/main/java/resources/showBroker.html 
b/broker-plugins/management-http/src/main/java/resources/showBroker.html
index cb32cb0..cd7f20f 100644
--- a/broker-plugins/management-http/src/main/java/resources/showBroker.html
+++ b/broker-plugins/management-http/src/main/java/resources/showBroker.html
@@ -19,45 +19,54 @@
  -
  -->
 <div class="broker">
-    <div data-dojo-type="dijit.TitlePane" data-dojo-props="title: 'Broker 
Attributes',  open: false">
-        <div id="brokerAttributes" class="clear">
-             <div id="brokerAttribute.name.container" class="clear">
-                <div class="formLabel-labelCell">Broker name:</div>
-                <div id="brokerAttribute.name"></div>
+    <div data-dojo-type="dijit.TitlePane" data-dojo-props="title: 'Broker',  
open: false">
+        <div data-dojo-type="dijit.TitlePane" data-dojo-props="title: 'Broker 
Attributes',  open: true">
+            <div id="brokerAttributes" class="clear">
+                 <div id="brokerAttribute.name.container" class="clear">
+                    <div class="formLabel-labelCell">Broker name:</div>
+                    <div id="brokerAttribute.name"></div>
+                </div>
+                <div id="brokerAttribute.operatingSystem.container" 
class="clear">
+                    <div class="formLabel-labelCell">Operating system:</div>
+                    <div id="brokerAttribute.operatingSystem"></div>
+                </div>
+                <div id="brokerAttribute.platform.container" class="clear">
+                    <div class="formLabel-labelCell">Platform:</div>
+                    <div id="brokerAttribute.platform"></div>
+                </div>
+                <div id="brokerAttribute.productVersion.container" 
class="clear">
+                    <div class="formLabel-labelCell">Broker version:</div>
+                    <div id="brokerAttribute.productVersion"></div>
+                </div>
+                <div id="brokerAttribute.modelVersion.container" class="clear">
+                    <div class="formLabel-labelCell">Broker model 
version:</div>
+                    <div id="brokerAttribute.modelVersion"></div>
+                </div>
+                <div id="brokerAttribute.processPid.container" class="clear">
+                    <div class="formLabel-labelCell">PID:</div>
+                    <div id="brokerAttribute.processPid"></div>
+                </div>
+                <div 
id="brokerAttribute.confidentialConfigurationEncryptionProvider.container" 
class="clear">
+                    <div class="formLabel-labelCell">Config Encryption:</div>
+                    <div 
id="brokerAttribute.confidentialConfigurationEncryptionProvider"></div>
+                </div>
+                <div id="brokerAttribute.statisticsReportingPeriod.container" 
class="hidden clear">
+                    <div class="formLabel-labelCell">Statistics reporting 
period (s):</div>
+                    <div id="brokerAttribute.statisticsReportingPeriod"></div>
+                </div>
+                <div 
id="brokerAttribute.statisticsReportingResetEnabled.container" class="hidden 
clear">
+                    <div class="formLabel-labelCell">Statistics reporting 
auto-reset enabled:</div>
+                    <div 
id="brokerAttribute.statisticsReportingResetEnabled"></div>
+                </div>
+                <div class="clear"></div>
             </div>
-            <div id="brokerAttribute.operatingSystem.container" class="clear">
-                <div class="formLabel-labelCell">Operation system:</div>
-                <div id="brokerAttribute.operatingSystem"></div>
-            </div>
-            <div id="brokerAttribute.platform.container" class="clear">
-                <div class="formLabel-labelCell">Platform:</div>
-                <div id="brokerAttribute.platform"></div>
-            </div>
-            <div id="brokerAttribute.productVersion.container" class="clear">
-                <div class="formLabel-labelCell">Broker version:</div>
-                <div id="brokerAttribute.productVersion"></div>
-            </div>
-            <div id="brokerAttribute.modelVersion.container" class="clear">
-                <div class="formLabel-labelCell">Broker model version:</div>
-                <div id="brokerAttribute.modelVersion"></div>
-            </div>
-            <div 
id="brokerAttribute.confidentialConfigurationEncryptionProvider.container" 
class="clear">
-                <div class="formLabel-labelCell">Config Encryption:</div>
-                <div 
id="brokerAttribute.confidentialConfigurationEncryptionProvider"></div>
-            </div>
-            <div id="brokerAttribute.statisticsReportingPeriod.container" 
class="hidden clear">
-                <div class="formLabel-labelCell">Statistics reporting period 
(s):</div>
-                <div id="brokerAttribute.statisticsReportingPeriod"></div>
-            </div>
-            <div 
id="brokerAttribute.statisticsReportingResetEnabled.container" class="hidden 
clear">
-                <div class="formLabel-labelCell">Statistics reporting 
auto-reset enabled:</div>
-                <div 
id="brokerAttribute.statisticsReportingResetEnabled"></div>
-            </div>
-            <div class="clear"></div>
+            <br/>
         </div>
-        <br/>
-        <button data-dojo-type="dijit.form.Button" 
class="editBroker">Edit</button>
-    </div>
+        <div class="dijitDialogPaneActionBar">
+            <button data-dojo-type="dijit.form.Button" 
class="editBroker">Edit</button>
+            <button data-dojo-type="dijit.form.Button" 
class="restartBroker">Restart</button>
+        </div>
+   </div>
     <br/>
     <div data-dojo-type="dijit.TitlePane" data-dojo-props="title: 'Virtual 
Hosts'">
         <div class="broker-virtualhosts"></div>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org
For additional commands, e-mail: commits-h...@qpid.apache.org

Reply via email to