You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2015/10/07 15:51:59 UTC
[18/31] ambari git commit: AMBARI-13317 API call to load Host
Component links on Service dashboard should be independent of metrics.
(atkach)
AMBARI-13317 API call to load Host Component links on Service dashboard should be independent of metrics. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/aeebae6e
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/aeebae6e
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/aeebae6e
Branch: refs/heads/branch-dev-patch-upgrade
Commit: aeebae6eb7609398c807360985724e1310829681
Parents: e672501
Author: Andrii Tkach <at...@hortonworks.com>
Authored: Tue Oct 6 11:19:39 2015 +0300
Committer: Andrii Tkach <at...@hortonworks.com>
Committed: Tue Oct 6 11:19:39 2015 +0300
----------------------------------------------------------------------
.../controllers/global/cluster_controller.js | 2 +
.../app/controllers/global/update_controller.js | 99 ++++++++++++--------
.../global/wizard_watcher_controller.js | 4 +
.../global/update_controller_test.js | 57 +++++++----
.../global/wizard_watcher_controller_test.js | 13 +++
5 files changed, 117 insertions(+), 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/aeebae6e/ambari-web/app/controllers/global/cluster_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/cluster_controller.js b/ambari-web/app/controllers/global/cluster_controller.js
index b6dba0e..f4c2837 100644
--- a/ambari-web/app/controllers/global/cluster_controller.js
+++ b/ambari-web/app/controllers/global/cluster_controller.js
@@ -249,6 +249,8 @@ App.ClusterController = Em.Controller.extend(App.ReloadPopupMixin, {
// service metrics loading doesn't affect overall progress
updater.updateServiceMetric(function () {
self.set('isServiceMetricsLoaded', true);
+ // make second call, because first is light since it doesn't request host-component metrics
+ updater.updateServiceMetric(Em.K);
// components config loading doesn't affect overall progress
updater.updateComponentConfig(function () {
self.set('isComponentsConfigLoaded', true);
http://git-wip-us.apache.org/repos/asf/ambari/blob/aeebae6e/ambari-web/app/controllers/global/update_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/update_controller.js b/ambari-web/app/controllers/global/update_controller.js
index 69deb74..0d003ca 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -39,6 +39,47 @@ App.UpdateController = Em.Controller.extend({
paginationKeys: ['page_size', 'from'],
/**
+ * @type {Array}
+ */
+ serviceComponentMetrics: [
+ 'host_components/metrics/jvm/memHeapUsedM',
+ 'host_components/metrics/jvm/HeapMemoryMax',
+ 'host_components/metrics/jvm/HeapMemoryUsed',
+ 'host_components/metrics/jvm/memHeapCommittedM',
+ 'host_components/metrics/mapred/jobtracker/trackers_decommissioned',
+ 'host_components/metrics/cpu/cpu_wio',
+ 'host_components/metrics/rpc/RpcQueueTime_avg_time',
+ 'host_components/metrics/dfs/FSNamesystem/*',
+ 'host_components/metrics/dfs/namenode/Version',
+ 'host_components/metrics/dfs/namenode/LiveNodes',
+ 'host_components/metrics/dfs/namenode/DeadNodes',
+ 'host_components/metrics/dfs/namenode/DecomNodes',
+ 'host_components/metrics/dfs/namenode/TotalFiles',
+ 'host_components/metrics/dfs/namenode/UpgradeFinalized',
+ 'host_components/metrics/dfs/namenode/Safemode',
+ 'host_components/metrics/runtime/StartTime'
+ ],
+
+ /**
+ * @type {object}
+ */
+ serviceSpecificParams: {
+ 'FLUME': "host_components/processes/HostComponentProcess",
+ 'YARN': "host_components/metrics/yarn/Queue," +
+ "host_components/metrics/yarn/ClusterMetrics/NumActiveNMs," +
+ "host_components/metrics/yarn/ClusterMetrics/NumLostNMs," +
+ "host_components/metrics/yarn/ClusterMetrics/NumUnhealthyNMs," +
+ "host_components/metrics/yarn/ClusterMetrics/NumRebootedNMs," +
+ "host_components/metrics/yarn/ClusterMetrics/NumDecommissionedNMs",
+ 'HBASE': "host_components/metrics/hbase/master/IsActiveMaster," +
+ "host_components/metrics/hbase/master/MasterStartTime," +
+ "host_components/metrics/hbase/master/MasterActiveTime," +
+ "host_components/metrics/hbase/master/AverageLoad," +
+ "host_components/metrics/master/AssignmentManger/ritCount",
+ 'STORM': 'metrics/api/v1/cluster/summary,metrics/api/v1/topology/summary,metrics/api/v1/nimbus/summary'
+ },
+
+ /**
* @type {string}
*/
HOSTS_TEST_URL: '/data/hosts/HDP2/hosts.json',
@@ -409,22 +450,6 @@ App.UpdateController = Em.Controller.extend({
'host_components/HostRoles/stale_configs,' +
'host_components/HostRoles/ha_state,' +
'host_components/HostRoles/desired_admin_state,' +
- 'host_components/metrics/jvm/memHeapUsedM,' +
- 'host_components/metrics/jvm/HeapMemoryMax,' +
- 'host_components/metrics/jvm/HeapMemoryUsed,' +
- 'host_components/metrics/jvm/memHeapCommittedM,' +
- 'host_components/metrics/mapred/jobtracker/trackers_decommissioned,' +
- 'host_components/metrics/cpu/cpu_wio,' +
- 'host_components/metrics/rpc/RpcQueueTime_avg_time,' +
- 'host_components/metrics/dfs/FSNamesystem/*,' +
- 'host_components/metrics/dfs/namenode/Version,' +
- 'host_components/metrics/dfs/namenode/LiveNodes,' +
- 'host_components/metrics/dfs/namenode/DeadNodes,' +
- 'host_components/metrics/dfs/namenode/DecomNodes,' +
- 'host_components/metrics/dfs/namenode/TotalFiles,' +
- 'host_components/metrics/dfs/namenode/UpgradeFinalized,' +
- 'host_components/metrics/dfs/namenode/Safemode,' +
- 'host_components/metrics/runtime/StartTime' +
conditionalFieldsString +
'&minimal_response=true';
@@ -438,8 +463,8 @@ App.UpdateController = Em.Controller.extend({
App.HttpClient.get(servicesUrl, App.serviceMetricsMapper, {
complete: function () {
App.set('router.mainServiceItemController.isServicesInfoLoaded', App.get('router.clusterController.isLoaded'));
- callback();
requestsRunningStatus["updateServiceMetric"] = false;
+ callback();
}
});
} else {
@@ -451,37 +476,33 @@ App.UpdateController = Em.Controller.extend({
* @return {Array}
*/
getConditionalFields: function () {
- var conditionalFields = [];
- var stormMetric = 'metrics/api/v1/cluster/summary,metrics/api/v1/topology/summary,metrics/api/v1/nimbus/summary';
+ var conditionalFields = this.get('serviceComponentMetrics').slice(0);
+ var serviceSpecificParams = $.extend({}, this.get('serviceSpecificParams'));
+ var metricsKey = 'metrics/';
+
if (/^2.1/.test(App.get('currentStackVersionNumber'))) {
- stormMetric = 'metrics/api/cluster/summary';
+ serviceSpecificParams['STORM'] = 'metrics/api/cluster/summary';
} else if (/^2.2/.test(App.get('currentStackVersionNumber'))) {
- stormMetric = 'metrics/api/v1/cluster/summary,metrics/api/v1/topology/summary';
+ serviceSpecificParams['STORM'] = 'metrics/api/v1/cluster/summary,metrics/api/v1/topology/summary';
}
- var serviceSpecificParams = {
- 'FLUME': "host_components/processes/HostComponentProcess",
- 'YARN': "host_components/metrics/yarn/Queue," +
- "host_components/metrics/yarn/ClusterMetrics/NumActiveNMs," +
- "host_components/metrics/yarn/ClusterMetrics/NumLostNMs," +
- "host_components/metrics/yarn/ClusterMetrics/NumUnhealthyNMs," +
- "host_components/metrics/yarn/ClusterMetrics/NumRebootedNMs," +
- "host_components/metrics/yarn/ClusterMetrics/NumDecommissionedNMs",
- 'HBASE': "host_components/metrics/hbase/master/IsActiveMaster," +
- "host_components/metrics/hbase/master/MasterStartTime," +
- "host_components/metrics/hbase/master/MasterActiveTime," +
- "host_components/metrics/hbase/master/AverageLoad," +
- "host_components/metrics/master/AssignmentManger/ritCount",
- 'STORM': stormMetric
- };
- var services = App.cache['services'];
- services.forEach(function (service) {
+
+ App.cache['services'].forEach(function (service) {
var urlParams = serviceSpecificParams[service.ServiceInfo.service_name];
if (urlParams) {
conditionalFields.push(urlParams);
}
});
+
+ //first load shouldn't contain metrics in order to make call lighter
+ if (!App.get('router.clusterController.isServiceMetricsLoaded')) {
+ return conditionalFields.filter(function (condition) {
+ return (condition.indexOf(metricsKey) === -1);
+ });
+ }
+
return conditionalFields;
},
+
updateServices: function (callback) {
var testUrl = '/data/services/HDP2/services.json';
var componentConfigUrl = this.getUrl(testUrl, '/services?fields=ServiceInfo/state,ServiceInfo/maintenance_state,components/ServiceComponentInfo/component_name&minimal_response=true');
@@ -496,6 +517,7 @@ App.UpdateController = Em.Controller.extend({
complete: callback
});
},
+
updateComponentsState: function (callback) {
var testUrl = '/data/services/HDP2/components_state.json';
var realUrl = '/components/?fields=ServiceComponentInfo/service_name,' +
@@ -506,6 +528,7 @@ App.UpdateController = Em.Controller.extend({
complete: callback
});
},
+
updateAlertDefinitions: function (callback) {
var testUrl = '/data/alerts/alertDefinitions.json';
var realUrl = '/alert_definitions?fields=' +
http://git-wip-us.apache.org/repos/asf/ambari/blob/aeebae6e/ambari-web/app/controllers/global/wizard_watcher_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/wizard_watcher_controller.js b/ambari-web/app/controllers/global/wizard_watcher_controller.js
index e9cd958..438e41a 100644
--- a/ambari-web/app/controllers/global/wizard_watcher_controller.js
+++ b/ambari-web/app/controllers/global/wizard_watcher_controller.js
@@ -103,5 +103,9 @@ App.WizardWatcherController = Em.Controller.extend(App.UserPref, {
this.set('wizardUser', data.userName);
this.set('controllerName', data.controllerName);
}
+ },
+
+ getUserPrefErrorCallback: function () {
+ this.resetUser();
}
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/aeebae6e/ambari-web/test/controllers/global/update_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/global/update_controller_test.js b/ambari-web/test/controllers/global/update_controller_test.js
index 83f0630..e8d4353 100644
--- a/ambari-web/test/controllers/global/update_controller_test.js
+++ b/ambari-web/test/controllers/global/update_controller_test.js
@@ -72,7 +72,7 @@ describe('App.UpdateController', function () {
{
title: 'No services exist',
services: [],
- result: []
+ result: ['metrics/1']
},
{
title: 'HDFS service',
@@ -83,7 +83,7 @@ describe('App.UpdateController', function () {
}
}
],
- result: []
+ result: ['metrics/1']
},
{
title: 'FLUME service',
@@ -94,7 +94,7 @@ describe('App.UpdateController', function () {
}
}
],
- result: ["host_components/processes/HostComponentProcess"]
+ result: ['metrics/1', "host_components/processes/HostComponentProcess"]
},
{
title: 'YARN service',
@@ -105,7 +105,7 @@ describe('App.UpdateController', function () {
}
}
],
- result: ["host_components/metrics/yarn/Queue," +
+ result: ['metrics/1', "host_components/metrics/yarn/Queue," +
"host_components/metrics/yarn/ClusterMetrics/NumActiveNMs," +
"host_components/metrics/yarn/ClusterMetrics/NumLostNMs," +
"host_components/metrics/yarn/ClusterMetrics/NumUnhealthyNMs," +
@@ -121,7 +121,7 @@ describe('App.UpdateController', function () {
}
}
],
- result: ["host_components/metrics/hbase/master/IsActiveMaster," +
+ result: ['metrics/1', "host_components/metrics/hbase/master/IsActiveMaster," +
"host_components/metrics/hbase/master/MasterStartTime," +
"host_components/metrics/hbase/master/MasterActiveTime," +
"host_components/metrics/hbase/master/AverageLoad," +
@@ -136,9 +136,9 @@ describe('App.UpdateController', function () {
}
}
],
- result: ["metrics/api/v1/cluster/summary," +
- "metrics/api/v1/topology/summary," +
- "metrics/api/v1/nimbus/summary"]
+ result: ['metrics/1', "metrics/api/v1/cluster/summary," +
+ "metrics/api/v1/topology/summary," +
+ "metrics/api/v1/nimbus/summary"]
}
];
@@ -153,7 +153,7 @@ describe('App.UpdateController', function () {
}
],
stackVersionNumber: '2.1',
- result: ["metrics/api/cluster/summary"]
+ result: ['metrics/1', "metrics/api/cluster/summary"]
},
{
title: 'STORM service stack 2.2',
@@ -165,7 +165,7 @@ describe('App.UpdateController', function () {
}
],
stackVersionNumber: '2.2',
- result: ["metrics/api/v1/cluster/summary,metrics/api/v1/topology/summary"]
+ result: ['metrics/1', "metrics/api/v1/cluster/summary,metrics/api/v1/topology/summary"]
},
{
title: 'STORM service stack 2.3',
@@ -177,28 +177,45 @@ describe('App.UpdateController', function () {
}
],
stackVersionNumber: '2.3',
- result: ["metrics/api/v1/cluster/summary,metrics/api/v1/topology/summary,metrics/api/v1/nimbus/summary"]
+ result: ['metrics/1', "metrics/api/v1/cluster/summary,metrics/api/v1/topology/summary,metrics/api/v1/nimbus/summary"]
}
];
- testCases.forEach(function(test){
+
+ beforeEach(function () {
+ this.mock = sinon.stub(App, 'get');
+ controller.set('serviceComponentMetrics', ['metrics/1']);
+ });
+ afterEach(function () {
+ this.mock.restore();
+ });
+ testCases.forEach(function (test) {
it(test.title, function () {
App.cache['services'] = test.services;
+ this.mock.withArgs('router.clusterController.isServiceMetricsLoaded').returns(true);
expect(controller.getConditionalFields()).to.eql(test.result);
});
});
- testCasesByStackVersion.forEach(function(test) {
- it(test.title, function() {
+ testCasesByStackVersion.forEach(function (test) {
+ it(test.title, function () {
App.cache['services'] = test.services;
- sinon.stub(App, 'get', function(key) {
- if (key == 'currentStackVersionNumber') {
- return test.stackVersionNumber;
- }
- });
+ this.mock.withArgs('currentStackVersionNumber').returns(test.stackVersionNumber);
+ this.mock.withArgs('router.clusterController.isServiceMetricsLoaded').returns(true);
expect(controller.getConditionalFields()).to.eql(test.result);
- App.get.restore();
});
});
+
+ it('FLUME service, first load', function () {
+ App.cache['services'] = [
+ {
+ ServiceInfo: {
+ service_name: 'FLUME'
+ }
+ }
+ ];
+ this.mock.withArgs('router.clusterController.isServiceMetricsLoaded').returns(false);
+ expect(controller.getConditionalFields()).to.eql(["host_components/processes/HostComponentProcess"]);
+ });
});
describe("#getComplexUrl()", function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/aeebae6e/ambari-web/test/controllers/global/wizard_watcher_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/global/wizard_watcher_controller_test.js b/ambari-web/test/controllers/global/wizard_watcher_controller_test.js
index 4afc70f..7c72977 100644
--- a/ambari-web/test/controllers/global/wizard_watcher_controller_test.js
+++ b/ambari-web/test/controllers/global/wizard_watcher_controller_test.js
@@ -148,4 +148,17 @@ describe('App.wizardWatcherController', function () {
expect(controller.get('controllerName')).to.equal('ctrl1');
});
});
+
+ describe("#getUserPrefErrorCallback()", function() {
+ beforeEach(function () {
+ sinon.stub(controller, 'resetUser', Em.K);
+ });
+ afterEach(function () {
+ controller.resetUser.restore();
+ });
+ it("reset wizard-data", function() {
+ controller.getUserPrefErrorCallback();
+ expect(controller.resetUser.calledOnce).to.be.true;
+ });
+ });
});