step4_controller.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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','TEZ']);
  110. },
  111. /**
  112. * Check whether we should turn on <code>Tez</code> service
  113. * @return {Boolean}
  114. */
  115. needToAddTez: function() {
  116. return this.needAddService('TEZ', ['YARN']);
  117. },
  118. /**
  119. * Check whether we should turn on <code>ZooKeeper</code> service
  120. * @return {Boolean}
  121. */
  122. needToAddZooKeeper: function() {
  123. return this.needAddService('ZOOKEEPER', ['HBASE','HIVE','WEBHCAT','STORM']);
  124. },
  125. /**
  126. * Check whether we should turn on <code>ZooKeeper</code> service (on 2.x stack)
  127. * @returns {Boolean}
  128. */
  129. needToAddZooKeeperOnStack2x: function() {
  130. return this.findProperty('serviceName', 'ZOOKEEPER') && this.findProperty('serviceName', 'ZOOKEEPER').get('isSelected') === false;
  131. },
  132. /**
  133. * Check whether we should turn on <code>HDFS or GLUSTERFS</code> service
  134. * @return {Boolean}
  135. */
  136. noDFSs: function () {
  137. return (this.findProperty('serviceName', 'HDFS').get('isSelected') === false &&
  138. (!this.findProperty('serviceName', 'GLUSTERFS') || this.findProperty('serviceName', 'GLUSTERFS').get('isSelected') === false));
  139. },
  140. /**
  141. * Check if multiple distributed file systems were selected
  142. * @return {Boolean}
  143. */
  144. multipleDFSs: function () {
  145. return (this.findProperty('serviceName', 'HDFS').get('isSelected') === true &&
  146. (this.findProperty('serviceName', 'GLUSTERFS') && this.findProperty('serviceName', 'GLUSTERFS').get('isSelected') === true));
  147. },
  148. /**
  149. * Check do we have any monitoring service turned on
  150. * @return {Boolean}
  151. */
  152. gangliaOrNagiosNotSelected: function () {
  153. return (this.findProperty('serviceName', 'GANGLIA').get('isSelected') === false || this.findProperty('serviceName', 'NAGIOS').get('isSelected') === false);
  154. },
  155. /**
  156. * Check whether user turned on monitoring service and go to next step
  157. */
  158. validateMonitoring: function () {
  159. if (this.gangliaOrNagiosNotSelected()) {
  160. this.monitoringCheckPopup();
  161. } else {
  162. App.router.send('next');
  163. }
  164. },
  165. /**
  166. * Onclick handler for <code>Next</code> button
  167. */
  168. submit: function () {
  169. if(!this.get("isSubmitDisabled")) {
  170. if (this.needToAddMapReduce()) {
  171. this.mapReduceCheckPopup();
  172. }
  173. else {
  174. if (this.noDFSs()) {
  175. this.needToAddHDFSPopup();
  176. }
  177. else {
  178. if (this.needToAddYarnMapReduce2()) {
  179. this.mapReduce2CheckPopup();
  180. }
  181. else {
  182. if ((!App.get('isHadoop2Stack') && this.needToAddZooKeeper()) || (App.get('isHadoop2Stack') && this.needToAddZooKeeperOnStack2x())) {
  183. this.zooKeeperCheckPopup();
  184. }
  185. else {
  186. if (this.multipleDFSs()) {
  187. this.multipleDFSPopup();
  188. }
  189. else {
  190. if(this.needToAddOozie()) {
  191. this.oozieCheckPopup();
  192. }
  193. else if (this.needToAddTez()) {
  194. this.tezCheckPopup();
  195. }
  196. else {
  197. this.validateMonitoring();
  198. }
  199. }
  200. }
  201. }
  202. }
  203. }
  204. }
  205. },
  206. /**
  207. * Select/deselect services
  208. * @param services array of objects
  209. * <code>
  210. * [
  211. * {
  212. * service: 'HDFS',
  213. * selected: true
  214. * },
  215. * ....
  216. * ]
  217. * </code>
  218. * @param i18nSuffix
  219. */
  220. needToAddServicePopup: function(services, i18nSuffix) {
  221. if (!(services instanceof Array)) {
  222. services = [services];
  223. }
  224. var self = this;
  225. App.ModalPopup.show({
  226. header: Em.I18n.t('installer.step4.' + i18nSuffix + '.popup.header'),
  227. body: Em.I18n.t('installer.step4.' + i18nSuffix + '.popup.body'),
  228. onPrimary: function () {
  229. services.forEach(function(service) {
  230. self.findProperty('serviceName', service.serviceName).set('isSelected', service.selected);
  231. });
  232. this.hide();
  233. self.submit();
  234. }
  235. });
  236. },
  237. multipleDFSPopup: function() {
  238. var services = [
  239. {serviceName: 'HDFS', selected: true},
  240. {serviceName: 'GLUSTERFS', selected: false}
  241. ];
  242. this.needToAddServicePopup(services, 'multipleDFS');
  243. },
  244. needToAddHDFSPopup: function() {
  245. this.needToAddServicePopup({serviceName:'HDFS', selected: true}, 'hdfsCheck');
  246. },
  247. mapReduceCheckPopup: function () {
  248. this.needToAddServicePopup({serviceName:'MAPREDUCE', selected: true}, 'mapreduceCheck');
  249. },
  250. mapReduce2CheckPopup: function () {
  251. this.needToAddServicePopup({serviceName:'YARN', selected:true}, 'yarnCheck');
  252. },
  253. tezCheckPopup: function() {
  254. this.needToAddServicePopup({serviceName:'TEZ', selected: true}, 'tezCheck');
  255. },
  256. zooKeeperCheckPopup: function () {
  257. this.needToAddServicePopup({serviceName:'ZOOKEEPER', selected: true}, 'zooKeeperCheck');
  258. },
  259. oozieCheckPopup: function () {
  260. this.needToAddServicePopup({serviceName:'OOZIE', selected: true}, 'oozieCheck');
  261. },
  262. monitoringCheckPopup: function () {
  263. App.ModalPopup.show({
  264. header: Em.I18n.t('installer.step4.monitoringCheck.popup.header'),
  265. body: Em.I18n.t('installer.step4.monitoringCheck.popup.body'),
  266. onPrimary: function () {
  267. this.hide();
  268. App.router.send('next');
  269. }
  270. });
  271. }
  272. });