You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2012/12/09 15:18:53 UTC
svn commit: r1418968 - in /incubator/ambari/branches/AMBARI-666: ./
ambari-web/app/ ambari-web/app/controllers/
ambari-web/app/controllers/wizard/ ambari-web/app/models/
ambari-web/app/routes/ ambari-web/app/utils/
Author: yusaku
Date: Sun Dec 9 14:18:52 2012
New Revision: 1418968
URL: http://svn.apache.org/viewvc?rev=1418968&view=rev
Log:
AMBARI-1031. Check for host registration at step3 of installer wizard and retrieve information for RAM and no. of cores. (Jaimin Jetly via yusaku)
Modified:
incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/installer.js
incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step2_controller.js
incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step3_controller.js
incubator/ambari/branches/AMBARI-666/ambari-web/app/messages.js
incubator/ambari/branches/AMBARI-666/ambari-web/app/models/hosts.js
incubator/ambari/branches/AMBARI-666/ambari-web/app/routes/installer.js
incubator/ambari/branches/AMBARI-666/ambari-web/app/utils/db.js
Modified: incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt?rev=1418968&r1=1418967&r2=1418968&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Sun Dec 9 14:18:52 2012
@@ -12,6 +12,10 @@ AMBARI-666 branch (unreleased changes)
NEW FEATURES
+ AMBARI-1031. Check for host registration at step3 of installer wizard
+ and retrieve information for RAM and no. of cores. (Jaimin Jetly via
+ yusaku)
+
AMBARI-1022. Integrate Heatmap UI to backend API. (Srimanth
Gunturi via yusaku)
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/installer.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/installer.js?rev=1418968&r1=1418967&r2=1418968&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/installer.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/installer.js Sun Dec 9 14:18:52 2012
@@ -301,6 +301,7 @@ App.InstallerController = Em.Controller.
* confirmPassphrase: '',
* localRepo: false,
* localRepoPath: ''
+ * bootRequestId: ''
* }
*/
loadInstallOptions: function () {
@@ -327,11 +328,12 @@ App.InstallerController = Em.Controller.
hostsInfo.localRepo = false;
hostsInfo.localRepoPath = '';
}
-
+ hostsInfo.bootRequestId = App.db.getBootRequestId() || null;
hostsInfo.sshKey = '';
hostsInfo.passphrase = '';
hostsInfo.confirmPassphrase = '';
+
this.set('content.hosts', hostsInfo);
console.log("InstallerController:loadHosts: loaded data ", hostsInfo);
},
@@ -345,6 +347,7 @@ App.InstallerController = Em.Controller.
//App.db.setBootStatus(false);
App.db.setAllHostNames(stepController.get('hostNames'));
+ App.db.setBootRequestId(stepController.get('bootRequestId'));
App.db.setHosts(stepController.getHostInfo());
if (stepController.get('manualInstall') === false) {
App.db.setInstallType({installType: 'ambari' });
@@ -811,10 +814,10 @@ App.InstallerController = Em.Controller.
},
error: function (request, ajaxOptions, error) {
- console.log("TRACE: STep8 -> In error function for the installService call");
- console.log("TRACE: STep8 -> value of the url is: " + url);
- console.log("TRACE: STep8 -> error code status is: " + request.status);
- console.log('Step8: Error message is: ' + request.responseText);
+ 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,
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step2_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step2_controller.js?rev=1418968&r1=1418967&r2=1418968&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step2_controller.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step2_controller.js Sun Dec 9 14:18:52 2012
@@ -21,6 +21,7 @@ var App = require('app');
App.WizardStep2Controller = Em.Controller.extend({
name: 'wizardStep2Controller',
hostNameArr: [],
+ bootRequestId: null,
hasSubmitted: false,
hostNames: function () {
@@ -145,6 +146,7 @@ App.WizardStep2Controller = Em.Controlle
return true;
}
+ var self = this;
var method = App.testMode ? 'GET' : 'POST';
var url = App.testMode ? '/data/wizard/bootstrap/bootstrap.json' : App.apiPrefix + '/bootstrap';
@@ -154,8 +156,10 @@ App.WizardStep2Controller = Em.Controlle
data: bootStrapData,
timeout: App.timeout,
contentType: 'application/json',
- success: function () {
+ success: function (data) {
console.log("TRACE: POST bootstrap succeeded");
+ var requestId = data.requestId;
+ self.set('bootRequestId',requestId);
App.router.send('next');
},
error: function () {
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step3_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step3_controller.js?rev=1418968&r1=1418967&r2=1418968&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step3_controller.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step3_controller.js Sun Dec 9 14:18:52 2012
@@ -23,7 +23,8 @@ App.WizardStep3Controller = Em.Controlle
hosts: [],
content: [],
bootHosts: [],
- isSubmitDisabled: false,
+ registrationAttempt: 7,
+ isSubmitDisabled: true,
categories: ['All Hosts', 'Success', 'Error'],
category: 'All Hosts',
allChecked: false,
@@ -42,7 +43,7 @@ App.WizardStep3Controller = Em.Controlle
navigateStep: function () {
this.loadStep();
- if (App.db.getInstallType().installType !== 'manual') {
+ if (this.get('content.hosts.manualInstall') !== true) {
if (App.db.getBootStatus() === false) {
this.startBootstrap();
}
@@ -52,6 +53,8 @@ App.WizardStep3Controller = Em.Controlle
_host.set('bootStatus', 'DONE');
_host.set('bootLog', 'Success');
});
+ this.set('bootHosts', this.get('hosts'));
+ this.isHostsRegistered(this.getHostInfo);
}
},
@@ -196,21 +199,23 @@ App.WizardStep3Controller = Em.Controlle
doBootstrap: function () {
this.numPolls++;
var self = this;
- var url = App.testMode ? '/data/wizard/bootstrap/poll_' + this.numPolls + '.json' : App.apiPrefix + '/bootstrap/1';
+ var url = App.testMode ? '/data/wizard/bootstrap/poll_' + this.numPolls + '.json' : App.apiPrefix + '/bootstrap/' + this.get('content.hosts.bootRequestId');
$.ajax({
type: 'GET',
url: url,
timeout: App.timeout,
success: function (data) {
if (data.hostsStatus !== null) {
- // in case of bootstrapping just one server, the server returns an object rather than an array...
+ // in case of bootstrapping just one host, the server returns an object rather than an array...
if (!(data.hostsStatus instanceof Array)) {
data.hostsStatus = [ data.hostsStatus ];
}
console.log("TRACE: In success function for the GET bootstrap call");
var result = self.parseHostInfo(data.hostsStatus);
if (result) {
- window.setTimeout(function () { self.doBootstrap() }, 3000);
+ window.setTimeout(function () {
+ self.doBootstrap()
+ }, 3000);
return;
}
}
@@ -232,11 +237,113 @@ App.WizardStep3Controller = Em.Controlle
//TODO: uncomment following line after the hook up with the API call
console.log('stopBootstrap() called');
// this.set('isSubmitDisabled',false);
+ this.startRegistration();
},
+ startRegistration: function () {
+ this.isHostsRegistered(this.getHostInfo);
+ },
+
+ isHostsRegistered: function (callback) {
+ var self = this;
+ var hosts = this.get('bootHosts');
+ var url = App.apiPrefix + '/hosts';
+ var method = 'GET';
+ $.ajax({
+ type: 'GET',
+ url: url,
+ timeout: App.timeout,
+ success: function (data) {
+ var jsonData = jQuery.parseJSON(data);
+ if (jsonData && jsonData.items.length === 0) {
+ if (self.get('registrationAttempt') !== 0) {
+ count--;
+ window.setTimeout(function () {
+ self.isHostsRegistered(callback);
+ }, 3000);
+ } else {
+ self.registerErrPopup(Em.I18n.t('installer.step3.hostRegister.popup.header'), Em.I18n.t('installer.step3.hostRegister.popup.body'));
+ return;
+ }
+ }
+ if (hosts.length === jsonData.items.length) {
+ callback.apply(self);
+ } else {
+ self.registerErrPopup(Em.I18n.t('installer.step3.hostRegister.popup.header'), Em.I18n.t('installer.step3.hostRegister.popup.body'));
+ }
+ },
+ error: function () {
+ console.log('Error: Getting registered host information from the server');
+ self.stopBootstrap();
+ },
+ statusCode: require('data/statusCodes')
+ });
+ },
+
+ registerErrPopup: function (header, message) {
+ App.ModalPopup.show({
+ header: header,
+ secondary: false,
+ onPrimary: function () {
+ this.hide();
+ },
+ bodyClass: Ember.View.extend({
+ template: Ember.Handlebars.compile(['<p>{{view.message}}</p>'].join('\n')),
+ message: message
+ })
+ });
+ },
+
+ /**
+ * Get disk info and cpu count of booted hosts from server
+ */
+
+
+ getHostInfo: function () {
+ var self = this;
+ var kbPerGb = 1024;
+ var hosts = this.get('bootHosts');
+ var url = App.apiPrefix + '/hosts?fields=Hosts/total_mem,Hosts/cpu_count';
+ var method = 'GET';
+ $.ajax({
+ type: 'GET',
+ url: url,
+ contentType: 'application/json',
+ timeout: App.timeout,
+ success: function (data) {
+ var jsonData = jQuery.parseJSON(data);
+ hosts.forEach(function (_host) {
+ if (jsonData.items.someProperty('Hosts.host_name', _host.name)) {
+ var host = jsonData.items.findProperty('Hosts.host_name', _host.name);
+ _host.cpu = host.Hosts.cpu_count;
+ _host.memory = ((parseInt(host.Hosts.total_mem)) / kbPerGb).toFixed(2);
+ console.log("The value of memory is: " + _host.memory);
+ alert ("The value of memory is: " + _host.memory);
+ debugger;
+ }
+ }, this);
+ self.set('bootHosts',hosts);
+ console.log("The value of hosts: " + JSON.stringify(hosts));
+ debugger;
+ self.stopRegistrataion();
+ },
+
+ 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')
+ });
+ },
+
+ stopRegistrataion: function () {
+ this.set('isSubmitDisabled', false);
+ },
+
+
submit: function () {
if (!this.get('isSubmitDisabled')) {
- this.set('content.hostsInfo', this.get('hosts'));
+ this.set('content.hostsInfo', this.get('bootHosts'));
App.router.send('next');
}
},
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/messages.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/messages.js?rev=1418968&r1=1418967&r2=1418968&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/messages.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/messages.js Sun Dec 9 14:18:52 2012
@@ -93,7 +93,10 @@ Em.I18n.translations = {
'installer.step3.hosts.remove.popup.body':'Are you sure you want to remove the selected host(s)?',
'installer.step3.hosts.retry.popup.header':'Retry Host Discovery',
'installer.step3.hosts.retry.popup.body':'Are you sure you want to retry discovery of the selected host(s)?',
-
+ 'installer.step3.hostRegister.popup.header':'Error in Host Registration',
+ 'installer.step3.hostRegister.popup.body':'All/Some hosts bootstrapped but unable to register with server',
+ 'installer.step3.hostInformation.popup.header':'Error in retrieving host Information',
+ 'installer.step3.hostInformation.popup.body' : 'All bootstrapped hosts registered but unable to retrieve cpu and memory related information',
'installer.step4.header':'Choose Services',
'installer.step4.body':'Choose which services you want to install on your cluster.<br>Note that some services have dependencies (e.g., HBase requires ZooKeeper.)',
'installer.step4.mapreduceCheck.popup.header':'MapReduce Needed',
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/models/hosts.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/models/hosts.js?rev=1418968&r1=1418967&r2=1418968&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/models/hosts.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/models/hosts.js Sun Dec 9 14:18:52 2012
@@ -21,8 +21,8 @@ var App = require('app');
App.HostInfo = Ember.Object.extend({
elementId: 'host',
name: '',
- cpu: 2,
- memory: 4000000000,
+ cpu: null,
+ memory: null,
message: 'Information',
barColor: 'progress-info',
isChecked: true,
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/routes/installer.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/routes/installer.js?rev=1418968&r1=1418967&r2=1418968&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/routes/installer.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/routes/installer.js Sun Dec 9 14:18:52 2012
@@ -93,6 +93,9 @@ module.exports = Em.Route.extend({
},
back: Em.Router.transitionTo('step1'),
next: function (router) {
+ var controller = router.get('installerController');
+ var wizardStep2Controller = router.get('wizardStep2Controller');
+ controller.saveHosts(wizardStep2Controller);
router.transitionTo('step3');
App.db.setBootStatus(false);
},
@@ -102,15 +105,11 @@ module.exports = Em.Route.extend({
* @param router
*/
evaluateStep: function (router) {
-
- var controller = router.get('installerController');
var wizardStep2Controller = router.get('wizardStep2Controller');
-
wizardStep2Controller.set('hasSubmitted', true);
if (!wizardStep2Controller.get('isSubmitDisabled')) {
App.db.setBootStatus(false);
- controller.saveHosts(wizardStep2Controller);
wizardStep2Controller.evaluateStep();
}
}
@@ -291,7 +290,7 @@ module.exports = Em.Route.extend({
var controller = router.get('installerController');
controller.setCurrentStep('10', false);
controller.loadAllPriorSteps();
- controller.connectOutlet('wizardStep10',controller.get('content'));
+ controller.connectOutlet('wizardStep10', controller.get('content'));
},
back: Em.Router.transitionTo('step9'),
complete: function (router, context) {
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/utils/db.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/utils/db.js?rev=1418968&r1=1418967&r2=1418968&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/utils/db.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/utils/db.js Sun Dec 9 14:18:52 2012
@@ -141,6 +141,13 @@ App.db.setSoftRepo = function (softRepo)
localStorage.setObject('ambari', App.db.data);
};
+App.db.setBootRequestId = function (requestId) {
+ console.log('TRACE: Entering db:setBootRequestId function');
+ App.db.data = localStorage.getObject('ambari');
+ App.db.data.Installer.bootRequestId = requestId;
+ localStorage.setObject('ambari', App.db.data);
+};
+
App.db.setBootStatus = function (status) {
console.log('TRACE: Entering db:setBootStatus function');
App.db.data = localStorage.getObject('ambari');
@@ -315,6 +322,12 @@ App.db.getBootStatus = function () {
return App.db.data.Installer.bootStatus;
};
+App.db.getBootRequestId = function () {
+ console.log('TRACE: Entering db:getBootRequestId function');
+ App.db.data = localStorage.getObject('ambari');
+ return App.db.data.Installer.bootRequestId;
+};
+
App.db.getService = function () {
App.db.data = localStorage.getObject('ambari');
return App.db.data.Installer.serviceInfo;