step4_controller.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. // prevent against getting error when not all elements have been loaded yet
  48. if (hbase && zookeeper && hive && hcatalog && webhcat) {
  49. if (stringUtils.compareVersions(App.get('currentStackVersionNumber'), "2.0") === -1) {
  50. zookeeper.set('isSelected', hbase.get('isSelected') || hive.get('isSelected'));
  51. }else{
  52. if (!zookeeper.get('isSelected')) {
  53. zookeeper.set('isSelected', hbase.get('isSelected'));
  54. }
  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>MapReduce</code> service
  74. * @return {Boolean}
  75. */
  76. needToAddMapReduce: function () {
  77. if (this.findProperty('serviceName', 'MAPREDUCE') && this.findProperty('serviceName', 'MAPREDUCE').get('isSelected') === false) {
  78. var mapreduceDependentServices = this.filter(function (item) {
  79. return ['PIG', 'OOZIE', 'HIVE'].contains(item.get('serviceName')) && item.get('isSelected', true);
  80. });
  81. return (mapreduceDependentServices.get('length') > 0);
  82. }
  83. return false;
  84. },
  85. /**
  86. * Check whether we should turn on <code>HDFS or HCFS</code> service
  87. * @return {Boolean}
  88. */
  89. needToAddHDFS: function () {
  90. return (this.findProperty('serviceName', 'HDFS').get('isSelected') === false &&
  91. (!this.findProperty('serviceName', 'HCFS') || this.findProperty('serviceName', 'HCFS').get('isSelected') === false));
  92. },
  93. /**
  94. * Check if multiple distributed file systems were selected
  95. * @return {Boolean}
  96. */
  97. multipleDFSs: function () {
  98. return (this.findProperty('serviceName', 'HDFS').get('isSelected') === true &&
  99. (this.findProperty('serviceName', 'HCFS') && this.findProperty('serviceName', 'HCFS').get('isSelected') === true));
  100. },
  101. /**
  102. * Check do we have any monitoring service turned on
  103. * @return {Boolean}
  104. */
  105. gangliaOrNagiosNotSelected: function () {
  106. return (this.findProperty('serviceName', 'GANGLIA').get('isSelected') === false || this.findProperty('serviceName', 'NAGIOS').get('isSelected') === false);
  107. },
  108. /**
  109. * Check whether user turned on monitoring service and go to next step
  110. */
  111. validateMonitoring: function () {
  112. if (this.gangliaOrNagiosNotSelected()) {
  113. this.monitoringCheckPopup();
  114. } else {
  115. App.router.send('next');
  116. }
  117. },
  118. /**
  119. * Onclick handler for <code>Next</code> button
  120. */
  121. submit: function () {
  122. if(!this.get("isSubmitDisabled")){
  123. if (this.needToAddMapReduce()) {
  124. this.mapReduceCheckPopup();
  125. } else if (this.needToAddHDFS()) {
  126. this.needToAddHDFSPopup();
  127. } else if (this.multipleDFSs()) {
  128. this.multipleDFSPopup();
  129. }
  130. else {
  131. this.validateMonitoring();
  132. }
  133. }
  134. },
  135. multipleDFSPopup: function() {
  136. var self = this;
  137. App.ModalPopup.show({
  138. header: Em.I18n.t('installer.step4.multipleDFS.popup.header'),
  139. body: Em.I18n.t('installer.step4.multipleDFS.popup.body'),
  140. onPrimary: function () {
  141. self.findProperty('serviceName', 'HDFS').set('isSelected', true);
  142. self.findProperty('serviceName', 'HCFS').set('isSelected', false);
  143. this.hide();
  144. self.validateMonitoring();
  145. },
  146. onSecondary: function () {
  147. this.hide();
  148. }
  149. });
  150. },
  151. needToAddHDFSPopup: function() {
  152. var self = this;
  153. App.ModalPopup.show({
  154. header: Em.I18n.t('installer.step4.hdfsCheck.popup.header'),
  155. body: Em.I18n.t('installer.step4.hdfsCheck.popup.body'),
  156. onPrimary: function () {
  157. self.findProperty('serviceName', 'HDFS').set('isSelected', true);
  158. this.hide();
  159. self.validateMonitoring();
  160. },
  161. onSecondary: function () {
  162. this.hide();
  163. }
  164. });
  165. },
  166. mapReduceCheckPopup: function () {
  167. var self = this;
  168. App.ModalPopup.show({
  169. header: Em.I18n.t('installer.step4.mapreduceCheck.popup.header'),
  170. body: Em.I18n.t('installer.step4.mapreduceCheck.popup.body'),
  171. onPrimary: function () {
  172. self.findProperty('serviceName', 'MAPREDUCE').set('isSelected', true);
  173. this.hide();
  174. self.validateMonitoring();
  175. },
  176. onSecondary: function () {
  177. this.hide();
  178. }
  179. });
  180. },
  181. monitoringCheckPopup: function () {
  182. App.ModalPopup.show({
  183. header: Em.I18n.t('installer.step4.monitoringCheck.popup.header'),
  184. body: Em.I18n.t('installer.step4.monitoringCheck.popup.body'),
  185. onPrimary: function () {
  186. this.hide();
  187. App.router.send('next');
  188. },
  189. onSecondary: function () {
  190. this.hide();
  191. }
  192. });
  193. }
  194. })