step10_controller.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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. color: 'text-info',
  48. displayStatement: registerHostsStatement,
  49. status: []
  50. });
  51. this.get('clusterInfo').pushObject(registerHostsObj);
  52. return registerHostsObj;
  53. },
  54. loadInstalledHosts: function (host) {
  55. var hosts = this.get('content.hostsInfo');
  56. var hostsInfo = [];
  57. for (var index in hosts) {
  58. hostsInfo.pushObject(hosts[index]);
  59. console.log('Step10 SUMMARY: value of hosts is: ' + hosts[index].status);
  60. }
  61. var succededHosts = hostsInfo.filterProperty('status', 'success');
  62. var warnedHosts = hostsInfo.filterProperty('status', 'warning').concat(hostsInfo.filterProperty('status', 'failed'));
  63. if (succededHosts.length) {
  64. var successStatement;
  65. if (succededHosts.length > 1) {
  66. successStatement = succededHosts.length + ' nodes succeded completely to install and start all service components assigned to them.';
  67. } else {
  68. successStatement = succededHosts.length + ' node succeded completely to install and start all service components assigned to it.';
  69. }
  70. this.get('clusterInfo').findProperty('id', 1).get('status').pushObject(Ember.Object.create({
  71. id: 1,
  72. color: 'text-success',
  73. displayStatement: successStatement
  74. }));
  75. }
  76. if (warnedHosts.length) {
  77. var warnStatement = warnedHosts.length + ' warnings';
  78. this.get('clusterInfo').findProperty('id', 1).get('status').pushObject(Ember.Object.create({
  79. id: 2,
  80. color: 'text-warning',
  81. displayStatement: warnStatement,
  82. statements: []
  83. }));
  84. warnedHosts.forEach(function (_host) {
  85. var clusterState;
  86. console.log("Content.cluster.staus is: " + this.get('content.cluster.status'));
  87. if (this.get('content.cluster.status') === 'INSTALL FAILED') {
  88. clusterState = 'Installing ';
  89. } else if (this.get('content.cluster.status') === 'START FAILED') {
  90. clusterState = 'Starting ';
  91. }
  92. console.log('host value is: ' + JSON.stringify(_host));
  93. var failedTasks = _host.tasks.filterProperty('Tasks.status', 'FAILED');
  94. failedTasks.forEach(function (_task) {
  95. var taskStatement = clusterState + _task.Tasks.role + ' failed on ' + _host.name;
  96. this.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', 2).get('statements').pushObject(Ember.Object.create({
  97. status: 'failed',
  98. color: 'text-info',
  99. displayStatement: taskStatement
  100. }));
  101. }, this);
  102. var abortedTasks = _host.tasks.filterProperty('Tasks.status', 'ABORTED');
  103. abortedTasks.forEach(function (_task) {
  104. var abortStatement = clusterState + _task.Tasks.role + ' aborted on ' + _host.name;
  105. this.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', 2).get('statements').pushObject(Ember.Object.create({
  106. status: 'aborted',
  107. color: 'text-info',
  108. displayStatement: abortStatement
  109. }));
  110. }, this);
  111. var timedOutTasks = _host.tasks.filterProperty('Tasks.status', 'TIMEDOUT');
  112. timedOutTasks.forEach(function (_task) {
  113. var abortStatement = clusterState + _task.Tasks.role + ' timed out on ' + _host.name;
  114. this.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', 2).get('statements').pushObject(Ember.Object.create({
  115. status: 'timedout',
  116. color: 'text-info',
  117. displayStatement: timedOutTasks
  118. }));
  119. }, this);
  120. }, this);
  121. }
  122. },
  123. loadMasterComponents: function () {
  124. var components = this.get('content.masterComponentHosts');
  125. var statement;
  126. if (this.get('content.cluster.status') === 'INSTALL FAILED') {
  127. this.get('clusterInfo').pushObject(Ember.Object.create({
  128. id: 2,
  129. displayStatement: 'Installing master services failed',
  130. color: 'text-error',
  131. status: []
  132. }));
  133. return false;
  134. } else {
  135. this.get('clusterInfo').pushObject(Ember.Object.create({
  136. id: 2,
  137. displayStatement: 'Master services installed',
  138. color: 'text-success',
  139. status: []
  140. }));
  141. }
  142. console.log('STEP10 master components: ' + JSON.stringify(components));
  143. components.forEach(function (_component) {
  144. var component = Ember.Object.create(_component);
  145. switch (component.component) {
  146. case 'NAMENODE':
  147. this.loadNn(component);
  148. break;
  149. case 'SECONDARY_NAMENODE':
  150. this.loadSnn(component);
  151. break;
  152. case 'JOBTRACKER' :
  153. this.loadJt(component);
  154. break;
  155. case 'ZOOKEEPER_SERVER' :
  156. // TODO: Fix this; redundant entries and wrong number
  157. //this.loadZk(component);
  158. break;
  159. case 'HBASE_MASTER':
  160. this.loadHb(component);
  161. break;
  162. case 'HIVE_SERVER':
  163. this.loadHiveServer(component);
  164. break;
  165. case 'OOZIE_SERVER':
  166. this.loadOozieServer(component);
  167. break;
  168. case 'GANGLIA_SERVER':
  169. this.loadGanglia(component)
  170. break;
  171. case 'NAGIOS_SERVER':
  172. this.loadNagios(component);
  173. break;
  174. }
  175. }, this);
  176. return true;
  177. },
  178. loadNn: function (component) {
  179. if (component.get('hostName')) {
  180. var statement = 'NameNode installed on ' + component.get('hostName');
  181. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  182. id: 1,
  183. color: 'text-info',
  184. displayStatement: statement
  185. }));
  186. } else {
  187. console.log('ERROR: no host name assigned to NameNode component');
  188. }
  189. },
  190. loadSnn: function (component) {
  191. if (component.get('hostName')) {
  192. var statement = 'SecondaryNameNode installed on ' + component.get('hostName');
  193. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  194. id: 1,
  195. color: 'text-info',
  196. displayStatement: statement
  197. }));
  198. } else {
  199. console.log('ERROR: no host name assigned to SecondaryNameNode component');
  200. }
  201. },
  202. loadJt: function (component) {
  203. if (component.get('hostName')) {
  204. var statement = 'JobTracker installed on ' + component.get('hostName');
  205. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  206. id: 1,
  207. color: 'text-info',
  208. displayStatement: statement
  209. }));
  210. } else {
  211. console.log('ERROR: no host name assigned to JobTracker component');
  212. }
  213. },
  214. loadZk: function (component) {
  215. var hostLength = component.get('hostName').length;
  216. if (hostLength) {
  217. var hostVal;
  218. if (hostLength === 1) {
  219. hostVal = 'host';
  220. } else {
  221. hostVal = 'hosts';
  222. }
  223. var statement = 'ZooKeeper installed on ' + component.get('hostName').length + ' ' + hostVal;
  224. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  225. id: 1,
  226. color: 'text-info',
  227. displayStatement: statement
  228. }));
  229. } else {
  230. console.log('ERROR: no host name assigned to Zookeeper component');
  231. }
  232. },
  233. loadHb: function (component) {
  234. if (component.get('hostName')) {
  235. var statement = 'HBase Master installed on ' + component.get('hostName');
  236. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  237. id: 1,
  238. color: 'text-info',
  239. displayStatement: statement
  240. }));
  241. } else {
  242. console.log('ERROR: no host name assigned to HBase Master component');
  243. }
  244. },
  245. loadHiveServer: function (component) {
  246. if (component.get('hostName')) {
  247. var statement = 'Hive Metastore installed on ' + component.get('hostName');
  248. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  249. id: 1,
  250. color: 'text-info',
  251. displayStatement: statement
  252. }));
  253. } else {
  254. console.log('ERROR: no host name assigned to Hive server component');
  255. }
  256. },
  257. loadOozieServer: function (component) {
  258. if (component.get('hostName')) {
  259. var statement = 'Oozie Server installed on ' + component.get('hostName');
  260. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  261. id: 1,
  262. color: 'text-info',
  263. displayStatement: statement
  264. }));
  265. } else {
  266. console.log('ERROR: no host name assigned to Oozie server component');
  267. }
  268. },
  269. loadGanglia: function (component) {
  270. if (component.get('hostName')) {
  271. var statement = 'Ganglia Server installed on ' + component.get('hostName');
  272. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  273. id: 1,
  274. color: 'text-info',
  275. displayStatement: statement
  276. }));
  277. } else {
  278. console.log('ERROR: no host name assigned to Ganglia server component');
  279. }
  280. },
  281. loadNagios: function (component) {
  282. if (component.get('hostName')) {
  283. var statement = 'Nagios Server installed on ' + component.get('hostName');
  284. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  285. id: 1,
  286. color: 'text-info',
  287. displayStatement: statement
  288. }));
  289. } else {
  290. console.log('ERROR: no host name assigned to Nagios server component');
  291. }
  292. },
  293. loadStartedServices: function (component) {
  294. if (this.get('content.cluster.status') === 'STARTED') {
  295. var statement = 'All services started';
  296. this.get('clusterInfo').pushObject(Ember.Object.create({
  297. id: 3,
  298. color: 'text-success',
  299. displayStatement: 'All services started',
  300. status: []
  301. }));
  302. this.get('clusterInfo').pushObject(Ember.Object.create({
  303. id: 4,
  304. color: 'text-success',
  305. displayStatement: 'All tests passed',
  306. status: []
  307. }));
  308. return true;
  309. } else {
  310. this.get('clusterInfo').pushObject(Ember.Object.create({
  311. id: 3,
  312. color: 'text-error',
  313. displayStatement: 'Starting services failed',
  314. status: []
  315. }));
  316. return false;
  317. }
  318. },
  319. loadInstallTime: function () {
  320. var secondsPerMinute = 60;
  321. var statement;
  322. if (this.get('content.cluster.installTime')) {
  323. var minutes = Math.floor(this.get('content.cluster.installTime'));
  324. var seconds = Math.floor((this.get('content.cluster.installTime') - minutes) * secondsPerMinute);
  325. var statement;
  326. if (minutes !== 0) {
  327. statement = 'Install and start of all services completed in ' + minutes + ' minutes and ' + seconds + ' seconds';
  328. } else {
  329. statement = 'Install and start of all services completed in ' + seconds + ' seconds';
  330. }
  331. this.get('clusterInfo').pushObject(Ember.Object.create({
  332. id: 5,
  333. color: 'text-info',
  334. displayStatement: statement,
  335. status: []
  336. }));
  337. }
  338. }
  339. });