step4_controller.js 8.1 KB

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