step10_controller.js 11 KB

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