You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sr...@apache.org on 2013/04/11 23:05:33 UTC
svn commit: r1467084 [1/2] - in /incubator/ambari/trunk: ./ ambari-web/app/
ambari-web/app/controllers/ ambari-web/app/controllers/global/
ambari-web/app/controllers/main/ ambari-web/app/controllers/main/admin/
ambari-web/app/controllers/main/admin/sec...
Author: srimanth
Date: Thu Apr 11 21:05:32 2013
New Revision: 1467084
URL: http://svn.apache.org/r1467084
Log:
AMBARI-1895. Refactor ajax requests. (srimanth)
Modified:
incubator/ambari/trunk/CHANGES.txt
incubator/ambari/trunk/ambari-web/app/controllers/global/cluster_controller.js
incubator/ambari/trunk/ambari-web/app/controllers/login_controller.js
incubator/ambari/trunk/ambari-web/app/controllers/main/admin.js
incubator/ambari/trunk/ambari-web/app/controllers/main/admin/cluster.js
incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step3.js
incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/disable.js
incubator/ambari/trunk/ambari-web/app/controllers/main/host/configs_service.js
incubator/ambari/trunk/ambari-web/app/controllers/main/service.js
incubator/ambari/trunk/ambari-web/app/controllers/wizard.js
incubator/ambari/trunk/ambari-web/app/controllers/wizard/stack_upgrade/step3_controller.js
incubator/ambari/trunk/ambari-web/app/controllers/wizard/step3_controller.js
incubator/ambari/trunk/ambari-web/app/controllers/wizard/step8_controller.js
incubator/ambari/trunk/ambari-web/app/controllers/wizard/step9_controller.js
incubator/ambari/trunk/ambari-web/app/router.js
incubator/ambari/trunk/ambari-web/app/routes/main.js
incubator/ambari/trunk/ambari-web/app/utils/ajax.js
incubator/ambari/trunk/ambari-web/app/views/common/chart/linear_time.js
incubator/ambari/trunk/ambari-web/app/views/common/modal_popup.js
incubator/ambari/trunk/ambari-web/app/views/main/dashboard/cluster_metrics/cpu.js
incubator/ambari/trunk/ambari-web/app/views/main/dashboard/cluster_metrics/load.js
incubator/ambari/trunk/ambari-web/app/views/main/dashboard/cluster_metrics/memory.js
incubator/ambari/trunk/ambari-web/app/views/main/dashboard/cluster_metrics/network.js
incubator/ambari/trunk/ambari-web/app/views/main/host/metrics/cpu.js
incubator/ambari/trunk/ambari-web/app/views/main/host/metrics/disk.js
incubator/ambari/trunk/ambari-web/app/views/main/host/metrics/load.js
incubator/ambari/trunk/ambari-web/app/views/main/host/metrics/memory.js
incubator/ambari/trunk/ambari-web/app/views/main/host/metrics/network.js
incubator/ambari/trunk/ambari-web/app/views/main/host/metrics/processes.js
incubator/ambari/trunk/ambari-web/app/views/main/service/info/metrics/hbase/cluster_requests.js
incubator/ambari/trunk/ambari-web/app/views/main/service/info/metrics/hbase/hlog_split_size.js
incubator/ambari/trunk/ambari-web/app/views/main/service/info/metrics/hbase/hlog_split_time.js
incubator/ambari/trunk/ambari-web/app/views/main/service/info/metrics/hbase/regionserver_queuesize.js
incubator/ambari/trunk/ambari-web/app/views/main/service/info/metrics/hbase/regionserver_regions.js
incubator/ambari/trunk/ambari-web/app/views/main/service/info/metrics/hbase/regionserver_rw_requests.js
incubator/ambari/trunk/ambari-web/app/views/main/service/info/metrics/hdfs/block_status.js
incubator/ambari/trunk/ambari-web/app/views/main/service/info/metrics/hdfs/file_operations.js
incubator/ambari/trunk/ambari-web/app/views/main/service/info/metrics/hdfs/gc.js
incubator/ambari/trunk/ambari-web/app/views/main/service/info/metrics/hdfs/io.js
incubator/ambari/trunk/ambari-web/app/views/main/service/info/metrics/hdfs/jvm_heap.js
incubator/ambari/trunk/ambari-web/app/views/main/service/info/metrics/hdfs/jvm_threads.js
incubator/ambari/trunk/ambari-web/app/views/main/service/info/metrics/hdfs/rpc.js
incubator/ambari/trunk/ambari-web/app/views/main/service/info/metrics/hdfs/space_utilization.js
incubator/ambari/trunk/ambari-web/app/views/main/service/info/metrics/mapreduce/gc.js
incubator/ambari/trunk/ambari-web/app/views/main/service/info/metrics/mapreduce/jobs_status.js
incubator/ambari/trunk/ambari-web/app/views/main/service/info/metrics/mapreduce/jvm_heap.js
incubator/ambari/trunk/ambari-web/app/views/main/service/info/metrics/mapreduce/jvm_threads.js
incubator/ambari/trunk/ambari-web/app/views/main/service/info/metrics/mapreduce/map_slots.js
incubator/ambari/trunk/ambari-web/app/views/main/service/info/metrics/mapreduce/reduce_slots.js
incubator/ambari/trunk/ambari-web/app/views/main/service/info/metrics/mapreduce/rpc.js
incubator/ambari/trunk/ambari-web/app/views/main/service/info/metrics/mapreduce/tasks_running_waiting.js
Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1467084&r1=1467083&r2=1467084&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Thu Apr 11 21:05:32 2013
@@ -12,6 +12,8 @@ Trunk (unreleased changes):
NEW FEATURES
+ AMBARI-1895. Refactor ajax requests. (srimanth)
+
AMBARI-1868. Include stack version as a parameter in manifest. (swagle)
AMBARI-1847. Make single PUT call for multiple host overrides. (srimanth)
Modified: incubator/ambari/trunk/ambari-web/app/controllers/global/cluster_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/global/cluster_controller.js?rev=1467084&r1=1467083&r2=1467084&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/global/cluster_controller.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/global/cluster_controller.js Thu Apr 11 21:05:32 2013
@@ -64,30 +64,30 @@ App.ClusterController = Em.Controller.ex
if (this.get('clusterName') && !reload) {
return;
}
- var self = this;
- var url = (App.testMode) ? '/data/clusters/info.json' : App.apiPrefix + '/clusters';
- $.ajax({
- async:false,
- type:"GET",
- url:url,
- dataType:'json',
- timeout:App.timeout,
- success:function (data) {
- self.set('cluster', data.items[0]);
- App.set('clusterName', data.items[0].Clusters.cluster_name);
- App.set('currentStackVersion', data.items[0].Clusters.version);
- },
- error:function (request, ajaxOptions, error) {
- console.log('failed on loading cluster name');
- self.set('isLoaded', true);
- },
- statusCode:require('data/statusCodes')
+
+ App.ajax.send({
+ name: 'cluster.load_cluster_name',
+ sender: this,
+ success: 'loadClusterNameSuccessCallback',
+ error: 'loadClusterNameErrorCallback'
});
+
if(!App.get('currentStackVersion')){
App.set('currentStackVersion', App.defaultStackVersion);
}
},
+ loadClusterNameSuccessCallback: function (data) {
+ this.set('cluster', data.items[0]);
+ App.set('clusterName', data.items[0].Clusters.cluster_name);
+ App.set('currentStackVersion', data.items[0].Clusters.version);
+ },
+
+ loadClusterNameErrorCallback: function (request, ajaxOptions, error) {
+ console.log('failed on loading cluster name');
+ this.set('isLoaded', true);
+ },
+
getUrl:function (testUrl, url) {
return (App.testMode) ? testUrl : App.apiPrefix + '/clusters/' + this.get('clusterName') + url;
},
@@ -213,7 +213,7 @@ App.ClusterController = Em.Controller.ex
};
App.HttpClient.get(dataUrl, App.alertsMapper, ajaxOptions);
} else {
- console.log("No Nagios URL provided.")
+ console.log("No Nagios URL provided.");
callback();
}
},
@@ -363,4 +363,4 @@ App.ClusterController = Em.Controller.ex
complete:function(){}
});
}
-})
+});
Modified: incubator/ambari/trunk/ambari-web/app/controllers/login_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/login_controller.js?rev=1467084&r1=1467083&r2=1467084&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/login_controller.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/login_controller.js Thu Apr 11 21:05:32 2013
@@ -32,12 +32,14 @@ App.LoginController = Em.Object.extend({
var self = this;
- App.get('router').login(function (isAuthenticated) {
- if (!isAuthenticated) {
- console.log('Failed to login as: ' + self.get('loginName'));
- self.set('errorMessage', Em.I18n.t('login.error'));
- }
- });
+ App.get('router').login();
+ },
+
+ postLogin: function (isAuthenticated) {
+ if (!isAuthenticated) {
+ console.log('Failed to login as: ' + this.get('loginName'));
+ this.set('errorMessage', Em.I18n.t('login.error'));
+ }
}
});
\ No newline at end of file
Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/admin.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/admin.js?rev=1467084&r1=1467083&r2=1467084&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/admin.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/admin.js Thu Apr 11 21:05:32 2013
@@ -24,113 +24,96 @@ App.MainAdminController = Em.Controller.
securityEnabled: false,
serviceUsers: [],
+ deferred: null,
+
+ tag: null,
+
/**
* return true if security status is loaded and false otherwise
*/
securityStatusLoading: function () {
- var dfd = $.Deferred();
- this.connectOutlet('loading');
+ var self = this;
+ this.set('deferred', $.Deferred());
if (App.testMode) {
window.setTimeout(function () {
- dfd.resolve();
+ self.get('deferred').resolve();
}, 50);
- } else {
- this.getSecurityStatusFromServer(dfd);
}
- return dfd.promise();
+ else {
+ //get Security Status From Server
+ App.ajax.send({
+ name: 'admin.security_status',
+ sender: this,
+ success: 'getSecurityStatusFromServerSuccessCallback',
+ error: 'errorCallback'
+ });
+ }
+ return this.get('deferred').promise();
},
- /**
- * return true if security status is loaded and false otherwise
- */
- getSecurityStatusFromServer: function (dfd) { //TODO: this should be obtain from cluster level config rather than HDFS global config
- var self = this;
- var url = App.apiPrefix + '/clusters/' + App.router.getClusterName();
- $.ajax({
- type: 'GET',
- url: url,
- async: false, // we are retrieving user information that is used ahead in addSecurity/apply stage
- timeout: 10000,
- dataType: 'text',
- success: function (data) {
- console.log("TRACE: The url is: " + url);
- var jsonData = jQuery.parseJSON(data);
- var configs = jsonData.Clusters.desired_configs;
- if ('global' in configs) {
- self.getServiceConfigsFromServer(dfd, 'global', configs['global'].tag);
- } else {
- if (dfd) {
- dfd.reject();
- }
- }
- },
-
- error: function (request, ajaxOptions, error) {
- if (dfd) {
- dfd.reject();
- }
- },
-
- statusCode: require('data/statusCodes')
- });
+ errorCallback: function() {
+ this.get('deferred').reject();
},
- getServiceConfigsFromServer: function (dfd, siteName, tagName) {
- var self = this;
- var url = App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/configurations/?type=' + siteName + '&tag=' + tagName;
- $.ajax({
- type: 'GET',
- url: url,
- async: false, // we are retrieving user information that is used ahead in addSecurity/apply stage
- timeout: 10000,
- dataType: 'json',
- success: function (data) {
- console.log("TRACE: In success function for the GET getServiceConfigsFromServer call");
- console.log("TRACE: The url is: " + url);
- var configs = data.items.findProperty('tag', tagName).properties;
- if (configs && configs['security_enabled'] === 'true') {
- self.set('securityEnabled', true);
- } else {
- self.loadUsers(configs);
- self.set('securityEnabled', false);
- }
- if (dfd) {
- dfd.resolve();
- }
- },
+ getSecurityStatusFromServerSuccessCallback: function (data) {
+ var configs = data.Clusters.desired_configs;
+ if ('global' in configs) {
+ this.set('tag', configs['global'].tag);
+ this.getServiceConfigsFromServer();
+ }
+ else {
+ this.get('deferred').reject();
+ }
+ },
- error: function (request, ajaxOptions, error) {
- if (dfd) {
- dfd.reject();
- }
+ getServiceConfigsFromServer: function () {
+ App.ajax.send({
+ name: 'admin.service_config',
+ sender: this,
+ data: {
+ siteName: 'global',
+ tagName: this.get('tag')
},
-
- statusCode: require('data/statusCodes')
+ success: 'getServiceConfigsFromServerSuccessCallback',
+ error: 'errorCallback'
});
},
+ getServiceConfigsFromServerSuccessCallback: function (data) {
+ console.log("TRACE: In success function for the GET getServiceConfigsFromServer call");
+ var configs = data.items.findProperty('tag', this.get('tag')).properties;
+ if (configs && configs['security_enabled'] === 'true') {
+ this.set('securityEnabled', true);
+ }
+ else {
+ this.loadUsers(configs);
+ this.set('securityEnabled', false);
+ }
+ this.get('deferred').resolve();
+ },
+
loadUsers: function (configs) {
var serviceUsers = this.get('serviceUsers');
- if (configs['hdfs_user']) {
- serviceUsers.pushObject({id: 'puppet var', name: 'hdfs_user', value: configs['hdfs_user']});
- } else {
- serviceUsers.pushObject({id: 'puppet var', name: 'hdfs_user', value: 'hdfs'});
- }
- if (configs['mapred_user']) {
- serviceUsers.pushObject({id: 'puppet var', name: 'mapred_user', value: configs['mapred_user']});
- } else {
- serviceUsers.pushObject({id: 'puppet var', name: 'mapred_user', value: 'mapred'});
- }
- if (configs['hbase_user']) {
- serviceUsers.pushObject({id: 'puppet var', name: 'hbase_user', value: configs['hbase_user']});
- } else {
- serviceUsers.pushObject({id: 'puppet var', name: 'hbase_user', value: 'hbase'});
- }
- if (configs['hive_user']) {
- serviceUsers.pushObject({id: 'puppet var', name: 'hive_user', value: configs['hive_user']});
- } else {
- serviceUsers.pushObject({id: 'puppet var', name: 'hive_user', value: 'hive'});
- }
+ serviceUsers.pushObject({
+ id: 'puppet var',
+ name: 'hdfs_user',
+ value: configs['hdfs_user'] ? configs['hdfs_user'] : 'hdfs'
+ });
+ serviceUsers.pushObject({
+ id: 'puppet var',
+ name: 'mapred_user',
+ value: configs['mapred_user'] ? configs['mapred_user'] : 'mapred'
+ });
+ serviceUsers.pushObject({
+ id: 'puppet var',
+ name: 'hbase_user',
+ value: configs['hbase_user'] ? configs['hbase_user'] : 'hbase'
+ });
+ serviceUsers.pushObject({
+ id: 'puppet var',
+ name: 'hive_user',
+ value: configs['hive_user'] ? configs['hive_user'] : 'hive'
+ });
}
});
\ No newline at end of file
Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/admin/cluster.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/admin/cluster.js?rev=1467084&r1=1467083&r2=1467084&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/admin/cluster.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/admin/cluster.js Thu Apr 11 21:05:32 2013
@@ -27,49 +27,47 @@ App.MainAdminClusterController = Em.Cont
*/
updateUpgradeVersion: function(){
if(App.router.get('clusterController.isLoaded')){
- var url = App.formatUrl(
- App.apiPrefix + "/stacks2/HDP/versions?fields=stackServices/StackServices,Versions",
- {},
- '/data/wizard/stack/stacks.json'
- );
- var upgradeVersion = this.get('upgradeVersion') || App.defaultStackVersion;
- var currentStack = {};
- var upgradeStack = {};
- $.ajax({
- type: "GET",
- url: url,
- async: false,
- dataType: 'json',
- timeout: App.timeout,
- success: function (data) {
- var currentVersion = App.currentStackVersion.replace(/HDP-/, '');
- var minUpgradeVersion = currentVersion;
- upgradeVersion = upgradeVersion.replace(/HDP-/, '');
- data.items.mapProperty('Versions.stack_version').forEach(function(version){
- upgradeVersion = (upgradeVersion < version) ? version : upgradeVersion;
- });
- currentStack = data.items.findProperty('Versions.stack_version', currentVersion);
- upgradeStack = data.items.findProperty('Versions.stack_version', upgradeVersion);
- minUpgradeVersion = upgradeStack.Versions.min_upgrade_version;
- if(minUpgradeVersion && (minUpgradeVersion > currentVersion)){
- upgradeVersion = currentVersion;
- upgradeStack = currentStack;
- }
- upgradeVersion = 'HDP-' + upgradeVersion;
- },
- error: function (request, ajaxOptions, error) {
- console.log('Error message is: ' + request.responseText);
- },
- statusCode: require('data/statusCodes')
+ App.ajax.send({
+ name: 'cluster.update_upgrade_version',
+ sender: this,
+ success: 'updateUpgradeVersionSuccessCallback',
+ error: 'updateUpgradeVersionErrorCallback'
});
- this.set('upgradeVersion', upgradeVersion);
- if(currentStack && upgradeStack){
- this.parseServicesInfo(currentStack, upgradeStack);
- } else {
- console.log('HDP stack doesn\'t have services with defaultStackVersion');
- }
}
}.observes('App.router.clusterController.isLoaded', 'App.currentStackVersion'),
+
+ updateUpgradeVersionSuccessCallback: function(data) {
+ var upgradeVersion = this.get('upgradeVersion') || App.defaultStackVersion;
+ var currentStack = {};
+ var upgradeStack = {};
+ var currentVersion = App.currentStackVersion.replace(/HDP-/, '');
+ var minUpgradeVersion = currentVersion;
+ upgradeVersion = upgradeVersion.replace(/HDP-/, '');
+ data.items.mapProperty('Versions.stack_version').forEach(function(version){
+ upgradeVersion = (upgradeVersion < version) ? version : upgradeVersion;
+ });
+ currentStack = data.items.findProperty('Versions.stack_version', currentVersion);
+ upgradeStack = data.items.findProperty('Versions.stack_version', upgradeVersion);
+ minUpgradeVersion = upgradeStack.Versions.min_upgrade_version;
+ if(minUpgradeVersion && (minUpgradeVersion > currentVersion)){
+ upgradeVersion = currentVersion;
+ upgradeStack = currentStack;
+ }
+ upgradeVersion = 'HDP-' + upgradeVersion;
+ this.set('upgradeVersion', upgradeVersion);
+ if(currentStack && upgradeStack) {
+ this.parseServicesInfo(currentStack, upgradeStack);
+ }
+ else {
+ console.log('HDP stack doesn\'t have services with defaultStackVersion');
+ }
+ },
+
+ updateUpgradeVersionErrorCallback: function(request, ajaxOptions, error) {
+ console.log('Error message is: ' + request.responseText);
+ console.log('HDP stack doesn\'t have services with defaultStackVersion');
+ },
+
/**
* parse services info(versions, description) by version
*/
Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step3.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step3.js?rev=1467084&r1=1467083&r2=1467084&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step3.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step3.js Thu Apr 11 21:05:32 2013
@@ -350,32 +350,30 @@ App.MainAdminSecurityAddStep3Controller
loadClusterConfigs: function () {
var self = this;
var url = App.apiPrefix + '/clusters/' + App.router.getClusterName();
- $.ajax({
- type: 'GET',
- url: url,
- timeout: 10000,
- dataType: 'text',
- success: function (data) {
- var jsonData = jQuery.parseJSON(data);
-
- //prepare tags to fetch all configuration for a service
- self.get('content.services').forEach(function (_secureService) {
- if (_secureService.serviceName !== 'GENERAL') {
- self.setServiceTagNames(_secureService, jsonData.Clusters.desired_configs);
- }
- });
- self.getAllConfigurations();
- },
- error: function (request, ajaxOptions, error) {
- self.get('stages').findProperty('stage', 'stage3').set('isError', true);
- console.log("TRACE: error code status is: " + request.status);
- },
+ App.ajax.send({
+ name: 'admin.security.add.cluster_configs',
+ sender: this,
+ success: 'loadClusterConfigsSuccessCallback',
+ error: 'loadClusterConfigsErrorCallback'
+ });
+ },
- statusCode: require('data/statusCodes')
+ loadClusterConfigsSuccessCallback: function (data) {
+ var self = this;
+ //prepare tags to fetch all configuration for a service
+ this.get('content.services').forEach(function (_secureService) {
+ if (_secureService.serviceName !== 'GENERAL') {
+ self.setServiceTagNames(_secureService, data.Clusters.desired_configs);
+ }
});
+ this.getAllConfigurations();
},
+ loadClusterConfigsErrorCallback: function (request, ajaxOptions, error) {
+ this.get('stages').findProperty('stage', 'stage3').set('isError', true);
+ console.log("TRACE: error code status is: " + request.status);
+ },
/**
* set tagnames for configuration of the *-site.xml
@@ -406,36 +404,34 @@ App.MainAdminSecurityAddStep3Controller
},
applyConfigurationToCluster: function (data) {
- var self = this;
- var url = App.apiPrefix + '/clusters/' + App.router.getClusterName();
var clusterData = {
Clusters: {
desired_config: data
}
};
- $.ajax({
- type: 'PUT',
- url: url,
- async: false,
- dataType: 'text',
- data: JSON.stringify(clusterData),
- timeout: 5000,
- success: function (data) {
- self.set('noOfWaitingAjaxCalls', self.get('noOfWaitingAjaxCalls') - 1);
- if (self.get('noOfWaitingAjaxCalls') == 0) {
- var currentStage = self.get('stages').findProperty('stage', 'stage3');
- currentStage.set('isSuccess', true);
- currentStage.set('isCompleted', true);
- }
+ App.ajax.send({
+ name: 'admin.security.apply_configuration',
+ sender: this,
+ data: {
+ clusterData: clusterData
},
- error: function (request, ajaxOptions, error) {
- self.get('stages').findProperty('stage', 'stage3').set('isError', true);
- },
- statusCode: require('data/statusCodes')
+ success: 'applyConfigurationToClusterSuccessCallback',
+ error: 'applyConfigurationToClusterErrorCallback'
});
+ },
+ applyConfigurationToClusterSuccessCallback: function (data) {
+ this.set('noOfWaitingAjaxCalls', this.get('noOfWaitingAjaxCalls') - 1);
+ if (this.get('noOfWaitingAjaxCalls') == 0) {
+ var currentStage = this.get('stages').findProperty('stage', 'stage3');
+ currentStage.set('isSuccess', true);
+ currentStage.set('isCompleted', true);
+ }
},
+ applyConfigurationToClusterErrorCallback: function (request, ajaxOptions, error) {
+ this.get('stages').findProperty('stage', 'stage3').set('isError', true);
+ },
/**
* gets site config properties from server and sets it for every configuration
@@ -443,41 +439,38 @@ App.MainAdminSecurityAddStep3Controller
*/
getAllConfigurations: function () {
- var self = this;
var urlParams = [];
this.get('serviceConfigTags').forEach(function (_tag) {
urlParams.push('(type=' + _tag.siteName + '&tag=' + _tag.tagName + ')');
}, this);
- var url = App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/configurations?' + urlParams.join('|');
if (urlParams.length > 0) {
- $.ajax({
- type: 'GET',
- url: url,
- async: true,
- timeout: 10000,
- dataType: 'json',
- success: function (data) {
- console.log("TRACE: In success function for the GET getServiceConfigsFromServer call");
- console.log("TRACE: The url is: " + url);
- self.get('serviceConfigTags').forEach(function (_tag) {
- _tag.configs = data.items.findProperty('type', _tag.siteName).properties;
- });
- self.addSecureConfigs();
- self.applyConfigurationsToCluster();
- },
-
- error: function (request, ajaxOptions, error) {
- self.get('stages').findProperty('stage', 'stage3').set('isError', true);
- console.log("TRACE: In error function for the getServiceConfigsFromServer call");
- console.log("TRACE: value of the url is: " + url);
- console.log("TRACE: error code status is: " + request.status);
+ App.ajax.send({
+ name: 'admin.security.all_configurations',
+ sender: this,
+ data: {
+ urlParams: urlParams.join('|')
},
-
- statusCode: require('data/statusCodes')
+ success: 'getAllConfigurationsSuccessCallback',
+ error: 'getAllConfigurationsErrorCallback'
});
}
},
+ getAllConfigurationsSuccessCallback: function (data) {
+ console.log("TRACE: In success function for the GET getServiceConfigsFromServer call");
+ this.get('serviceConfigTags').forEach(function (_tag) {
+ _tag.configs = data.items.findProperty('type', _tag.siteName).properties;
+ });
+ this.addSecureConfigs();
+ this.applyConfigurationsToCluster();
+ },
+
+ getAllConfigurationsErrorCallback: function (request, ajaxOptions, error) {
+ this.get('stages').findProperty('stage', 'stage3').set('isError', true);
+ console.log("TRACE: In error function for the getServiceConfigsFromServer call");
+ console.log("TRACE: error code status is: " + request.status);
+ },
+
addSecureConfigs: function () {
this.get('serviceConfigTags').forEach(function (_serviceConfigTags, index) {
_serviceConfigTags.newTagName = 'version' + (new Date).getTime();
@@ -485,7 +478,8 @@ App.MainAdminSecurityAddStep3Controller
this.get('globalProperties').forEach(function (_globalProperty) {
_serviceConfigTags.configs[_globalProperty.name] = _globalProperty.value;
}, this);
- } else {
+ }
+ else {
this.get('configs').filterProperty('id', 'site property').filterProperty('filename', _serviceConfigTags.siteName + '.xml').forEach(function (_config) {
_serviceConfigTags.configs[_config.name] = _config.value;
}, this);
Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/disable.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/disable.js?rev=1467084&r1=1467083&r2=1467084&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/disable.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/disable.js Thu Apr 11 21:05:32 2013
@@ -150,68 +150,63 @@ App.MainAdminSecurityDisableController =
},
loadClusterConfigs: function () {
- var self = this;
- var url = App.apiPrefix + '/clusters/' + App.router.getClusterName();
- $.ajax({
- type: 'GET',
- url: url,
- timeout: 10000,
- dataType: 'text',
- success: function (data) {
- var jsonData = jQuery.parseJSON(data);
- //prepare tags to fetch all configuration for a service
- self.get('secureServices').forEach(function (_secureService) {
- self.setServiceTagNames(_secureService, jsonData.Clusters.desired_configs);
- });
- self.getAllConfigurations();
- },
-
- error: function (request, ajaxOptions, error) {
- self.get('stages').findProperty('stage', 'stage3').set('isError', true);
- console.log("TRACE: error code status is: " + request.status);
- },
+ App.ajax.send({
+ name: 'admin.security.cluster_configs',
+ sender: this,
+ success: 'loadClusterConfigsSuccessCallback',
+ error: 'loadClusterConfigsErrorCallback'
+ });
+ },
- statusCode: require('data/statusCodes')
+ loadClusterConfigsSuccessCallback: function (jsonData) {
+ var self = this;
+ //prepare tags to fetch all configuration for a service
+ this.get('secureServices').forEach(function (_secureService) {
+ self.setServiceTagNames(_secureService, jsonData.Clusters.desired_configs);
});
+ this.getAllConfigurations();
+ },
+
+ loadClusterConfigsErrorCallback: function (request, ajaxOptions, error) {
+ this.get('stages').findProperty('stage', 'stage3').set('isError', true);
+ console.log("TRACE: error code status is: " + request.status);
},
getAllConfigurations: function () {
- var self = this;
var urlParams = [];
this.get('serviceConfigTags').forEach(function (_tag) {
urlParams.push('(type=' + _tag.siteName + '&tag=' + _tag.tagName + ')');
}, this);
- var url = App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/configurations?' + urlParams.join('|');
if (urlParams.length > 0) {
- $.ajax({
- type: 'GET',
- url: url,
- async: true,
- timeout: 10000,
- dataType: 'json',
- success: function (data) {
- console.log("TRACE: In success function for the GET getServiceConfigsFromServer call");
- console.log("TRACE: The url is: " + url);
- self.get('serviceConfigTags').forEach(function (_tag) {
- _tag.configs = data.items.findProperty('type', _tag.siteName).properties;
- });
- self.removeSecureConfigs();
- self.applyConfigurationsToCluster();
+ App.ajax.send({
+ name: 'admin.security.all_configurations',
+ sender: this,
+ data: {
+ urlParams: urlParams.join('|')
},
-
- error: function (request, ajaxOptions, error) {
- self.get('stages').findProperty('stage', 'stage3').set('isError', true);
- console.log("TRACE: In error function for the getServiceConfigsFromServer call");
- console.log("TRACE: value of the url is: " + url);
- console.log("TRACE: error code status is: " + request.status);
- },
-
- statusCode: require('data/statusCodes')
+ success: 'getAllConfigurationsSuccessCallback',
+ error: 'getAllConfigurationsErrorCallback'
});
}
},
- loadSecureServices: function () {
+ getAllConfigurationsSuccessCallback: function(data) {
+ console.log("TRACE: In success function for the GET getServiceConfigsFromServer call");
+ this.get('serviceConfigTags').forEach(function (_tag) {
+ _tag.configs = data.items.findProperty('type', _tag.siteName).properties;
+ });
+ this.removeSecureConfigs();
+ this.applyConfigurationsToCluster();
+ },
+
+ getAllConfigurationsErrorCallback: function (request, ajaxOptions, error) {
+ this.get('stages').findProperty('stage', 'stage3').set('isError', true);
+ console.log("TRACE: In error function for the getServiceConfigsFromServer call");
+ console.log("TRACE: error code status is: " + request.status);
+ },
+
+
+loadSecureServices: function () {
var secureServices = require('data/secure_configs');
var installedServices = App.Service.find().mapProperty('serviceName');
//General (only non service tab) tab is always displayed
@@ -231,35 +226,35 @@ App.MainAdminSecurityDisableController =
},
applyConfigurationToCluster: function (data) {
- var self = this;
- var url = App.apiPrefix + '/clusters/' + App.router.getClusterName();
var clusterData = {
Clusters: {
desired_config: data
}
};
- $.ajax({
- type: 'PUT',
- url: url,
- async: false,
- dataType: 'text',
- data: JSON.stringify(clusterData),
- timeout: 5000,
- success: function (data) {
- self.set('noOfWaitingAjaxCalls', self.get('noOfWaitingAjaxCalls') - 1);
- if (self.get('noOfWaitingAjaxCalls') == 0) {
- var currentStage = self.get('stages').findProperty('stage', 'stage3');
- currentStage.set('isSuccess', true);
- currentStage.set('isCompleted', true);
- }
+ App.ajax.send({
+ name: 'admin.security.apply_configuration',
+ sender: this,
+ data: {
+ clusterData: clusterData
},
- error: function (request, ajaxOptions, error) {
- self.get('stages').findProperty('stage', 'stage3').set('isError', true);
- },
- statusCode: require('data/statusCodes')
+ success: 'applyConfigurationToClusterSuccessCallback',
+ error: 'applyConfigurationToClusterErrorCallback'
});
},
+ applyConfigurationToClusterSuccessCallback: function (data) {
+ this.set('noOfWaitingAjaxCalls', this.get('noOfWaitingAjaxCalls') - 1);
+ if (this.get('noOfWaitingAjaxCalls') == 0) {
+ var currentStage = this.get('stages').findProperty('stage', 'stage3');
+ currentStage.set('isSuccess', true);
+ currentStage.set('isCompleted', true);
+ }
+ },
+
+ applyConfigurationToClusterErrorCallback: function (request, ajaxOptions, error) {
+ this.get('stages').findProperty('stage', 'stage3').set('isError', true);
+ },
+
getAllConfigsFromServer: function () {
this.set('noOfWaitingAjaxCalls', this.get('serviceConfigTags').length - 1);
this.get('serviceConfigTags').forEach(function (_serviceConfigTags) {
Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/host/configs_service.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/host/configs_service.js?rev=1467084&r1=1467083&r2=1467084&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/host/configs_service.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/host/configs_service.js Thu Apr 11 21:05:32 2013
@@ -61,6 +61,10 @@ App.MainHostServiceConfigsController = A
this._super(newServiceConfigs);
},
+ typeTagToHostMap: null,
+
+ configKeyToConfigMap: null,
+
/**
* This method will *not load* the overridden properties. However it will
* replace the value shown for properties which this host has override for.
@@ -83,55 +87,56 @@ App.MainHostServiceConfigsController = A
}
}
}
+ this.set('typeTagToHostMap', typeTagToHostMap);
+ this.set('configKeyToConfigMap', configKeyToConfigMap);
if (urlParams.length > 0) {
- var hostOverridesConfigsUrl = this.getUrl('', '/configurations?' + urlParams.join('|'));
- $.ajax({
- type: 'GET',
- url: hostOverridesConfigsUrl,
- async: false,
- timeout: 10000,
- dataType: 'json',
- success: function (data) {
- console.debug("loadServiceConfigHostsOverrides(" + hostOverridesConfigsUrl + "): Data=", data);
- data.items.forEach(function (config) {
- var hostname = typeTagToHostMap[config.type + "///" + config.tag];
- var properties = config.properties;
- for ( var prop in properties) {
- var serviceConfig = configKeyToConfigMap[prop];
- var hostOverrideValue = properties[prop];
- if (serviceConfig && serviceConfig.displayType === 'int') {
- if (/\d+m$/.test(hostOverrideValue)) {
- hostOverrideValue = hostOverrideValue.slice(0, hostOverrideValue.length - 1);
- }
- } else if (serviceConfig && serviceConfig.displayType === 'checkbox') {
- switch (hostOverrideValue) {
- case 'true':
- hostOverrideValue = true;
- break;
- case 'false':
- hostOverrideValue = false;
- break;
- }
- }
- if (serviceConfig) {
- // Value of this property is different for this host.
- console.log("loadServiceConfigHostsOverrides(" + thisHostName + "): [" + hostname + "] OVERRODE(" + serviceConfig.name + "): " + serviceConfig.value + " -> " + hostOverrideValue);
- serviceConfig.value = hostOverrideValue;
- serviceConfig.defaultValue = hostOverrideValue;
- serviceConfig.isOriginalSCP = false;
- serviceConfig.selectedHostOptions = [thisHostName];
- }
- }
- });
- console.log("loadServiceConfigHostsOverrides(" + thisHostName + "): Finished loading.");
- },
- error: function (request, ajaxOptions, error) {
- console.log("TRACE: loadServiceConfigHostsOverrides(" + thisHostName + "): ERROR");
- console.log("TRACE: value of the url is: " + hostOverridesConfigsUrl);
- console.log("TRACE: error code status is: " + request.status);
+ App.ajax.send({
+ name: 'host.service_config_hosts_overrides',
+ sender: this,
+ data: {
+ urlParams: urlParams.join('|')
},
- statusCode: require('data/statusCodes')
+ success: 'loadServiceConfigHostsOverridesSuccessCallback',
+ error: 'loadServiceConfigHostsOverridesErrorCallback'
});
}
+ },
+ loadServiceConfigHostsOverridesSuccessCallback: function (data) {
+ var typeTagToHostMap = this.get('typeTagToHostMap');
+ var configKeyToConfigMap = this.get('configKeyToConfigMap');
+ data.items.forEach(function (config) {
+ var hostname = typeTagToHostMap[config.type + "///" + config.tag];
+ var properties = config.properties;
+ for ( var prop in properties) {
+ var serviceConfig = configKeyToConfigMap[prop];
+ var hostOverrideValue = properties[prop];
+ if (serviceConfig && serviceConfig.displayType === 'int') {
+ if (/\d+m$/.test(hostOverrideValue)) {
+ hostOverrideValue = hostOverrideValue.slice(0, hostOverrideValue.length - 1);
+ }
+ } else if (serviceConfig && serviceConfig.displayType === 'checkbox') {
+ switch (hostOverrideValue) {
+ case 'true':
+ hostOverrideValue = true;
+ break;
+ case 'false':
+ hostOverrideValue = false;
+ break;
+ }
+ }
+ if (serviceConfig) {
+ // Value of this property is different for this host.
+ console.log("loadServiceConfigHostsOverrides(" + this.get('host.hostName') + "): [" + hostname + "] OVERRODE(" + serviceConfig.name + "): " + serviceConfig.value + " -> " + hostOverrideValue);
+ serviceConfig.value = hostOverrideValue;
+ serviceConfig.defaultValue = hostOverrideValue;
+ serviceConfig.isOriginalSCP = false;
+ serviceConfig.selectedHostOptions = [this.get('host.hostName')];
+ }
+ }
+ });
+ console.log("loadServiceConfigHostsOverrides(" + this.get('host.hostName') + "): Finished loading.");
+ },
+ loadServiceConfigHostsOverridesErrorCallback: function (request, ajaxOptions, error) {
+ console.log("TRACE: error code status is: " + request.status);
}
});
\ No newline at end of file
Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/service.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/service.js?rev=1467084&r1=1467083&r2=1467084&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/service.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/service.js Thu Apr 11 21:05:32 2013
@@ -74,8 +74,8 @@ App.MainServiceController = Em.ArrayCont
return;
}
var self = this;
- App.showConfirmationPopup2(function() {
- self.startAllServicesCall('startAllService');
+ App.showConfirmationPopup(function() {
+ self.allServicesCall('startAllService');
});
},
@@ -87,51 +87,40 @@ App.MainServiceController = Em.ArrayCont
return;
}
var self = this;
- App.showConfirmationPopup2(function() {
- self.startAllServicesCall('stopAllService');
+ App.showConfirmationPopup(function() {
+ self.allServicesCall('stopAllService');
});
},
- startAllServicesCall: function(state){
- var clusterName = App.router.get('applicationController').get('clusterName');
- var method = 'PUT';
- var url = App.apiPrefix + '/clusters/' + clusterName + '/services?ServiceInfo';
+ allServicesCall: function(state) {
var data;
- if(state == 'stopAllService'){
+ if(state == 'stopAllService') {
data = '{"RequestInfo": {"context" :"'+ Em.I18n.t('requestInfo.stopAllServices') +'"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}';
- }else{
- data = '{"RequestInfo": {"context" :"'+ Em.I18n.t('requestInfo.startAllServices') +'"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}';
}
-
- if (App.testMode) {
- url = this.get('mockDataPrefix') + '/poll_6.json';
- method = 'GET';
- this.numPolls = 6;
+ else {
+ data = '{"RequestInfo": {"context" :"'+ Em.I18n.t('requestInfo.startAllServices') +'"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}';
}
- $.ajax({
- type: method,
- url: url,
- async: false,
- data: data,
- dataType: 'text',
- timeout: App.timeout,
- success: function (data) {
- var jsonData = jQuery.parseJSON(data);
- console.log("TRACE: Start/Stop all service -> In success function for the start/stop all Service call");
- console.log("TRACE: Start/Stop all service -> value of the url is: " + url);
- console.log("TRACE: Start/Stop all service -> value of the received data is: " + jsonData);
- var requestId = jsonData.Requests.id;
- console.log('requestId is: ' + requestId);
-
- App.router.get('backgroundOperationsController').showPopup();
- },
- error: function () {
- console.log("ERROR");
+ App.ajax.send({
+ name: 'service.start_stop',
+ sender: this,
+ data: {
+ data: data
},
-
- statusCode: require('data/statusCodes')
+ success: 'allServicesCallSuccessCallback',
+ error: 'allServicesCallErrorCallback'
});
+ },
+ allServicesCallSuccessCallback: function(data) {
+ console.log("TRACE: Start/Stop all service -> In success function for the start/stop all Service call");
+ console.log("TRACE: Start/Stop all service -> value of the received data is: " + data);
+ var requestId = data.Requests.id;
+ console.log('requestId is: ' + requestId);
+
+ App.router.get('backgroundOperationsController').showPopup();
+ },
+ allServicesCallErrorCallback: function() {
+ console.log("ERROR");
}
})
\ No newline at end of file
Modified: incubator/ambari/trunk/ambari-web/app/controllers/wizard.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/wizard.js?rev=1467084&r1=1467083&r2=1467084&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/wizard.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/wizard.js Thu Apr 11 21:05:32 2013
@@ -253,105 +253,103 @@ App.WizardController = Em.Controller.ext
this.set('content.cluster.oldRequestsId', []);
this.set('content.cluster.requestId', null);
- var self = this;
var clusterName = this.get('content.cluster.name');
- var url;
- var method = (App.testMode) ? 'GET' : 'PUT';
var data;
+ var name;
switch (this.get('content.controllerName')) {
case 'addHostController':
if (isRetry) {
- url = App.apiPrefix + '/clusters/' + clusterName + '/host_components?HostRoles/state=INSTALLED';
- } else {
- url = App.apiPrefix + '/clusters/' + clusterName + '/host_components?HostRoles/state=INIT';
+ name = 'wizard.install_services.add_host_controller.is_retry';
+ }
+ else {
+ name = 'wizard.install_services.add_host_controller.not_is_retry';
}
data = '{"RequestInfo": {"context" :"'+ Em.I18n.t('requestInfo.installComponents') +'"}, "Body": {"HostRoles": {"state": "INSTALLED"}}}';
break;
case 'installerController':
default:
if (isRetry) {
- url = (App.testMode) ? '/data/wizard/deploy/2_hosts/poll_1.json' : App.apiPrefix + '/clusters/' + clusterName + '/host_components?HostRoles/state!=INSTALLED';
+ name = 'wizard.install_services.installer_controller.is_retry';
data = '{"RequestInfo": {"context" :"'+ Em.I18n.t('requestInfo.installComponents') +'"}, "Body": {"HostRoles": {"state": "INSTALLED"}}}';
- } else {
- url = (App.testMode) ? '/data/wizard/deploy/2_hosts/poll_1.json' : App.apiPrefix + '/clusters/' + clusterName + '/services?ServiceInfo/state=INIT';
+ }
+ else {
+ name = 'wizard.install_services.installer_controller.not_is_retry';
data = '{"RequestInfo": {"context" :"'+ Em.I18n.t('requestInfo.installServices') +'"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}';
}
break;
}
- $.ajax({
- type: method,
- url: url,
- data: data,
- async: false,
- dataType: 'text',
- timeout: App.timeout,
- success: function (data) {
- var jsonData = jQuery.parseJSON(data);
- var installStartTime = new Date().getTime();
- console.log("TRACE: In success function for the installService call");
- console.log("TRACE: value of the url is: " + url);
- if (jsonData) {
- var requestId = jsonData.Requests.id;
- console.log('requestId is: ' + requestId);
- var clusterStatus = {
- status: 'PENDING',
- requestId: requestId,
- isInstallError: false,
- isCompleted: false,
- installStartTime: installStartTime
- };
- self.saveClusterStatus(clusterStatus);
- } else {
- console.log('ERROR: Error occurred in parsing JSON data');
- }
+ App.ajax.send({
+ name: name,
+ sender: this,
+ data: {
+ data: data,
+ cluster: clusterName
},
+ success: 'installServicesSuccessCallback',
+ error: 'installServicesErrorCallback'
+ });
+ },
- error: function (request, ajaxOptions, error) {
- console.log("TRACE: In error function for the installService call");
- console.log("TRACE: value of the url is: " + url);
- console.log("TRACE: error code status is: " + request.status);
- console.log('Error message is: ' + request.responseText);
- var clusterStatus = {
- status: 'PENDING',
- isInstallError: false,
- isCompleted: false
- };
-
- self.saveClusterStatus(clusterStatus);
- },
+ installServicesSuccessCallback: function (jsonData) {
+ var installStartTime = new Date().getTime();
+ console.log("TRACE: In success function for the installService call");
+ if (jsonData) {
+ var requestId = jsonData.Requests.id;
+ console.log('requestId is: ' + requestId);
+ var clusterStatus = {
+ status: 'PENDING',
+ requestId: requestId,
+ isInstallError: false,
+ isCompleted: false,
+ installStartTime: installStartTime
+ };
+ this.saveClusterStatus(clusterStatus);
+ } else {
+ console.log('ERROR: Error occurred in parsing JSON data');
+ }
+ },
- statusCode: require('data/statusCodes')
- });
+ installServicesErrorCallback: function (request, ajaxOptions, error) {
+ console.log("TRACE: In error function for the installService call");
+ console.log("TRACE: error code status is: " + request.status);
+ console.log('Error message is: ' + request.responseText);
+ var clusterStatus = {
+ status: 'PENDING',
+ isInstallError: false,
+ isCompleted: false
+ };
+ this.saveClusterStatus(clusterStatus);
},
+ bootstrapRequestId: null,
+
/*
Bootstrap selected hosts.
*/
launchBootstrap: function (bootStrapData) {
- var self = this;
- var requestId = null;
- var method = App.testMode ? 'GET' : 'POST';
- var url = App.testMode ? '/data/wizard/bootstrap/bootstrap.json' : App.apiPrefix + '/bootstrap';
- $.ajax({
- type: method,
- url: url,
- async: false,
- data: bootStrapData,
- timeout: App.timeout,
- contentType: 'application/json',
- success: function (data) {
- console.log("TRACE: POST bootstrap succeeded");
- requestId = data.requestId;
- },
- error: function () {
- console.log("ERROR: POST bootstrap failed");
- alert('Bootstrap call failed. Please try again.');
+ App.ajax.send({
+ name: 'wizard.launch_bootstrap',
+ sender: this,
+ data: {
+ bootStrapData: bootStrapData
},
- statusCode: require('data/statusCodes')
+ success: 'launchBootstrapSuccessCallback',
+ error: 'launchBootstrapErrorCallback'
});
- return requestId;
+
+ return this.get('bootstrapRequestId');
+ },
+
+ launchBootstrapSuccessCallback: function (data) {
+ console.log("TRACE: POST bootstrap succeeded");
+ this.set('bootstrapRequestId', data.requestId);
+ },
+
+ launchBootstrapErrorCallback: function () {
+ console.log("ERROR: POST bootstrap failed");
+ alert('Bootstrap call failed. Please try again.');
},
/**
@@ -423,77 +421,75 @@ App.WizardController = Em.Controller.ext
sshKey: "", //string
bootRequestId: null //string
},
+
+ loadedServiceComponents: null,
+
/**
* Generate serviceComponents as pr the stack definition and save it to localdata
* called form stepController step4WizardController
*/
- loadServiceComponents: function (displayOrderConfig, apiUrl) {
- var result = null;
- var method = 'GET';
- var testUrl = '/data/wizard/stack/hdp/version/1.3.0.json';
- var url = (App.testMode) ? testUrl : App.apiPrefix + apiUrl + '?fields=stackServices/StackServices';
- $.ajax({
- type: method,
- url: url,
- async: false,
- dataType: 'text',
- timeout: App.timeout,
- success: function (data) {
- var jsonData = jQuery.parseJSON(data);
- console.log("TRACE: getService ajax call -> In success function for the getServiceComponents call");
- console.log("TRACE: jsonData.services : " + jsonData.services);
-
- // Creating Model
- var Service = Ember.Object.extend({
- serviceName: null,
- displayName: null,
- isDisabled: true,
- isSelected: true,
- isInstalled: false,
- description: null,
- version: null
- });
+ loadServiceComponents: function () {
+ App.ajax.send({
+ name: 'wizard.service_components',
+ sender: this,
+ data: {
+ stackUrl: App.get('stackVersionURL')
+ },
+ success: 'loadServiceComponentsSuccessCallback',
+ error: 'loadServiceComponentsErrorCallback'
+ });
+ return this.get('loadedServiceComponents');
+ },
- var data = [];
+ loadServiceComponentsSuccessCallback: function (jsonData) {
+ var displayOrderConfig = require('data/services');
+ console.log("TRACE: getService ajax call -> In success function for the getServiceComponents call");
+ console.log("TRACE: jsonData.services : " + jsonData.services);
- // loop through all the service components
- for (var i = 0; i < displayOrderConfig.length; i++) {
- var entry = jsonData.stackServices.findProperty("StackServices.service_name", displayOrderConfig[i].serviceName);
- if (entry) {
- entry = entry.StackServices;
- var myService = Service.create({
- serviceName: entry.service_name,
- displayName: displayOrderConfig[i].displayName,
- isDisabled: i === 0,
- isSelected: true,
- isInstalled: false,
- isHidden: displayOrderConfig[i].isHidden,
- description: entry.comments,
- version: entry.service_version
- });
+ // Creating Model
+ var Service = Ember.Object.extend({
+ serviceName: null,
+ displayName: null,
+ isDisabled: true,
+ isSelected: true,
+ isInstalled: false,
+ description: null,
+ version: null
+ });
- data.push(myService);
- }
- else {
- console.warn('Service not found - ', displayOrderConfig[i].serviceName);
- }
- }
+ var data = [];
- result = data;
- console.log('TRACE: service components: ' + JSON.stringify(data));
+ // loop through all the service components
+ for (var i = 0; i < displayOrderConfig.length; i++) {
+ var entry = jsonData.services.findProperty("name", displayOrderConfig[i].serviceName);
+ if (entry) {
+ var myService = Service.create({
+ serviceName: entry.name,
+ displayName: displayOrderConfig[i].displayName,
+ isDisabled: i === 0,
+ isSelected: true,
+ isInstalled: false,
+ isHidden: displayOrderConfig[i].isHidden,
+ description: entry.comment,
+ version: entry.version
+ });
- },
+ data.push(myService);
+ }
+ else {
+ console.warn('Service not found - ', displayOrderConfig[i].serviceName);
+ }
+ }
- error: function (request, ajaxOptions, error) {
- console.log("TRACE: STep5 -> In error function for the getServiceComponents call");
- console.log("TRACE: STep5 -> value of the url is: " + url);
- console.log("TRACE: STep5 -> error code status is: " + request.status);
- console.log('Step8: Error message is: ' + request.responseText);
- },
+ this.set('loadedServiceComponents', data);
+ console.log('TRACE: service components: ' + JSON.stringify(data));
- statusCode: require('data/statusCodes')
- });
- return result;
+ },
+
+ loadServiceComponentsErrorCallback: function (request, ajaxOptions, error) {
+ console.log("TRACE: STep5 -> In error function for the getServiceComponents call");
+ console.log("TRACE: STep5 -> error code status is: " + request.status);
+ console.log('Step8: Error message is: ' + request.responseText);
},
loadServicesFromServer: function() {
@@ -501,9 +497,7 @@ App.WizardController = Em.Controller.ext
if (services) {
return;
}
- var displayOrderConfig = require('data/services');
- var apiUrl = App.get('stack2VersionURL');
- var apiService = this.loadServiceComponents(displayOrderConfig, apiUrl);
+ var apiService = this.loadServiceComponents();
this.set('content.services', apiService);
App.db.setService(apiService);
},
Modified: incubator/ambari/trunk/ambari-web/app/controllers/wizard/stack_upgrade/step3_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/wizard/stack_upgrade/step3_controller.js?rev=1467084&r1=1467083&r2=1467084&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/wizard/stack_upgrade/step3_controller.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/wizard/stack_upgrade/step3_controller.js Thu Apr 11 21:05:32 2013
@@ -142,12 +142,7 @@ App.StackUpgradeStep3Controller = Em.Con
* run stop services
*/
stopServices: function () {
- var clusterName = this.get('content.cluster.name');
- var url = App.apiPrefix + '/clusters/' + clusterName + '/services?ServiceInfo/state=STARTED';
- var data = '{"RequestInfo": {"context": "'+ Em.I18n.t("requestInfo.stopAllServices") +'"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}';
- var method = 'PUT';
var process = this.get('processes').findProperty('name', 'STOP_SERVICES');
- var self = this;
process.set('isRunning', true);
if (App.testMode) {
this.startPolling();
@@ -156,43 +151,43 @@ App.StackUpgradeStep3Controller = Em.Con
status: 'STOPPING_SERVICES',
isCompleted: false
});
- } else {
- $.ajax({
- type: method,
- url: url,
- async: false,
- data: data,
- dataType: 'text',
- timeout: App.timeout,
- success: function (data) {
- var requestId = jQuery.parseJSON(data).Requests.id;
- var clusterStatus = {
- requestId: requestId,
- status: 'STOPPING_SERVICES',
- isCompleted: false
- };
- process.set('status', 'IN_PROGRESS');
- self.saveClusterStatus(clusterStatus);
- self.startPolling();
- console.log('Call to stop service successful')
- },
- error: function () {
- self.finishProcess(process, 'FAILED');
- process.set('status', 'FAILED');
- console.log("Call to stop services failed");
+ }
+ else {
+ var data = '{"RequestInfo": {"context": "'+ Em.I18n.t("requestInfo.stopAllServices") +'"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}';
+ App.ajax.send({
+ name: 'admin.stack_upgrade.stop_services',
+ sender: this,
+ data: {
+ data: data
},
- statusCode: require('data/statusCodes')
+ success: 'stopServicesSuccessCallback',
+ error: 'stopServicesErrorCallback'
});
}
},
+ stopServicesSuccessCallback: function (data) {
+ var process = this.get('processes').findProperty('name', 'STOP_SERVICES');
+ var requestId = data.Requests.id;
+ var clusterStatus = {
+ requestId: requestId,
+ status: 'STOPPING_SERVICES',
+ isCompleted: false
+ };
+ process.set('status', 'IN_PROGRESS');
+ this.saveClusterStatus(clusterStatus);
+ this.startPolling();
+ console.log('Call to stop service successful')
+ },
+ stopServicesErrorCallback: function () {
+ var process = this.get('processes').findProperty('name', 'STOP_SERVICES');
+ this.finishProcess(process, 'FAILED');
+ process.set('status', 'FAILED');
+ console.log("Call to stop services failed");
+ },
/**
* send request to run upgrade all services
*/
runUpgrade: function () {
- var method = "PUT";
- var url = App.apiPrefix + '/clusters/' + this.get('content.cluster.name');
- var self = this;
- var data = '{"Clusters": {"version" : "' + this.get('content.upgradeVersion') + '"}}';
var process = this.get('processes').findProperty('name', 'UPGRADE_SERVICES');
process.set('isRunning', true);
if (App.testMode) {
@@ -202,34 +197,39 @@ App.StackUpgradeStep3Controller = Em.Con
status: 'STACK_UPGRADING',
isCompleted: false
});
- } else {
- $.ajax({
- type: method,
- url: url,
- async: false,
- data: data,
- dataType: 'text',
- timeout: App.timeout,
- success: function (data) {
- var jsonData = jQuery.parseJSON(data);
- var requestId = jsonData.Requests.id;
- var clusterStatus = {
- status: 'STACK_UPGRADING',
- requestId: requestId,
- isCompleted: false
- };
- process.set('status', 'IN_PROGRESS');
- self.saveClusterStatus(clusterStatus);
- self.startPolling();
- },
- error: function (request, ajaxOptions, error) {
- self.finishProcess(process, 'FAILED');
- process.set('status', 'FAILED');
+ }
+ else {
+ var data = '{"Clusters": {"version" : "' + this.get('content.upgradeVersion') + '"}}';
+ App.ajax.send({
+ name: 'admin.stack_upgrade.run_upgrade',
+ sender: this,
+ data: {
+ data: data
},
- statusCode: require('data/statusCodes')
+ success: 'runUpgradeSuccessCallback',
+ error: 'runUpgradeErrorCallback'
});
}
},
+ runUpgradeSuccessCallback: function (jsonData) {
+ var process = this.get('processes').findProperty('name', 'UPGRADE_SERVICES');
+ var requestId = jsonData.Requests.id;
+ var clusterStatus = {
+ status: 'STACK_UPGRADING',
+ requestId: requestId,
+ isCompleted: false
+ };
+ process.set('status', 'IN_PROGRESS');
+ this.saveClusterStatus(clusterStatus);
+ this.startPolling();
+ },
+
+ runUpgradeErrorCallback: function (request, ajaxOptions, error) {
+ var process = this.get('processes').findProperty('name', 'UPGRADE_SERVICES');
+ this.finishProcess(process, 'FAILED');
+ process.set('status', 'FAILED');
+ },
+
/**
* start polling tasks for current process
*/
@@ -253,17 +253,17 @@ App.StackUpgradeStep3Controller = Em.Con
var simulateAttempt = this.get('simulateAttempt');
var process = this.get('processes').findProperty('isRunning', true);
var upgradeURLs = [
- '/data/wizard/upgrade/poll_1.json',
- '/data/wizard/upgrade/poll_2.json',
- '/data/wizard/upgrade/poll_3.json',
- '/data/wizard/upgrade/poll_4.json',
- '/data/wizard/upgrade/poll_5.json'
+ '/upgrade/poll_1.json',
+ '/upgrade/poll_2.json',
+ '/upgrade/poll_3.json',
+ '/upgrade/poll_4.json',
+ '/upgrade/poll_5.json'
];
var stopURLs = [
- '/data/wizard/stop_services/poll_1.json',
- '/data/wizard/stop_services/poll_2.json',
- '/data/wizard/stop_services/poll_3.json',
- '/data/wizard/stop_services/poll_4.json'
+ '/stop_services/poll_1.json',
+ '/stop_services/poll_2.json',
+ '/stop_services/poll_3.json',
+ '/stop_services/poll_4.json'
];
if(process.get('name') == 'STOP_SERVICES'){
if(simulateAttempt < 4){
@@ -291,41 +291,51 @@ App.StackUpgradeStep3Controller = Em.Con
* poll server for tasks, which contain process progress data
* @param interval
*/
- doPoll: function(interval){
- var url = this.getUrl();
+ doPoll: function(interval) {
var self = this;
var pollInterval = interval || self.POLL_INTERVAL;
if (self.get('isPolling')) {
setTimeout(function () {
- $.ajax({
- type: 'GET',
- url: url,
- async: true,
- timeout: App.timeout,
- dataType: 'json',
- success: function (data) {
- var result = self.parseTasks(data);
- if(result){
- if (App.testMode) {
- self.simulatePolling();
- } else {
- self.doPoll();
- }
- }
- },
- error: function () {
- console.log('ERROR: poll request failed')
+
+ App.ajax.send({
+ name: 'admin.stack_upgrade.do_poll',
+ sender: self,
+ data: {
+ cluster: self.get('content.cluster.name'),
+ requestId: self.get('content.cluster.requestId'),
+ mock: self.get('mockUrl')
},
- statusCode: require('data/statusCodes')
- }).retry({times: App.maxRetries, timeout: App.timeout}).then(null,
- function () {
- App.showReloadPopup();
- console.log('Install services all retries failed');
- }
- );
+ success: 'doPollSuccessCallback',
+ error: 'doPollErrorCallback'
+ }).retry({
+ times: App.maxRetries,
+ timeout: App.timeout
+ }).then(
+ null,
+ function () {
+ App.showReloadPopup();
+ console.log('Install services all retries failed');
+ });
}, pollInterval);
}
},
+
+ doPollSuccessCallback: function (data) {
+ var result = this.parseTasks(data);
+ if(result){
+ if (App.testMode) {
+ this.simulatePolling();
+ }
+ else {
+ this.doPoll();
+ }
+ }
+ },
+
+ doPollErrorCallback: function () {
+ console.log('ERROR: poll request failed')
+ },
+
/**
* parse tasks from poll
* change status, message, progress on services according to tasks
Modified: incubator/ambari/trunk/ambari-web/app/controllers/wizard/step3_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/wizard/step3_controller.js?rev=1467084&r1=1467083&r2=1467084&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/wizard/step3_controller.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/wizard/step3_controller.js Thu Apr 11 21:05:32 2013
@@ -290,61 +290,69 @@ App.WizardStep3Controller = Em.Controlle
return;
}
this.numPolls++;
- var self = this;
- var url = App.testMode ? '/data/wizard/bootstrap/poll_' + this.numPolls + '.json' : App.apiPrefix + '/bootstrap/' + this.get('content.installOptions.bootRequestId');
- $.ajax({
- type: 'GET',
- url: url,
- timeout: App.timeout,
- success: function (data) {
- if (data.hostsStatus !== null) {
- // in case of bootstrapping just one host, the server returns an object rather than an array, so
- // force into an array
- if (!(data.hostsStatus instanceof Array)) {
- data.hostsStatus = [ data.hostsStatus ];
- }
- console.log("TRACE: In success function for the GET bootstrap call");
- var keepPolling = self.parseHostInfo(data.hostsStatus);
-
- // Single host : if the only hostname is invalid (data.status == 'ERROR')
- // Multiple hosts : if one or more hostnames are invalid
- // following check will mark the bootStatus as 'FAILED' for the invalid hostname
- if (data.status == 'ERROR' || data.hostsStatus.length != self.get('bootHosts').length) {
-
- var hosts = self.get('bootHosts');
-
- for (var i = 0; i < hosts.length; i++) {
-
- var isValidHost = data.hostsStatus.someProperty('hostName', hosts[i].get('name'));
- if(hosts[i].get('bootStatus') !== 'REGISTERED'){
- if (!isValidHost) {
- hosts[i].set('bootStatus', 'FAILED');
- hosts[i].set('bootLog', Em.I18n.t('installer.step3.hosts.bootLog.failed'));
- }
- }
- }
- }
- if (data.hostsStatus.someProperty('status', 'DONE') || data.hostsStatus.someProperty('status', 'FAILED')) {
- // kicking off registration polls after at least one host has succeeded
- self.startRegistration();
- }
- if (keepPolling) {
- window.setTimeout(function () {
- self.doBootstrap()
- }, 3000);
- return;
+ App.ajax.send({
+ name: 'wizard.step3.bootstrap',
+ sender: this,
+ data: {
+ bootRequestId: this.get('content.installOptions.bootRequestId'),
+ numPolls: this.numPolls
+ },
+ success: 'doBootstrapSuccessCallback'
+ }).
+ retry({
+ times: App.maxRetries,
+ timeout: App.timeout
+ }).
+ then(
+ null,
+ function () {
+ App.showReloadPopup();
+ console.log('Bootstrap failed');
+ }
+ );
+ },
+
+ doBootstrapSuccessCallback: function (data) {
+ if (data.hostsStatus !== null) {
+ // in case of bootstrapping just one host, the server returns an object rather than an array, so
+ // force into an array
+ if (!(data.hostsStatus instanceof Array)) {
+ data.hostsStatus = [ data.hostsStatus ];
+ }
+ console.log("TRACE: In success function for the GET bootstrap call");
+ var keepPolling = this.parseHostInfo(data.hostsStatus);
+
+ // Single host : if the only hostname is invalid (data.status == 'ERROR')
+ // Multiple hosts : if one or more hostnames are invalid
+ // following check will mark the bootStatus as 'FAILED' for the invalid hostname
+ if (data.status == 'ERROR' || data.hostsStatus.length != this.get('bootHosts').length) {
+
+ var hosts = this.get('bootHosts');
+
+ for (var i = 0; i < hosts.length; i++) {
+
+ var isValidHost = data.hostsStatus.someProperty('hostName', hosts[i].get('name'));
+ if(hosts[i].get('bootStatus') !== 'REGISTERED'){
+ if (!isValidHost) {
+ hosts[i].set('bootStatus', 'FAILED');
+ hosts[i].set('bootLog', Em.I18n.t('installer.step3.hosts.bootLog.failed'));
+ }
}
}
- },
- statusCode: require('data/statusCodes')
- }).retry({times: App.maxRetries, timeout: App.timeout}).then(null,
- function () {
- App.showReloadPopup();
- console.log('Bootstrap failed');
}
- );
+ if (data.hostsStatus.someProperty('status', 'DONE') || data.hostsStatus.someProperty('status', 'FAILED')) {
+ // kicking off registration polls after at least one host has succeeded
+ this.startRegistration();
+ }
+ if (keepPolling) {
+ var self = this;
+ window.setTimeout(function () {
+ self.doBootstrap()
+ }, 3000);
+ }
+ }
},
/*
@@ -368,88 +376,94 @@ App.WizardStep3Controller = Em.Controlle
if (this.get('stopBootstrap')) {
return;
}
- var self = this;
+ App.ajax.send({
+ name: 'wizard.step3.is_hosts_registered',
+ sender: this,
+ success: 'isHostsRegisteredSuccessCallback'
+ }).
+ retry({
+ times: App.maxRetries,
+ timeout: App.timeout
+ }).
+ then(
+ null,
+ function () {
+ App.showReloadPopup();
+ console.log('Error: Getting registered host information from the server');
+ }
+ );
+ },
+
+ isHostsRegisteredSuccessCallback: function (data) {
+ console.log('registration attempt...');
var hosts = this.get('bootHosts');
- var url = App.testMode ? '/data/wizard/bootstrap/single_host_registration.json' : App.apiPrefix + '/hosts';
+ var jsonData = data;
+ if (!jsonData) {
+ console.warn("Error: jsonData is null");
+ return;
+ }
- $.ajax({
- type: 'GET',
- url: url,
- timeout: App.timeout,
- success: function (data) {
- console.log('registration attempt...');
- var jsonData = App.testMode ? data : jQuery.parseJSON(data);
- if (!jsonData) {
- console.log("Error: jsonData is null");
- return;
+ // keep polling until all hosts have registered/failed, or registrationTimeout seconds after the last host finished bootstrapping
+ var stopPolling = true;
+ hosts.forEach(function (_host, index) {
+ // Change name of first host for test mode.
+ if (App.testMode) {
+ if (index == 0) {
+ _host.set('name', 'localhost.localdomain');
}
-
- // keep polling until all hosts have registered/failed, or registrationTimeout seconds after the last host finished bootstrapping
- var stopPolling = true;
- hosts.forEach(function (_host, index) {
- // Change name of first host for test mode.
- if (App.testMode) {
- if (index == 0) {
- _host.set('name', 'localhost.localdomain');
- }
+ }
+ // actions to take depending on the host's current bootStatus
+ // RUNNING - bootstrap is running; leave it alone
+ // DONE - bootstrap is done; transition to REGISTERING
+ // REGISTERING - bootstrap is done but has not registered; transition to REGISTERED if host found in polling API result
+ // REGISTERED - bootstrap and registration is done; leave it alone
+ // FAILED - either bootstrap or registration failed; leave it alone
+ console.log(_host.name + ' bootStatus=' + _host.get('bootStatus'));
+ switch (_host.get('bootStatus')) {
+ case 'DONE':
+ _host.set('bootStatus', 'REGISTERING');
+ _host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + Em.I18n.t('installer.step3.hosts.bootLog.registering'));
+ // update registration timestamp so that the timeout is computed from the last host that finished bootstrapping
+ this.set('registrationStartedAt', new Date().getTime());
+ stopPolling = false;
+ break;
+ case 'REGISTERING':
+ if (jsonData.items.someProperty('Hosts.host_name', _host.name)) {
+ console.log(_host.name + ' has been registered');
+ _host.set('bootStatus', 'REGISTERED');
+ _host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + Em.I18n.t('installer.step3.hosts.bootLog.registering'));
+ } else {
+ console.log(_host.name + ' is registering...');
+ stopPolling = false;
}
- // actions to take depending on the host's current bootStatus
- // RUNNING - bootstrap is running; leave it alone
- // DONE - bootstrap is done; transition to REGISTERING
- // REGISTERING - bootstrap is done but has not registered; transition to REGISTERED if host found in polling API result
- // REGISTERED - bootstrap and registration is done; leave it alone
- // FAILED - either bootstrap or registration failed; leave it alone
- console.log(_host.name + ' bootStatus=' + _host.get('bootStatus'));
- switch (_host.get('bootStatus')) {
- case 'DONE':
- _host.set('bootStatus', 'REGISTERING');
- _host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + Em.I18n.t('installer.step3.hosts.bootLog.registering'));
- // update registration timestamp so that the timeout is computed from the last host that finished bootstrapping
- self.set('registrationStartedAt', new Date().getTime());
- stopPolling = false;
- break;
- case 'REGISTERING':
- if (jsonData.items.someProperty('Hosts.host_name', _host.name)) {
- console.log(_host.name + ' has been registered');
- _host.set('bootStatus', 'REGISTERED');
- _host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + Em.I18n.t('installer.step3.hosts.bootLog.registering'));
- } else {
- console.log(_host.name + ' is registering...');
- stopPolling = false;
- }
- break;
- case 'RUNNING':
- stopPolling = false;
- break;
- case 'REGISTERED':
- case 'FAILED':
- default:
- break;
- }
- }, this);
-
- if (stopPolling) {
- self.getHostInfo();
- } else if (hosts.someProperty('bootStatus', 'RUNNING') || new Date().getTime() - self.get('registrationStartedAt') < self.get('registrationTimeoutSecs') * 1000) {
- // we want to keep polling for registration status if any of the hosts are still bootstrapping (so we check for RUNNING).
- window.setTimeout(function () {
- self.isHostsRegistered();
- }, 3000);
- } else {
- // registration timed out. mark all REGISTERING hosts to FAILED
- console.log('registration timed out');
- hosts.filterProperty('bootStatus', 'REGISTERING').forEach(function (_host) {
- _host.set('bootStatus', 'FAILED');
- _host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + Em.I18n.t('installer.step3.hosts.bootLog.failed'));
- });
- self.getHostInfo();
- }
- },
- statusCode: require('data/statusCodes')
- }).retry({times: App.maxRetries, timeout: App.timeout}).then(null, function () {
- App.showReloadPopup();
- console.log('Error: Getting registered host information from the server');
+ break;
+ case 'RUNNING':
+ stopPolling = false;
+ break;
+ case 'REGISTERED':
+ case 'FAILED':
+ default:
+ break;
+ }
+ }, this);
+
+ if (stopPolling) {
+ this.getHostInfo();
+ } else if (hosts.someProperty('bootStatus', 'RUNNING') || new Date().getTime() - this.get('registrationStartedAt') < this.get('registrationTimeoutSecs') * 1000) {
+ // we want to keep polling for registration status if any of the hosts are still bootstrapping (so we check for RUNNING).
+ var self = this;
+ window.setTimeout(function () {
+ self.isHostsRegistered();
+ }, 3000);
+ } else {
+ // registration timed out. mark all REGISTERING hosts to FAILED
+ console.log('registration timed out');
+ hosts.filterProperty('bootStatus', 'REGISTERING').forEach(function (_host) {
+ _host.set('bootStatus', 'FAILED');
+ _host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + Em.I18n.t('installer.step3.hosts.bootLog.failed'));
});
+ this.getHostInfo();
+ }
},
registerErrPopup: function (header, message) {
@@ -470,44 +484,39 @@ App.WizardStep3Controller = Em.Controlle
* Get disk info and cpu count of booted hosts from server
*/
getHostInfo: function () {
- var self = this;
- var kbPerGb = 1024;
+ App.ajax.send({
+ name: 'wizard.step3.host_info',
+ sender: this,
+ success: 'getHostInfoSuccessCallback',
+ error: 'getHostInfoErrorCallback'
+ });
+ },
+
+ getHostInfoSuccessCallback: function (jsonData) {
var hosts = this.get('bootHosts');
- var url = App.testMode ? '/data/wizard/bootstrap/two_hosts_information.json' : App.apiPrefix + '/hosts?fields=Hosts/total_mem,Hosts/cpu_count,Hosts/disk_info,Hosts/last_agent_env';
- var method = 'GET';
- $.ajax({
- type: 'GET',
- url: url,
- contentType: 'application/json',
- timeout: App.timeout,
- success: function (data) {
- var jsonData = (App.testMode) ? data : jQuery.parseJSON(data);
- self.parseWarnings(jsonData);
- hosts.forEach(function (_host) {
- var host = (App.testMode) ? jsonData.items[0] : jsonData.items.findProperty('Hosts.host_name', _host.name);
- if (App.skipBootstrap) {
- _host.cpu = 2;
- _host.memory = ((parseInt(2000000))).toFixed(2);
- _host.disk_info = [{"mountpoint": "/", "type":"ext4"},{"mountpoint": "/grid/0", "type":"ext4"}, {"mountpoint": "/grid/1", "type":"ext4"}, {"mountpoint": "/grid/2", "type":"ext4"}];
- } else if (host) {
- _host.cpu = host.Hosts.cpu_count;
- _host.memory = ((parseInt(host.Hosts.total_mem))).toFixed(2);
- _host.disk_info = host.Hosts.disk_info;
-
- console.log("The value of memory is: " + _host.memory);
- }
- });
- self.set('bootHosts', hosts);
- console.log("The value of hosts: " + JSON.stringify(hosts));
- self.stopRegistration();
- },
+ this.parseWarnings(jsonData);
+ hosts.forEach(function (_host) {
+ var host = (App.testMode) ? jsonData.items[0] : jsonData.items.findProperty('Hosts.host_name', _host.name);
+ if (App.skipBootstrap) {
+ _host.cpu = 2;
+ _host.memory = ((parseInt(2000000))).toFixed(2);
+ _host.disk_info = [{"mountpoint": "/", "type":"ext4"},{"mountpoint": "/grid/0", "type":"ext4"}, {"mountpoint": "/grid/1", "type":"ext4"}, {"mountpoint": "/grid/2", "type":"ext4"}];
+ } else if (host) {
+ _host.cpu = host.Hosts.cpu_count;
+ _host.memory = ((parseInt(host.Hosts.total_mem))).toFixed(2);
+ _host.disk_info = host.Hosts.disk_info;
- error: function () {
- console.log('INFO: Getting host information(cpu_count and total_mem) from the server failed');
- self.registerErrPopup(Em.I18n.t('installer.step3.hostInformation.popup.header'), Em.I18n.t('installer.step3.hostInformation.popup.body'));
- },
- statusCode: require('data/statusCodes')
+ console.log("The value of memory is: " + _host.memory);
+ }
});
+ this.set('bootHosts', hosts);
+ console.log("The value of hosts: " + JSON.stringify(hosts));
+ this.stopRegistration();
+ },
+
+ getHostInfoErrorCallback: function () {
+ console.log('INFO: Getting host information(cpu_count and total_mem) from the server failed');
+ this.registerErrPopup(Em.I18n.t('installer.step3.hostInformation.popup.header'), Em.I18n.t('installer.step3.hostInformation.popup.body'));
},
stopRegistration: function () {
@@ -593,27 +602,29 @@ App.WizardStep3Controller = Em.Controlle
}, 1000);
setTimeout(function(){
clearInterval(interval);
- $.ajax({
- type: 'GET',
- url: url,
- contentType: 'application/json',
- timeout: App.timeout,
- success: function (data) {
- var jsonData = (App.testMode) ? data : jQuery.parseJSON(data);
- self.set('checksUpdateProgress', 100);
- self.set('checksUpdateStatus', 'SUCCESS');
- self.parseWarnings(jsonData);
- },
- error: function () {
- self.set('checksUpdateProgress', 100);
- self.set('checksUpdateStatus', 'FAILED');
- console.log('INFO: Getting host information(last_agent_env) from the server failed');
- },
- statusCode: require('data/statusCodes')
- })
+ App.ajax.send({
+ name: 'wizard.step3.rerun_checks',
+ sender: this,
+ success: 'rerunChecksSuccessCallback',
+ error: 'rerunChecksErrorCallback'
+ });
}, this.get('warningsTimeInterval'));
},
+
+ rerunChecksSuccessCallback: function (data) {
+ var jsonData = (App.testMode) ? data : jQuery.parseJSON(data);
+ this.set('checksUpdateProgress', 100);
+ this.set('checksUpdateStatus', 'SUCCESS');
+ this.parseWarnings(jsonData);
+ },
+
+ rerunChecksErrorCallback: function () {
+ this.set('checksUpdateProgress', 100);
+ this.set('checksUpdateStatus', 'FAILED');
+ console.log('INFO: Getting host information(last_agent_env) from the server failed');
+ },
+
warnings: [],
warningsTimeInterval: 60000,
/**
Modified: incubator/ambari/trunk/ambari-web/app/controllers/wizard/step8_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/wizard/step8_controller.js?rev=1467084&r1=1467083&r2=1467084&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/wizard/step8_controller.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/wizard/step8_controller.js Thu Apr 11 21:05:32 2013
@@ -878,49 +878,55 @@ App.WizardStep8Controller = Em.Controlle
return this.get('content.cluster.name');
}.property('content.cluster.name'),
+ clusterNames: [],
+
// returns an array of existing cluster names.
// returns an empty array if there are no existing clusters.
getExistingClusterNames: function () {
var url = App.apiPrefix + '/clusters';
- var clusterNames = [];
-
- $.ajax({
- type: 'GET',
- url: url,
- async: false,
- success: function (data) {
- var jsonData = jQuery.parseJSON(data);
- clusterNames = jsonData.items.mapProperty('Clusters.cluster_name');
- console.log("Got existing cluster names: " + clusterNames);
- },
- error: function () {
- console.log("Failed to get existing cluster names");
- }
+ App.ajax.send({
+ name: 'wizard.step8.existing_cluster_names',
+ sender: this,
+ success: 'getExistingClusterNamesSuccessCallBack',
+ error: 'getExistingClusterNamesErrorCallback'
});
- return clusterNames;
+ return this.get('clusterNames');
},
- deleteClusters: function (clusterNames) {
- clusterNames.forEach(function (clusterName) {
+ getExistingClusterNamesSuccessCallBack: function (data) {
+ var clusterNames = data.items.mapProperty('Clusters.cluster_name');
+ console.log("Got existing cluster names: " + clusterNames);
+ this.set('clusterNames', clusterNames);
+ },
- var url = App.apiPrefix + '/clusters/' + clusterName;
+ getExistingClusterNamesErrorCallback: function () {
+ console.log("Failed to get existing cluster names");
+ this.set('clusterNames', []);
+ },
- $.ajax({
- type: 'DELETE',
- url: url,
- async: false,
- success: function () {
- console.log('DELETE cluster ' + clusterName + ' succeeded');
+ deleteClusters: function (clusterNames) {
+ clusterNames.forEach(function (clusterName) {
+ App.ajax.send({
+ name: 'wizard.step8.delete_cluster',
+ sender: this,
+ data: {
+ name: clusterName
},
- error: function () {
- console.log('DELETE cluster ' + clusterName + ' failed');
- }
+ success: 'deleteClustersSuccessCallback',
+ error: 'deleteClustersErrorCallback'
});
});
},
+ deleteClustersSuccessCallback: function(data, opt) {
+ console.log('DELETE cluster ' + opt.data.name + ' succeeded');
+ },
+ deleteClustersErrorCallback: function(request, ajaxOptions, error, opt) {
+ console.log('DELETE cluster ' + opt.data.name + ' failed');
+ },
+
/**
* The following create* functions are called upon submitting Step 8.
*/