Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

AMBARI-1059. Refactor cluster management. (yusaku)

  • Loading branch information...
commit c357ac4960385fd55240887a6b9b8c0f76d35672 1 parent 5ed4c1c
Yusaku Sako authored

Showing 53 changed files with 583 additions and 568 deletions. Show diff stats Hide diff stats

  1. +1 0  ambari-web/app/controllers.js
  2. +11 7 ambari-web/app/controllers/global/cluster_controller.js
  3. +1 1  ambari-web/app/controllers/global/update_controller.js
  4. +41 202 ambari-web/app/controllers/installer.js
  5. +1 1  ambari-web/app/controllers/main/charts/heatmap.js
  6. +3 111 ambari-web/app/controllers/main/host/add_controller.js
  7. +3 112 ambari-web/app/controllers/main/service/add_controller.js
  8. +199 0 ambari-web/app/controllers/wizard.js
  9. +41 32 ambari-web/app/controllers/wizard/step3_controller.js
  10. +1 1  ambari-web/app/controllers/wizard/step5_controller.js
  11. +2 1  ambari-web/app/controllers/wizard/step6_controller.js
  12. +8 0 ambari-web/app/controllers/wizard/step8_controller.js
  13. +1 1  ambari-web/app/controllers/wizard/step9_controller.js
  14. 0  ambari-web/app/data/{mock → }/services.js
  15. +1 0  ambari-web/app/initialize.js
  16. +20 5 ambari-web/app/mappers/alerts_mapper.js
  17. +1 2  ambari-web/app/messages.js
  18. +26 4 ambari-web/app/models/hosts.js
  19. +2 1  ambari-web/app/router.js
  20. +6 0 ambari-web/app/routes/add_host_routes.js
  21. +6 0 ambari-web/app/routes/add_service_routes.js
  22. +9 1 ambari-web/app/routes/installer.js
  23. +4 4 ambari-web/app/routes/main.js
  24. +22 0 ambari-web/app/styles/application.less
  25. +18 0 ambari-web/app/styles/apps.less
  26. +1 1  ambari-web/app/templates/main/charts/heatmap.hbs
  27. +3 1 ambari-web/app/templates/main/charts/heatmap/heatmap_host.hbs
  28. +0 3  ambari-web/app/templates/main/charts/heatmap/heatmap_rack.hbs
  29. +1 1  ambari-web/app/templates/main/charts/linear_time.hbs
  30. +1 1  ambari-web/app/templates/main/dashboard.hbs
  31. +5 0 ambari-web/app/templates/main/dashboard/service/hbase.hbs
  32. +5 0 ambari-web/app/templates/main/dashboard/service/hdfs.hbs
  33. +5 0 ambari-web/app/templates/main/dashboard/service/mapreduce.hbs
  34. +3 3 ambari-web/app/templates/main/host.hbs
  35. +0 49 ambari-web/app/templates/main/service/info/client_summary.hbs
  36. +15 9 ambari-web/app/templates/main/service/info/summary.hbs
  37. +1 1  ambari-web/app/templates/wizard/step3.hbs
  38. +2 0  ambari-web/app/templates/wizard/step4.hbs
  39. +1 1  ambari-web/app/templates/wizard/step8.hbs
  40. +10 1 ambari-web/app/utils/graph.js
  41. +26 3 ambari-web/app/views/common/chart/linear_time.js
  42. +1 0  ambari-web/app/views/main/admin/user/create.js
  43. +1 1  ambari-web/app/views/main/dashboard.js
  44. +2 2 ambari-web/app/views/main/dashboard/service.js
  45. +3 0  ambari-web/app/views/main/dashboard/service/hbase.js
  46. +3 0  ambari-web/app/views/main/dashboard/service/hdfs.js
  47. +3 0  ambari-web/app/views/main/dashboard/service/mapreduce.js
  48. +10 1 ambari-web/app/views/main/service/info/summary.js
  49. +1 1  ambari-web/app/views/main/service/menu.js
  50. +6 1 ambari-web/app/views/wizard/step1_view.js
  51. +1 1  ambari-web/app/views/wizard/step3_view.js
  52. +43 1 ambari-web/app/views/wizard/step8_view.js
  53. +2 0  ambari-web/vendor/scripts/spin.min.js
1  ambari-web/app/controllers.js
@@ -21,6 +21,7 @@
21 21
22 22 require('controllers/application');
23 23 require('controllers/login_controller');
  24 +require('controllers/wizard');
24 25 require('controllers/installer');
25 26 require('controllers/global/background_operations_controller');
26 27 require('controllers/main');
18 ambari-web/app/controllers/global/cluster_controller.js
@@ -141,7 +141,7 @@ App.ClusterController = Em.Controller.extend({
141 141 }
142 142 return null;
143 143 }
144   - }.property('App.router.updateController.isUpdated', 'dataLoadList.hosts'),
  144 + }.property('App.router.updateController.isUpdated'),
145 145
146 146 isNagiosInstalled:function () {
147 147 if (App.testMode) {
@@ -157,7 +157,8 @@ App.ClusterController = Em.Controller.extend({
157 157 * Sorted list of alerts.
158 158 * Changes whenever alerts are loaded.
159 159 */
160   - alerts:function () {
  160 + alerts:[],
  161 + updateAlerts: function(){
161 162 var alerts = App.Alert.find();
162 163 var alertsArray = alerts.toArray();
163 164 var sortedArray = alertsArray.sort(function (left, right) {
@@ -171,9 +172,8 @@ App.ClusterController = Em.Controller.extend({
171 172 }
172 173 return statusDiff;
173 174 });
174   - return sortedArray;
175   - }.property('dataLoadList.alerts'),
176   -
  175 + this.set('alerts', sortedArray);
  176 + },
177 177 loadRuns:function () {
178 178 if (this.get('postLoadList.runs')) {
179 179 return;
@@ -197,6 +197,9 @@ App.ClusterController = Em.Controller.extend({
197 197 * property, which will trigger the alerts property.
198 198 */
199 199 loadAlerts:function () {
  200 + if(App.router.get('updateController.isUpdated')){
  201 + return;
  202 + }
200 203 var nagiosUrl = this.get('nagiosUrl');
201 204 if (nagiosUrl) {
202 205 var lastSlash = nagiosUrl.lastIndexOf('/');
@@ -209,10 +212,11 @@ App.ClusterController = Em.Controller.extend({
209 212 jsonp:"jsonp",
210 213 context:this,
211 214 complete:function (jqXHR, textStatus) {
212   - this.updateLoadStatus('alerts')
  215 + this.updateLoadStatus('alerts');
  216 + this.updateAlerts();
213 217 },
214 218 error: function(jqXHR, testStatus, error) {
215   - this.showMessage(Em.I18n.t('nagios.alerts.unavailable'));
  219 + // this.showMessage(Em.I18n.t('nagios.alerts.unavailable'));
216 220 console.log('Nagios $.ajax() response:', error);
217 221 }
218 222 };
2  ambari-web/app/controllers/global/update_controller.js
@@ -89,7 +89,7 @@ App.UpdateController = Em.Controller.extend({
89 89 updateServiceMetric:function(callback){
90 90 var self = this;
91 91 self.set('isUpdated', false);
92   - var servicesUrl = this.getUrl('/data/dashboard/services.json', '/services?ServiceInfo/service_name!=MISCELLANEOUS&ServiceInfo/service_name!=DASHBOARD&fields=*,components/host_components/*');
  92 + var servicesUrl = this.getUrl('/data/dashboard/services.json', '/services?ServiceInfo/service_name!=MISCELLANEOUS&ServiceInfo/service_name!=DASHBOARD&fields=*,components/host_components/*,components/ServiceComponentInfo');
93 93 var callback = callback || function(jqXHR, textStatus){
94 94 self.set('isUpdated', true);
95 95 };
243 ambari-web/app/controllers/installer.js
@@ -19,205 +19,12 @@
19 19
20 20 var App = require('app');
21 21
22   -App.InstallerController = Em.Controller.extend({
  22 +App.InstallerController = App.WizardController.extend({
23 23
24 24 name: 'installerController',
25 25
26   - isStepDisabled: [],
27   -
28 26 totalSteps: 10,
29 27
30   - init: function () {
31   - this.clusters = App.Cluster.find();
32   - this.isStepDisabled.pushObject(Ember.Object.create({
33   - step: 1,
34   - value: false
35   - }));
36   - for (var i = 2; i <= this.totalSteps; i++) {
37   - this.isStepDisabled.pushObject(Ember.Object.create({
38   - step: i,
39   - value: true
40   - }));
41   - }
42   - // window.onbeforeunload = function () {
43   - // return "You have not saved your document yet. If you continue, your work will not be saved."
44   - //}
45   - },
46   -
47   - setStepsEnable: function () {
48   - for (var i = 2; i <= this.totalSteps; i++) {
49   - var step = this.get('isStepDisabled').findProperty('step', i);
50   - if (i <= this.get('currentStep')) {
51   - step.set('value', false);
52   - } else {
53   - step.set('value', true);
54   - }
55   - }
56   - }.observes('currentStep'),
57   -
58   - setLowerStepsDisable: function (stepNo) {
59   - for (var i = 1; i < stepNo; i++) {
60   - var step = this.get('isStepDisabled').findProperty('step', i);
61   - step.set('value', true);
62   - }
63   - },
64   -
65   - prevInstallStatus: function () {
66   - console.log('Inside the prevInstallStep function: The name is ' + App.router.get('loginController.loginName'));
67   - var result = App.db.isCompleted()
68   - if (result == '1') {
69   - return true;
70   - }
71   - }.property('App.router.loginController.loginName'),
72   -
73   - /**
74   - * Set current step to new value.
75   - * Method moved from App.router.setInstallerCurrentStep
76   - * @param currentStep
77   - * @param completed
78   - */
79   - currentStep: function () {
80   - return App.get('router').getWizardCurrentStep('installer');
81   - }.property(),
82   -
83   - /**
84   - * Set current step to new value.
85   - * Method moved from App.router.setInstallerCurrentStep
86   - * @param currentStep
87   - * @param completed
88   - */
89   - setCurrentStep: function (currentStep, completed) {
90   - App.db.setWizardCurrentStep('installer', currentStep, completed);
91   - this.set('currentStep', currentStep);
92   - },
93   -
94   - clusters: null,
95   -
96   - isStep1: function () {
97   - return this.get('currentStep') == 1;
98   - }.property('currentStep'),
99   -
100   - isStep2: function () {
101   - return this.get('currentStep') == 2;
102   - }.property('currentStep'),
103   -
104   - isStep3: function () {
105   - return this.get('currentStep') == 3;
106   - }.property('currentStep'),
107   -
108   - isStep4: function () {
109   - return this.get('currentStep') == 4;
110   - }.property('currentStep'),
111   -
112   - isStep5: function () {
113   - return this.get('currentStep') == 5;
114   - }.property('currentStep'),
115   -
116   - isStep6: function () {
117   - return this.get('currentStep') == 6;
118   - }.property('currentStep'),
119   -
120   - isStep7: function () {
121   - return this.get('currentStep') == 7;
122   - }.property('currentStep'),
123   -
124   - isStep8: function () {
125   - return this.get('currentStep') == 8;
126   - }.property('currentStep'),
127   -
128   - isStep9: function () {
129   - return this.get('currentStep') == 9;
130   - }.property('currentStep'),
131   -
132   - isStep10: function () {
133   - return this.get('currentStep') == 10;
134   - }.property('currentStep'),
135   -
136   - gotoStep1: function () {
137   - if (this.get('isStepDisabled').findProperty('step', 1).get('value') === true) {
138   - return;
139   - } else {
140   - App.router.send('gotoStep1');
141   - }
142   -
143   - },
144   -
145   - gotoStep2: function () {
146   - if (this.get('isStepDisabled').findProperty('step', 2).get('value') === true) {
147   - return;
148   - } else {
149   - App.router.send('gotoStep2');
150   - }
151   -
152   - },
153   -
154   - gotoStep3: function () {
155   - if (this.get('isStepDisabled').findProperty('step', 3).get('value') === true) {
156   - return;
157   - } else {
158   - App.router.send('gotoStep3');
159   - }
160   -
161   - },
162   -
163   - gotoStep4: function () {
164   -
165   - if (this.get('isStepDisabled').findProperty('step', 4).get('value') === true) {
166   - return;
167   - } else {
168   - App.router.send('gotoStep4');
169   - }
170   - },
171   -
172   - gotoStep5: function () {
173   - if (this.get('isStepDisabled').findProperty('step', 5).get('value') === true) {
174   - return;
175   - } else {
176   - App.router.send('gotoStep5');
177   - }
178   - },
179   -
180   - gotoStep6: function () {
181   - if (this.get('isStepDisabled').findProperty('step', 6).get('value') === true) {
182   - return;
183   - } else {
184   - App.router.send('gotoStep6');
185   - }
186   -
187   - },
188   -
189   - gotoStep7: function () {
190   - if (this.get('isStepDisabled').findProperty('step', 7).get('value') === true) {
191   - return;
192   - } else {
193   - App.router.send('gotoStep7');
194   - }
195   - },
196   -
197   - gotoStep8: function () {
198   - if (this.get('isStepDisabled').findProperty('step', 8).get('value') === true) {
199   - return;
200   - } else {
201   - App.router.send('gotoStep8');
202   - }
203   - },
204   -
205   - gotoStep9: function () {
206   - if (this.get('isStepDisabled').findProperty('step', 9).get('value') === true) {
207   - return;
208   - } else {
209   - App.router.send('gotoStep9');
210   - }
211   - },
212   -
213   - gotoStep10: function () {
214   - if (this.get('isStepDisabled').findProperty('step', 10).get('value') === true) {
215   - return;
216   - } else {
217   - App.router.send('gotoStep10');
218   - }
219   - },
220   -
221 28 content: Em.Object.create({
222 29 cluster: null,
223 30 hosts: null,
@@ -691,10 +498,11 @@ App.InstallerController = Em.Controller.extend({
691 498 * Generate serviceComponents as pr the stack definition and save it to localdata
692 499 * called form stepController step4WizardController
693 500 */
694   - loadComponents: function (stepController) {
  501 + loadServiceComponents : function (stepController, displayOrderConfig, apiUrl) {
695 502 var self = this;
696 503 var method = 'GET';
697   - var url = (App.testMode) ? '/data/wizard/stack/hdp/version0.1.json' : App.apiPrefix + '/stacks/HDP/version/1.2.0'; // TODO: get this url from the stack selected by the user in Install Options page
  504 + var testUrl = '/data/wizard/stack/hdp/version/1.2.0.json';
  505 + var url = (App.testMode) ? testUrl : App.apiPrefix + apiUrl;
698 506 $.ajax({
699 507 type: method,
700 508 url: url,
@@ -703,14 +511,45 @@ App.InstallerController = Em.Controller.extend({
703 511 timeout: App.timeout,
704 512 success: function (data) {
705 513 var jsonData = jQuery.parseJSON(data);
706   - console.log("TRACE: STep5 -> In success function for the getServiceComponents call");
707   - console.log("TRACE: STep5 -> value of the url is: " + url);
708   - var serviceComponents = [];
709   - jsonData.services.forEach(function (_service) {
  514 + console.log("TRACE: getService ajax call -> In success function for the getServiceComponents call");
  515 + console.log("TRACE: jsonData.services : " + jsonData.services);
  516 +
  517 + // Creating Model
  518 + var Service = Ember.Object.extend({
  519 + serviceName: null,
  520 + displayName: null,
  521 + isDisabled: true,
  522 + isSelected: true,
  523 + description:null,
  524 + version:null
  525 + });
  526 +
  527 + var data = [];
  528 +
  529 + // loop through all the service components
  530 + for (var i = 0 ; i < displayOrderConfig.length ; i++) {
  531 + var entry = jsonData.services.filterProperty("name",displayOrderConfig[i].serviceName)[0];
710 532
711   - }, this);
712   - stepController.set('components', jsonData.services);
  533 + // dont show the service whose isHidden is true
  534 + if ( displayOrderConfig[i].isHidden ) {
  535 + continue;
  536 + }
  537 +
  538 + var myService = Service.create({
  539 + serviceName: entry.name,
  540 + displayName: displayOrderConfig[i].displayName,
  541 + isDisabled: i === 0 ,
  542 + isSelected: true,
  543 + description: entry.comment,
  544 + version: entry.version
  545 + });
  546 +
  547 + data.push(myService);
  548 + }
  549 +
  550 + stepController.set('serviceComponents', data);
713 551 console.log('TRACE: service components: ' + JSON.stringify(stepController.get('components')));
  552 +
714 553 },
715 554
716 555 error: function (request, ajaxOptions, error) {
2  ambari-web/app/controllers/main/charts/heatmap.js
@@ -32,7 +32,7 @@ App.MainChartsHeatmapController = Em.Controller.extend({
32 32 * @param event
33 33 */
34 34 routeHostDetail: function(event){
35   - App.router.transitionTo('main.hostDetails.summary', event.context)
  35 + App.router.transitionTo('main.hosts.hostDetails.summary', event.context)
36 36 },
37 37 showHeatMapMetric: function (event) {
38 38 var metricItem = event.context;
114 ambari-web/app/controllers/main/host/add_controller.js
@@ -19,7 +19,7 @@
19 19
20 20 var App = require('app');
21 21
22   -App.AddHostController = Em.Controller.extend({
  22 +App.AddHostController = App.WizardController.extend({
23 23
24 24 name: 'addHostController',
25 25
@@ -52,115 +52,7 @@ App.AddHostController = Em.Controller.extend({
52 52 */
53 53 hideBackButton: true,
54 54
55   - isStepDisabled: [],
56   -
57   - totalSteps: 9,
58   -
59   - init: function () {
60   - this.isStepDisabled.pushObject(Ember.Object.create({
61   - step: 1,
62   - value: false
63   - }));
64   - for (var i = 2; i <= this.totalSteps; i++) {
65   - this.isStepDisabled.pushObject(Ember.Object.create({
66   - step: i,
67   - value: true
68   - }));
69   - }
70   - },
71   -
72   - setStepsEnable: function () {
73   - for (var i = 2; i <= this.totalSteps; i++) {
74   - var step = this.get('isStepDisabled').findProperty('step', i);
75   - if (i <= this.get('currentStep')) {
76   - step.set('value', false);
77   - } else {
78   - step.set('value', true);
79   - }
80   - }
81   - }.observes('currentStep'),
82   -
83   - /**
84   - * Return current step of Add Host Wizard
85   - */
86   - currentStep: function () {
87   - return App.get('router').getWizardCurrentStep('addHost');
88   - }.property(),
89   -
90   - clusters: null,
91   -
92   - /**
93   - * Set current step to new value.
94   - * Method moved from App.router.setInstallerCurrentStep
95   - * @param currentStep
96   - * @param completed
97   - */
98   - setCurrentStep: function (currentStep, completed) {
99   - App.db.setWizardCurrentStep('addHost', currentStep, completed);
100   - this.set('currentStep', currentStep);
101   - },
102   -
103   - isStep1: function () {
104   - return this.get('currentStep') == 1;
105   - }.property('currentStep'),
106   -
107   - isStep2: function () {
108   - return this.get('currentStep') == 2;
109   - }.property('currentStep'),
110   -
111   - isStep3: function () {
112   - return this.get('currentStep') == 3;
113   - }.property('currentStep'),
114   -
115   - isStep4: function () {
116   - return this.get('currentStep') == 4;
117   - }.property('currentStep'),
118   -
119   - isStep5: function () {
120   - return this.get('currentStep') == 5;
121   - }.property('currentStep'),
122   -
123   - isStep6: function () {
124   - return this.get('currentStep') == 6;
125   - }.property('currentStep'),
126   -
127   - isStep7: function () {
128   - return this.get('currentStep') == 7;
129   - }.property('currentStep'),
130   -
131   - gotoStep: function (step) {
132   - if (this.get('isStepDisabled').findProperty('step', step).get('value') === false) {
133   - App.router.send('gotoStep' + step);
134   - }
135   - },
136   -
137   - gotoStep1: function () {
138   - this.gotoStep(1);
139   - },
140   -
141   - gotoStep2: function () {
142   - this.gotoStep(2);
143   - },
144   -
145   - gotoStep3: function () {
146   - this.gotoStep(3);
147   - },
148   -
149   - gotoStep4: function () {
150   - this.gotoStep(4);
151   - },
152   -
153   - gotoStep5: function () {
154   - this.gotoStep(5);
155   - },
156   -
157   - gotoStep6: function () {
158   - this.gotoStep(6);
159   - },
160   -
161   - gotoStep7: function () {
162   - this.gotoStep(7);
163   - },
  55 + totalSteps: 7,
164 56
165 57 /**
166 58 * Load clusterInfo(step1) to model
@@ -361,7 +253,7 @@ App.AddHostController = Em.Controller.extend({
361 253 loadServices: function () {
362 254 var servicesInfo = App.db.getService();
363 255 if(!servicesInfo || !servicesInfo.length){
364   - servicesInfo = require('data/mock/services').slice(0);
  256 + servicesInfo = require('data/services').slice(0);
365 257 servicesInfo.forEach(function (item) {
366 258 item.isSelected = App.Service.find().someProperty('id', item.serviceName)
367 259 item.isInstalled = item.isSelected;
115 ambari-web/app/controllers/main/service/add_controller.js
@@ -19,7 +19,7 @@
19 19
20 20 var App = require('app');
21 21
22   -App.AddServiceController = Em.Controller.extend({
  22 +App.AddServiceController = App.WizardController.extend({
23 23
24 24 name: 'addServiceController',
25 25
@@ -52,116 +52,7 @@ App.AddServiceController = Em.Controller.extend({
52 52 */
53 53 hideBackButton: true,
54 54
55   - isStepDisabled: [],
56   -
57   - totalSteps: 9,
58   -
59   - init: function () {
60   - this.isStepDisabled.pushObject(Ember.Object.create({
61   - step: 1,
62   - value: false
63   - }));
64   - for (var i = 2; i <= this.totalSteps; i++) {
65   - this.isStepDisabled.pushObject(Ember.Object.create({
66   - step: i,
67   - value: true
68   - }));
69   - }
70   - },
71   -
72   - setStepsEnable: function () {
73   - for (var i = 2; i <= this.totalSteps; i++) {
74   - var step = this.get('isStepDisabled').findProperty('step', i);
75   - if (i <= this.get('currentStep')) {
76   - step.set('value', false);
77   - } else {
78   - step.set('value', true);
79   - }
80   - }
81   - }.observes('currentStep'),
82   -
83   - /**
84   - * Return current step of Add Host Wizard
85   - */
86   - currentStep: function () {
87   - return App.get('router').getWizardCurrentStep('addService');
88   - }.property(),
89   -
90   - clusters: null,
91   -
92   - /**
93   - * Set current step to new value.
94   - * Method moved from App.router.setInstallerCurrentStep
95   - * @param currentStep
96   - * @param completed
97   - */
98   - setCurrentStep: function (currentStep, completed) {
99   - App.db.setWizardCurrentStep('addService', currentStep, completed);
100   - this.set('currentStep', currentStep);
101   - },
102   -
103   - isStep1: function () {
104   - return this.get('currentStep') == 1;
105   - }.property('currentStep'),
106   -
107   - isStep2: function () {
108   - return this.get('currentStep') == 2;
109   - }.property('currentStep'),
110   -
111   - isStep3: function () {
112   - return this.get('currentStep') == 3;
113   - }.property('currentStep'),
114   -
115   - isStep4: function () {
116   - return this.get('currentStep') == 4;
117   - }.property('currentStep'),
118   -
119   - isStep5: function () {
120   - return this.get('currentStep') == 5;
121   - }.property('currentStep'),
122   -
123   - isStep6: function () {
124   - return this.get('currentStep') == 6;
125   - }.property('currentStep'),
126   -
127   - isStep7: function () {
128   - return this.get('currentStep') == 7;
129   - }.property('currentStep'),
130   -
131   - gotoStep: function (step) {
132   - if (this.get('isStepDisabled').findProperty('step', step).get('value') === false) {
133   - App.router.send('gotoStep' + step);
134   - }
135   - },
136   -
137   - gotoStep1: function () {
138   - this.gotoStep(1);
139   - },
140   -
141   - gotoStep2: function () {
142   - this.gotoStep(2);
143   - },
144   -
145   - gotoStep3: function () {
146   - this.gotoStep(3);
147   - },
148   -
149   - gotoStep4: function () {
150   - this.gotoStep(4);
151   - },
152   -
153   - gotoStep5: function () {
154   - this.gotoStep(5);
155   - },
156   -
157   - gotoStep6: function () {
158   - this.gotoStep(6);
159   - },
160   -
161   - gotoStep7: function () {
162   - this.gotoStep(7);
163   - },
164   -
  55 + totalSteps: 7,
165 56
166 57 /**
167 58 * Load clusterInfo(step1) to model
@@ -275,7 +166,7 @@ App.AddServiceController = Em.Controller.extend({
275 166 loadServices: function () {
276 167 var servicesInfo = App.db.getService();
277 168 if(!servicesInfo || !servicesInfo.length){
278   - servicesInfo = require('data/mock/services').slice(0);
  169 + servicesInfo = require('data/services').slice(0);
279 170 servicesInfo.forEach(function(item, index){
280 171 servicesInfo[index].isSelected = App.Service.find().someProperty('id', item.serviceName);
281 172 servicesInfo[index].isDisabled = servicesInfo[index].isSelected;
199 ambari-web/app/controllers/wizard.js
... ... @@ -0,0 +1,199 @@
  1 +/**
  2 + * Licensed to the Apache Software Foundation (ASF) under one
  3 + * or more contributor license agreements. See the NOTICE file
  4 + * distributed with this work for additional information
  5 + * regarding copyright ownership. The ASF licenses this file
  6 + * to you under the Apache License, Version 2.0 (the
  7 + * "License"); you may not use this file except in compliance
  8 + * with the License. You may obtain a copy of the License at
  9 + *
  10 + * http://www.apache.org/licenses/LICENSE-2.0
  11 + *
  12 + * Unless required by applicable law or agreed to in writing, software
  13 + * distributed under the License is distributed on an "AS IS" BASIS,
  14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15 + * See the License for the specific language governing permissions and
  16 + * limitations under the License.
  17 + */
  18 +
  19 +
  20 +var App = require('app');
  21 +
  22 +App.WizardController = Em.Controller.extend({
  23 +
  24 + isStepDisabled: [],
  25 +
  26 + init: function () {
  27 + this.clusters = App.Cluster.find();
  28 + this.isStepDisabled.pushObject(Ember.Object.create({
  29 + step: 1,
  30 + value: false
  31 + }));
  32 + for (var i = 2; i <= this.totalSteps; i++) {
  33 + this.isStepDisabled.pushObject(Ember.Object.create({
  34 + step: i,
  35 + value: true
  36 + }));
  37 + }
  38 + // window.onbeforeunload = function () {
  39 + // return "You have not saved your document yet. If you continue, your work will not be saved."
  40 + //}
  41 + },
  42 +
  43 + setStepsEnable: function () {
  44 + for (var i = 2; i <= this.totalSteps; i++) {
  45 + var step = this.get('isStepDisabled').findProperty('step', i);
  46 + if (i <= this.get('currentStep')) {
  47 + step.set('value', false);
  48 + } else {
  49 + step.set('value', true);
  50 + }
  51 + }
  52 + }.observes('currentStep'),
  53 +
  54 + setLowerStepsDisable: function (stepNo) {
  55 + for (var i = 1; i < stepNo; i++) {
  56 + var step = this.get('isStepDisabled').findProperty('step', i);
  57 + step.set('value', true);
  58 + }
  59 + },
  60 +
  61 + prevInstallStatus: function () {
  62 + console.log('Inside the prevInstallStep function: The name is ' + App.router.get('loginController.loginName'));
  63 + var result = App.db.isCompleted()
  64 + if (result == '1') {
  65 + return true;
  66 + }
  67 + }.property('App.router.loginController.loginName'),
  68 +
  69 + /**
  70 + * Set current step to new value.
  71 + * Method moved from App.router.setInstallerCurrentStep
  72 + * @param currentStep
  73 + * @param completed
  74 + */
  75 + currentStep: function () {
  76 + return App.get('router').getWizardCurrentStep(this.get('name').substr(0, this.get('name').length - 10));
  77 + }.property(),
  78 +
  79 + /**
  80 + * Set current step to new value.
  81 + * Method moved from App.router.setInstallerCurrentStep
  82 + * @param currentStep
  83 + * @param completed
  84 + */
  85 + setCurrentStep: function (currentStep, completed) {
  86 + App.db.setWizardCurrentStep(this.get('name').substr(0, this.get('name').length - 10), currentStep, completed);
  87 + this.set('currentStep', currentStep);
  88 + },
  89 +
  90 + clusters: null,
  91 +
  92 + isStep1: function () {
  93 + return this.get('currentStep') == 1;
  94 + }.property('currentStep'),
  95 +
  96 + isStep2: function () {
  97 + return this.get('currentStep') == 2;
  98 + }.property('currentStep'),
  99 +
  100 + isStep3: function () {
  101 + return this.get('currentStep') == 3;
  102 + }.property('currentStep'),
  103 +
  104 + isStep4: function () {
  105 + return this.get('currentStep') == 4;
  106 + }.property('currentStep'),
  107 +
  108 + isStep5: function () {
  109 + return this.get('currentStep') == 5;
  110 + }.property('currentStep'),
  111 +
  112 + isStep6: function () {
  113 + return this.get('currentStep') == 6;
  114 + }.property('currentStep'),
  115 +
  116 + isStep7: function () {
  117 + return this.get('currentStep') == 7;
  118 + }.property('currentStep'),
  119 +
  120 + isStep8: function () {
  121 + return this.get('currentStep') == 8;
  122 + }.property('currentStep'),
  123 +
  124 + isStep9: function () {
  125 + return this.get('currentStep') == 9;
  126 + }.property('currentStep'),
  127 +
  128 + isStep10: function () {
  129 + return this.get('currentStep') == 10;
  130 + }.property('currentStep'),
  131 +
  132 + gotoStep: function (step) {
  133 + if (this.get('isStepDisabled').findProperty('step', step).get('value') !== false) {
  134 + return;
  135 + }
  136 + if ((this.get('currentStep') - step) > 1) {
  137 + App.ModalPopup.show({
  138 + header: Em.I18n.t('installer.navigation.warning.header'),
  139 + onPrimary: function () {
  140 + App.router.send('gotoStep' + step);
  141 + this.hide();
  142 + },
  143 + body: "If you proceed to go back to Step " + step + ", you will lose any changes you have made beyond this step"
  144 + });
  145 + } else {
  146 + App.router.send('gotoStep' + step);
  147 + }
  148 + },
  149 +
  150 + gotoStep1: function () {
  151 + this.gotoStep(1);
  152 + },
  153 +
  154 + gotoStep2: function () {
  155 + this.gotoStep(2);
  156 + },
  157 +
  158 + gotoStep3: function () {
  159 + this.gotoStep(3);
  160 + },
  161 +
  162 + gotoStep4: function () {
  163 + this.gotoStep(4);
  164 + },
  165 +
  166 + gotoStep5: function () {
  167 + this.gotoStep(5);
  168 + },
  169 +
  170 + gotoStep6: function () {
  171 + this.gotoStep(6);
  172 + },
  173 +
  174 + gotoStep7: function () {
  175 + this.gotoStep(7);
  176 + },
  177 +
  178 + gotoStep8: function () {
  179 + this.gotoStep(8);
  180 + },
  181 +
  182 + gotoStep9: function () {
  183 + this.gotoStep(9);
  184 + },
  185 +
  186 + gotoStep10: function () {
  187 + this.gotoStep(10);
  188 + },
  189 +
  190 + load: function (name, reload) {
  191 + if (this.get('content.' + name) && !reload) {
  192 + return false;
  193 + }
  194 + var result = App.db['get' + name.capitalize()];
  195 + if (!result) result = this['get' + name.capitalize()];
  196 + this.set('content.' + name, result);
  197 + console.log("Installer controller: loaded" + name, result);
  198 + }
  199 +})
73 ambari-web/app/controllers/wizard/step3_controller.js
@@ -23,7 +23,8 @@ App.WizardStep3Controller = Em.Controller.extend({
23 23 hosts: [],
24 24 content: [],
25 25 bootHosts: [],
26   - registrationAttempt: 7,
  26 + maxRegistrationAttempts: 20,
  27 + registrationAttempts: null,
27 28 isSubmitDisabled: true,
28 29 categories: ['All Hosts', 'Success', 'Error'],
29 30 category: 'All Hosts',
@@ -49,13 +50,15 @@ App.WizardStep3Controller = Em.Controller.extend({
49 50 }
50 51 } else {
51 52 this.set('bootHosts', this.get('hosts'));
52   - this.isHostsRegistered(this.getHostInfo);
  53 + this.isHostsRegistered();
53 54 }
54 55 },
55 56
56 57 clearStep: function () {
57 58 this.hosts.clear();
58 59 this.bootHosts.clear();
  60 + this.set('isSubmitDisabled', true);
  61 + this.set('registrationAttempts', 1);
59 62 },
60 63
61 64 loadStep: function () {
@@ -113,7 +116,7 @@ App.WizardStep3Controller = Em.Controller.extend({
113 116 /* Returns the current set of visible hosts on view (All, Succeeded, Failed) */
114 117 visibleHosts: function () {
115 118 if (this.get('category') === 'Success') {
116   - return (this.hosts.filterProperty('bootStatus', 'DONE'));
  119 + return (this.hosts.filterProperty('bootStatus', 'REGISTERED'));
117 120 } else if (this.get('category') === 'Error') {
118 121 return (this.hosts.filterProperty('bootStatus', 'FAILED'));
119 122 } else { // if (this.get('category') === 'All Hosts')
@@ -166,7 +169,7 @@ App.WizardStep3Controller = Em.Controller.extend({
166 169 if (self.get('content.hosts.manualInstall') !== true) {
167 170 self.doBootstrap();
168 171 } else {
169   - self.isHostsRegistered(self.getHostInfo);
  172 + self.isHostsRegistered();
170 173 }
171 174 this.hide();
172 175 },
@@ -241,10 +244,10 @@ App.WizardStep3Controller = Em.Controller.extend({
241 244 },
242 245
243 246 startRegistration: function () {
244   - this.isHostsRegistered(this.getHostInfo);
  247 + this.isHostsRegistered();
245 248 },
246 249
247   - isHostsRegistered: function (callback) {
  250 + isHostsRegistered: function () {
248 251 var self = this;
249 252 var hosts = this.get('bootHosts');
250 253 var url = App.testMode ? '/data/wizard/bootstrap/single_host_registration.json' : App.apiPrefix + '/hosts';
@@ -254,6 +257,7 @@ App.WizardStep3Controller = Em.Controller.extend({
254 257 url: url,
255 258 timeout: App.timeout,
256 259 success: function (data) {
  260 + console.log('registration attempt #' + self.get('registrationAttempts'));
257 261 var jsonData;
258 262 if (App.testMode === true) {
259 263 jsonData = data;
@@ -264,31 +268,38 @@ App.WizardStep3Controller = Em.Controller.extend({
264 268 console.log("Error: jsonData is null");
265 269 return;
266 270 }
267   - if (jsonData.items.length === 0) {
268   - if (self.get('registrationAttempt') !== 0) {
269   - count--;
270   - window.setTimeout(function () {
271   - self.isHostsRegistered(callback);
272   - }, 3000);
273   - return;
274   - } else {
275   - self.registerErrPopup(Em.I18n.t('installer.step3.hostRegister.popup.header'), Em.I18n.t('installer.step3.hostRegister.popup.body'));
276   - return;
277   - }
278   - }
279   - var flag = true;
  271 +
  272 + // keep polling until all hosts are registered
  273 + var allRegistered = true;
280 274 hosts.forEach(function (_host) {
281 275 if (jsonData.items.someProperty('Hosts.host_name', _host.name)) {
282   - _host.set('bootStatus', 'DONE');
283   - _host.set('bootLog', 'Success');
  276 + if (_host.get('bootStatus') != 'REGISTERED') {
  277 + _host.set('bootStatus', 'REGISTERED');
  278 + _host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + '\nRegistration with the server succeeded.');
  279 + }
284 280 } else {
285   - flag = false;
  281 + allRegistered = false;
  282 + if (_host.get('bootStatus') != 'FAILED' && _host.get('bootStatus') != 'REGISTERING') {
  283 + _host.set('bootStatus', 'REGISTERING');
  284 + currentBootLog = _host.get('bootLog') != null ? _host.get('bootLog') : '';
  285 + _host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + '\nRegistering with the server...');
  286 + }
286 287 }
287 288 }, this);
288   - if (flag) {
289   - callback.apply(self);
  289 + if (allRegistered) {
  290 + self.getHostInfo();
  291 + } else if (self.get('maxRegistrationAttempts') - self.get('registrationAttempts') >= 0) {
  292 + self.set('registrationAttempts', self.get('registrationAttempts') + 1);
  293 + window.setTimeout(function () {
  294 + self.isHostsRegistered();
  295 + }, 3000);
290 296 } else {
291   - self.registerErrPopup(Em.I18n.t('installer.step3.hostRegister.popup.header'), Em.I18n.t('installer.step3.hostRegister.popup.body'));
  297 + // maxed out on registration attempts. mark all REGISTERING hosts to FAILED
  298 + hosts.filterProperty('bootStatus', 'REGISTERING').forEach(function (_host) {
  299 + _host.set('bootStatus', 'FAILED');
  300 + _host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + '\nRegistration with the server failed.');
  301 + });
  302 + self.getHostInfo();
292 303 }
293 304 },
294 305 error: function () {
@@ -315,8 +326,6 @@ App.WizardStep3Controller = Em.Controller.extend({
315 326 /**
316 327 * Get disk info and cpu count of booted hosts from server
317 328 */
318   -
319   -
320 329 getHostInfo: function () {
321 330 var self = this;
322 331 var kbPerGb = 1024;
@@ -336,16 +345,16 @@ App.WizardStep3Controller = Em.Controller.extend({
336 345 jsonData = jQuery.parseJSON(data);
337 346 }
338 347 hosts.forEach(function (_host) {
339   - if (jsonData.items.someProperty('Hosts.host_name', _host.name)) {
340   - var host = jsonData.items.findProperty('Hosts.host_name', _host.name);
  348 + var host = jsonData.items.findProperty('Hosts.host_name', _host.name);
  349 + if (host) {
341 350 _host.cpu = host.Hosts.cpu_count;
342 351 _host.memory = ((parseInt(host.Hosts.total_mem))).toFixed(2);
343 352 console.log("The value of memory is: " + _host.memory);
344 353 }
345   - }, this);
  354 + });
346 355 self.set('bootHosts', hosts);
347 356 console.log("The value of hosts: " + JSON.stringify(hosts));
348   - self.stopRegistrataion();
  357 + self.stopRegistration();
349 358 },
350 359
351 360 error: function () {
@@ -356,7 +365,7 @@ App.WizardStep3Controller = Em.Controller.extend({
356 365 });
357 366 },
358 367
359   - stopRegistrataion: function () {
  368 + stopRegistration: function () {
360 369 this.set('isSubmitDisabled', false);
361 370 },
362 371
2  ambari-web/app/controllers/wizard/step5_controller.js
@@ -58,7 +58,7 @@ App.WizardStep5Controller = Em.Controller.extend({
58 58
59 59 for (var index in hostInfo) {
60 60 var _host = hostInfo[index];
61   - if (_host.bootStatus === 'DONE') { // TODO: remove "true" after integrating with bootstrap
  61 + if (_host.bootStatus === 'REGISTERED') {
62 62 var hostObj = Ember.Object.create({
63 63 host_name:_host.name,
64 64
3  ambari-web/app/controllers/wizard/step6_controller.js
@@ -166,8 +166,9 @@ App.WizardStep6Controller = Em.Controller.extend({
166 166 var hostInfo = this.get('content.hostsInfo');
167 167 var hostNames = [];
168 168 for (var index in hostInfo) {
169   - if (hostInfo[index].bootStatus === 'DONE') //TODO: remove true after integration with bootstrap
  169 + if (hostInfo[index].bootStatus === 'REGISTERED') {
170 170 hostNames.push(hostInfo[index].name);
  171 + }
171 172 }
172 173 return hostNames;
173 174 },
8 ambari-web/app/controllers/wizard/step8_controller.js
@@ -28,6 +28,8 @@ App.WizardStep8Controller = Em.Controller.extend({
28 28 globals: [],
29 29 configMapping: require('data/config_mapping'),
30 30
  31 + isSubmitDisabled : false,
  32 +
31 33 selectedServices: function () {
32 34 return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false);
33 35 }.property('content.services').cacheable(),
@@ -596,6 +598,12 @@ App.WizardStep8Controller = Em.Controller.extend({
596 598 */
597 599 submit: function () {
598 600
  601 + if (this.get('isSubmitDisabled')) {
  602 + return;
  603 + }
  604 +
  605 + this.set('isSubmitDisabled', true);
  606 +
599 607 if (App.testMode) {
600 608 App.router.send('next');
601 609 return;
2  ambari-web/app/controllers/wizard/step9_controller.js
@@ -95,7 +95,7 @@ App.WizardStep9Controller = Em.Controller.extend({
95 95 console.log("TRACE: host name is: " + hostInfo[index].name);
96 96 }
97 97 // return hosts;
98   - return hosts.filterProperty('bootStatus', 'DONE'); //TODO: uncomment after actual hookup with bootstrap
  98 + return hosts.filterProperty('bootStatus', 'REGISTERED');
99 99 },
100 100
101 101 renderHosts: function (hostsInfo) {
0  ambari-web/app/data/mock/services.js → ambari-web/app/data/services.js
File renamed without changes
1  ambari-web/app/initialize.js
@@ -30,6 +30,7 @@ App.componentsUpdateInterval = 6000;
30 30 App.contentUpdateInterval = 15000;
31 31
32 32 require('messages');
  33 +require('utils/base64');
33 34 require('utils/data_table');
34 35 require('utils/db');
35 36 require('utils/helper');
25 ambari-web/app/mappers/alerts_mapper.js
@@ -42,11 +42,26 @@ App.alertsMapper = App.QuickDataMapper.create({
42 42 return;
43 43 }
44 44 if (json.alerts) {
45   - var result = [];
46   - json.alerts.forEach(function (item) {
47   - result.push(this.parseIt(item, this.config));
48   - }, this);
49   - App.store.loadMany(this.get('model'), result);