step10_controller.js 13 KB

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