step4_controller.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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. mapreduce2.set('isSelected', yarn.get('isSelected'));
  56. }
  57. hcatalog.set('isSelected', hive.get('isSelected'));
  58. webhcat.set('isSelected', hive.get('isSelected'));
  59. }
  60. }.observes('@each.isSelected'),
  61. /**
  62. * Onclick handler for <code>select all</code> link
  63. */
  64. selectAll: function () {
  65. this.filterProperty('canBeSelected', true).setEach('isSelected', true);
  66. },
  67. /**
  68. * onclick handler for <code>select minimum</code> link
  69. */
  70. selectMinimum: function () {
  71. this.filterProperty('isDisabled', false).setEach('isSelected', false);
  72. },
  73. /**
  74. * Check whether we should turn on <code>serviceName</code> service according to selected <code>dependentServices</code>
  75. * @param serviceName checked service
  76. * @param dependentServices list of dependent services
  77. * @returns {boolean}
  78. */
  79. needAddService: function(serviceName, dependentServices) {
  80. if (!(dependentServices instanceof Array)) {
  81. dependentServices = [dependentServices];
  82. }
  83. if (this.findProperty('serviceName', serviceName) && this.findProperty('serviceName', serviceName).get('isSelected') === false) {
  84. var ds = this.filter(function (item) {
  85. return dependentServices.contains(item.get('serviceName')) && item.get('isSelected');
  86. });
  87. return (ds.get('length') > 0);
  88. }
  89. return false;
  90. },
  91. /**
  92. * Check whether we should turn on <code>MapReduce</code> service
  93. * @return {Boolean}
  94. */
  95. needToAddMapReduce: function () {
  96. return this.needAddService('MAPREDUCE', ['PIG', 'OOZIE', 'HIVE']);
  97. },
  98. /**
  99. * Check whether we should turn on <code>MapReduce2</code> service
  100. * @return {Boolean}
  101. */
  102. needToAddYarnMapReduce2: function() {
  103. return this.needAddService('YARN', ['PIG', 'OOZIE', 'HIVE']);
  104. },
  105. /**
  106. * Check whether we should turn on <code>ZooKeeper</code> service
  107. * @return {Boolean}
  108. */
  109. needToAddZooKeeper: function() {
  110. return this.needAddService('ZOOKEEPER', 'HBASE');
  111. },
  112. /**
  113. * Check whether we should turn on <code>HDFS or HCFS</code> service
  114. * @return {Boolean}
  115. */
  116. noDFSs: function () {
  117. return (this.findProperty('serviceName', 'HDFS').get('isSelected') === false &&
  118. (!this.findProperty('serviceName', 'HCFS') || this.findProperty('serviceName', 'HCFS').get('isSelected') === false));
  119. },
  120. /**
  121. * Check if multiple distributed file systems were selected
  122. * @return {Boolean}
  123. */
  124. multipleDFSs: function () {
  125. return (this.findProperty('serviceName', 'HDFS').get('isSelected') === true &&
  126. (this.findProperty('serviceName', 'HCFS') && this.findProperty('serviceName', 'HCFS').get('isSelected') === true));
  127. },
  128. /**
  129. * Check do we have any monitoring service turned on
  130. * @return {Boolean}
  131. */
  132. gangliaOrNagiosNotSelected: function () {
  133. return (this.findProperty('serviceName', 'GANGLIA').get('isSelected') === false || this.findProperty('serviceName', 'NAGIOS').get('isSelected') === false);
  134. },
  135. /**
  136. * Check whether user turned on monitoring service and go to next step
  137. */
  138. validateMonitoring: function () {
  139. if (this.gangliaOrNagiosNotSelected()) {
  140. this.monitoringCheckPopup();
  141. } else {
  142. App.router.send('next');
  143. }
  144. },
  145. /**
  146. * Onclick handler for <code>Next</code> button
  147. */
  148. submit: function () {
  149. if(!this.get("isSubmitDisabled")) {
  150. if (this.needToAddMapReduce()) {
  151. this.mapReduceCheckPopup();
  152. }
  153. else {
  154. if (this.noDFSs()) {
  155. this.needToAddHDFSPopup();
  156. }
  157. else {
  158. if (this.needToAddYarnMapReduce2()) {
  159. this.mapReduce2CheckPopup();
  160. }
  161. else {
  162. if (this.needToAddZooKeeper()) {
  163. this.zooKeeperCheckPopup();
  164. }
  165. else {
  166. if (this.multipleDFSs()) {
  167. this.multipleDFSPopup();
  168. }
  169. else {
  170. this.validateMonitoring();
  171. }
  172. }
  173. }
  174. }
  175. }
  176. }
  177. },
  178. multipleDFSPopup: function() {
  179. var services = [
  180. {serviceName: 'HDFS', selected: true},
  181. {serviceName: 'HCFS', selected: false}
  182. ];
  183. this.needToAddServicePopup(services, 'multipleDFS');
  184. },
  185. /**
  186. * Select/deselect services
  187. * @param services array of objects
  188. * <code>
  189. * [
  190. * {
  191. * service: 'HDFS',
  192. * selected: true
  193. * },
  194. * ....
  195. * ]
  196. * </code>
  197. * @param i18nSuffix
  198. */
  199. needToAddServicePopup: function(services, i18nSuffix) {
  200. if (!(services instanceof Array)) {
  201. services = [services];
  202. }
  203. var self = this;
  204. App.ModalPopup.show({
  205. header: Em.I18n.t('installer.step4.' + i18nSuffix + '.popup.header'),
  206. body: Em.I18n.t('installer.step4.' + i18nSuffix + '.popup.body'),
  207. onPrimary: function () {
  208. services.forEach(function(service) {
  209. self.findProperty('serviceName', service.serviceName).set('isSelected', service.selected);
  210. });
  211. this.hide();
  212. self.submit();
  213. },
  214. onSecondary: function () {
  215. this.hide();
  216. }
  217. });
  218. },
  219. needToAddHDFSPopup: function() {
  220. this.needToAddServicePopup({serviceName:'HDFS', selected: true}, 'hdfsCheck');
  221. },
  222. mapReduceCheckPopup: function () {
  223. this.needToAddServicePopup({serviceName:'MAPREDUCE', selected: true}, 'mapreduceCheck');
  224. },
  225. mapReduce2CheckPopup: function () {
  226. this.needToAddServicePopup({serviceName:'YARN', selected:true}, 'yarnCheck');
  227. },
  228. zooKeeperCheckPopup: function () {
  229. this.needToAddServicePopup({serviceName:'ZOOKEEPER', selected: true}, 'zooKeeperCheck');
  230. },
  231. monitoringCheckPopup: function () {
  232. App.ModalPopup.show({
  233. header: Em.I18n.t('installer.step4.monitoringCheck.popup.header'),
  234. body: Em.I18n.t('installer.step4.monitoringCheck.popup.body'),
  235. onPrimary: function () {
  236. this.hide();
  237. App.router.send('next');
  238. },
  239. onSecondary: function () {
  240. this.hide();
  241. }
  242. });
  243. }
  244. });