step4_controller.js 8.7 KB

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