step10_controller.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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. App.WizardStep10Controller = Em.Controller.extend({
  20. name: 'wizardStep10Controller',
  21. clusterInfo: [],
  22. clearStep: function () {
  23. this.get('clusterInfo').clear();
  24. },
  25. loadStep: function () {
  26. console.log("TRACE: Loading step10: Summary Page");
  27. this.clearStep();
  28. this.loadInstalledHosts(this.loadRegisteredHosts());
  29. var installFlag = this.loadMasterComponents();
  30. var startFlag = this.loadStartedServices();
  31. if (installFlag && startFlag) {
  32. this.loadInstallTime();
  33. }
  34. },
  35. loadRegisteredHosts: function () {
  36. var masterHosts = this.get('content.masterComponentHosts').mapProperty('hostName').uniq();
  37. var slaveHosts = this.get('content.slaveComponentHosts');
  38. var hostObj = [];
  39. slaveHosts.forEach(function (_hosts) {
  40. hostObj = hostObj.concat(_hosts.hosts);
  41. }, this);
  42. slaveHosts = hostObj.mapProperty('hostname').uniq();
  43. var registeredHosts = masterHosts.concat(slaveHosts).uniq();
  44. var registerHostsStatement = registeredHosts.length + ' hosts registered to the cluster.';
  45. var registerHostsObj = Ember.Object.create({
  46. id: 1,
  47. displayStatement: registerHostsStatement,
  48. status: []
  49. });
  50. this.get('clusterInfo').pushObject(registerHostsObj);
  51. return registerHostsObj;
  52. },
  53. loadInstalledHosts: function (host) {
  54. var hosts = this.get('content.hostsInfo');
  55. var hostsInfo = [];
  56. for (var index in hosts) {
  57. hostsInfo.pushObject(hosts[index]);
  58. console.log('Step10 SUMMARY: value of hosts is: ' + hosts[index].status);
  59. }
  60. var succededHosts = hostsInfo.filterProperty('status', 'success');
  61. var warnedHosts = hostsInfo.filterProperty('status', 'warning').concat(hostsInfo.filterProperty('status', 'failed'));
  62. if (succededHosts.length) {
  63. var successStatement = succededHosts.length + ' nodes succeded completely to install and start all service components assigned to them.';
  64. this.get('clusterInfo').findProperty('id', 1).get('status').pushObject(Ember.Object.create({
  65. id: 1,
  66. displayStatement: successStatement
  67. }));
  68. }
  69. if (warnedHosts.length) {
  70. var warnStatement = warnedHosts.length + ' warnings';
  71. this.get('clusterInfo').findProperty('id', 1).get('status').pushObject(Ember.Object.create({
  72. id: 2,
  73. displayStatement: warnStatement,
  74. statements: []
  75. }));
  76. warnedHosts.forEach(function (_host) {
  77. var clusterState;
  78. console.log("Content.cluster.staus is: " + this.get('content.cluster.status'));
  79. if (this.get('content.cluster.status') === 'INSTALL FAILED') {
  80. clusterState = 'Installing ';
  81. } else if (this.get('content.cluster.status') === 'START FAILED') {
  82. clusterState = 'Starting ';
  83. }
  84. console.log('host value is: ' + JSON.stringify(_host));
  85. var failedTasks = _host.tasks.filterProperty('Tasks.status', 'FAILED');
  86. failedTasks.forEach(function (_task) {
  87. var taskStatement = clusterState + _task.Tasks.role + ' failed on ' + _host.name;
  88. console.log('Over here in SUMMARY page...');
  89. this.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', 2).get('statements').pushObject(Ember.Object.create({
  90. status: 'failed',
  91. displayStatement: taskStatement
  92. }));
  93. }, this);
  94. var abortedTasks = _host.tasks.filterProperty('Tasks.status', 'ABORTED');
  95. abortedTasks.forEach(function (_task) {
  96. var abortStatement = clusterState + _task.Tasks.role + ' aborted on ' + _host.name;
  97. this.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', 2).get('statements').pushObject(Ember.Object.create({
  98. status: 'aborted',
  99. displayStatement: abortStatement
  100. }));
  101. }, this);
  102. var timedOutTasks = _host.tasks.filterProperty('Tasks.status', 'TIMEDOUT');
  103. timedOutTasks.forEach(function (_task) {
  104. var abortStatement = clusterState + _task.Tasks.role + ' timed out on ' + _host.name;
  105. this.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', 2).get('statements').pushObject(Ember.Object.create({
  106. status: 'timedout',
  107. displayStatement: timedOutTasks
  108. }));
  109. }, this);
  110. }, this);
  111. }
  112. },
  113. loadMasterComponents: function () {
  114. var components = this.get('content.masterComponentHosts');
  115. var statement;
  116. if (this.get('content.cluster.status') === 'INSTALL FAILED') {
  117. this.get('clusterInfo').pushObject(Ember.Object.create({
  118. id: 2,
  119. displayStatement: 'Installing master services failed',
  120. status: []
  121. }));
  122. return false;
  123. } else {
  124. this.get('clusterInfo').pushObject(Ember.Object.create({
  125. id: 2,
  126. displayStatement: 'Master services installed',
  127. status: []
  128. }));
  129. }
  130. console.log('STEP10 master components: ' + JSON.stringify(components));
  131. components.forEach(function (_component) {
  132. var component = Ember.Object.create(_component);
  133. switch (component.component) {
  134. case 'NAMENODE':
  135. this.loadNn(component);
  136. break;
  137. case 'SECONDARY_NAMENODE':
  138. this.loadSnn(component);
  139. break;
  140. case 'JOBTRACKER' :
  141. this.loadJt(component);
  142. break;
  143. case 'ZOOKEEPER_SERVER' :
  144. this.loadZk(component);
  145. break;
  146. case 'HBASE_MASTER':
  147. this.loadHb(component);
  148. break;
  149. case 'HIVE_SERVER':
  150. this.loadHiveServer(component);
  151. break;
  152. case 'OOZIE_SERVER':
  153. this.loadOozieServer(component);
  154. break;
  155. case 'GANGLIA_SERVER':
  156. this.loadGanglia(component)
  157. break;
  158. case 'NAGIOS_SERVER':
  159. this.loadNagios(component);
  160. break;
  161. }
  162. }, this);
  163. return true;
  164. },
  165. loadNn: function (component) {
  166. if (component.get('hostName')) {
  167. var statement = 'NameNode installed on ' + component.get('hostName');
  168. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  169. id: 1,
  170. displayStatement: statement
  171. }));
  172. } else {
  173. console.log('ERROR: no host name assigned to NameNode component');
  174. }
  175. },
  176. loadSnn: function (component) {
  177. if (component.get('hostName')) {
  178. var statement = 'SecondaryNameNode installed on ' + component.get('hostName');
  179. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  180. id: 1,
  181. displayStatement: statement
  182. }));
  183. } else {
  184. console.log('ERROR: no host name assigned to SecondaryNameNode component');
  185. }
  186. },
  187. loadJt: function (component) {
  188. if (component.get('hostName')) {
  189. var statement = 'JobTracker installed on ' + component.get('hostName');
  190. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  191. id: 1,
  192. displayStatement: statement
  193. }));
  194. } else {
  195. console.log('ERROR: no host name assigned to JobTracker component');
  196. }
  197. },
  198. loadZk: function (component) {
  199. var hostLength = component.get('hostName').length;
  200. if (hostLength) {
  201. var hostVal;
  202. if (hostLength === 1) {
  203. hostVal = 'host';
  204. } else {
  205. hostVal = 'hosts';
  206. }
  207. var statement = 'ZooKeeper installed on ' + component.get('hostName').length + ' ' + hostVal;
  208. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  209. id: 1,
  210. displayStatement: statement
  211. }));
  212. } else {
  213. console.log('ERROR: no host name assigned to Zookeeper component');
  214. }
  215. },
  216. loadHb: function (component) {
  217. if (component.get('hostName')) {
  218. var statement = 'HBase Master installed on ' + component.get('hostName');
  219. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  220. id: 1,
  221. displayStatement: statement
  222. }));
  223. } else {
  224. console.log('ERROR: no host name assigned to HBase Master component');
  225. }
  226. },
  227. loadHiveServer: function (component) {
  228. if (component.get('hostName')) {
  229. var statement = 'Hive Metastore installed on ' + component.get('hostName');
  230. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  231. id: 1,
  232. displayStatement: statement
  233. }));
  234. } else {
  235. console.log('ERROR: no host name assigned to Hive server component');
  236. }
  237. },
  238. loadOozieServer: function (component) {
  239. if (component.get('hostName')) {
  240. var statement = 'Hive Metastore installed on ' + component.get('hostName');
  241. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  242. id: 1,
  243. displayStatement: statement
  244. }));
  245. } else {
  246. console.log('ERROR: no host name assigned to Oozie server component');
  247. }
  248. },
  249. loadGanglia: function (component) {
  250. if (component.get('hostName')) {
  251. var statement = 'Ganglia Server installed on ' + component.get('hostName');
  252. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  253. id: 1,
  254. displayStatement: statement
  255. }));
  256. } else {
  257. console.log('ERROR: no host name assigned to Ganglia server component');
  258. }
  259. },
  260. loadNagios: function (component) {
  261. if (component.get('hostName')) {
  262. var statement = 'Ganglia Server installed on ' + component.get('hostName');
  263. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  264. id: 1,
  265. displayStatement: statement
  266. }));
  267. } else {
  268. console.log('ERROR: no host name assigned to Nagios server component');
  269. }
  270. },
  271. loadStartedServices: function (component) {
  272. if (this.get('content.cluster.status') === 'STARTED') {
  273. var statement = 'All services started'
  274. this.get('clusterInfo').pushObject(Ember.Object.create({
  275. id: 3,
  276. displayStatement: 'All services started',
  277. status: []
  278. }));
  279. this.get('clusterInfo').pushObject(Ember.Object.create({
  280. id: 4,
  281. displayStatement: 'All tests passed',
  282. status: []
  283. }));
  284. return true;
  285. } else {
  286. this.get('clusterInfo').pushObject(Ember.Object.create({
  287. id: 3,
  288. displayStatement: 'Starting services failed',
  289. status: []
  290. }));
  291. return false;
  292. }
  293. },
  294. loadInstallTime: function() {
  295. var statement = 'Install and start of all services completed in ' + this.get('content.cluster.serviceStartTime') + ' minutes';
  296. this.get('clusterInfo').pushObject(Ember.Object.create({
  297. id: 5,
  298. displayStatement: statement,
  299. status: []
  300. }));
  301. }
  302. });