step4_controller.js 9.0 KB

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