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 16:20:27 UTC

svn commit: r1419008 - in /incubator/ambari/branches/AMBARI-666: ./ ambari-web/app/controllers/ ambari-web/app/controllers/wizard/ ambari-web/app/routes/ ambari-web/app/templates/wizard/ ambari-web/app/utils/

Author: yusaku
Date: Sun Dec  9 15:20:25 2012
New Revision: 1419008

URL: http://svn.apache.org/viewvc?rev=1419008&view=rev
Log:
AMBARI-1054. Implement retrying of bootstrap on confirm host page. (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/routes/installer.js
    incubator/ambari/branches/AMBARI-666/ambari-web/app/templates/wizard/step3.hbs
    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=1419008&r1=1419007&r2=1419008&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Sun Dec  9 15:20:25 2012
@@ -11,6 +11,9 @@ AMBARI-666 branch (unreleased changes)
   INCOMPATIBLE CHANGES
 
   NEW FEATURES
+  
+  AMBARI-1054. Implement retrying of bootstrap on confirm host page.
+  (Jaimin Jetly via yusaku)
 
   AMBARI-1048. Integrate slave configuration parameters with respective
   service on step7 of installer wizard. (Jaimin Jetly 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=1419008&r1=1419007&r2=1419008&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 15:20:25 2012
@@ -111,7 +111,7 @@ App.InstallerController = App.WizardCont
       hostsInfo.localRepoPath = '';
     }
     hostsInfo.bootRequestId = App.db.getBootRequestId() || null;
-    hostsInfo.sshKey = '';
+    hostsInfo.sshKey = App.db.getSshKey() || '';
     hostsInfo.passphrase = '';
     hostsInfo.confirmPassphrase = '';
 
@@ -133,6 +133,7 @@ App.InstallerController = App.WizardCont
     App.db.setHosts(stepController.getHostInfo());
     if (stepController.get('manualInstall') === false) {
       App.db.setInstallType({installType: 'ambari' });
+      App.db.setSshKey(stepController.get('sshKey'));
     } else {
       App.db.setInstallType({installType: 'manual' });
     }
@@ -570,6 +571,7 @@ App.InstallerController = App.WizardCont
     this.set('content.advancedServiceConfig', configs);
     App.db.setAdvancedServiceConfig(configs);
   },
+
   /**
    * Generate serviceProperties save it to localdata
    * called form stepController step6WizardController
@@ -607,6 +609,36 @@ App.InstallerController = App.WizardCont
     return serviceComponents;
   },
 
+
+  /*
+   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.');
+      },
+      statusCode: require('data/statusCodes')
+    });
+    return requestId;
+  },
+
+
   /**
    * Clear all temporary data
    */
@@ -620,5 +652,6 @@ App.InstallerController = App.WizardCont
     App.db.setAllHostNames(undefined);
   }
 
-});
+})
+;
 

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=1419008&r1=1419007&r2=1419008&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 15:20:25 2012
@@ -129,27 +129,11 @@ 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';
-
-    $.ajax({
-      type: method,
-      url: url,
-      data: bootStrapData,
-      timeout: App.timeout,
-      contentType: 'application/json',
-      success: function (data) {
-        console.log("TRACE: POST bootstrap succeeded");
-        var requestId = data.requestId;
-        self.set('bootRequestId',requestId);
-        App.router.send('next');
-      },
-      error: function () {
-        console.log("ERROR: POST bootstrap failed");
-        alert('Bootstrap call failed.  Please try again.');
-      }
-    });
+    var requestId = App.get('router.installerController').launchBootstrap(bootStrapData);
+    if(requestId) {
+    this.set('bootRequestId',requestId);
+    App.router.send('next');
+    }
   },
 
   manualInstallPopup: function (event) {

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=1419008&r1=1419007&r2=1419008&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 15:20:25 2012
@@ -39,6 +39,10 @@ App.WizardStep3Controller = Em.Controlle
     return !(this.hosts.someProperty('isChecked', true));
   }.property('hosts.@each.isChecked'),
 
+  isRetryDisabled: function () {
+    return !(this.get('bootHosts').someProperty('bootStatus', 'FAILED') && !this.get('isSubmitDisabled'));
+  }.property('bootHosts.@each.bootStatus','isSubmitDisabled'),
+
   mockData: require('data/mock/step3_hosts'),
   mockRetryData: require('data/mock/step3_pollData'),
 
@@ -70,7 +74,7 @@ App.WizardStep3Controller = Em.Controlle
 
   loadStep: function () {
     console.log("TRACE: Loading step3: Confirm Hosts");
-    if(!this.get('hosts').length){
+    if (!this.get('hosts').length) {
       this.clearStep();
       var hosts = this.loadHosts();
       // hosts.setEach('bootStatus', 'RUNNING');
@@ -149,7 +153,7 @@ App.WizardStep3Controller = Em.Controlle
       onPrimary: function () {
         App.router.send('removeHosts', hosts);
         self.hosts.removeObjects(hosts);
-        if(!self.hosts.length){
+        if (!self.hosts.length) {
           self.set('isSubmitDisabled', true);
         }
         this.hide();
@@ -174,36 +178,30 @@ App.WizardStep3Controller = Em.Controlle
     }
   },
 
-  retryHosts: function (hosts) {
-    var self = this;
-
-    App.ModalPopup.show({
-      header: Em.I18n.t('installer.step3.hosts.retry.popup.header'),
-      onPrimary: function () {
-        hosts.forEach(function (_host) {
-          console.log('Retrying:  ' + _host.name);
-        });
-
-        //TODO: uncomment below code to hookup with @GET bootstrap API
-        self.set('bootHosts', hosts);
-        if (self.get('content.hosts.manualInstall') !== true) {
-          self.doBootstrap();
-        } else {
-          self.isHostsRegistered();
-        }
-        this.hide();
-      },
-      body: Em.I18n.t('installer.step3.hosts.retry.popup.body')
-    });
-  },
-
   retryHost: function (hostInfo) {
     this.retryHosts([hostInfo]);
   },
 
+  retryHosts: function (hosts) {
+    var bootStrapData = JSON.stringify({'verbose': true, 'sshKey': this.get('content.hosts.sshKey'), hosts: hosts.mapProperty('name')});
+    this.numPolls = 0;
+    this.set('registrationAttempts', null);
+    if (this.get('content.hosts.manualInstall') !== true) {
+      var requestId = App.router.get('installerController').launchBootstrap(bootStrapData);
+      this.set('content.hosts.bootRequestId', requestId);
+      this.doBootstrap();
+    } else {
+      this.isHostsRegistered();
+    }
+  },
+
   retrySelectedHosts: function () {
-    if (!this.get('noHostsSelected')) {
-      var selectedHosts = this.get('visibleHosts').filterProperty('isChecked', true);
+    if (!this.get('isRetryDisabled')) {
+      var selectedHosts = this.get('bootHosts').filterProperty('bootStatus', 'FAILED');
+      selectedHosts.forEach(function (_host) {
+        _host.set('bootStatus', 'RUNNING');
+        _host.set('bootLog', 'Retrying ...');
+      }, this);
       this.retryHosts(selectedHosts);
     }
   },
@@ -258,7 +256,7 @@ App.WizardStep3Controller = Em.Controlle
     //TODO: uncomment following line after the hook up with the API call
     console.log('stopBootstrap() called');
     // this.set('isSubmitDisabled',false);
-    Ember.run.later(this, function(){
+    Ember.run.later(this, function () {
       this.startRegistration();
     }, 1000);
   },
@@ -416,7 +414,7 @@ App.WizardStep3Controller = Em.Controlle
           var self = this;
           var button = $(this.get('element')).find('.textTrigger');
           button.click(function () {
-            if(self.get('isTextArea')){
+            if (self.get('isTextArea')) {
               $(this).text('click to highlight');
             } else {
               $(this).text('press CTRL+C');
@@ -437,7 +435,7 @@ App.WizardStep3Controller = Em.Controlle
         },
         isTextArea: false,
         textArea: Em.TextArea.extend({
-          didInsertElement: function(){
+          didInsertElement: function () {
             var element = $(this.get('element'));
             element.width($(this.get('parentView').get('element')).width() - 10);
             element.height($(this.get('parentView').get('element')).height());
@@ -445,7 +443,7 @@ App.WizardStep3Controller = Em.Controlle
             element.css('resize', 'none');
           },
           readOnly: true,
-          value: function(){
+          value: function () {
             return this.get('content');
           }.property('content')
         })

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=1419008&r1=1419007&r2=1419008&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 15:20:25 2012
@@ -134,8 +134,7 @@ module.exports = Em.Route.extend({
       var installerController = router.get('installerController');
       var wizardStep3Controller = router.get('wizardStep3Controller');
       installerController.saveConfirmedHosts(wizardStep3Controller);
-
-
+      App.db.setSshKey(null);
       App.db.setBootStatus(true);
       var displayOrderConfig = require('data/services');
       var apiUrl = '/stacks/HDP/version/1.2.0';

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/templates/wizard/step3.hbs
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/templates/wizard/step3.hbs?rev=1419008&r1=1419007&r2=1419008&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/templates/wizard/step3.hbs (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/templates/wizard/step3.hbs Sun Dec  9 15:20:25 2012
@@ -24,7 +24,7 @@
   <div class="box">
     <div class="box-header">
       <div class="button-section">
-        <a class="btn btn-primary decommission" {{bindAttr disabled="noHostsSelected"}}
+        <a class="btn btn-primary decommission" {{bindAttr disabled="isRetryDisabled"}}
            href="#" {{action retrySelectedHosts target="controller"}}><i
                 class="icon-repeat icon-white"></i>
           Retry

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=1419008&r1=1419007&r2=1419008&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 15:20:25 2012
@@ -155,6 +155,12 @@ App.db.setBootStatus = function (status)
   localStorage.setObject('ambari', App.db.data);
 };
 
+App.db.setSshKey = function (sshKey) {
+  App.db.data = localStorage.getObject('ambari');
+  App.db.data.Installer.sshKey = sshKey;
+  localStorage.setObject('ambari', App.db.data);
+};
+
 App.db.removeHosts = function (hostInfo) {
   console.log('TRACE: Entering db:setSoftRepo function');
   var hostList = App.db.getHosts();
@@ -334,6 +340,11 @@ App.db.getBootRequestId = function () {
   return App.db.data.Installer.bootRequestId;
 };
 
+App.db.getSshKey = function () {
+  App.db.data = localStorage.getObject('ambari');
+  return  App.db.data.Installer.sshKey;
+};
+
 App.db.getService = function () {
   App.db.data = localStorage.getObject('ambari');
   return App.db.data.Installer.serviceInfo;