step4_controller.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. var App = require('app');
  19. var stringUtils = require('utils/string_utils');
  20. App.WizardStep4Controller = Em.ArrayController.extend({
  21. name: 'wizardStep4Controller',
  22. content: [],
  23. isSubmitDisabled:function(){
  24. return this.filterProperty('isSelected', true).filterProperty('isInstalled', false).length === 0;
  25. }.property("@each.isSelected"),
  26. /**
  27. * Check whether all properties are selected
  28. */
  29. isAll: function () {
  30. return this.filterProperty('canBeSelected', true).everyProperty('isSelected', true);
  31. }.property('@each.isSelected'),
  32. /**
  33. * Check whether none properties(minimum) are selected
  34. */
  35. isMinimum: function () {
  36. return this.filterProperty('isDisabled', false).everyProperty('isSelected', false);
  37. }.property('@each.isSelected'),
  38. /**
  39. * Update hidden services. Make them to have the same status as master ones.
  40. */
  41. checkDependencies: function () {
  42. var hbase = this.findProperty('serviceName', 'HBASE');
  43. var zookeeper = this.findProperty('serviceName', 'ZOOKEEPER');
  44. var hive = this.findProperty('serviceName', 'HIVE');
  45. var hcatalog = this.findProperty('serviceName', 'HCATALOG');
  46. var webhcat = this.findProperty('serviceName', 'WEBHCAT');
  47. var yarn = this.findProperty('serviceName', 'YARN');
  48. var mapreduce2 = this.findProperty('serviceName', 'MAPREDUCE2');
  49. // prevent against getting error when not all elements have been loaded yet
  50. if (hbase && zookeeper && hive && hcatalog && webhcat && yarn && mapreduce2) {
  51. if (stringUtils.compareVersions(App.get('currentStackVersionNumber'), "2.0") === -1) {
  52. zookeeper.set('isSelected', hbase.get('isSelected') || hive.get('isSelected'));
  53. }
  54. else {
  55. if (!zookeeper.get('isSelected')) {
  56. zookeeper.set('isSelected', hbase.get('isSelected'));
  57. }
  58. mapreduce2.set('isSelected', yarn.get('isSelected'));
  59. }
  60. hcatalog.set('isSelected', hive.get('isSelected'));
  61. webhcat.set('isSelected', hive.get('isSelected'));
  62. }
  63. }.observes('@each.isSelected'),
  64. /**
  65. * Onclick handler for <code>select all</code> link
  66. */
  67. selectAll: function () {
  68. this.filterProperty('canBeSelected', true).setEach('isSelected', true);
  69. },
  70. /**
  71. * onclick handler for <code>select minimum</code> link
  72. */
  73. selectMinimum: function () {
  74. this.filterProperty('isDisabled', false).setEach('isSelected', false);
  75. },
  76. /**
  77. * Check whether we should turn on <code>MapReduce</code> service
  78. * @return {Boolean}
  79. */
  80. needToAddMapReduce: function () {
  81. if (this.findProperty('serviceName', 'MAPREDUCE') && this.findProperty('serviceName', 'MAPREDUCE').get('isSelected') === false) {
  82. var mapreduceDependentServices = this.filter(function (item) {
  83. return ['PIG', 'OOZIE', 'HIVE'].contains(item.get('serviceName')) && item.get('isSelected', true);
  84. });
  85. return (mapreduceDependentServices.get('length') > 0);
  86. }
  87. return false;
  88. },
  89. /**
  90. * Check whether we should turn on <code>HDFS or HCFS</code> service
  91. * @return {Boolean}
  92. */
  93. needToAddHDFS: function () {
  94. return (this.findProperty('serviceName', 'HDFS').get('isSelected') === false &&
  95. (!this.findProperty('serviceName', 'HCFS') || this.findProperty('serviceName', 'HCFS').get('isSelected') === false));
  96. },
  97. /**
  98. * Check if multiple distributed file systems were selected
  99. * @return {Boolean}
  100. */
  101. multipleDFSs: function () {
  102. return (this.findProperty('serviceName', 'HDFS').get('isSelected') === true &&
  103. (this.findProperty('serviceName', 'HCFS') && this.findProperty('serviceName', 'HCFS').get('isSelected') === true));
  104. },
  105. /**
  106. * Check do we have any monitoring service turned on
  107. * @return {Boolean}
  108. */
  109. gangliaOrNagiosNotSelected: function () {
  110. return (this.findProperty('serviceName', 'GANGLIA').get('isSelected') === false || this.findProperty('serviceName', 'NAGIOS').get('isSelected') === false);
  111. },
  112. /**
  113. * Check whether user turned on monitoring service and go to next step
  114. */
  115. validateMonitoring: function () {
  116. if (this.gangliaOrNagiosNotSelected()) {
  117. this.monitoringCheckPopup();
  118. } else {
  119. App.router.send('next');
  120. }
  121. },
  122. /**
  123. * Onclick handler for <code>Next</code> button
  124. */
  125. submit: function () {
  126. if(!this.get("isSubmitDisabled")){
  127. if (this.needToAddMapReduce()) {
  128. this.mapReduceCheckPopup();
  129. } else if (this.needToAddHDFS()) {
  130. this.needToAddHDFSPopup();
  131. } else if (this.multipleDFSs()) {
  132. this.multipleDFSPopup();
  133. }
  134. else {
  135. this.validateMonitoring();
  136. }
  137. }
  138. },
  139. multipleDFSPopup: function() {
  140. var self = this;
  141. App.ModalPopup.show({
  142. header: Em.I18n.t('installer.step4.multipleDFS.popup.header'),
  143. body: Em.I18n.t('installer.step4.multipleDFS.popup.body'),
  144. onPrimary: function () {
  145. self.findProperty('serviceName', 'HDFS').set('isSelected', true);
  146. self.findProperty('serviceName', 'HCFS').set('isSelected', false);
  147. this.hide();
  148. self.validateMonitoring();
  149. },
  150. onSecondary: function () {
  151. this.hide();
  152. }
  153. });
  154. },
  155. needToAddHDFSPopup: function() {
  156. var self = this;
  157. App.ModalPopup.show({
  158. header: Em.I18n.t('installer.step4.hdfsCheck.popup.header'),
  159. body: Em.I18n.t('installer.step4.hdfsCheck.popup.body'),
  160. onPrimary: function () {
  161. self.findProperty('serviceName', 'HDFS').set('isSelected', true);
  162. this.hide();
  163. self.validateMonitoring();
  164. },
  165. onSecondary: function () {
  166. this.hide();
  167. }
  168. });
  169. },
  170. mapReduceCheckPopup: function () {
  171. var self = this;
  172. App.ModalPopup.show({
  173. header: Em.I18n.t('installer.step4.mapreduceCheck.popup.header'),
  174. body: Em.I18n.t('installer.step4.mapreduceCheck.popup.body'),
  175. onPrimary: function () {
  176. self.findProperty('serviceName', 'MAPREDUCE').set('isSelected', true);
  177. this.hide();
  178. self.validateMonitoring();
  179. },
  180. onSecondary: function () {
  181. this.hide();
  182. }
  183. });
  184. },
  185. monitoringCheckPopup: function () {
  186. App.ModalPopup.show({
  187. header: Em.I18n.t('installer.step4.monitoringCheck.popup.header'),
  188. body: Em.I18n.t('installer.step4.monitoringCheck.popup.body'),
  189. onPrimary: function () {
  190. this.hide();
  191. App.router.send('next');
  192. },
  193. onSecondary: function () {
  194. this.hide();
  195. }
  196. });
  197. }
  198. })