123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398 |
- /**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- var App = require('app');
- App.WizardStep10Controller = Em.Controller.extend({
- clusterInfo: [],
- isNagiosRestartRequired: function() {
- return this.get('content.controllerName') !== 'installerController' && App.Service.find('NAGIOS').get('isLoaded');
- }.property(),
- clearStep: function () {
- this.get('clusterInfo').clear();
- },
- loadStep: function () {
- console.log("TRACE: Loading step10: Summary Page");
- this.clearStep();
- this.loadInstalledHosts(this.loadRegisteredHosts());
- var installFlag = true;
- var startFlag = true;
- if (this.get('content.controllerName') == 'installerController') {
- installFlag = this.loadMasterComponents();
- startFlag = this.loadStartedServices();
- }
- if (installFlag && startFlag) {
- this.loadInstallTime();
- }
- },
- loadRegisteredHosts: function () {
- var masterHosts = this.get('content.masterComponentHosts').mapProperty('hostName').uniq();
- var slaveHosts = this.get('content.slaveComponentHosts');
- var hostObj = [];
- slaveHosts.forEach(function (_hosts) {
- hostObj = hostObj.concat(_hosts.hosts);
- }, this);
- slaveHosts = hostObj.mapProperty('hostName').uniq();
- var registeredHosts = App.Host.find().mapProperty('hostName').concat(masterHosts.concat(slaveHosts)).uniq();
- var registerHostsStatement = Em.I18n.t('installer.step10.hostsSummary').format(registeredHosts.length);
- var registerHostsObj = Ember.Object.create({
- id: 1,
- color: 'text-info',
- displayStatement: registerHostsStatement,
- status: []
- });
- this.get('clusterInfo').pushObject(registerHostsObj);
- return registerHostsObj;
- },
- loadInstalledHosts: function (host) {
- var hosts = this.get('content.hosts');
- var hostsInfo = [];
- for (var index in hosts) {
- hostsInfo.pushObject(hosts[index]);
- console.log('Step10 SUMMARY: value of hosts is: ' + hosts[index].status);
- }
- var succeededHosts = hostsInfo.filterProperty('status', 'success');
- var warnedHosts = hostsInfo.filterProperty('status', 'warning').concat(hostsInfo.filterProperty('status', 'failed'));
- if (succeededHosts.length) {
- 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'));
- this.get('clusterInfo').findProperty('id', 1).get('status').pushObject(Ember.Object.create({
- id: 1,
- color: 'text-success',
- displayStatement: successStatement
- }));
- }
- if (warnedHosts.length) {
- var warnStatement = warnedHosts.length + Em.I18n.t('installer.step10.warnings');
- this.get('clusterInfo').findProperty('id', 1).get('status').pushObject(Ember.Object.create({
- id: 2,
- color: 'text-warning',
- displayStatement: warnStatement,
- statements: []
- }));
- warnedHosts.forEach(function (_host) {
- var clusterState;
- console.log("Content.cluster.status is: " + this.get('content.cluster.status'));
- if (this.get('content.cluster.status') === 'INSTALL FAILED') {
- clusterState = Em.I18n.t('installer.step10.clusterState.installing');
- } else if (this.get('content.cluster.status') === 'START FAILED') {
- clusterState = Em.I18n.t('installer.step10.clusterState.starting');
- }
- console.log('host value is: ' + JSON.stringify(_host));
- var failedTasks = _host.tasks.filterProperty('Tasks.status', 'FAILED');
- failedTasks.forEach(function (_task) {
- var taskStatement = clusterState + App.format.role(_task.Tasks.role) + Em.I18n.t('installer.step10.taskStatus.failed') + _host.name;
- this.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', 2).get('statements').pushObject(Ember.Object.create({
- status: 'failed',
- color: 'text-info',
- displayStatement: taskStatement
- }));
- }, this);
- var abortedTasks = _host.tasks.filterProperty('Tasks.status', 'ABORTED');
- abortedTasks.forEach(function (_task) {
- var abortStatement = clusterState + App.format.role(_task.Tasks.role) + Em.I18n.t('installer.step10.taskStatus.aborted') + _host.name;
- this.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', 2).get('statements').pushObject(Ember.Object.create({
- status: 'aborted',
- color: 'text-info',
- displayStatement: abortStatement
- }));
- }, this);
- var timedOutTasks = _host.tasks.filterProperty('Tasks.status', 'TIMEDOUT');
- timedOutTasks.forEach(function (_task) {
- var timedOutStatement = clusterState + App.format.role(_task.Tasks.role) + Em.I18n.t('installer.step10.taskStatus.timedOut') + _host.name;
- this.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', 2).get('statements').pushObject(Ember.Object.create({
- status: 'timedout',
- color: 'text-info',
- displayStatement: timedOutStatement
- }));
- }, this);
- }, this);
- }
- },
- loadMasterComponents: function () {
- var components = this.get('content.masterComponentHosts');
- var statement;
- if (this.get('content.cluster.status') === 'INSTALL FAILED') {
- this.get('clusterInfo').pushObject(Ember.Object.create({
- id: 2,
- displayStatement: Em.I18n.t('installer.step10.installStatus.failed'),
- color: 'text-error',
- status: []
- }));
- return false;
- } else {
- this.get('clusterInfo').pushObject(Ember.Object.create({
- id: 2,
- displayStatement: Em.I18n.t('installer.step10.installStatus.installed'),
- color: 'text-success',
- status: []
- }));
- }
- console.log('STEP10 master components: ' + JSON.stringify(components));
- components.forEach(function (_component) {
- var component = Ember.Object.create(_component);
- switch (component.component) {
- case 'NAMENODE':
- this.loadNn(component);
- break;
- case 'SECONDARY_NAMENODE':
- this.loadSnn(component);
- break;
- case 'JOBTRACKER' :
- this.loadJt(component);
- break;
- case 'HISTORYSERVER':
- this.loadHS(component);
- break;
- case 'RESOURCEMANAGER':
- this.loadRM(component);
- break;
- case 'ZOOKEEPER_SERVER' :
- // TODO: Fix this; redundant entries and wrong number
- //this.loadZk(component);
- break;
- case 'HBASE_MASTER':
- this.loadHb(component);
- break;
- case 'HIVE_SERVER':
- this.loadHiveServer(component);
- break;
- case 'OOZIE_SERVER':
- this.loadOozieServer(component);
- break;
- case 'GANGLIA_SERVER':
- this.loadGanglia(component)
- break;
- case 'NAGIOS_SERVER':
- this.loadNagios(component);
- break;
- }
- }, this);
- return true;
- },
- loadHS: function (component) {
- if (component.get('hostName')) {
- var statement = Em.I18n.t('installer.step10.master.historyServer') + component.get('hostName');
- this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
- id: 1,
- color: 'text-info',
- displayStatement: statement
- }));
- } else {
- console.log('ERROR: no host name assigned to HistoryServer component');
- }
- },
- loadRM: function (component) {
- if (component.get('hostName')) {
- var statement = Em.I18n.t('installer.step10.master.resourceManager') + component.get('hostName');
- this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
- id: 1,
- color: 'text-info',
- displayStatement: statement
- }));
- } else {
- console.log('ERROR: no host name assigned to ResourceManager component');
- }
- },
- loadNn: function (component) {
- if (component.get('hostName')) {
- var statement = Em.I18n.t('installer.step10.master.nameNode') + component.get('hostName');
- this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
- id: 1,
- color: 'text-info',
- displayStatement: statement
- }));
- } else {
- console.log('ERROR: no host name assigned to NameNode component');
- }
- },
- loadSnn: function (component) {
- if (component.get('hostName')) {
- var statement = Em.I18n.t('installer.step10.master.secondaryNameNode') + component.get('hostName');
- this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
- id: 1,
- color: 'text-info',
- displayStatement: statement
- }));
- } else {
- console.log('ERROR: no host name assigned to SecondaryNameNode component');
- }
- },
- loadJt: function (component) {
- if (component.get('hostName')) {
- var statement = Em.I18n.t('installer.step10.master.jobTracker') + component.get('hostName');
- this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
- id: 1,
- color: 'text-info',
- displayStatement: statement
- }));
- } else {
- console.log('ERROR: no host name assigned to JobTracker component');
- }
- },
- loadZk: function (component) {
- var hostLength = component.get('hostName').length;
- if (hostLength) {
- var hostVal;
- if (hostLength === 1) {
- hostVal = Em.I18n.t('installer.step8.host');
- } else {
- hostVal = Em.I18n.t('installer.step8.hosts');
- }
- var statement = Em.I18n.t('installer.step10.master.zooKeeper') + component.get('hostName').length + ' ' + hostVal;
- this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
- id: 1,
- color: 'text-info',
- displayStatement: statement
- }));
- } else {
- console.log('ERROR: no host name assigned to Zookeeper component');
- }
- },
- loadHb: function (component) {
- if (component.get('hostName')) {
- var statement = Em.I18n.t('installer.step10.master.hbase') + component.get('hostName');
- this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
- id: 1,
- color: 'text-info',
- displayStatement: statement
- }));
- } else {
- console.log('ERROR: no host name assigned to HBase Master component');
- }
- },
- loadHiveServer: function (component) {
- if (component.get('hostName')) {
- var statement = Em.I18n.t('installer.step10.master.hiveMetastore') + component.get('hostName');
- this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
- id: 1,
- color: 'text-info',
- displayStatement: statement
- }));
- } else {
- console.log('ERROR: no host name assigned to Hive server component');
- }
- },
- loadOozieServer: function (component) {
- if (component.get('hostName')) {
- var statement = Em.I18n.t('installer.step10.master.oozie') + component.get('hostName');
- this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
- id: 1,
- color: 'text-info',
- displayStatement: statement
- }));
- } else {
- console.log('ERROR: no host name assigned to Oozie server component');
- }
- },
- loadGanglia: function (component) {
- if (component.get('hostName')) {
- var statement = Em.I18n.t('installer.step10.master.ganglia') + component.get('hostName');
- this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
- id: 1,
- color: 'text-info',
- displayStatement: statement
- }));
- } else {
- console.log('ERROR: no host name assigned to Ganglia server component');
- }
- },
- loadNagios: function (component) {
- if (component.get('hostName')) {
- var statement = Em.I18n.t('installer.step10.master.nagios') + component.get('hostName');
- this.get('clusterInfo').findProperty('id', 2).get('status').pushObject(Ember.Object.create({
- id: 1,
- color: 'text-info',
- displayStatement: statement
- }));
- } else {
- console.log('ERROR: no host name assigned to Nagios server component');
- }
- },
- loadStartedServices: function (component) {
- if (this.get('content.cluster.status') === 'STARTED') {
- var statement = Em.I18n.t('installer.step10.startStatus.started');
- this.get('clusterInfo').pushObject(Ember.Object.create({
- id: 3,
- color: 'text-success',
- displayStatement: Em.I18n.t('installer.step10.startStatus.started'),
- status: []
- }));
- this.get('clusterInfo').pushObject(Ember.Object.create({
- id: 4,
- color: 'text-success',
- displayStatement: Em.I18n.t('installer.step10.startStatus.passed'),
- status: []
- }));
- return true;
- } else {
- this.get('clusterInfo').pushObject(Ember.Object.create({
- id: 3,
- color: 'text-error',
- displayStatement: Em.I18n.t('installer.step10.startStatus.failed'),
- status: []
- }));
- return false;
- }
- },
- loadInstallTime: function () {
- var secondsPerMinute = 60;
- var statement;
- if (this.get('content.cluster.installTime')) {
- var minutes = Math.floor(this.get('content.cluster.installTime'));
- var seconds = Math.floor((this.get('content.cluster.installTime') - minutes) * secondsPerMinute);
- var statement;
- if (minutes !== 0) {
- statement = Em.I18n.t('installer.step10.installTime.minutes').format(minutes, seconds);
- } else {
- statement = Em.I18n.t('installer.step10.installTime.seconds').format(seconds);
- }
- this.get('clusterInfo').pushObject(Ember.Object.create({
- id: 5,
- color: 'text-info',
- displayStatement: statement,
- status: []
- }));
- }
- }
- });
|