step10_controller.js 12 KB

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