You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2015/03/04 19:07:10 UTC
ambari git commit: AMBARI-9930. Namenode HA wizard: on Finalize HA
setup request load task logs (alexantonenko)
Repository: ambari
Updated Branches:
refs/heads/trunk 3db526ca9 -> a6a5618c7
AMBARI-9930. Namenode HA wizard: on Finalize HA setup request load task logs (alexantonenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/a6a5618c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a6a5618c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a6a5618c
Branch: refs/heads/trunk
Commit: a6a5618c798860a5ac9df56db7c48dee051ef2e5
Parents: 3db526c
Author: Alex Antonenko <hi...@gmail.com>
Authored: Wed Mar 4 19:36:16 2015 +0200
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Wed Mar 4 20:07:03 2015 +0200
----------------------------------------------------------------------
ambari-web/app/assets/test/tests.js | 1 +
.../progress_popup_controller.js | 48 ++++++-
.../resourceManager/step3_controller.js | 6 +
.../wizard/wizardProgressPageController.js | 2 +-
ambari-web/app/utils/ajax/ajax.js | 4 +-
ambari-web/app/utils/host_progress_popup.js | 47 ++++++-
.../progress_popup_controller_test.js | 140 +++++++++++++++++++
7 files changed, 238 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/a6a5618c/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index 78ea459..e6f6264 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -58,6 +58,7 @@ var files = ['test/init_model_test',
'test/controllers/main/admin/serviceAccounts_controller_test',
'test/controllers/main/admin/highAvailability_controller_test',
'test/controllers/main/admin/highAvailability/progress_controller_test',
+ 'test/controllers/main/admin/highAvailability/progress_popup_controller_test',
'test/controllers/main/admin/highAvailability/nameNode/step3_controller_test',
'test/controllers/main/admin/highAvailability/nameNode/step4_controller_test',
'test/controllers/main/admin/highAvailability/resourceManager/step3_controller_test',
http://git-wip-us.apache.org/repos/asf/ambari/blob/a6a5618c/ambari-web/app/controllers/main/admin/highAvailability/progress_popup_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/highAvailability/progress_popup_controller.js b/ambari-web/app/controllers/main/admin/highAvailability/progress_popup_controller.js
index 9c9302a..3441723 100644
--- a/ambari-web/app/controllers/main/admin/highAvailability/progress_popup_controller.js
+++ b/ambari-web/app/controllers/main/admin/highAvailability/progress_popup_controller.js
@@ -68,6 +68,10 @@ App.HighAvailabilityProgressPopupController = Ember.Controller.extend({
*/
spinnerPopup: null,
+ isTaskPolling: false,
+
+ taskInfo: null,
+
/**
* Get info for <code>requestIds</code> and initialize <code>App.HostPopup</code>
* @param popupTitle {String}
@@ -102,8 +106,8 @@ App.HighAvailabilityProgressPopupController = Ember.Controller.extend({
getHosts: function () {
var requestIds = this.get('requestIds');
var stageId = this.get('stageId');
- var name = 'admin.high_availability.polling';
- if (stageId) {
+ var name = 'background_operations.get_by_request';
+ if (!Em.isNone(stageId)) {
name = 'common.request.polling';
}
requestIds.forEach(function (requestId) {
@@ -215,6 +219,46 @@ App.HighAvailabilityProgressPopupController = Ember.Controller.extend({
}
});
return result;
+ },
+
+ startTaskPolling: function (requestId, taskId) {
+ this.setProperties({
+ isTaskPolling: true,
+ taskInfo: {
+ id: taskId,
+ requestId: requestId
+ }
+ });
+ App.updater.run(this, 'updateTask', 'isTaskPolling', App.bgOperationsUpdateInterval);
+ App.updater.immediateRun('updateTask');
+ },
+
+ stopTaskPolling: function () {
+ this.set('isTaskPolling', false);
+ },
+
+ updateTask: function (callback) {
+ App.ajax.send({
+ name: 'background_operations.get_by_task',
+ sender: this,
+ data: {
+ requestId: this.get('taskInfo.requestId'),
+ taskId: this.get('taskInfo.id')
+ },
+ success: 'updateTaskSuccessCallback',
+ callback: callback
+ })
+ },
+
+ updateTaskSuccessCallback: function (data) {
+ this.setProperties({
+ 'taskInfo.stderr': data.Tasks.stderr,
+ 'taskInfo.stdout': data.Tasks.stdout,
+ 'taskInfo.outputLog': data.Tasks.output_log,
+ 'taskInfo.errorLog': data.Tasks.error_log,
+ 'isTaskPolling': !['FAILED', 'COMPLETED', 'TIMEDOUT', 'ABORTED'].contains(data.Tasks.status)
+ });
}
+
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/a6a5618c/ambari-web/app/controllers/main/admin/highAvailability/resourceManager/step3_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/highAvailability/resourceManager/step3_controller.js b/ambari-web/app/controllers/main/admin/highAvailability/resourceManager/step3_controller.js
index 18e1d38..d5428d7 100644
--- a/ambari-web/app/controllers/main/admin/highAvailability/resourceManager/step3_controller.js
+++ b/ambari-web/app/controllers/main/admin/highAvailability/resourceManager/step3_controller.js
@@ -117,6 +117,12 @@ App.RMHighAvailabilityWizardStep3Controller = Em.Controller.extend({
configProperties.findProperty('name', 'yarn.resourcemanager.hostname.rm1').set('value', currentRMHost).set('defaultValue', currentRMHost);
configProperties.findProperty('name', 'yarn.resourcemanager.hostname.rm2').set('value', additionalRMHost).set('defaultValue', additionalRMHost);
configProperties.findProperty('name', 'yarn.resourcemanager.zk-address').set('value', zooKeeperHostsWithPort).set('defaultValue', zooKeeperHostsWithPort);
+
+ configProperties.findProperty('name', 'yarn.resourcemanager.webapp.address.rm1').set('value', additionalRMHost).set('defaultValue', additionalRMHost);
+ configProperties.findProperty('name', 'yarn.resourcemanager.webapp.address.rm2').set('value', additionalRMHost).set('defaultValue', additionalRMHost);
+ configProperties.findProperty('name', 'yarn.resourcemanager.webapp.https.address.rm1').set('value', additionalRMHost).set('defaultValue', additionalRMHost);
+ configProperties.findProperty('name', 'yarn.resourcemanager.webapp.https.address.rm2').set('value', additionalRMHost).set('defaultValue', additionalRMHost);
+
},
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/a6a5618c/ambari-web/app/mixins/wizard/wizardProgressPageController.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/wizard/wizardProgressPageController.js b/ambari-web/app/mixins/wizard/wizardProgressPageController.js
index 561637c..74e83cd 100644
--- a/ambari-web/app/mixins/wizard/wizardProgressPageController.js
+++ b/ambari-web/app/mixins/wizard/wizardProgressPageController.js
@@ -524,7 +524,7 @@ App.wizardProgressPageControllerMixin = Em.Mixin.create({
this.set('logs', []);
for (var i = 0; i < requestIds.length; i++) {
App.ajax.send({
- name: 'admin.high_availability.polling',
+ name: 'background_operations.get_by_request',
sender: this,
data: {
requestId: requestIds[i]
http://git-wip-us.apache.org/repos/asf/ambari/blob/a6a5618c/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index 9185364..f572e93 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -187,7 +187,7 @@ var urls = {
},
'common.request.polling': {
- 'real': '/clusters/{clusterName}/requests/{requestId}?fields=tasks/*,Requests/*&tasks/Tasks/stage_id={stageId}',
+ 'real': '/clusters/{clusterName}/requests/{requestId}?fields=tasks/Tasks/request_id,tasks/Tasks/command,tasks/Tasks/command_detail,tasks/Tasks/start_time,tasks/Tasks/end_time,tasks/Tasks/exit_code,Requests/*&tasks/Tasks/stage_id={stageId}',
'mock': '/data/background_operations/host_upgrade_tasks.json'
},
@@ -449,7 +449,7 @@ var urls = {
'testInProduction': true
},
'background_operations.get_by_request': {
- 'real': '/clusters/{clusterName}/requests/{requestId}?fields=*,tasks/Tasks/command,tasks/Tasks/command_detail,tasks/Tasks/start_time,tasks/Tasks/end_time,tasks/Tasks/exit_code,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status&minimal_response=true',
+ 'real': '/clusters/{clusterName}/requests/{requestId}?fields=*,tasks/Tasks/request_id,tasks/Tasks/command,tasks/Tasks/command_detail,tasks/Tasks/start_time,tasks/Tasks/end_time,tasks/Tasks/exit_code,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status&minimal_response=true',
'mock': '/data/background_operations/task_by_request{requestId}.json',
'testInProduction': true
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/a6a5618c/ambari-web/app/utils/host_progress_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/host_progress_popup.js b/ambari-web/app/utils/host_progress_popup.js
index 8088a1a..6c75340 100644
--- a/ambari-web/app/utils/host_progress_popup.js
+++ b/ambari-web/app/utils/host_progress_popup.js
@@ -68,6 +68,13 @@ App.HostPopup = Em.Object.create({
*/
isPopup: null,
+ detailedProperties: {
+ stdout: 'stdout',
+ stderr: 'stderr',
+ outputLog: 'output_log',
+ errorLog: 'error_log'
+ },
+
abortIcon: Em.View.extend({
tagName: 'i',
classNames: ['abort-icon', 'icon-remove-circle', 'pointer'],
@@ -445,6 +452,7 @@ App.HostPopup = Em.Object.create({
role: App.format.role(_task.Tasks.role),
stderr: _task.Tasks.stderr,
stdout: _task.Tasks.stdout,
+ request_id: _task.Tasks.request_id,
isVisible: true,
startTime: date.startTime(_task.Tasks.start_time),
duration: date.durationSummary(_task.Tasks.start_time, _task.Tasks.end_time),
@@ -516,11 +524,12 @@ App.HostPopup = Em.Object.create({
if (existTask) {
var status = _task.Tasks.status;
existTask.set('status', App.format.taskStatus(status));
- existTask.set('stdout', _task.Tasks.stdout);
- existTask.set('stderr', _task.Tasks.stderr);
- // Verified that this is needed.
- existTask.set('outputLog', _task.Tasks.output_log);
- existTask.set('errorLog', _task.Tasks.error_log);
+ Em.keys(this.get('detailedProperties')).forEach(function (key) {
+ var value = _task.Tasks[this.get('detailedProperties')[key]];
+ if (!Em.isNone(value)) {
+ existTask.set(key, value);
+ }
+ }, this);
existTask.set('startTime', date.startTime(_task.Tasks.start_time));
existTask.set('duration', date.durationSummary(_task.Tasks.start_time, _task.Tasks.end_time));
// Puts some command information to render it
@@ -643,6 +652,8 @@ App.HostPopup = Em.Object.create({
*/
isOpen: false,
+ detailedProperties: self.get('detailedProperties'),
+
didInsertElement: function(){
this._super();
this.set('isOpen', true);
@@ -769,6 +780,12 @@ App.HostPopup = Em.Object.create({
return [];
}.property('currentHost.tasks', 'currentHost.tasks.@each.status'),
+ willDestroyElement: function () {
+ if (this.get('controller.dataSourceController.name') == 'highAvailabilityProgressPopupController') {
+ this.set('controller.dataSourceController.isTaskPolling', false);
+ }
+ },
+
/**
* Preset values on init
*/
@@ -934,6 +951,26 @@ App.HostPopup = Em.Object.create({
} else {
dataSourceController.stopUpdatingTask(this.get('controller.currentServiceId'));
}
+ } else if (dataSourceController.get('name') == 'highAvailabilityProgressPopupController') {
+ if (levelName === 'TASK_DETAILS') {
+ this.set('isLevelLoaded', false);
+ dataSourceController.startTaskPolling(this.get('openedTask.request_id'), this.get('openedTask.id'));
+ Em.keys(this.get('parentView.detailedProperties')).forEach(function (key) {
+ dataSourceController.addObserver('taskInfo.' + this.get('parentView.detailedProperties')[key], this, 'updateTaskInfo');
+ }, this);
+ } else {
+ dataSourceController.stopTaskPolling();
+ }
+ }
+ },
+ updateTaskInfo: function () {
+ var dataSourceController = this.get('controller.dataSourceController');
+ var openedTask = this.get('openedTask');
+ if (openedTask && openedTask.get('id') == dataSourceController.get('taskInfo.id')) {
+ this.set('isLevelLoaded', true);
+ Em.keys(this.get('parentView.detailedProperties')).forEach(function (key) {
+ openedTask.set(key, dataSourceController.get('taskInfo.' + key));
+ }, this);
}
},
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/a6a5618c/ambari-web/test/controllers/main/admin/highAvailability/progress_popup_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/highAvailability/progress_popup_controller_test.js b/ambari-web/test/controllers/main/admin/highAvailability/progress_popup_controller_test.js
new file mode 100644
index 0000000..c6ec583
--- /dev/null
+++ b/ambari-web/test/controllers/main/admin/highAvailability/progress_popup_controller_test.js
@@ -0,0 +1,140 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+
+require('controllers/main/admin/highAvailability/progress_popup_controller');
+
+describe('App.HighAvailabilityProgressPopupController', function () {
+
+ var controller;
+
+ beforeEach(function () {
+ controller = App.HighAvailabilityProgressPopupController.create();
+ });
+
+ describe('#startTaskPolling', function () {
+
+ beforeEach(function () {
+ sinon.stub(App.updater, 'run', Em.K);
+ sinon.stub(App.updater, 'immediateRun', Em.K);
+ });
+
+ afterEach(function () {
+ App.updater.run.restore();
+ App.updater.immediateRun.restore();
+ });
+
+ it('should start task polling', function () {
+ controller.startTaskPolling(1, 2);
+ expect(controller.get('isTaskPolling')).to.be.true;
+ expect(controller.get('taskInfo.id'), 2);
+ expect(controller.get('taskInfo.requestId'), 1);
+ expect(App.updater.run.calledOnce).to.be.true;
+ expect(App.updater.immediateRun.calledOnce).to.be.true;
+ });
+
+ });
+
+ describe('#stopTaskPolling', function () {
+
+ it('should stop task polling', function () {
+ controller.stopTaskPolling();
+ expect(controller.get('isTaskPolling')).to.be.false;
+ });
+
+ });
+
+ describe('#updateTask', function () {
+
+ beforeEach(function () {
+ sinon.stub(App.ajax, 'send', Em.K);
+ });
+
+ afterEach(function () {
+ App.ajax.send.restore();
+ });
+
+ it('should send polling request', function () {
+ controller.updateTask();
+ expect(App.ajax.send.calledOnce).to.be.true;
+ });
+
+ });
+
+ describe('#updateTaskSuccessCallback', function () {
+
+ beforeEach(function () {
+ controller.reopen({
+ taskInfo: {}
+ });
+ });
+
+ var cases = [
+ {
+ status: 'FAILED',
+ isTaskPolling: false
+ },
+ {
+ status: 'COMPLETED',
+ isTaskPolling: false
+ },
+ {
+ status: 'TIMEDOUT',
+ isTaskPolling: false
+ },
+ {
+ status: 'ABORTED',
+ isTaskPolling: false
+ },
+ {
+ status: 'QUEUED',
+ isTaskPolling: true
+ },
+ {
+ status: 'IN_PROGRESS',
+ isTaskPolling: true
+ }
+ ],
+ tasks = {
+ stderr: 'error',
+ stdout: 'output',
+ output_log: 'output-log.txt',
+ error_log: 'error-log.txt'
+ },
+ title = '{0}polling task if it\'s status is {1}';
+
+ cases.forEach(function (item) {
+ var message = title.format(item.isTaskPolling ? '' : 'not ', item.status);
+ it(message, function () {
+ controller.updateTaskSuccessCallback({
+ Tasks: $.extend(tasks, {
+ status: item.status
+ })
+ });
+ expect(controller.get('taskInfo.stderr')).to.equal('error');
+ expect(controller.get('taskInfo.stdout')).to.equal('output');
+ expect(controller.get('taskInfo.outputLog')).to.equal('output-log.txt');
+ expect(controller.get('taskInfo.errorLog')).to.equal('error-log.txt');
+ expect(controller.get('isTaskPolling')).to.equal(item.isTaskPolling);
+ });
+ });
+
+ });
+
+});