step10_controller.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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.db.getSlaveComponentHosts().findProperty('componentName', 'HBASE_REGIONSERVER').hosts.length;
  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 = 'The cluster consists of ' + registeredHosts.length + ' hosts';
  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 = 'Installed and started services successfully on ' + succeededHosts.length + ' new ' + ((succeededHosts.length > 1) ? 'hosts' : '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 + ' 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 = 'Installing ';
  90. } else if (this.get('content.cluster.status') === 'START FAILED') {
  91. 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) + ' failed on ' + _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) + ' aborted on ' + _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) + ' timed out on ' + _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: 'Installing master services 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: 'Master services 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 'ZOOKEEPER_SERVER' :
  157. // TODO: Fix this; redundant entries and wrong number
  158. //this.loadZk(component);
  159. break;
  160. case 'HBASE_MASTER':
  161. this.loadHb(component);
  162. break;
  163. case 'HIVE_SERVER':
  164. this.loadHiveServer(component);
  165. break;
  166. case 'OOZIE_SERVER':
  167. this.loadOozieServer(component);
  168. break;
  169. case 'GANGLIA_SERVER':
  170. this.loadGanglia(component)
  171. break;
  172. case 'NAGIOS_SERVER':
  173. this.loadNagios(component);
  174. break;
  175. }
  176. }, this);
  177. return true;
  178. },
  179. loadNn: function (component) {
  180. if (component.get('hostName')) {
  181. var statement = 'NameNode installed on ' + component.get('hostName');
  182. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  183. id: 1,
  184. color: 'text-info',
  185. displayStatement: statement
  186. }));
  187. } else {
  188. console.log('ERROR: no host name assigned to NameNode component');
  189. }
  190. },
  191. loadSnn: function (component) {
  192. if (component.get('hostName')) {
  193. var statement = 'SecondaryNameNode installed on ' + component.get('hostName');
  194. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  195. id: 1,
  196. color: 'text-info',
  197. displayStatement: statement
  198. }));
  199. } else {
  200. console.log('ERROR: no host name assigned to SecondaryNameNode component');
  201. }
  202. },
  203. loadJt: function (component) {
  204. if (component.get('hostName')) {
  205. var statement = 'JobTracker installed on ' + component.get('hostName');
  206. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  207. id: 1,
  208. color: 'text-info',
  209. displayStatement: statement
  210. }));
  211. } else {
  212. console.log('ERROR: no host name assigned to JobTracker component');
  213. }
  214. },
  215. loadZk: function (component) {
  216. var hostLength = component.get('hostName').length;
  217. if (hostLength) {
  218. var hostVal;
  219. if (hostLength === 1) {
  220. hostVal = 'host';
  221. } else {
  222. hostVal = 'hosts';
  223. }
  224. var statement = 'ZooKeeper installed on ' + component.get('hostName').length + ' ' + hostVal;
  225. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  226. id: 1,
  227. color: 'text-info',
  228. displayStatement: statement
  229. }));
  230. } else {
  231. console.log('ERROR: no host name assigned to Zookeeper component');
  232. }
  233. },
  234. loadHb: function (component) {
  235. if (component.get('hostName')) {
  236. var statement = 'HBase Master installed on ' + component.get('hostName');
  237. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  238. id: 1,
  239. color: 'text-info',
  240. displayStatement: statement
  241. }));
  242. } else {
  243. console.log('ERROR: no host name assigned to HBase Master component');
  244. }
  245. },
  246. loadHiveServer: function (component) {
  247. if (component.get('hostName')) {
  248. var statement = 'Hive Metastore installed on ' + component.get('hostName');
  249. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  250. id: 1,
  251. color: 'text-info',
  252. displayStatement: statement
  253. }));
  254. } else {
  255. console.log('ERROR: no host name assigned to Hive server component');
  256. }
  257. },
  258. loadOozieServer: function (component) {
  259. if (component.get('hostName')) {
  260. var statement = 'Oozie Server installed on ' + component.get('hostName');
  261. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  262. id: 1,
  263. color: 'text-info',
  264. displayStatement: statement
  265. }));
  266. } else {
  267. console.log('ERROR: no host name assigned to Oozie server component');
  268. }
  269. },
  270. loadGanglia: function (component) {
  271. if (component.get('hostName')) {
  272. var statement = 'Ganglia Server installed on ' + component.get('hostName');
  273. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  274. id: 1,
  275. color: 'text-info',
  276. displayStatement: statement
  277. }));
  278. } else {
  279. console.log('ERROR: no host name assigned to Ganglia server component');
  280. }
  281. },
  282. loadNagios: function (component) {
  283. if (component.get('hostName')) {
  284. var statement = 'Nagios Server installed on ' + component.get('hostName');
  285. this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
  286. id: 1,
  287. color: 'text-info',
  288. displayStatement: statement
  289. }));
  290. } else {
  291. console.log('ERROR: no host name assigned to Nagios server component');
  292. }
  293. },
  294. loadStartedServices: function (component) {
  295. if (this.get('content.cluster.status') === 'STARTED') {
  296. var statement = 'All services started';
  297. this.get('clusterInfo').pushObject(Ember.Object.create({
  298. id: 3,
  299. color: 'text-success',
  300. displayStatement: 'All services started',
  301. status: []
  302. }));
  303. this.get('clusterInfo').pushObject(Ember.Object.create({
  304. id: 4,
  305. color: 'text-success',
  306. displayStatement: 'All tests passed',
  307. status: []
  308. }));
  309. return true;
  310. } else {
  311. this.get('clusterInfo').pushObject(Ember.Object.create({
  312. id: 3,
  313. color: 'text-error',
  314. displayStatement: 'Starting services failed',
  315. status: []
  316. }));
  317. return false;
  318. }
  319. },
  320. loadInstallTime: function () {
  321. var secondsPerMinute = 60;
  322. var statement;
  323. if (this.get('content.cluster.installTime')) {
  324. var minutes = Math.floor(this.get('content.cluster.installTime'));
  325. var seconds = Math.floor((this.get('content.cluster.installTime') - minutes) * secondsPerMinute);
  326. var statement;
  327. if (minutes !== 0) {
  328. statement = 'Install and start completed in ' + minutes + ' minutes and ' + seconds + ' seconds';
  329. } else {
  330. statement = 'Install and start completed in ' + seconds + ' seconds';
  331. }
  332. this.get('clusterInfo').pushObject(Ember.Object.create({
  333. id: 5,
  334. color: 'text-info',
  335. displayStatement: statement,
  336. status: []
  337. }));
  338. }
  339. }
  340. });