step10_controller.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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. }
  66. var succeededHosts = hostsInfo.filterProperty('status', 'success');
  67. var warnedHosts = hostsInfo.filterProperty('status', 'warning').concat(hostsInfo.filterProperty('status', 'failed'));
  68. if (succeededHosts.length) {
  69. 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'));
  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 + Em.I18n.t('installer.step10.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.status is: " + this.get('content.cluster.status'));
  87. if (this.get('content.cluster.status') === 'INSTALL FAILED') {
  88. clusterState = Em.I18n.t('installer.step10.clusterState.installing');
  89. } else if (this.get('content.cluster.status') === 'START FAILED') {
  90. clusterState = Em.I18n.t('installer.step10.clusterState.starting');
  91. }
  92. var failedTasks = _host.tasks.filterProperty('Tasks.status', 'FAILED');
  93. failedTasks.forEach(function (_task) {
  94. var taskStatement = clusterState + App.format.role(_task.Tasks.role) + Em.I18n.t('installer.step10.taskStatus.failed') + _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) + Em.I18n.t('installer.step10.taskStatus.aborted') + _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) + Em.I18n.t('installer.step10.taskStatus.timedOut') + _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: Em.I18n.t('installer.step10.installStatus.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: Em.I18n.t('installer.step10.installStatus.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 'HISTORYSERVER':
  155. this.loadHS(component);
  156. break;
  157. case 'RESOURCEMANAGER':
  158. this.loadRM(component);
  159. break;
  160. case 'ZOOKEEPER_SERVER' :
  161. // TODO: Fix this; redundant entries and wrong number
  162. //this.loadZk(component);
  163. break;
  164. case 'HBASE_MASTER':
  165. this.loadHb(component);
  166. break;
  167. case 'HIVE_SERVER':
  168. this.loadHiveServer(component);
  169. break;
  170. case 'OOZIE_SERVER':
  171. this.loadOozieServer(component);
  172. break;
  173. case 'GANGLIA_SERVER':
  174. this.loadGanglia(component);
  175. break;
  176. case 'NAGIOS_SERVER':
  177. this.loadNagios(component);
  178. break;
  179. }
  180. }, this);
  181. return true;
  182. },
  183. loadHS: function (component) {
  184. if (component.get('hostName')) {
  185. var statement = Em.I18n.t('installer.step10.master.historyServer') + component.get('hostName');
  186. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  187. id: 1,
  188. color: 'text-info',
  189. displayStatement: statement
  190. }));
  191. } else {
  192. console.log('ERROR: no host name assigned to HistoryServer component');
  193. }
  194. },
  195. loadRM: function (component) {
  196. if (component.get('hostName')) {
  197. var statement = Em.I18n.t('installer.step10.master.resourceManager') + component.get('hostName');
  198. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  199. id: 1,
  200. color: 'text-info',
  201. displayStatement: statement
  202. }));
  203. } else {
  204. console.log('ERROR: no host name assigned to ResourceManager component');
  205. }
  206. },
  207. loadNn: function (component) {
  208. if (component.get('hostName')) {
  209. var statement = Em.I18n.t('installer.step10.master.nameNode') + component.get('hostName');
  210. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  211. id: 1,
  212. color: 'text-info',
  213. displayStatement: statement
  214. }));
  215. } else {
  216. console.log('ERROR: no host name assigned to NameNode component');
  217. }
  218. },
  219. loadSnn: function (component) {
  220. if (component.get('hostName')) {
  221. var statement = Em.I18n.t('installer.step10.master.secondaryNameNode') + component.get('hostName');
  222. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  223. id: 1,
  224. color: 'text-info',
  225. displayStatement: statement
  226. }));
  227. } else {
  228. console.log('ERROR: no host name assigned to SecondaryNameNode component');
  229. }
  230. },
  231. loadJt: function (component) {
  232. if (component.get('hostName')) {
  233. var statement = Em.I18n.t('installer.step10.master.jobTracker') + component.get('hostName');
  234. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  235. id: 1,
  236. color: 'text-info',
  237. displayStatement: statement
  238. }));
  239. } else {
  240. console.log('ERROR: no host name assigned to JobTracker component');
  241. }
  242. },
  243. loadZk: function (component) {
  244. var hostLength = component.get('hostName').length;
  245. if (hostLength) {
  246. var hostVal;
  247. if (hostLength === 1) {
  248. hostVal = Em.I18n.t('installer.step8.host');
  249. } else {
  250. hostVal = Em.I18n.t('installer.step8.hosts');
  251. }
  252. var statement = Em.I18n.t('installer.step10.master.zooKeeper') + component.get('hostName').length + ' ' + hostVal;
  253. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  254. id: 1,
  255. color: 'text-info',
  256. displayStatement: statement
  257. }));
  258. } else {
  259. console.log('ERROR: no host name assigned to Zookeeper component');
  260. }
  261. },
  262. loadHb: function (component) {
  263. if (component.get('hostName')) {
  264. var statement = Em.I18n.t('installer.step10.master.hbase') + component.get('hostName');
  265. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  266. id: 1,
  267. color: 'text-info',
  268. displayStatement: statement
  269. }));
  270. } else {
  271. console.log('ERROR: no host name assigned to HBase Master component');
  272. }
  273. },
  274. loadHiveServer: function (component) {
  275. if (component.get('hostName')) {
  276. var statement = Em.I18n.t('installer.step10.master.hiveMetastore') + component.get('hostName');
  277. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  278. id: 1,
  279. color: 'text-info',
  280. displayStatement: statement
  281. }));
  282. } else {
  283. console.log('ERROR: no host name assigned to Hive server component');
  284. }
  285. },
  286. loadOozieServer: function (component) {
  287. if (component.get('hostName')) {
  288. var statement = Em.I18n.t('installer.step10.master.oozie') + component.get('hostName');
  289. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  290. id: 1,
  291. color: 'text-info',
  292. displayStatement: statement
  293. }));
  294. } else {
  295. console.log('ERROR: no host name assigned to Oozie server component');
  296. }
  297. },
  298. loadGanglia: function (component) {
  299. if (component.get('hostName')) {
  300. var statement = Em.I18n.t('installer.step10.master.ganglia') + component.get('hostName');
  301. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  302. id: 1,
  303. color: 'text-info',
  304. displayStatement: statement
  305. }));
  306. } else {
  307. console.log('ERROR: no host name assigned to Ganglia server component');
  308. }
  309. },
  310. loadNagios: function (component) {
  311. if (component.get('hostName')) {
  312. var statement = Em.I18n.t('installer.step10.master.nagios') + component.get('hostName');
  313. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  314. id: 1,
  315. color: 'text-info',
  316. displayStatement: statement
  317. }));
  318. } else {
  319. console.log('ERROR: no host name assigned to Nagios server component');
  320. }
  321. },
  322. loadStartedServices: function (component) {
  323. if (this.get('content.cluster.status') === 'STARTED') {
  324. var statement = Em.I18n.t('installer.step10.startStatus.started');
  325. this.get('clusterInfo').pushObject(Ember.Object.create({
  326. id: 3,
  327. color: 'text-success',
  328. displayStatement: Em.I18n.t('installer.step10.startStatus.started'),
  329. status: []
  330. }));
  331. this.get('clusterInfo').pushObject(Ember.Object.create({
  332. id: 4,
  333. color: 'text-success',
  334. displayStatement: Em.I18n.t('installer.step10.startStatus.passed'),
  335. status: []
  336. }));
  337. return true;
  338. } else {
  339. this.get('clusterInfo').pushObject(Ember.Object.create({
  340. id: 3,
  341. color: 'text-error',
  342. displayStatement: Em.I18n.t('installer.step10.startStatus.failed'),
  343. status: []
  344. }));
  345. return false;
  346. }
  347. },
  348. loadInstallTime: function () {
  349. var statement;
  350. var time;
  351. if (this.get('content.cluster.installTime')) {
  352. time = this.calculateInstallTime(this.get('content.cluster.installTime'));
  353. if (time.minutes !== 0) {
  354. statement = Em.I18n.t('installer.step10.installTime.minutes').format(time.minutes, time.seconds);
  355. } else {
  356. statement = Em.I18n.t('installer.step10.installTime.seconds').format(time.seconds);
  357. }
  358. this.get('clusterInfo').pushObject(Ember.Object.create({
  359. id: 5,
  360. color: 'text-info',
  361. displayStatement: statement,
  362. status: []
  363. }));
  364. }
  365. },
  366. calculateInstallTime: function(installTime){
  367. var secondsPerMinute = 60;
  368. var minutes = Math.floor(installTime);
  369. var seconds = Math.floor((installTime - minutes) * secondsPerMinute);
  370. return {
  371. minutes: minutes,
  372. seconds: seconds
  373. }
  374. }
  375. });