step10_controller.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  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. clusterInfo: [],
  21. isNagiosRestartRequired: function() {
  22. return this.get('content.controllerName') !== 'installerController' && App.Service.find('NAGIOS').get('isLoaded');
  23. }.property(),
  24. clearStep: function () {
  25. this.get('clusterInfo').clear();
  26. },
  27. loadStep: function () {
  28. console.log("TRACE: Loading step10: Summary Page");
  29. this.clearStep();
  30. this.loadInstalledHosts(this.loadRegisteredHosts());
  31. var installFlag = true;
  32. var startFlag = true;
  33. if (this.get('content.controllerName') == 'installerController') {
  34. installFlag = this.loadMasterComponents();
  35. startFlag = this.loadStartedServices();
  36. }
  37. if (installFlag && startFlag) {
  38. this.loadInstallTime();
  39. }
  40. },
  41. loadRegisteredHosts: function () {
  42. var masterHosts = this.get('content.masterComponentHosts').mapProperty('hostName').uniq();
  43. var slaveHosts = this.get('content.slaveComponentHosts');
  44. var hostObj = [];
  45. slaveHosts.forEach(function (_hosts) {
  46. hostObj = hostObj.concat(_hosts.hosts);
  47. }, this);
  48. slaveHosts = hostObj.mapProperty('hostName').uniq();
  49. var registeredHosts = App.Host.find().mapProperty('hostName').concat(masterHosts.concat(slaveHosts)).uniq();
  50. var registerHostsStatement = Em.I18n.t('installer.step10.hostsSummary').format(registeredHosts.length);
  51. var registerHostsObj = Ember.Object.create({
  52. id: 1,
  53. color: 'text-info',
  54. displayStatement: registerHostsStatement,
  55. status: []
  56. });
  57. this.get('clusterInfo').pushObject(registerHostsObj);
  58. return registerHostsObj;
  59. },
  60. loadInstalledHosts: function (host) {
  61. var hosts = this.get('content.hosts');
  62. var hostsInfo = [];
  63. for (var index in hosts) {
  64. hostsInfo.pushObject(hosts[index]);
  65. console.log('Step10 SUMMARY: value of hosts is: ' + hosts[index].status);
  66. }
  67. var succeededHosts = hostsInfo.filterProperty('status', 'success');
  68. var warnedHosts = hostsInfo.filterProperty('status', 'warning').concat(hostsInfo.filterProperty('status', 'failed'));
  69. if (succeededHosts.length) {
  70. var successStatement = Em.I18n.t('installer.step10.servicesSummary').format(succeededHosts.length) + ((succeededHosts.length > 1) ? Em.I18n.t('installer.step8.hosts') : Em.I18n.t('installer.step8.host'));
  71. this.get('clusterInfo').findProperty('id', 1).get('status').pushObject(Ember.Object.create({
  72. id: 1,
  73. color: 'text-success',
  74. displayStatement: successStatement
  75. }));
  76. }
  77. if (warnedHosts.length) {
  78. var warnStatement = warnedHosts.length + Em.I18n.t('installer.step10.warnings');
  79. this.get('clusterInfo').findProperty('id', 1).get('status').pushObject(Ember.Object.create({
  80. id: 2,
  81. color: 'text-warning',
  82. displayStatement: warnStatement,
  83. statements: []
  84. }));
  85. warnedHosts.forEach(function (_host) {
  86. var clusterState;
  87. console.log("Content.cluster.status is: " + this.get('content.cluster.status'));
  88. if (this.get('content.cluster.status') === 'INSTALL FAILED') {
  89. clusterState = Em.I18n.t('installer.step10.clusterState.installing');
  90. } else if (this.get('content.cluster.status') === 'START FAILED') {
  91. clusterState = Em.I18n.t('installer.step10.clusterState.starting');
  92. }
  93. console.log('host value is: ' + JSON.stringify(_host));
  94. var failedTasks = _host.tasks.filterProperty('Tasks.status', 'FAILED');
  95. failedTasks.forEach(function (_task) {
  96. var taskStatement = clusterState + App.format.role(_task.Tasks.role) + Em.I18n.t('installer.step10.taskStatus.failed') + _host.name;
  97. this.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', 2).get('statements').pushObject(Ember.Object.create({
  98. status: 'failed',
  99. color: 'text-info',
  100. displayStatement: taskStatement
  101. }));
  102. }, this);
  103. var abortedTasks = _host.tasks.filterProperty('Tasks.status', 'ABORTED');
  104. abortedTasks.forEach(function (_task) {
  105. var abortStatement = clusterState + App.format.role(_task.Tasks.role) + Em.I18n.t('installer.step10.taskStatus.aborted') + _host.name;
  106. this.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', 2).get('statements').pushObject(Ember.Object.create({
  107. status: 'aborted',
  108. color: 'text-info',
  109. displayStatement: abortStatement
  110. }));
  111. }, this);
  112. var timedOutTasks = _host.tasks.filterProperty('Tasks.status', 'TIMEDOUT');
  113. timedOutTasks.forEach(function (_task) {
  114. var timedOutStatement = clusterState + App.format.role(_task.Tasks.role) + Em.I18n.t('installer.step10.taskStatus.timedOut') + _host.name;
  115. this.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', 2).get('statements').pushObject(Ember.Object.create({
  116. status: 'timedout',
  117. color: 'text-info',
  118. displayStatement: timedOutStatement
  119. }));
  120. }, this);
  121. }, this);
  122. }
  123. },
  124. loadMasterComponents: function () {
  125. var components = this.get('content.masterComponentHosts');
  126. var statement;
  127. if (this.get('content.cluster.status') === 'INSTALL FAILED') {
  128. this.get('clusterInfo').pushObject(Ember.Object.create({
  129. id: 2,
  130. displayStatement: Em.I18n.t('installer.step10.installStatus.failed'),
  131. color: 'text-error',
  132. status: []
  133. }));
  134. return false;
  135. } else {
  136. this.get('clusterInfo').pushObject(Ember.Object.create({
  137. id: 2,
  138. displayStatement: Em.I18n.t('installer.step10.installStatus.installed'),
  139. color: 'text-success',
  140. status: []
  141. }));
  142. }
  143. console.log('STEP10 master components: ' + JSON.stringify(components));
  144. components.forEach(function (_component) {
  145. var component = Ember.Object.create(_component);
  146. switch (component.component) {
  147. case 'NAMENODE':
  148. this.loadNn(component);
  149. break;
  150. case 'SECONDARY_NAMENODE':
  151. this.loadSnn(component);
  152. break;
  153. case 'JOBTRACKER' :
  154. this.loadJt(component);
  155. break;
  156. case 'HISTORYSERVER':
  157. this.loadHS(component);
  158. break;
  159. case 'RESOURCEMANAGER':
  160. this.loadRM(component);
  161. break;
  162. case 'ZOOKEEPER_SERVER' :
  163. // TODO: Fix this; redundant entries and wrong number
  164. //this.loadZk(component);
  165. break;
  166. case 'HBASE_MASTER':
  167. this.loadHb(component);
  168. break;
  169. case 'HIVE_SERVER':
  170. this.loadHiveServer(component);
  171. break;
  172. case 'OOZIE_SERVER':
  173. this.loadOozieServer(component);
  174. break;
  175. case 'GANGLIA_SERVER':
  176. this.loadGanglia(component)
  177. break;
  178. case 'NAGIOS_SERVER':
  179. this.loadNagios(component);
  180. break;
  181. }
  182. }, this);
  183. return true;
  184. },
  185. loadHS: function (component) {
  186. if (component.get('hostName')) {
  187. var statement = Em.I18n.t('installer.step10.master.historyServer') + 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 HistoryServer component');
  195. }
  196. },
  197. loadRM: function (component) {
  198. if (component.get('hostName')) {
  199. var statement = Em.I18n.t('installer.step10.master.resourceManager') + 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 ResourceManager component');
  207. }
  208. },
  209. loadNn: function (component) {
  210. if (component.get('hostName')) {
  211. var statement = Em.I18n.t('installer.step10.master.nameNode') + component.get('hostName');
  212. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  213. id: 1,
  214. color: 'text-info',
  215. displayStatement: statement
  216. }));
  217. } else {
  218. console.log('ERROR: no host name assigned to NameNode component');
  219. }
  220. },
  221. loadSnn: function (component) {
  222. if (component.get('hostName')) {
  223. var statement = Em.I18n.t('installer.step10.master.secondaryNameNode') + component.get('hostName');
  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 SecondaryNameNode component');
  231. }
  232. },
  233. loadJt: function (component) {
  234. if (component.get('hostName')) {
  235. var statement = Em.I18n.t('installer.step10.master.jobTracker') + 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 JobTracker component');
  243. }
  244. },
  245. loadZk: function (component) {
  246. var hostLength = component.get('hostName').length;
  247. if (hostLength) {
  248. var hostVal;
  249. if (hostLength === 1) {
  250. hostVal = Em.I18n.t('installer.step8.host');
  251. } else {
  252. hostVal = Em.I18n.t('installer.step8.hosts');
  253. }
  254. var statement = Em.I18n.t('installer.step10.master.zooKeeper') + component.get('hostName').length + ' ' + hostVal;
  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 Zookeeper component');
  262. }
  263. },
  264. loadHb: function (component) {
  265. if (component.get('hostName')) {
  266. var statement = Em.I18n.t('installer.step10.master.hbase') + 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 HBase Master component');
  274. }
  275. },
  276. loadHiveServer: function (component) {
  277. if (component.get('hostName')) {
  278. var statement = Em.I18n.t('installer.step10.master.hiveMetastore') + 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 Hive server component');
  286. }
  287. },
  288. loadOozieServer: function (component) {
  289. if (component.get('hostName')) {
  290. var statement = Em.I18n.t('installer.step10.master.oozie') + component.get('hostName');
  291. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  292. id: 1,
  293. color: 'text-info',
  294. displayStatement: statement
  295. }));
  296. } else {
  297. console.log('ERROR: no host name assigned to Oozie server component');
  298. }
  299. },
  300. loadGanglia: function (component) {
  301. if (component.get('hostName')) {
  302. var statement = Em.I18n.t('installer.step10.master.ganglia') + component.get('hostName');
  303. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  304. id: 1,
  305. color: 'text-info',
  306. displayStatement: statement
  307. }));
  308. } else {
  309. console.log('ERROR: no host name assigned to Ganglia server component');
  310. }
  311. },
  312. loadNagios: function (component) {
  313. if (component.get('hostName')) {
  314. var statement = Em.I18n.t('installer.step10.master.nagios') + component.get('hostName');
  315. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  316. id: 1,
  317. color: 'text-info',
  318. displayStatement: statement
  319. }));
  320. } else {
  321. console.log('ERROR: no host name assigned to Nagios server component');
  322. }
  323. },
  324. loadStartedServices: function (component) {
  325. if (this.get('content.cluster.status') === 'STARTED') {
  326. var statement = Em.I18n.t('installer.step10.startStatus.started');
  327. this.get('clusterInfo').pushObject(Ember.Object.create({
  328. id: 3,
  329. color: 'text-success',
  330. displayStatement: Em.I18n.t('installer.step10.startStatus.started'),
  331. status: []
  332. }));
  333. this.get('clusterInfo').pushObject(Ember.Object.create({
  334. id: 4,
  335. color: 'text-success',
  336. displayStatement: Em.I18n.t('installer.step10.startStatus.passed'),
  337. status: []
  338. }));
  339. return true;
  340. } else {
  341. this.get('clusterInfo').pushObject(Ember.Object.create({
  342. id: 3,
  343. color: 'text-error',
  344. displayStatement: Em.I18n.t('installer.step10.startStatus.failed'),
  345. status: []
  346. }));
  347. return false;
  348. }
  349. },
  350. loadInstallTime: function () {
  351. var secondsPerMinute = 60;
  352. var statement;
  353. if (this.get('content.cluster.installTime')) {
  354. var minutes = Math.floor(this.get('content.cluster.installTime'));
  355. var seconds = Math.floor((this.get('content.cluster.installTime') - minutes) * secondsPerMinute);
  356. var statement;
  357. if (minutes !== 0) {
  358. statement = Em.I18n.t('installer.step10.installTime.minutes').format(minutes, seconds);
  359. } else {
  360. statement = Em.I18n.t('installer.step10.installTime.seconds').format(seconds);
  361. }
  362. this.get('clusterInfo').pushObject(Ember.Object.create({
  363. id: 5,
  364. color: 'text-info',
  365. displayStatement: statement,
  366. status: []
  367. }));
  368. }
  369. }
  370. });