step10_controller.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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. // TODO: Fix this; redundant entries and wrong number
  145. //this.loadZk(component);
  146. break;
  147. case 'HBASE_MASTER':
  148. this.loadHb(component);
  149. break;
  150. case 'HIVE_SERVER':
  151. this.loadHiveServer(component);
  152. break;
  153. case 'OOZIE_SERVER':
  154. this.loadOozieServer(component);
  155. break;
  156. case 'GANGLIA_SERVER':
  157. this.loadGanglia(component)
  158. break;
  159. case 'NAGIOS_SERVER':
  160. this.loadNagios(component);
  161. break;
  162. }
  163. }, this);
  164. return true;
  165. },
  166. loadNn: function (component) {
  167. if (component.get('hostName')) {
  168. var statement = 'NameNode installed on ' + component.get('hostName');
  169. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  170. id: 1,
  171. displayStatement: statement
  172. }));
  173. } else {
  174. console.log('ERROR: no host name assigned to NameNode component');
  175. }
  176. },
  177. loadSnn: function (component) {
  178. if (component.get('hostName')) {
  179. var statement = 'SecondaryNameNode installed on ' + component.get('hostName');
  180. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  181. id: 1,
  182. displayStatement: statement
  183. }));
  184. } else {
  185. console.log('ERROR: no host name assigned to SecondaryNameNode component');
  186. }
  187. },
  188. loadJt: function (component) {
  189. if (component.get('hostName')) {
  190. var statement = 'JobTracker installed on ' + component.get('hostName');
  191. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  192. id: 1,
  193. displayStatement: statement
  194. }));
  195. } else {
  196. console.log('ERROR: no host name assigned to JobTracker component');
  197. }
  198. },
  199. loadZk: function (component) {
  200. var hostLength = component.get('hostName').length;
  201. if (hostLength) {
  202. var hostVal;
  203. if (hostLength === 1) {
  204. hostVal = 'host';
  205. } else {
  206. hostVal = 'hosts';
  207. }
  208. var statement = 'ZooKeeper installed on ' + component.get('hostName').length + ' ' + hostVal;
  209. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  210. id: 1,
  211. displayStatement: statement
  212. }));
  213. } else {
  214. console.log('ERROR: no host name assigned to Zookeeper component');
  215. }
  216. },
  217. loadHb: function (component) {
  218. if (component.get('hostName')) {
  219. var statement = 'HBase Master installed on ' + component.get('hostName');
  220. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  221. id: 1,
  222. displayStatement: statement
  223. }));
  224. } else {
  225. console.log('ERROR: no host name assigned to HBase Master component');
  226. }
  227. },
  228. loadHiveServer: function (component) {
  229. if (component.get('hostName')) {
  230. var statement = 'Hive Metastore installed on ' + component.get('hostName');
  231. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  232. id: 1,
  233. displayStatement: statement
  234. }));
  235. } else {
  236. console.log('ERROR: no host name assigned to Hive server component');
  237. }
  238. },
  239. loadOozieServer: function (component) {
  240. if (component.get('hostName')) {
  241. var statement = 'Hive Metastore installed on ' + component.get('hostName');
  242. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  243. id: 1,
  244. displayStatement: statement
  245. }));
  246. } else {
  247. console.log('ERROR: no host name assigned to Oozie server component');
  248. }
  249. },
  250. loadGanglia: function (component) {
  251. if (component.get('hostName')) {
  252. var statement = 'Ganglia Server installed on ' + component.get('hostName');
  253. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  254. id: 1,
  255. displayStatement: statement
  256. }));
  257. } else {
  258. console.log('ERROR: no host name assigned to Ganglia server component');
  259. }
  260. },
  261. loadNagios: function (component) {
  262. if (component.get('hostName')) {
  263. var statement = 'Ganglia Server installed on ' + component.get('hostName');
  264. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  265. id: 1,
  266. displayStatement: statement
  267. }));
  268. } else {
  269. console.log('ERROR: no host name assigned to Nagios server component');
  270. }
  271. },
  272. loadStartedServices: function (component) {
  273. if (this.get('content.cluster.status') === 'STARTED') {
  274. var statement = 'All services started'
  275. this.get('clusterInfo').pushObject(Ember.Object.create({
  276. id: 3,
  277. displayStatement: 'All services started',
  278. status: []
  279. }));
  280. this.get('clusterInfo').pushObject(Ember.Object.create({
  281. id: 4,
  282. displayStatement: 'All tests passed',
  283. status: []
  284. }));
  285. return true;
  286. } else {
  287. this.get('clusterInfo').pushObject(Ember.Object.create({
  288. id: 3,
  289. displayStatement: 'Starting services failed',
  290. status: []
  291. }));
  292. return false;
  293. }
  294. },
  295. loadInstallTime: function() {
  296. var statement = 'Install and start of all services completed in ' + this.get('content.cluster.serviceStartTime') + ' minutes';
  297. this.get('clusterInfo').pushObject(Ember.Object.create({
  298. id: 5,
  299. displayStatement: statement,
  300. status: []
  301. }));
  302. }
  303. });