You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2014/04/30 18:59:13 UTC
git commit: AMBARI-5638 Error in persisting web client state when
enabling security on cluster with ambari-server database set to MySQL.
(atkach)
Repository: ambari
Updated Branches:
refs/heads/trunk 2182d60cf -> 9ede3dee3
AMBARI-5638 Error in persisting web client state when enabling security on cluster with ambari-server database set to MySQL. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9ede3dee
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9ede3dee
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9ede3dee
Branch: refs/heads/trunk
Commit: 9ede3dee3a29ac8e4cde21ffda9f939460a39fc1
Parents: 2182d60
Author: atkach <at...@hortonworks.com>
Authored: Wed Apr 30 19:56:44 2014 +0300
Committer: atkach <at...@hortonworks.com>
Committed: Wed Apr 30 19:59:13 2014 +0300
----------------------------------------------------------------------
ambari-web/app/controllers/installer.js | 22 +++
.../security/security_progress_controller.js | 26 ++++
ambari-web/app/controllers/wizard.js | 27 ++--
ambari-web/app/utils/host_progress_popup.js | 29 ++--
ambari-web/app/utils/polling.js | 136 ++++++++++++-------
.../app/views/main/service/reconfigure.js | 9 +-
6 files changed, 179 insertions(+), 70 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/9ede3dee/ambari-web/app/controllers/installer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/installer.js b/ambari-web/app/controllers/installer.js
index 48c501e..8ed9884 100644
--- a/ambari-web/app/controllers/installer.js
+++ b/ambari-web/app/controllers/installer.js
@@ -40,6 +40,28 @@ App.InstallerController = App.WizardController.extend({
controllerName: 'installerController'
}),
+ /**
+ * Wizard properties in local storage, which should be cleaned right after wizard has been finished
+ */
+ dbPropertiesToClean: [
+ 'service',
+ 'hosts',
+ 'masterComponentHosts',
+ 'slaveComponentHosts',
+ 'cluster',
+ 'allHostNames',
+ 'installOptions',
+ 'allHostNamesPattern',
+ 'serviceComponents',
+ 'advancedServiceConfig',
+ 'clientInfo',
+ 'selectedServiceNames',
+ 'serviceConfigGroups',
+ 'serviceConfigProperties',
+ 'configsToUpdate',
+ 'bootStatus'
+ ],
+
init: function () {
this._super();
this.get('isStepDisabled').setEach('value', true);
http://git-wip-us.apache.org/repos/asf/ambari/blob/9ede3dee/ambari-web/app/controllers/main/admin/security/security_progress_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/security/security_progress_controller.js b/ambari-web/app/controllers/main/admin/security/security_progress_controller.js
index 12ada41..2c80943 100644
--- a/ambari-web/app/controllers/main/admin/security/security_progress_controller.js
+++ b/ambari-web/app/controllers/main/admin/security/security_progress_controller.js
@@ -62,6 +62,7 @@ App.MainAdminSecurityProgressController = Em.Controller.extend({
retry: function () {
var failedCommand = this.get('commands').findProperty('isError');
if (failedCommand) {
+ failedCommand.set('requestId', null);
failedCommand.set('isStarted', false);
failedCommand.set('isError', false);
this.startCommand(failedCommand);
@@ -69,6 +70,31 @@ App.MainAdminSecurityProgressController = Em.Controller.extend({
},
/**
+ * start updating current task in parallel
+ * @param requestId
+ * @param taskId
+ * @return {Boolean}
+ */
+ startUpdatingTask: function (requestId, taskId) {
+ if (!requestId || !taskId) return false;
+ var command = this.get('commands').findProperty('requestId', requestId);
+ command.updateTaskLog(taskId);
+ return true;
+ },
+
+ /**
+ * stop updating current task
+ * @param requestId
+ * @return {Boolean}
+ */
+ stopUpdatingTask: function (requestId) {
+ if (!requestId) return false;
+ var command = this.get('commands').findProperty('requestId', requestId);
+ command.set('currentTaskId', null);
+ return true;
+ },
+
+ /**
* update info about progress of operation of commands
*/
updateServices: function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/9ede3dee/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index 00591aa..d047c1a 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -24,6 +24,21 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
isStepDisabled: null,
+ /**
+ * Wizard properties in local storage, which should be cleaned right after wizard has been finished
+ */
+ dbPropertiesToClean: [
+ 'service',
+ 'hosts',
+ 'masterComponentHosts',
+ 'slaveComponentHosts',
+ 'cluster',
+ 'allHostNames',
+ 'installOptions',
+ 'allHostNamesPattern',
+ 'serviceComponents'
+ ],
+
init: function () {
this.set('isStepDisabled', []);
this.clusters = App.Cluster.find();
@@ -403,15 +418,9 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
},
clearStorageData: function () {
- this.setDBProperty('service',undefined); //not to use this data at AddService page
- this.setDBProperty('hosts', undefined);
- this.setDBProperty('masterComponentHosts', undefined);
- this.setDBProperty('slaveComponentHosts', undefined);
- this.setDBProperty('cluster', undefined);
- this.setDBProperty('allHostNames', undefined);
- this.setDBProperty('installOptions', undefined);
- this.setDBProperty('allHostNamesPattern', undefined);
- this.setDBProperty('serviceComponents', undefined);
+ this.get('dbPropertiesToClean').forEach(function (key) {
+ this.setDBProperty(key, undefined);
+ }, this);
},
installOptionsTemplate: {
http://git-wip-us.apache.org/repos/asf/ambari/blob/9ede3dee/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 7a5edd1..64bc7c7 100644
--- a/ambari-web/app/utils/host_progress_popup.js
+++ b/ambari-web/app/utils/host_progress_popup.js
@@ -68,14 +68,17 @@ App.HostPopup = Em.Object.create({
/**
* Entering point of this component
* @param {String} serviceName
- * @param {App.Controller} controller
- * @param {bool} isBackgroundOperations
+ * @param {Object} controller
+ * @param {Boolean} isBackgroundOperations
+ * @param {Integer} requestId
*/
- initPopup: function (serviceName, controller, isBackgroundOperations) {
+ initPopup: function (serviceName, controller, isBackgroundOperations, requestId) {
if (!isBackgroundOperations) {
this.clearHostPopup();
this.set("popupHeaderName", serviceName);
}
+
+ this.set('currentServiceId', requestId);
this.set("serviceName", serviceName);
this.set("dataSourceController", controller);
this.set("isBackgroundOperations", isBackgroundOperations);
@@ -697,21 +700,31 @@ App.HostPopup = Em.Object.create({
* @param levelName
*/
switchLevel: function (levelName) {
+ var dataSourceController = this.get('controller.dataSourceController');
+ var securityControllers = [
+ 'mainAdminSecurityDisableController',
+ 'mainAdminSecurityAddStep4Controller'
+ ];
if (this.get("controller.isBackgroundOperations")) {
- var BGController = App.router.get('backgroundOperationsController');
- var levelInfo = BGController.get('levelInfo');
+ var levelInfo = dataSourceController.get('levelInfo');
levelInfo.set('taskId', this.get('openedTaskId'));
levelInfo.set('requestId', this.get('controller.currentServiceId'));
levelInfo.set('name', levelName);
if (levelName === 'HOSTS_LIST') {
levelInfo.set('sync', (this.get('controller.hosts').length === 0));
- BGController.requestMostRecent();
+ dataSourceController.requestMostRecent();
} else if (levelName === 'TASK_DETAILS') {
levelInfo.set('sync', true);
- BGController.requestMostRecent();
+ dataSourceController.requestMostRecent();
} else if (levelName === 'REQUESTS_LIST') {
this.get('controller.hosts').clear();
- BGController.requestMostRecent();
+ dataSourceController.requestMostRecent();
+ }
+ } else if (securityControllers.contains(dataSourceController.get('name'))) {
+ if (levelName === 'TASK_DETAILS') {
+ dataSourceController.startUpdatingTask(this.get('controller.currentServiceId'), this.get('openedTaskId'));
+ } else {
+ dataSourceController.stopUpdatingTask(this.get('controller.currentServiceId'));
}
}
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/9ede3dee/ambari-web/app/utils/polling.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/polling.js b/ambari-web/app/utils/polling.js
index 97d7348..a0281a8 100644
--- a/ambari-web/app/utils/polling.js
+++ b/ambari-web/app/utils/polling.js
@@ -25,7 +25,7 @@ App.Poll = Em.Object.extend({
isStarted: false,
isPolling: true,
clusterName: null,
- requestId: undefined,
+ requestId: null,
temp: false,
progress: 0,
url: null,
@@ -37,6 +37,7 @@ App.Poll = Em.Object.extend({
polledData: [],
numPolls: 0,
mockDataPrefix: '/data/wizard/deploy/5_hosts',
+ currentTaskId: null,
barWidth: function () {
return 'width: ' + this.get('progress') + '%;';
@@ -51,7 +52,7 @@ App.Poll = Em.Object.extend({
}.property('isPolling', 'isStarted'),
start: function () {
- if (this.get('requestId') === undefined) {
+ if (Em.isNone(this.get('requestId'))) {
this.setRequestId();
} else {
this.startPolling();
@@ -81,10 +82,9 @@ App.Poll = Em.Object.extend({
console.log("TRACE: Polling -> value of the url is: " + url);
console.log("TRACE: Polling-> value of the sent data is: " + self.get('data'));
console.log("TRACE: Polling-> value of the received data is: " + jsonData);
- if (jsonData === null) {
+ if (Em.isNone(jsonData)) {
self.set('isSuccess', true);
self.set('isError', false);
- self.set('requestId',undefined);
} else {
var requestId = jsonData.Requests.id;
self.set('requestId', requestId);
@@ -103,59 +103,93 @@ App.Poll = Em.Object.extend({
});
},
+ /**
+ * set current task id and send request
+ * @param taskId
+ */
+ updateTaskLog: function (taskId) {
+ this.set('currentTaskId', taskId);
+ this.pollTaskLog();
+ },
+
doPolling: function () {
if (this.get('requestId')) {
this.startPolling();
}
},
- startPolling: function () {
- if (!this.get('requestId')) {
- return;
- }
- var self = this;
- var url = App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/requests/' + this.get('requestId') + '?fields=tasks/*';
- if (App.testMode) {
- this.set('POLL_INTERVAL', 1);
- this.numPolls++;
- url = this.get('mockDataPrefix') + '/poll_' + this.get('numPolls') + '.json';
+ /**
+ * server call to obtain task logs
+ */
+ pollTaskLog: function () {
+ if (this.get('currentTaskId')) {
+ App.ajax.send({
+ name: 'background_operations.get_by_task',
+ sender: this,
+ data: {
+ requestId: this.get('requestId'),
+ taskId: this.get('currentTaskId'),
+ sync: true
+ },
+ success: 'pollTaskLogSuccessCallback'
+ })
}
+ },
- $.ajax({
- type: 'GET',
- url: url,
- async: true,
- dataType: 'text',
- timeout: App.timeout,
- success: function (data) {
- console.log("TRACE: In success function for the GET logs data");
- console.log("TRACE: The value is: ", jQuery.parseJSON(data));
- var result = self.parseInfo(jQuery.parseJSON(data));
- if (result !== true) {
- window.setTimeout(function () {
- self.startPolling();
- }, self.POLL_INTERVAL);
- } else {
- self.set('requestId', undefined);
- }
- },
+ /**
+ * update logs of current task
+ * @param data
+ */
+ pollTaskLogSuccessCallback: function (data) {
+ var currentTask = this.get('polledData').findProperty('Tasks.id', data.Tasks.id);
+ currentTask.Tasks.stdout = data.Tasks.stdout;
+ currentTask.Tasks.stderr = data.Tasks.stderr;
+ Em.propertyDidChange(this, 'polledData');
+ },
- error: function (request, ajaxOptions, error) {
- console.log("TRACE: In error function for the GET data");
- console.log("TRACE: value of the url is: " + url);
- console.log("TRACE: error code status is: " + request.status);
- if (!self.get('isSuccess')) {
- self.set('isError', true);
- }
- },
+ /**
+ * start polling operation data
+ * @return {Boolean}
+ */
+ startPolling: function () {
+ if (!this.get('requestId')) return false;
- statusCode: require('data/statusCodes')
- }).retry({times: App.maxRetries, timeout: App.timeout}).then(null,
- function () {
+ this.pollTaskLog();
+ App.ajax.send({
+ name: 'background_operations.get_by_request',
+ sender: this,
+ data: {
+ requestId: this.get('requestId'),
+ sync: false
+ },
+ success: 'startPollingSuccessCallback',
+ error: 'startPollingErrorCallback'
+ })
+ .retry({times: App.maxRetries, timeout: App.timeout})
+ .then(null, function () {
App.showReloadPopup();
console.log('Install services all retries failed');
- }
- );
+ });
+ return true;
+ },
+
+ startPollingSuccessCallback: function (data) {
+ var self = this;
+ var result = this.parseInfo(data);
+ if (!result) {
+ window.setTimeout(function () {
+ self.startPolling();
+ }, this.POLL_INTERVAL);
+ }
+ },
+
+ startPollingErrorCallback: function (request, ajaxOptions, error) {
+ console.log("TRACE: In error function for the GET data");
+ console.log("TRACE: value of the url is: " + url);
+ console.log("TRACE: error code status is: " + request.status);
+ if (!this.get('isSuccess')) {
+ this.set('isError', true);
+ }
},
stopPolling: function () {
@@ -163,7 +197,13 @@ App.Poll = Em.Object.extend({
},
replacePolledData: function (polledData) {
- this.polledData.clear();
+ var currentTaskId = this.get('currentTaskId');
+ if (currentTaskId) {
+ var task = this.get('polledData').findProperty('Tasks.id', currentTaskId);
+ var currentTask = polledData.findProperty('Tasks.id', currentTaskId);
+ currentTask.Tasks.stdout = task.Tasks.stdout;
+ currentTask.Tasks.stderr = task.Tasks.stderr;
+ }
this.set('polledData', polledData);
},
@@ -208,9 +248,9 @@ App.Poll = Em.Object.extend({
}
var requestId = this.get('requestId');
if (polledData.Requests && polledData.Requests.id && polledData.Requests.id != requestId) {
- // We dont want to use non-current requestId's tasks data to
+ // We don't want to use non-current requestId's tasks data to
// determine the current install status.
- // Also, we dont want to keep polling if it is not the
+ // Also, we don't want to keep polling if it is not the
// current requestId.
return false;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/9ede3dee/ambari-web/app/views/main/service/reconfigure.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/reconfigure.js b/ambari-web/app/views/main/service/reconfigure.js
index 49196ac..aaa1ee4 100644
--- a/ambari-web/app/views/main/service/reconfigure.js
+++ b/ambari-web/app/views/main/service/reconfigure.js
@@ -42,16 +42,15 @@ App.StageLabelView = Em.View.extend({
command: null,
click: function () {
if (this.get('command') && this.get('showLink')) {
- this.showHostPopup(this.get('command.label'));
+ this.showHostPopup(this.get('command'));
}
},
- showHostPopup: function (label) {
- var serviceName = label;
+ showHostPopup: function (command) {
var controller = this.get("controller");
App.router.get('applicationController').dataLoading().done(function (initValue) {
- var popupView = App.HostPopup.initPopup(serviceName, controller);
- popupView.set ('isNotShowBgChecked', !initValue);
+ var popupView = App.HostPopup.initPopup(command.get('label'), controller, false, command.get('requestId'));
+ popupView.set('isNotShowBgChecked', !initValue);
})
},