You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2017/09/04 21:21:27 UTC
qpid-broker-j git commit: QPID-7772: [Java Broker] Add generic
statistics panel to the Broker tab
Repository: qpid-broker-j
Updated Branches:
refs/heads/master 4018399ac -> 195413ef7
QPID-7772: [Java Broker] Add generic statistics panel to the Broker tab
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/195413ef
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/195413ef
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/195413ef
Branch: refs/heads/master
Commit: 195413ef7285a9f89a84d5baefc32052af51977d
Parents: 4018399
Author: Keith Wall <ke...@gmail.com>
Authored: Fri Aug 18 20:32:56 2017 +0100
Committer: Keith Wall <ke...@gmail.com>
Committed: Mon Sep 4 22:20:02 2017 +0100
----------------------------------------------------------------------
.../java/resources/common/StatisticsWidget.html | 27 +++
.../js/qpid/common/StatisticsWidget.js | 236 +++++++++++++++++++
.../java/resources/js/qpid/common/metadata.js | 20 ++
.../java/resources/js/qpid/management/Broker.js | 15 +-
.../src/main/java/resources/showBroker.html | 4 +-
5 files changed, 300 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/195413ef/broker-plugins/management-http/src/main/java/resources/common/StatisticsWidget.html
----------------------------------------------------------------------
diff --git a/broker-plugins/management-http/src/main/java/resources/common/StatisticsWidget.html b/broker-plugins/management-http/src/main/java/resources/common/StatisticsWidget.html
new file mode 100644
index 0000000..e882780
--- /dev/null
+++ b/broker-plugins/management-http/src/main/java/resources/common/StatisticsWidget.html
@@ -0,0 +1,27 @@
+<!--
+ ~
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ ~
+ -->
+<div>
+ <div data-dojo-type="dijit.TitlePane" data-dojo-props="title: 'Statistics', open: false" data-dojo-attach-point="statisticsPane">
+ <div data-dojo-attach-point="cumulativeStatisticsGridContainer"></div>
+ <br/>
+ <div data-dojo-attach-point="pointInTimeStatisticsGridContainer"></div>
+ </div>
+</div>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/195413ef/broker-plugins/management-http/src/main/java/resources/js/qpid/common/StatisticsWidget.js
----------------------------------------------------------------------
diff --git a/broker-plugins/management-http/src/main/java/resources/js/qpid/common/StatisticsWidget.js b/broker-plugins/management-http/src/main/java/resources/js/qpid/common/StatisticsWidget.js
new file mode 100644
index 0000000..bd4d6bb
--- /dev/null
+++ b/broker-plugins/management-http/src/main/java/resources/js/qpid/common/StatisticsWidget.js
@@ -0,0 +1,236 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+define(["qpid/common/UpdatableStore",
+ "qpid/common/formatter",
+ "dojox/grid/EnhancedGrid",
+ "dojo/_base/declare",
+ "dojo/_base/array",
+ "dojo/_base/lang",
+ "dojo/_base/connect",
+ "dojo/on",
+ "dojo/mouse",
+ "dojo/number",
+ "dijit/_WidgetBase",
+ "dijit/Tooltip",
+ "dijit/registry",
+ "dojo/text!common/StatisticsWidget.html",
+ "dojo/domReady!"],
+ function (UpdatableStore,
+ formatter,
+ EnhancedGrid,
+ declare,
+ array,
+ lang,
+ connect,
+ on,
+ mouse,
+ number,
+ _WidgetBase,
+ Tooltip,
+ registry,
+ template) {
+
+ return declare("qpid.common.StatisticsWidget",
+ [dijit._WidgetBase, dijit._TemplatedMixin, dijit._WidgetsInTemplateMixin],
+ {
+ //Strip out the apache comment header from the template html as comments unsupported.
+ templateString: template.replace(/<!--[\s\S]*?-->/g, ""),
+
+ cumulativeStatisticsGridContainer: null,
+ pointInTimeStatisticsGridContainer: null,
+ statisticsPane: null,
+
+ category: null,
+ type: null,
+ management: null,
+
+ _grid: null,
+ _sampleTime: null,
+ _previousSampleTime: null,
+
+ postCreate: function () {
+ this.inherited(arguments);
+
+ this.userPreferences = this.management.userPreferences;
+
+ this.cumulativeStatisticsGrid =
+ new UpdatableStore([], this.cumulativeStatisticsGridContainer, [{
+ name: "Name",
+ field: "label",
+ width: "50%"
+ }, {
+ name: "Value",
+ fields: ["value","units"],
+ width: "25%",
+ formatter: lang.hitch(this, this._formatValue)
+ }, {
+ name: "Rate",
+ fields: ["value", "previousValue", "units"],
+ width: "25%",
+ formatter: lang.hitch(this, this._formatRate)
+ }], null, {}, EnhancedGrid);
+
+ this.pointInTimeStatisticsGrid =
+ new UpdatableStore([], this.pointInTimeStatisticsGridContainer, [{
+ name: "Name",
+ field: "label",
+ width: "50%"
+ }, {
+ name: "Value",
+ fields: ["value","units"],
+ width: "50%",
+ formatter: lang.hitch(this, this._formatValue)
+ }], null, {}, EnhancedGrid);
+
+ var metadata = this.management.metadata;
+ var type = this.type ? this.type : this.category;
+ var cumulativeStatistics = metadata.getStatisticsMetadata(this.category, type, "CUMULATIVE");
+ var pointInTimeStatistics = metadata.getStatisticsMetadata(this.category, type, "POINT_IN_TIME");
+ var augmentedCumulativeStatistics = this._augmentStatisticsForDisplay(cumulativeStatistics);
+ var augmentedPointInTimeStatistics = this._augmentStatisticsForDisplay(pointInTimeStatistics);
+
+ this.cumulativeStatisticsGrid.grid.beginUpdate();
+ this.cumulativeStatisticsGrid.update(augmentedCumulativeStatistics);
+ this.cumulativeStatisticsGrid.grid.endUpdate();
+
+ this.pointInTimeStatisticsGrid.grid.beginUpdate();
+ this.pointInTimeStatisticsGrid.update(augmentedPointInTimeStatistics);
+ this.pointInTimeStatisticsGrid.grid.endUpdate();
+
+ connect.connect(this.statisticsPane, "toggle", lang.hitch(this, this.resize));
+ connect.connect(this.cumulativeStatisticsGrid.grid, "onCellMouseOver", lang.hitch(this, function(e)
+ {
+ this._addDynamicTooltipToGridRow(e, augmentedCumulativeStatistics);
+ }));
+ connect.connect(this.pointInTimeStatisticsGrid.grid, "onCellMouseOver", lang.hitch(this, function(e)
+ {
+ this._addDynamicTooltipToGridRow(e, augmentedPointInTimeStatistics);
+ }));
+ },
+ _formatRate : function (fields)
+ {
+ if (this._previousSampleTime)
+ {
+ var value = fields[0] ? fields[0] : 0;
+ var previousValue = fields[1] ? fields[1] : 0;
+ var units = fields[2];
+
+ var samplePeriod = this._sampleTime.getTime() - this._previousSampleTime.getTime();
+
+ var rate = number.round((1000 * (value - previousValue)) / samplePeriod);
+
+ if (units === "BYTES")
+ {
+ return formatter.formatBytes(rate) + "/s";
+ }
+ else if (units === "MESSAGES")
+ {
+ return "" + rate + " msg/s"
+ }
+ else
+ {
+ return "" + rate + " Δs"
+ }
+ }
+ return "N/A";
+ },
+ _formatValue : function (fields) {
+ var value = fields[0] ? fields[0] : 0;
+ var units = fields[1];
+ if (units === "BYTES")
+ {
+ return formatter.formatBytes(value);
+ }
+ else if (units === "MESSAGES")
+ {
+ return "" + value + " msg"
+ }
+ else if (units === "ABSOLUTE_TIME")
+ {
+ return this.userPreferences.formatDateTime(value, {
+ addOffset: true,
+ appendTimeZone: true
+ });
+ }
+ else
+ {
+ return value;
+ }
+ },
+ resize: function ()
+ {
+ this.inherited(arguments);
+ this.cumulativeStatisticsGrid.grid.resize();
+ this.pointInTimeStatisticsGrid.grid.resize();
+ },
+ update: function (statistics)
+ {
+ this._previousSampleTime = this._sampleTime;
+ this._sampleTime = new Date();
+
+ this.cumulativeStatisticsGrid.grid.beginUpdate();
+ this._updateStoreData(statistics, this.cumulativeStatisticsGrid.store.data);
+ this.cumulativeStatisticsGrid.grid.endUpdate();
+
+ this.pointInTimeStatisticsGrid.grid.beginUpdate();
+ this._updateStoreData(statistics, this.pointInTimeStatisticsGrid.store.data);
+ this.pointInTimeStatisticsGrid.grid.endUpdate();
+ },
+ _updateStoreData: function (statistics, data) {
+ array.forEach(data, function (storeItem) {
+ storeItem["previousValue"] = storeItem["value"];
+ storeItem["value"] = statistics[storeItem.id];
+ }, this);
+ },
+ _augmentStatisticsForDisplay : function(statItems)
+ {
+ var items = [];
+ array.forEach(statItems, function(statItem) {
+ var item = lang.mixin(statItem,
+ {id: statItem.name,
+ value: null,
+ previousValue: null});
+ items.push(item);
+
+ }, this);
+ items.sort(function(x,y) {return ((x.label === y.label) ? 0 : ((x.label > y.label) ? 1 : -1 ))});
+ return items;
+ },
+ destroy: function ()
+ {
+ this.inherited(arguments);
+ this.cumulativeStatisticsGrid.close();
+ this.pointInTimeStatisticsGrid.close();
+ },
+ _addDynamicTooltipToGridRow: function(e, data)
+ {
+ var tip = data[e.rowIndex];
+ if (tip && tip.description)
+ {
+ Tooltip.show(tip.description, e.rowNode);
+ on.once(e.rowNode, mouse.leave, function()
+ {
+ Tooltip.hide(e.rowNode);
+ });
+ }
+ }
+ });
+ });
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/195413ef/broker-plugins/management-http/src/main/java/resources/js/qpid/common/metadata.js
----------------------------------------------------------------------
diff --git a/broker-plugins/management-http/src/main/java/resources/js/qpid/common/metadata.js b/broker-plugins/management-http/src/main/java/resources/js/qpid/common/metadata.js
index 4ed26be..a2b0c2f 100644
--- a/broker-plugins/management-http/src/main/java/resources/js/qpid/common/metadata.js
+++ b/broker-plugins/management-http/src/main/java/resources/js/qpid/common/metadata.js
@@ -32,6 +32,26 @@ define(["dojo/_base/array", "dojox/lang/functional/object"], function (array, fo
return null;
};
+ Metadata.prototype.getStatisticsMetadata = function (category, type, statisticType)
+ {
+ var metadata = this.getMetaData(category, type);
+ if (metadata && metadata.statistics)
+ {
+ var filteredStatItems = [];
+ fobject.forIn(metadata.statistics, function(statItem) {
+ if (statItem.statisticType === statisticType)
+ {
+ filteredStatItems.push(statItem);
+ }
+ }, this);
+ return filteredStatItems;
+ }
+ else
+ {
+ return [];
+ }
+ };
+
Metadata.prototype.getDefaultValueForAttribute = function (category, type, attributeName)
{
var metaDataForInstance = this.getMetaData(category, type);
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/195413ef/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 68f99f8..65b0389 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
@@ -21,6 +21,7 @@
define(["dojo/parser",
"dojo/query",
"dojo/json",
+ "dojo/dom",
"dojo/_base/lang",
"dojo/_base/event",
"dojo/_base/connect",
@@ -57,10 +58,12 @@ define(["dojo/parser",
"dijit/form/DropDownButton",
"dijit/Menu",
"dijit/MenuItem",
+ "qpid/common/StatisticsWidget",
"dojo/domReady!"],
function (parser,
query,
json,
+ dom,
lang,
event,
connect,
@@ -375,6 +378,13 @@ define(["dojo/parser",
this.controller = brokerTab.controller;
this.brokerObj = brokerTab.modelObj;
this.contentPane = brokerTab.contentPane;
+ this.brokerStatistics = new qpid.common.StatisticsWidget({
+ category: "Broker",
+ type: null,
+ management: this.controller.management
+ });
+ this.brokerStatistics.placeAt(dom.byId("showBroker.statistics"));
+
this.accessControlProvidersWarn = query(".broker-access-control-providers-warning", node)[0];
this.management = this.controller.management;
var that = this;
@@ -889,7 +899,7 @@ define(["dojo/parser",
BrokerUpdater.prototype.showVirtualHost = function (item)
{
this.controller.showById(item.vhId);
- }
+ };
BrokerUpdater.prototype.updateHeader = function ()
{
@@ -980,6 +990,9 @@ define(["dojo/parser",
}
}
}
+ that.brokerStatistics.update(that.brokerData.statistics);
+ that.brokerStatistics.resize();
+
util.flattenStatistics(that.brokerData);
that.updateHeader();
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/195413ef/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 4d0df82..e176292 100644
--- a/broker-plugins/management-http/src/main/java/resources/showBroker.html
+++ b/broker-plugins/management-http/src/main/java/resources/showBroker.html
@@ -73,7 +73,9 @@
</div>
</div>
</div>
- </div>
+ <br/>
+ <div id="showBroker.statistics"></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-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org