step10_controller.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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. /**
  22. * check if were added regionservers then NAGIOS services should be restarted
  23. * to update number of regionservers in NAGIOS
  24. */
  25. isNagiosRestartRequired: function() {
  26. return this.get('content.controllerName') !== 'installerController' && App.Service.find('NAGIOS').get('isLoaded');
  27. }.property(),
  28. clearStep: function () {
  29. this.get('clusterInfo').clear();
  30. },
  31. loadStep: function () {
  32. console.log("TRACE: Loading step10: Summary Page");
  33. this.clearStep();
  34. this.loadInstalledHosts(this.loadRegisteredHosts());
  35. var installFlag = true;
  36. var startFlag = true;
  37. if (this.get('content.controllerName') == 'installerController') {
  38. installFlag = this.loadMasterComponents();
  39. startFlag = this.loadStartedServices();
  40. }
  41. if (installFlag && startFlag) {
  42. this.loadInstallTime();
  43. }
  44. },
  45. loadRegisteredHosts: function () {
  46. var masterHosts = this.get('content.masterComponentHosts').mapProperty('hostName').uniq();
  47. var slaveHosts = this.get('content.slaveComponentHosts');
  48. var hostObj = [];
  49. slaveHosts.forEach(function (_hosts) {
  50. hostObj = hostObj.concat(_hosts.hosts);
  51. }, this);
  52. slaveHosts = hostObj.mapProperty('hostName').uniq();
  53. var registeredHosts = App.Host.find().mapProperty('hostName').concat(masterHosts.concat(slaveHosts)).uniq();
  54. var registerHostsStatement = Em.I18n.t('installer.step10.hostsSummary').format(registeredHosts.length);
  55. var registerHostsObj = Ember.Object.create({
  56. id: 1,
  57. color: 'text-info',
  58. displayStatement: registerHostsStatement,
  59. status: []
  60. });
  61. this.get('clusterInfo').pushObject(registerHostsObj);
  62. return registerHostsObj;
  63. },
  64. loadInstalledHosts: function (host) {
  65. var hosts = this.get('content.hosts');
  66. var hostsInfo = [];
  67. for (var index in hosts) {
  68. hostsInfo.pushObject(hosts[index]);
  69. console.log('Step10 SUMMARY: value of hosts is: ' + hosts[index].status);
  70. }
  71. var succeededHosts = hostsInfo.filterProperty('status', 'success');
  72. var warnedHosts = hostsInfo.filterProperty('status', 'warning').concat(hostsInfo.filterProperty('status', 'failed'));
  73. if (succeededHosts.length) {
  74. 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'));
  75. this.get('clusterInfo').findProperty('id', 1).get('status').pushObject(Ember.Object.create({
  76. id: 1,
  77. color: 'text-success',
  78. displayStatement: successStatement
  79. }));
  80. }
  81. if (warnedHosts.length) {
  82. var warnStatement = warnedHosts.length + Em.I18n.t('installer.step10.warnings');
  83. this.get('clusterInfo').findProperty('id', 1).get('status').pushObject(Ember.Object.create({
  84. id: 2,
  85. color: 'text-warning',
  86. displayStatement: warnStatement,
  87. statements: []
  88. }));
  89. warnedHosts.forEach(function (_host) {
  90. var clusterState;
  91. console.log("Content.cluster.status is: " + this.get('content.cluster.status'));
  92. if (this.get('content.cluster.status') === 'INSTALL FAILED') {
  93. clusterState = Em.I18n.t('installer.step10.clusterState.installing');
  94. } else if (this.get('content.cluster.status') === 'START FAILED') {
  95. clusterState = Em.I18n.t('installer.step10.clusterState.starting');
  96. }
  97. console.log('host value is: ' + JSON.stringify(_host));
  98. var failedTasks = _host.tasks.filterProperty('Tasks.status', 'FAILED');
  99. failedTasks.forEach(function (_task) {
  100. var taskStatement = clusterState + App.format.role(_task.Tasks.role) + Em.I18n.t('installer.step10.taskStatus.failed') + _host.name;
  101. this.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', 2).get('statements').pushObject(Ember.Object.create({
  102. status: 'failed',
  103. color: 'text-info',
  104. displayStatement: taskStatement
  105. }));
  106. }, this);
  107. var abortedTasks = _host.tasks.filterProperty('Tasks.status', 'ABORTED');
  108. abortedTasks.forEach(function (_task) {
  109. var abortStatement = clusterState + App.format.role(_task.Tasks.role) + Em.I18n.t('installer.step10.taskStatus.aborted') + _host.name;
  110. this.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', 2).get('statements').pushObject(Ember.Object.create({
  111. status: 'aborted',
  112. color: 'text-info',
  113. displayStatement: abortStatement
  114. }));
  115. }, this);
  116. var timedOutTasks = _host.tasks.filterProperty('Tasks.status', 'TIMEDOUT');
  117. timedOutTasks.forEach(function (_task) {
  118. var timedOutStatement = clusterState + App.format.role(_task.Tasks.role) + Em.I18n.t('installer.step10.taskStatus.timedOut') + _host.name;
  119. this.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', 2).get('statements').pushObject(Ember.Object.create({
  120. status: 'timedout',
  121. color: 'text-info',
  122. displayStatement: timedOutStatement
  123. }));
  124. }, this);
  125. }, this);
  126. }
  127. },
  128. loadMasterComponents: function () {
  129. var components = this.get('content.masterComponentHosts');
  130. var statement;
  131. if (this.get('content.cluster.status') === 'INSTALL FAILED') {
  132. this.get('clusterInfo').pushObject(Ember.Object.create({
  133. id: 2,
  134. displayStatement: Em.I18n.t('installer.step10.installStatus.failed'),
  135. color: 'text-error',
  136. status: []
  137. }));
  138. return false;
  139. } else {
  140. this.get('clusterInfo').pushObject(Ember.Object.create({
  141. id: 2,
  142. displayStatement: Em.I18n.t('installer.step10.installStatus.installed'),
  143. color: 'text-success',
  144. status: []
  145. }));
  146. }
  147. console.log('STEP10 master components: ' + JSON.stringify(components));
  148. components.forEach(function (_component) {
  149. var component = Ember.Object.create(_component);
  150. switch (component.component) {
  151. case 'NAMENODE':
  152. this.loadNn(component);
  153. break;
  154. case 'SECONDARY_NAMENODE':
  155. this.loadSnn(component);
  156. break;
  157. case 'JOBTRACKER' :
  158. this.loadJt(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. loadNn: function (component) {
  184. if (component.get('hostName')) {
  185. var statement = Em.I18n.t('installer.step10.master.nameNode') + 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 NameNode component');
  193. }
  194. },
  195. loadSnn: function (component) {
  196. if (component.get('hostName')) {
  197. var statement = Em.I18n.t('installer.step10.master.secondaryNameNode') + 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 SecondaryNameNode component');
  205. }
  206. },
  207. loadJt: function (component) {
  208. if (component.get('hostName')) {
  209. var statement = Em.I18n.t('installer.step10.master.jobTracker') + 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 JobTracker component');
  217. }
  218. },
  219. loadZk: function (component) {
  220. var hostLength = component.get('hostName').length;
  221. if (hostLength) {
  222. var hostVal;
  223. if (hostLength === 1) {
  224. hostVal = Em.I18n.t('installer.step8.host');
  225. } else {
  226. hostVal = Em.I18n.t('installer.step8.hosts');
  227. }
  228. var statement = Em.I18n.t('installer.step10.master.zooKeeper') + component.get('hostName').length + ' ' + hostVal;
  229. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  230. id: 1,
  231. color: 'text-info',
  232. displayStatement: statement
  233. }));
  234. } else {
  235. console.log('ERROR: no host name assigned to Zookeeper component');
  236. }
  237. },
  238. loadHb: function (component) {
  239. if (component.get('hostName')) {
  240. var statement = Em.I18n.t('installer.step10.master.hbase') + component.get('hostName');
  241. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  242. id: 1,
  243. color: 'text-info',
  244. displayStatement: statement
  245. }));
  246. } else {
  247. console.log('ERROR: no host name assigned to HBase Master component');
  248. }
  249. },
  250. loadHiveServer: function (component) {
  251. if (component.get('hostName')) {
  252. var statement = Em.I18n.t('installer.step10.master.hiveMetastore') + component.get('hostName');
  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 Hive server component');
  260. }
  261. },
  262. loadOozieServer: function (component) {
  263. if (component.get('hostName')) {
  264. var statement = Em.I18n.t('installer.step10.master.oozie') + 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 Oozie server component');
  272. }
  273. },
  274. loadGanglia: function (component) {
  275. if (component.get('hostName')) {
  276. var statement = Em.I18n.t('installer.step10.master.ganglia') + 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 Ganglia server component');
  284. }
  285. },
  286. loadNagios: function (component) {
  287. if (component.get('hostName')) {
  288. var statement = Em.I18n.t('installer.step10.master.nagios') + 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 Nagios server component');
  296. }
  297. },
  298. loadStartedServices: function (component) {
  299. if (this.get('content.cluster.status') === 'STARTED') {
  300. var statement = Em.I18n.t('installer.step10.startStatus.started');
  301. this.get('clusterInfo').pushObject(Ember.Object.create({
  302. id: 3,
  303. color: 'text-success',
  304. displayStatement: Em.I18n.t('installer.step10.startStatus.started'),
  305. status: []
  306. }));
  307. this.get('clusterInfo').pushObject(Ember.Object.create({
  308. id: 4,
  309. color: 'text-success',
  310. displayStatement: Em.I18n.t('installer.step10.startStatus.passed'),
  311. status: []
  312. }));
  313. return true;
  314. } else {
  315. this.get('clusterInfo').pushObject(Ember.Object.create({
  316. id: 3,
  317. color: 'text-error',
  318. displayStatement: Em.I18n.t('installer.step10.startStatus.failed'),
  319. status: []
  320. }));
  321. return false;
  322. }
  323. },
  324. loadInstallTime: function () {
  325. var secondsPerMinute = 60;
  326. var statement;
  327. if (this.get('content.cluster.installTime')) {
  328. var minutes = Math.floor(this.get('content.cluster.installTime'));
  329. var seconds = Math.floor((this.get('content.cluster.installTime') - minutes) * secondsPerMinute);
  330. var statement;
  331. if (minutes !== 0) {
  332. statement = Em.I18n.t('installer.step10.installTime.minutes').format(minutes, seconds);
  333. } else {
  334. statement = Em.I18n.t('installer.step10.installTime.seconds').format(seconds);
  335. }
  336. this.get('clusterInfo').pushObject(Ember.Object.create({
  337. id: 5,
  338. color: 'text-info',
  339. displayStatement: statement,
  340. status: []
  341. }));
  342. }
  343. }
  344. });