step10_controller.js 13 KB

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