step10_controller.js 13 KB

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