You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2012/11/07 05:00:25 UTC
svn commit: r1406442 [2/4] - in /incubator/ambari/branches/AMBARI-666: ./
ambari-web/ ambari-web/app/ ambari-web/app/assets/data/apps/
ambari-web/app/controllers/ ambari-web/app/controllers/installer/
ambari-web/app/controllers/main/ ambari-web/app/con...
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step3_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step3_controller.js?rev=1406442&r1=1406441&r2=1406442&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step3_controller.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step3_controller.js Wed Nov 7 04:00:21 2012
@@ -18,92 +18,155 @@
var App = require('app');
-App.WizardStep3Controller = Em.ArrayController.extend({
+App.WizardStep3Controller = Em.Controller.extend({
name: 'wizardStep3Controller',
+ hosts: [],
content: [],
bootHosts: [],
isSubmitDisabled: false,
- categories: ['Hosts', 'Succeeded', 'Failed'],
- category: 'Hosts',
- allChecked: true,
+ categories: ['All Hosts', 'Success', 'Error'],
+ category: 'All Hosts',
+ allChecked: false,
onAllChecked: function () {
- var hosts = this.visibleHosts();
- if (this.get('allChecked') === true) {
- hosts.setEach('isChecked', true);
- } else {
- hosts.setEach('isChecked', false);
- }
+ var hosts = this.get('visibleHosts');
+ hosts.setEach('isChecked', this.get('allChecked'));
}.observes('allChecked'),
+ noHostsSelected: function () {
+ return !(this.hosts.someProperty('isChecked', true));
+ }.property('hosts.@each.isChecked'),
+
mockData: require('data/mock/step3_hosts'),
mockRetryData: require('data/mock/step3_pollData'),
- /**
- * Provide some initialisation work. Start bootstrap if needed
- */
navigateStep: function () {
+ this.loadStep();
if (App.db.getBootStatus() === false) {
this.startBootstrap();
}
},
- /**
- * Onclick handler for <code>Retry</code> button.
- */
- retry: function () {
- if (this.get('isSubmitDisabled')) {
- return;
- }
- var hosts = this.visibleHosts();
- var selectedHosts = hosts.filterProperty('isChecked', true);
- selectedHosts.forEach(function (_host) {
- console.log('Retrying: ' + _host.name);
- });
+ clearStep: function () {
+ this.hosts.clear();
+ },
- //TODO: uncomment below code to hookup with @GET bootstrap API
- /*
- this.set('bootHosts',selectedHosts);
- this.doBootstrap();
- */
+ loadStep: function () {
+ console.log("TRACE: Loading step3: Confirm Hosts");
+ this.clearStep();
+ var hosts = this.loadHosts();
+ // hosts.setEach('bootStatus', 'pending');
+ this.renderHosts(hosts);
},
- /**
- * Below function returns the current set of visible hosts on view (All, succeded, failed)
- */
- visibleHosts: function () {
- if (this.get('category') === 'Succeeded') {
- return (this.filterProperty('bootStatus', 'success'));
- } else if (this.get('category') === 'Failed') {
- return (this.filterProperty('bootStatus', 'error'));
- } else if (this.get('category') === 'Hosts') {
- return this.content;
+ /* Loads the hostinfo from localStorage on the insertion of view. It's being called from view */
+ loadHosts: function () {
+ var hostInfo = [];
+ debugger;
+ hostInfo = this.get('content.hostsInfo');
+ var hosts = new Ember.Set();
+ for (var index in hostInfo) {
+ hosts.add(hostInfo[index]);
+ console.log("TRACE: host name is: " + hostInfo[index].name);
}
+
+ return hosts;
+ },
+
+ /* Renders the set of passed hosts */
+ renderHosts: function (hostsInfo) {
+ var self = this;
+ hostsInfo.forEach(function (_hostInfo) {
+ var hostInfo = App.HostInfo.create({
+ name: _hostInfo.name,
+ bootStatus: _hostInfo.bootStatus,
+ isChecked: false
+ });
+
+ console.log('pushing ' + hostInfo.name);
+ self.hosts.pushObject(hostInfo);
+ });
},
/**
- * Onclick handler for <code>Remove</code> button
+ * Parses and updates the content, and governs the possibility
+ * of the next doBootstrap (polling) call.
+ * Returns true if polling should stop (no hosts are in "pending" state); false otherwise
*/
- removeBtn: function () {
- if (this.get('isSubmitDisabled')) {
- return;
+ parseHostInfo: function (hostsFromServer, hostsFromContent) {
+ var result = true; // default value as true implies
+ hostsFromServer.forEach(function (_hostFromServer) {
+ var host = hostsFromContent.findProperty('name', _hostFromServer.name);
+ if (host !== null && host !== undefined) { // check if hostname extracted from REST API data matches any hostname in content
+ host.set('bootStatus', _hostFromServer.status);
+ host.set('cpu', _hostFromServer.cpu);
+ host.set('memory', _hostFromServer.memory);
+ }
+ });
+ // if the data rendered by REST API has no hosts or no hosts are in "pending" state, polling will stop
+ return this.hosts.length == 0 || !this.hosts.someProperty('bootStatus', 'pending');
+ },
+
+ /* Returns the current set of visible hosts on view (All, Succeeded, Failed) */
+ visibleHosts: function () {
+ if (this.get('category') === 'Success') {
+ return (this.hosts.filterProperty('bootStatus', 'success'));
+ } else if (this.get('category') === 'Error') {
+ return (this.hosts.filterProperty('bootStatus', 'error'));
+ } else { // if (this.get('category') === 'All Hosts')
+ return this.hosts;
}
- var hostResult = this.visibleHosts();
- var selectedHosts = hostResult.filterProperty('isChecked', true);
- selectedHosts.forEach(function (_hostInfo) {
- console.log('Removing: ' + _hostInfo.name);
+ }.property('category', 'hosts.@each.bootStatus'),
+
+ removeHosts: function (hosts) {
+ var self = this;
+
+ App.ModalPopup.show({
+ header: Em.I18n.t('installer.step3.hosts.remove.popup.header'),
+ onPrimary: function () {
+ App.router.send('removeHosts', hosts);
+ self.hosts.removeObjects(hosts);
+ this.hide();
+ },
+ body: Em.I18n.t('installer.step3.hosts.remove.popup.body')
});
- this.removeHosts(selectedHosts);
},
- /**
- * Do remove hosts logic: remove host info from UI and save it to model
- * @param hosts
- */
- removeHosts: function (hosts) {
- this.removeObjects(hosts);
- App.router.send('removeHosts', hosts);
+ /* Removes a single element on the trash icon click. Called from View */
+ removeHost: function (hostInfo) {
+ this.removeHosts([hostInfo]);
+ },
+
+ removeSelectedHosts: function () {
+ if (!this.get('noHostsSelected')) {
+ var selectedHosts = this.get('visibleHosts').filterProperty('isChecked', true);
+ selectedHosts.forEach(function (_hostInfo) {
+ console.log('Removing: ' + _hostInfo.name);
+ });
+ this.removeHosts(selectedHosts);
+ }
+ },
+
+ retryHosts: function (hosts) {
+ var self = this;
+
+ App.ModalPopup.show({
+ header: Em.I18n.t('installer.step3.hosts.retry.popup.header'),
+ onPrimary: function () {
+ hosts.forEach(function (_host) {
+ console.log('Retrying: ' + _host.name);
+ });
+
+ //TODO: uncomment below code to hookup with @GET bootstrap API
+ /*
+ self.set('bootHosts',selectedHosts);
+ self.doBootstrap();
+ */
+ this.hide();
+ },
+ body: Em.I18n.t('installer.step3.hosts.retry.popup.body')
+ });
},
startBootstrap: function () {
@@ -112,43 +175,34 @@ App.WizardStep3Controller = Em.ArrayCont
this.doBootstrap();
},
- /**
- * Below function parses and updates the content, and governs
- * the possibility of the next doBootstrap (polling) call
- *
- * @param hostsFrmServer
- * @param hostsFrmContent
- * @return {Boolean}
- */
- parseHostInfo: function (hostsFrmServer, hostsFrmContent) {
- var result = true; // default value as true implies if the data rendered by REST API has no hosts, polling will stop
- hostsFrmServer.forEach(function (_hostFrmServer) {
- var host = hostsFrmContent.findProperty('name', _hostFrmServer.name);
- if (host !== null && host !== undefined) { // check if hostname extracted from REST API data matches any hostname in content
- host.set('bootStatus', _hostFrmServer.status);
- host.set('cpu', _hostFrmServer.cpu);
- host.set('memory', _hostFrmServer.memory);
- }
- });
- result = !this.content.someProperty('bootStatus', 'pending');
- return result;
+ retryHost: function (hostInfo) {
+ this.retryHosts([hostInfo]);
+ },
+
+ retrySelectedHosts: function () {
+ if (!this.get('noHostsSelected')) {
+ var selectedHosts = this.get('visibleHosts').filterProperty('isChecked', true);
+ this.retryHosts(selectedHosts);
+ }
+ },
+
+ startBootstrap: function () {
+ this.set('isSubmitDisabled', true);
+ this.set('bootHosts', this.get('hosts'));
+ this.doBootstrap();
},
doBootstrap: function () {
var self = this;
+ var url = '/api/bootstrap';
$.ajax({
type: 'GET',
- url: '/ambari_server/api/bootstrap',
- async: false,
+ url: url,
timeout: 5000,
success: function (data) {
console.log("TRACE: In success function for the GET bootstrap call");
var result = self.parseHostInfo(data, this.get('bootHosts'));
- if (result !== true && App.router.getInstallerCurrentStep() === '3') {
- window.setTimeout(self.doBootstrap, 3000);
- } else {
- self.stopBootstrap();
- }
+ window.setTimeout(self.doBootstrap, 3000);
},
error: function () {
@@ -156,13 +210,7 @@ App.WizardStep3Controller = Em.ArrayCont
self.stopBootstrap();
},
- statusCode: {
- 404: function () {
- console.log("URI not found.");
- }
- },
-
- dataType: 'application/json'
+ statusCode: require('data/statusCodes')
});
},
@@ -172,6 +220,13 @@ App.WizardStep3Controller = Em.ArrayCont
// this.set('isSubmitDisabled',false);
},
+ submit: function () {
+ if (!this.get('isSubmitDisabled')) {
+ this.set('content.hostsInfo', this.get('hosts'));
+ App.router.send('next');
+ }
+ },
+
hostLogPopup: function (event) {
App.ModalPopup.show({
header: Em.I18n.t('installer.step3.hostLog.popup.header'),
@@ -179,7 +234,7 @@ App.WizardStep3Controller = Em.ArrayCont
this.hide();
},
bodyClass: Ember.View.extend({
- templateName: require('templates/installer/step3HostLogPopup')
+ templateName: require('templates/wizard/step3HostLogPopup')
})
});
},
@@ -187,33 +242,25 @@ App.WizardStep3Controller = Em.ArrayCont
// TODO: dummy button. Remove this after the hook up with actual REST API.
mockBtn: function () {
this.set('isSubmitDisabled', false);
- this.clear();
+ this.hosts.clear();
var hostInfo = this.mockData;
this.renderHosts(hostInfo);
},
- renderHosts: function (hostsInfo) {
- var self = this;
- hostsInfo.forEach(function (_hostInfo) {
- var hostInfo = App.HostInfo.create({
- name: _hostInfo.name,
- bootStatus: _hostInfo.bootStatus
- });
-
- console.log('pushing ' + hostInfo.name);
- self.content.pushObject(hostInfo);
- });
- },
-
pollBtn: function () {
if (this.get('isSubmitDisabled')) {
return;
}
- var hosts = this.visibleHosts();
+ var hosts = this.get('visibleHosts');
var selectedHosts = hosts.filterProperty('isChecked', true);
+ selectedHosts.forEach(function (_host) {
+ console.log('Retrying: ' + _host.name);
+ });
var mockHosts = this.mockRetryData;
-
+ mockHosts.forEach(function (_host) {
+ console.log('Retrying: ' + _host.name);
+ });
if (this.parseHostInfo(mockHosts, selectedHosts)) {
// this.saveHostInfoToDb();
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step5_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step5_controller.js?rev=1406442&r1=1406441&r2=1406442&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step5_controller.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step5_controller.js Wed Nov 7 04:00:21 2012
@@ -20,13 +20,13 @@ var App = require('app');
App.WizardStep5Controller = Em.Controller.extend({
- name:"wizardStep5Controller",
+ name: "wizardStep5Controller",
- hosts:[],
+ hosts: [],
- selectedServices:[],
- selectedServicesMasters:[],
- zId:0,
+ selectedServices: [],
+ selectedServicesMasters: [],
+ zId: 0,
components: require('data/service_components'),
@@ -53,7 +53,7 @@ App.WizardStep5Controller = Em.Controlle
for (var index in hostInfo) {
var _host = hostInfo[index];
- if(_host.bootStatus === 'success'){
+ if (_host.bootStatus === 'success' || true) { // TODO: remove "true" after integrating with bootstrap
var hostObj = Ember.Object.create({
host_name: _host.name,
@@ -74,7 +74,7 @@ App.WizardStep5Controller = Em.Controlle
loadComponents: function () {
var services = this.get('content.services')
- .filterProperty('isSelected', true).mapProperty('serviceName');
+ .filterProperty('isSelected', true).mapProperty('serviceName');
services.forEach(function (item) {
this.get("selectedServices").pushObject(Ember.Object.create({service_name: item}));
@@ -91,7 +91,8 @@ App.WizardStep5Controller = Em.Controlle
componentInfo.forEach(function (_componentInfo) {
console.log("TRACE: master component name is: " + _componentInfo.display_name);
var componentObj = {};
- componentObj.component_name = _componentInfo.display_name;
+ componentObj.component_name = _componentInfo.component_name;
+ componentObj.display_name = _componentInfo.display_name;
componentObj.selectedHost = this.selectHost(_componentInfo.component_name); // call the method that plays selectNode algorithm or fetches from server
componentObj.availableHosts = [];
components.add(componentObj);
@@ -102,8 +103,9 @@ App.WizardStep5Controller = Em.Controlle
masterHosts.forEach(function (_masterComponentHost) {
var componentObj = {};
- componentObj.component_name =_masterComponentHost.component;
- componentObj.selectedHost = _masterComponentHost.hostName; // call the method that plays selectNode algorithm or fetches from server
+ componentObj.component_name = _masterComponentHost.component_name;
+ componentObj.display_name = _masterComponentHost.display_name;
+ componentObj.selectedHost = _masterComponentHost.hostName;
componentObj.availableHosts = [];
components.add(componentObj);
}, this);
@@ -126,7 +128,8 @@ App.WizardStep5Controller = Em.Controlle
masterComponents.forEach(function (item) {
//add the zookeeper component at the end if exists
- if (item.component_name === "ZooKeeper") {
+ console.log("TRACE: render master component name is: " + item.component_name);
+ if (item.display_name === "ZooKeeper") {
if (services.length) {
services.forEach(function (_service) {
this.get('selectedServicesMasters').pushObject(_service);
@@ -337,7 +340,8 @@ App.WizardStep5Controller = Em.Controlle
var zooKeeperHosts = new Ember.Set();
extraHosts.forEach(function (_host) {
var zooKeeperHost = {};
- zooKeeperHost.component_name = 'ZooKeeper';
+ zooKeeperHost.display_name = 'ZooKeeper';
+ zooKeeperHost.component_name = 'ZOOKEEPER';
zooKeeperHost.selectedHost = _host;
zooKeeperHost.availableHosts = [];
zooKeeperHosts.add(zooKeeperHost);
@@ -393,7 +397,7 @@ App.WizardStep5Controller = Em.Controlle
zookeeperHosts = null;
if (componentName === "ZooKeeper") {
- zookeeperHosts = this.get("selectedServicesMasters").filterProperty("component_name", "ZooKeeper").mapProperty("selectedHost").uniq();
+ zookeeperHosts = this.get("selectedServicesMasters").filterProperty("display_name", "ZooKeeper").mapProperty("selectedHost").uniq();
this.get("hosts").forEach(function (item) {
if (!(zookeeperHosts.contains(item.get("host_name")))) {
assignableHosts.pushObject(item);
@@ -413,15 +417,15 @@ App.WizardStep5Controller = Em.Controlle
this.rebalanceZookeeperHosts();
}
else {
- this.get('selectedServicesMasters').findProperty("component_name", masterService).set("selectedHost", selectedHost);
+ this.get('selectedServicesMasters').findProperty("display_name", masterService).set("selectedHost", selectedHost);
}
}
},
lastZooKeeper: function () {
- var currentZooKeepers = this.get("selectedServicesMasters").filterProperty("component_name", "ZooKeeper");
- if(currentZooKeepers){
+ var currentZooKeepers = this.get("selectedServicesMasters").filterProperty("display_name", "ZooKeeper");
+ if (currentZooKeepers) {
return currentZooKeepers.get("lastObject");
}
@@ -436,7 +440,7 @@ App.WizardStep5Controller = Em.Controlle
*/
var maxNumZooKeepers = this.get("hosts.length"),
- currentZooKeepers = this.get("selectedServicesMasters").filterProperty("component_name", "ZooKeeper"),
+ currentZooKeepers = this.get("selectedServicesMasters").filterProperty("display_name", "ZooKeeper"),
newZookeeper = null,
zookeeperHosts = null,
suggestedHost = null,
@@ -459,7 +463,7 @@ App.WizardStep5Controller = Em.Controlle
//create a new zookeeper based on an existing one
newZookeeper = Ember.Object.create({});
lastZoo = currentZooKeepers.get("lastObject");
- newZookeeper.set("component_name", lastZoo.get("component_name"));
+ newZookeeper.set("display_name", lastZoo.get("display_name"));
newZookeeper.set("selectedHost", lastZoo.get("selectedHost"));
newZookeeper.set("availableHosts", this.getAvailableHosts("ZooKeeper"));
@@ -501,12 +505,12 @@ App.WizardStep5Controller = Em.Controlle
return false;
}
- currentZooKeepers = this.get("selectedServicesMasters").filterProperty("component_name", "ZooKeeper");
+ currentZooKeepers = this.get("selectedServicesMasters").filterProperty("display_name", "ZooKeeper");
if (currentZooKeepers.get("length") > 1) {
this.get("selectedServicesMasters").removeAt(this.get("selectedServicesMasters").indexOf(this.get("selectedServicesMasters").findProperty("zId", zId)));
- currentZooKeepers = this.get("selectedServicesMasters").filterProperty("component_name", "ZooKeeper");
+ currentZooKeepers = this.get("selectedServicesMasters").filterProperty("display_name", "ZooKeeper");
if (currentZooKeepers.get("length") < this.get("hosts.length")) {
currentZooKeepers.set("lastObject.showAddControl", true);
}
@@ -527,7 +531,7 @@ App.WizardStep5Controller = Em.Controlle
rebalanceZookeeperHosts: function () {
//for a zookeeper update the available hosts for the other zookeepers
- var currentZooKeepers = this.get("selectedServicesMasters").filterProperty("component_name", "ZooKeeper"),
+ var currentZooKeepers = this.get("selectedServicesMasters").filterProperty("display_name", "ZooKeeper"),
zooHosts = currentZooKeepers.mapProperty("selectedHost"),
availableZooHosts = [],
preparedAvailableHosts = null;
@@ -545,7 +549,6 @@ App.WizardStep5Controller = Em.Controlle
preparedAvailableHosts.sort(this.sortHostsByConfig, this);
item.set("availableHosts", preparedAvailableHosts);
}, this);
-
},
sortHostsByConfig: function (a, b) {
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step6_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step6_controller.js?rev=1406442&r1=1406441&r2=1406442&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step6_controller.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step6_controller.js Wed Nov 7 04:00:21 2012
@@ -155,7 +155,7 @@ App.WizardStep6Controller = Em.Controlle
var hostInfo = this.get('content.hostsInfo');
var hostNames = [];
for (var index in hostInfo) {
- if (hostInfo[index].bootStatus === 'success')
+ if (hostInfo[index].bootStatus === 'success' || true) //TODO: remove true after integration with bootstrap
hostNames.push(hostInfo[index].name);
}
return hostNames;
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step8_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step8_controller.js?rev=1406442&r1=1406441&r2=1406442&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step8_controller.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step8_controller.js Wed Nov 7 04:00:21 2012
@@ -19,36 +19,37 @@
var App = require('app');
App.WizardStep8Controller = Em.Controller.extend({
- name: 'wizardStep8Controller',
- rawContent: require('data/review_configs'),
+ name: 'wizardStep8Controller',
+ rawContent: require('data/review_configs'),
+ totalHosts: [],
+ clusterInfo: [],
+ services: [],
- clusterInfo : [],
- services: [],
-
- selectedServices : function(){
+ selectedServices: function () {
return this.get('content.services').filterProperty('isSelected', true);
}.property('content.services').cacheable(),
- clearStep: function () {
- this.get('services').clear();
+ clearStep: function () {
+ this.get('services').clear();
this.get('clusterInfo').clear();
- },
+ },
- loadStep: function () {
- console.log("TRACE: Loading step8: Review Page");
- this.clearStep();
+ loadStep: function () {
+ console.log("TRACE: Loading step8: Review Page");
+ this.clearStep();
this.loadClusterInfo();
- this.loadServices();
- },
+ this.loadServices();
+ },
/**
* Load all info about cluster to <code>clusterInfo</code> variable
*/
- loadClusterInfo : function(){
+ loadClusterInfo: function () {
// cluster name
var cluster = this.rawContent.findProperty('config_name', 'cluster');
cluster.config_value = this.get('content.cluster.name');
+ console.log("STEP8: the value of content cluster name: " + this.get('content.cluster.name'));
this.get('clusterInfo').pushObject(Ember.Object.create(cluster));
//hosts
@@ -62,10 +63,10 @@ App.WizardStep8Controller = Em.Controlle
slaveHosts = hostObj.mapProperty('hostname').uniq();
- var totalHosts = masterHosts.concat(slaveHosts).uniq().length;
-
+ var totalHosts = masterHosts.concat(slaveHosts).uniq();
+ this.set('totalHosts',totalHosts);
var totalHostsObj = this.rawContent.findProperty('config_name', 'hosts');
- totalHostsObj.config_value = totalHosts;
+ totalHostsObj.config_value = totalHosts.length;
this.get('clusterInfo').pushObject(Ember.Object.create(totalHostsObj));
//repo
@@ -77,476 +78,684 @@ App.WizardStep8Controller = Em.Controlle
repoObj.config_value = 'No';
}
this.get('clusterInfo').pushObject(Ember.Object.create(repoObj));
-
},
/**
* Load all info about services to <code>services</code> variable
*/
- loadServices: function () {
+ loadServices: function () {
var selectedServices = this.get('selectedServices');
- this.set('services', selectedServices.mapProperty('serviceName'));
+ this.set('services', selectedServices.mapProperty('serviceName'));
selectedServices.forEach(function (_service) {
- console.log('INFO: step8: Name of the service from getService function: ' + _service.serviceName);
- var reviewService = this.rawContent.findProperty('config_name', 'services');
- var serviceObj = reviewService.config_value.findProperty('service_name', _service.serviceName);
-
- if (serviceObj) {
- switch (serviceObj.service_name) {
- case 'HDFS':
- this.loadHDFS(serviceObj);
- break;
- case 'MAPREDUCE':
- this.loadMapReduce(serviceObj);
- break;
- case 'HIVE':
- this.loadHive(serviceObj);
- break;
- case 'HBASE':
- this.loadHbase(serviceObj);
- break;
- case 'ZOOKEEPER':
- this.loadZk(serviceObj);
- break;
- case 'OOZIE':
- this.loadOozie(serviceObj);
- break;
- case 'NAGIOS':
- this.loadNagios(serviceObj);
- break;
- case 'GANGLIA':
- this.loadGanglia(serviceObj);
- case 'HCATALOG':
- break;
- default:
- }
- }
- //serviceObj.displayName = tempObj.service_name;
- //serviceObj.componentNames = tempObj.service_components;
+ console.log('INFO: step8: Name of the service from getService function: ' + _service.serviceName);
+ var reviewService = this.rawContent.findProperty('config_name', 'services');
+ var serviceObj = reviewService.config_value.findProperty('service_name', _service.serviceName);
+
+ if (serviceObj) {
+ switch (serviceObj.service_name) {
+ case 'HDFS':
+ this.loadHDFS(serviceObj);
+ break;
+ case 'MAPREDUCE':
+ this.loadMapReduce(serviceObj);
+ break;
+ case 'HIVE':
+ this.loadHive(serviceObj);
+ break;
+ case 'HBASE':
+ this.loadHbase(serviceObj);
+ break;
+ case 'ZOOKEEPER':
+ this.loadZk(serviceObj);
+ break;
+ case 'OOZIE':
+ this.loadOozie(serviceObj);
+ break;
+ case 'NAGIOS':
+ this.loadNagios(serviceObj);
+ break;
+ case 'GANGLIA':
+ this.loadGanglia(serviceObj);
+ case 'HCATALOG':
+ break;
+ default:
+ }
+ }
+ //serviceObj.displayName = tempObj.service_name;
+ //serviceObj.componentNames = tempObj.service_components;
- }, this);
- },
+ }, this);
+ },
/**
* load all info about HDFS service
* @param hdfsObj
*/
- loadHDFS: function (hdfsObj) {
- hdfsObj.get('service_components').forEach(function (_component) {
- switch (_component.get('display_name')) {
- case 'NameNode':
- this.loadNnValue(_component);
- break;
- case 'SecondaryNameNode':
- this.loadSnnValue(_component);
- break;
- case 'DataNodes':
- this.loadDnValue(_component);
- break;
- default:
- }
- }, this);
- //var
- this.get('services').pushObject(hdfsObj);
- },
-
- loadNnValue: function (nnComponent) {
- var nnHostName = this.get('content.masterComponentHosts').findProperty('component', nnComponent.display_name);
- nnComponent.set('component_value', nnHostName.hostName);
- },
-
- loadSnnValue: function (snnComponent) {
- var snnHostName = this.get('content.masterComponentHosts').findProperty('component', 'SNameNode');
- snnComponent.set('component_value', snnHostName.hostName);
- },
-
- loadDnValue: function (dnComponent) {
- var dnHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'DataNode');
- var totalDnHosts = dnHosts.hosts.length;
- var dnHostGroups = [];
- dnHosts.hosts.forEach(function (_dnHost) {
- dnHostGroups.push(_dnHost.group);
-
- }, this);
- var totalGroups = dnHostGroups.uniq().length;
- var groupLabel;
- if (totalGroups == 1) {
- groupLabel = 'group';
- } else {
- groupLabel = 'groups';
- }
- dnComponent.set('component_value', totalDnHosts + ' hosts ' + '(' + totalGroups + ' ' + groupLabel + ')');
- },
+ loadHDFS: function (hdfsObj) {
+ hdfsObj.get('service_components').forEach(function (_component) {
+ switch (_component.get('display_name')) {
+ case 'NameNode':
+ this.loadNnValue(_component);
+ break;
+ case 'SecondaryNameNode':
+ this.loadSnnValue(_component);
+ break;
+ case 'DataNodes':
+ this.loadDnValue(_component);
+ break;
+ default:
+ }
+ }, this);
+ //var
+ this.get('services').pushObject(hdfsObj);
+ },
+
+ loadNnValue: function (nnComponent) {
+ var nnHostName = this.get('content.masterComponentHosts').findProperty('display_name', nnComponent.display_name);
+ nnComponent.set('component_value', nnHostName.hostName);
+ },
+
+ loadSnnValue: function (snnComponent) {
+ var snnHostName = this.get('content.masterComponentHosts').findProperty('display_name', 'SNameNode');
+ snnComponent.set('component_value', snnHostName.hostName);
+ },
+
+ loadDnValue: function (dnComponent) {
+ var dnHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'DataNode');
+ var totalDnHosts = dnHosts.hosts.length;
+ var dnHostGroups = [];
+ dnHosts.hosts.forEach(function (_dnHost) {
+ dnHostGroups.push(_dnHost.group);
+
+ }, this);
+ var totalGroups = dnHostGroups.uniq().length;
+ var groupLabel;
+ if (totalGroups == 1) {
+ groupLabel = 'group';
+ } else {
+ groupLabel = 'groups';
+ }
+ dnComponent.set('component_value', totalDnHosts + ' hosts ' + '(' + totalGroups + ' ' + groupLabel + ')');
+ },
/**
* Load all info about mapReduce service
* @param mrObj
*/
- loadMapReduce: function (mrObj) {
- mrObj.get('service_components').forEach(function (_component) {
- switch (_component.get('display_name')) {
- case 'JobTracker':
- this.loadJtValue(_component);
- break;
- case 'TaskTrackers':
- this.loadTtValue(_component);
- break;
- default:
- }
- }, this);
- this.get('services').pushObject(mrObj);
- },
-
- loadJtValue: function (jtComponent) {
- var jtHostName = this.get('content.masterComponentHosts').findProperty('component', jtComponent.display_name);
- jtComponent.set('component_value', jtHostName.hostName);
- },
-
- loadTtValue: function (ttComponent) {
- var ttHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'TaskTracker');
- var totalTtHosts = ttHosts.hosts.length;
- var ttHostGroups = [];
- ttHosts.hosts.forEach(function (_ttHost) {
- ttHostGroups.push(_ttHost.group);
- }, this);
- var totalGroups = ttHostGroups.uniq().length;
- var groupLabel;
- if (totalGroups == 1) {
- groupLabel = 'group';
- } else {
- groupLabel = 'groups';
- }
- ttComponent.set('component_value', totalTtHosts + ' hosts ' + '(' + totalGroups + ' ' + groupLabel + ')');
- },
+ loadMapReduce: function (mrObj) {
+ mrObj.get('service_components').forEach(function (_component) {
+ switch (_component.get('display_name')) {
+ case 'JobTracker':
+ this.loadJtValue(_component);
+ break;
+ case 'TaskTrackers':
+ this.loadTtValue(_component);
+ break;
+ default:
+ }
+ }, this);
+ this.get('services').pushObject(mrObj);
+ },
+
+ loadJtValue: function (jtComponent) {
+ var jtHostName = this.get('content.masterComponentHosts').findProperty('display_name', jtComponent.display_name);
+ jtComponent.set('component_value', jtHostName.hostName);
+ },
+
+ loadTtValue: function (ttComponent) {
+ var ttHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'TaskTracker');
+ var totalTtHosts = ttHosts.hosts.length;
+ var ttHostGroups = [];
+ ttHosts.hosts.forEach(function (_ttHost) {
+ ttHostGroups.push(_ttHost.group);
+ }, this);
+ var totalGroups = ttHostGroups.uniq().length;
+ var groupLabel;
+ if (totalGroups == 1) {
+ groupLabel = 'group';
+ } else {
+ groupLabel = 'groups';
+ }
+ ttComponent.set('component_value', totalTtHosts + ' hosts ' + '(' + totalGroups + ' ' + groupLabel + ')');
+ },
/**
* Load all info about Hive service
* @param hiveObj
*/
- loadHive: function (hiveObj) {
- hiveObj.get('service_components').forEach(function (_component) {
- switch (_component.get('display_name')) {
- case 'Hive Metastore Server':
- this.loadHiveMetaStoreValue(_component);
- break;
- case 'Database':
- this.loadHiveDbValue(_component);
- break;
- default:
- }
- }, this);
- this.get('services').pushObject(hiveObj);
-
- },
-
- loadHiveMetaStoreValue: function (metaStoreComponent) {
- var hiveHostName = this.get('content.masterComponentHosts').findProperty('component', 'Hive Metastore');
- metaStoreComponent.set('component_value', hiveHostName.hostName);
- },
-
- loadHiveDbValue: function (dbComponent) {
- dbComponent.set('component_value', 'MySQL');
- },
+ loadHive: function (hiveObj) {
+ hiveObj.get('service_components').forEach(function (_component) {
+ switch (_component.get('display_name')) {
+ case 'Hive Metastore Server':
+ this.loadHiveMetaStoreValue(_component);
+ break;
+ case 'Database':
+ this.loadHiveDbValue(_component);
+ break;
+ default:
+ }
+ }, this);
+ this.get('services').pushObject(hiveObj);
+
+ },
+
+ loadHiveMetaStoreValue: function (metaStoreComponent) {
+ var hiveHostName = this.get('content.masterComponentHosts').findProperty('display_name', 'Hive Metastore');
+ metaStoreComponent.set('component_value', hiveHostName.hostName);
+ },
+
+ loadHiveDbValue: function (dbComponent) {
+ var hiveDb = App.db.getServiceConfigProperties().findProperty('name', 'hive_database');
+
+ if (hiveDb.value === 'New PostgreSQL Database') {
+
+ dbComponent.set('component_value', 'PostgreSQL (New Database)');
+
+ } else {
+
+ var db = App.db.getServiceConfigProperties().findProperty('name', 'hive_existing_database');
+
+ dbComponent.set('component_value', db.value + ' (' + hiveDb.value + ')');
+
+ }
+ },
/**
* Load all info about Hbase
* @param hbaseObj
*/
- loadHbase: function (hbaseObj) {
- hbaseObj.service_components.forEach(function (_component) {
- switch (_component.display_name) {
- case 'Master':
- this.loadMasterValue(_component);
- break;
- case 'Region Servers':
- this.loadRegionServerValue(_component);
- break;
- default:
- }
- }, this);
- this.get('services').pushObject(hbaseObj);
- },
-
- loadMasterValue: function (hbaseMaster) {
- var hbaseHostName = this.get('content.masterComponentHosts').findProperty('component', 'HBase Master');
- hbaseMaster.set('component_value', hbaseHostName.hostName);
- },
-
- loadRegionServerValue: function (rsComponent) {
- var rsHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'RegionServer');
- var totalRsHosts = rsHosts.hosts.length;
- var rsHostGroups = [];
- rsHosts.hosts.forEach(function (_ttHost) {
- rsHostGroups.push(_ttHost.group);
- }, this);
- var totalGroups = rsHostGroups.uniq().length;
- var groupLabel;
- if (totalGroups == 1) {
- groupLabel = 'group';
- } else {
- groupLabel = 'groups';
- }
- rsComponent.set('component_value', totalRsHosts + ' hosts ' + '(' + totalGroups + ' ' + groupLabel + ')');
- },
+ loadHbase: function (hbaseObj) {
+ hbaseObj.service_components.forEach(function (_component) {
+ switch (_component.display_name) {
+ case 'Master':
+ this.loadMasterValue(_component);
+ break;
+ case 'Region Servers':
+ this.loadRegionServerValue(_component);
+ break;
+ default:
+ }
+ }, this);
+ this.get('services').pushObject(hbaseObj);
+ },
+
+ loadMasterValue: function (hbaseMaster) {
+ var hbaseHostName = this.get('content.masterComponentHosts').findProperty('display_name', 'HBase Master');
+ hbaseMaster.set('component_value', hbaseHostName.hostName);
+ },
+
+ loadRegionServerValue: function (rsComponent) {
+ var rsHosts = this.get('content.slaveComponentHosts').findProperty('displayName', 'RegionServer');
+ var totalRsHosts = rsHosts.hosts.length;
+ var rsHostGroups = [];
+ rsHosts.hosts.forEach(function (_ttHost) {
+ rsHostGroups.push(_ttHost.group);
+ }, this);
+ var totalGroups = rsHostGroups.uniq().length;
+ var groupLabel;
+ if (totalGroups == 1) {
+ groupLabel = 'group';
+ } else {
+ groupLabel = 'groups';
+ }
+ rsComponent.set('component_value', totalRsHosts + ' hosts ' + '(' + totalGroups + ' ' + groupLabel + ')');
+ },
/**
* Load all info about ZooKeeper service
* @param zkObj
*/
- loadZk: function (zkObj) {
- zkObj.get('service_components').forEach(function (_component) {
- switch (_component.get('display_name')) {
- case 'Servers':
- this.loadZkServerValue(_component);
- break;
- default:
- }
- }, this);
- this.get('services').pushObject(zkObj);
- },
-
- loadZkServerValue: function (serverComponent) {
- var zkHostNames = this.get('content.masterComponentHosts').filterProperty('component', 'ZooKeeper').length;
- var hostSuffix;
- if (zkHostNames === 1) {
- hostSuffix = 'host';
- } else {
- hostSuffix = 'hosts';
- }
- serverComponent.set('component_value', zkHostNames + ' ' + hostSuffix);
- },
+ loadZk: function (zkObj) {
+ zkObj.get('service_components').forEach(function (_component) {
+ switch (_component.get('display_name')) {
+ case 'Servers':
+ this.loadZkServerValue(_component);
+ break;
+ default:
+ }
+ }, this);
+ this.get('services').pushObject(zkObj);
+ },
+
+ loadZkServerValue: function (serverComponent) {
+ var zkHostNames = this.get('content.masterComponentHosts').filterProperty('display_name', 'ZooKeeper').length;
+ var hostSuffix;
+ if (zkHostNames === 1) {
+ hostSuffix = 'host';
+ } else {
+ hostSuffix = 'hosts';
+ }
+ serverComponent.set('component_value', zkHostNames + ' ' + hostSuffix);
+ },
/**
* Load all info about Oozie services
* @param oozieObj
*/
- loadOozie: function (oozieObj) {
- oozieObj.get('service_components').forEach(function (_component) {
- switch (_component.get('display_name')) {
- case 'Server':
- this.loadOozieServerValue(_component);
- break;
- default:
- }
- }, this);
- this.get('services').pushObject(oozieObj);
- },
-
- loadOozieServerValue: function (oozieServer) {
- var oozieServerName = this.get('content.masterComponentHosts').findProperty('component', 'Oozie Server');
- oozieServer.set('component_value', oozieServerName.hostName);
- },
+ loadOozie: function (oozieObj) {
+ oozieObj.get('service_components').forEach(function (_component) {
+ switch (_component.get('display_name')) {
+ case 'Server':
+ this.loadOozieServerValue(_component);
+ break;
+ case 'Database':
+ this.loadOozieDbValue(_component);
+ break;
+ default:
+ }
+ }, this);
+ this.get('services').pushObject(oozieObj);
+ },
+
+ loadOozieServerValue: function (oozieServer) {
+ var oozieServerName = this.get('content.masterComponentHosts').findProperty('display_name', 'Oozie Server');
+ oozieServer.set('component_value', oozieServerName.hostName);
+ },
+
+ loadOozieDbValue: function (dbComponent) {
+ var oozieDb = App.db.getServiceConfigProperties().findProperty('name', 'oozie_database');
+ if (oozieDb.value === 'New PostgreSQL Database') {
+ dbComponent.set('component_value', 'PostgreSQL (New Database)');
+ } else {
+ var db = App.db.getServiceConfigProperties().findProperty('name', 'oozie_existing_database');
+ dbComponent.set('component_value', db.value + ' (' + oozieDb.value + ')');
+ }
+ },
+
/**
* Load all info about Nagios service
* @param nagiosObj
*/
- loadNagios: function (nagiosObj) {
- nagiosObj.service_components.forEach(function (_component) {
- switch (_component.display_name) {
- case 'Server':
- this.loadNagiosServerValue(_component);
- break;
- case 'Administrator':
- this.loadNagiosAdminValue(_component);
- break;
- default:
- }
- }, this);
- this.get('services').pushObject(nagiosObj);
- },
-
- loadNagiosServerValue: function (nagiosServer) {
- var nagiosServerName = this.get('content.masterComponentHosts').findProperty('component', 'Nagios Server');
- nagiosServer.set('component_value', nagiosServerName.hostName);
- },
+ loadNagios: function (nagiosObj) {
+ nagiosObj.service_components.forEach(function (_component) {
+ switch (_component.display_name) {
+ case 'Server':
+ this.loadNagiosServerValue(_component);
+ break;
+ case 'Administrator':
+ this.loadNagiosAdminValue(_component);
+ break;
+ default:
+ }
+ }, this);
+ this.get('services').pushObject(nagiosObj);
+ },
+
+ loadNagiosServerValue: function (nagiosServer) {
+ var nagiosServerName = this.get('content.masterComponentHosts').findProperty('display_name', 'Nagios Server');
+ nagiosServer.set('component_value', nagiosServerName.hostName);
+ },
- loadNagiosAdminValue: function (nagiosAdmin) {
+ loadNagiosAdminValue: function (nagiosAdmin) {
var config = this.get('content.serviceConfigProperties');
- var adminLoginName = config.findProperty('name', 'nagios_web_login');
- var adminEmail = config.findProperty('name', 'nagios_contact');
- nagiosAdmin.set('component_value', adminLoginName.value + ' / (' + adminEmail.value +')');
- },
+ var adminLoginName = config.findProperty('name', 'nagios_web_login');
+ var adminEmail = config.findProperty('name', 'nagios_contact');
+ nagiosAdmin.set('component_value', adminLoginName.value + ' / (' + adminEmail.value + ')');
+ },
/**
* Load all info about ganglia
* @param gangliaObj
*/
- loadGanglia: function (gangliaObj) {
- gangliaObj.get('service_components').forEach(function (_component) {
- switch (_component.get('display_name')) {
- case 'Server':
- this.loadGangliaServerValue(_component);
- break;
- default:
- }
- }, this);
- this.get('services').pushObject(gangliaObj);
- },
-
- loadGangliaServerValue: function (gangliaServer) {
- var gangliaServerName = this.get('content.masterComponentHosts').findProperty('component', 'Ganglia Collector');
- gangliaServer.set('component_value', gangliaServerName.hostName);
- },
+ loadGanglia: function (gangliaObj) {
+ gangliaObj.get('service_components').forEach(function (_component) {
+ switch (_component.get('display_name')) {
+ case 'Server':
+ this.loadGangliaServerValue(_component);
+ break;
+ default:
+ }
+ }, this);
+ this.get('services').pushObject(gangliaObj);
+ },
+ loadGangliaServerValue: function (gangliaServer) {
+ var gangliaServerName = this.get('content.masterComponentHosts').findProperty('display_name', 'Ganglia Collector');
+ gangliaServer.set('component_value', gangliaServerName.hostName);
+ },
/**
* Onclick handler for <code>next</code> button
*/
- submit: function () {
- this.createCluster();
- this.createSelectedServices();
- this.createComponents();
- this.createHostComponents();
- App.router.send('next');
- },
-
-
- /* Following create* functions are called on submitting step8 */
-
- createCluster: function () {
- var self = this;
- var clusterName = this.get('clusterInfo').findProperty('config_name', 'cluster').config_value;
- var url = '/api/clusters/' + clusterName;
- $.ajax({
- type: 'PUT',
- url: url,
- async: false,
- //accepts: 'text',
- dataType: 'text',
- timeout: 5000,
- success: function (data) {
- var jsonData = jQuery.parseJSON(data);
- console.log("TRACE: STep8 -> In success function for createCluster call");
- console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
-
- },
-
- error: function (request, ajaxOptions, error) {
- console.log('Step8: In Error ');
- console.log('Step8: Error message is: ' + request.responseText);
- },
+ submit: function () {
+ this.createCluster();
+ this.createSelectedServices();
+ this.createConfigurations();
+ this.applyCreatedConfToServices();
+ this.createComponents();
+ this.registerHostsToCluster();
+ this.createHostComponents();
+ App.router.send('next');
+ },
+
+
+ /* Following create* functions are called on submitting step8 */
+
+ createCluster: function () {
+ var self = this;
+ var clusterName = this.get('clusterInfo').findProperty('config_name', 'cluster').config_value;
+ var url = '/api/clusters/' + clusterName;
+ $.ajax({
+ type: 'POST',
+ url: url,
+ async: false,
+ //accepts: 'text',
+ dataType: 'text',
+ timeout: 5000,
+ success: function (data) {
+ var jsonData = jQuery.parseJSON(data);
+ console.log("TRACE: STep8 -> In success function for createCluster call");
+ console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
+
+ },
+
+ error: function (request, ajaxOptions, error) {
+ console.log('Step8: In Error ');
+ console.log('Step8: Error message is: ' + request.responseText);
+ },
+
+ statusCode: require('data/statusCodes')
+ });
+ console.log("Exiting createCluster");
+
+ },
+
+ createSelectedServices: function () {
+ var services = this.get('selectedServices').mapProperty('serviceName');
+ services.forEach(function (_service) {
+ this.createService(_service, 'POST');
+ }, this);
+ },
- statusCode: require('data/statusCodes')
- });
+ createService: function (service, httpMethod) {
+ var clusterName = this.get('clusterInfo').findProperty('config_name', 'cluster').config_value;
+ var url = '/api/clusters/' + clusterName + '/services/' + service;
+ $.ajax({
+ type: httpMethod,
+ url: url,
+ async: false,
+ dataType: 'text',
+ timeout: 5000,
+ success: function (data) {
+ var jsonData = jQuery.parseJSON(data);
+ console.log("TRACE: STep8 -> In success function for the createService call");
+ console.log("TRACE: STep8 -> value of the url is: " + url);
+ console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
+
+ },
+
+ error: function (request, ajaxOptions, error) {
+ console.log('Step8: In Error ');
+ console.log('Step8: Error message is: ' + request.responseText);
+ },
- },
+ statusCode: require('data/statusCodes')
+ });
+ },
- createSelectedServices: function () {
+ createComponents: function () {
+ //TODO: Uncomment following after hooking up with all services.
+ var serviceComponents = require('data/service_components');
var services = this.get('selectedServices').mapProperty('serviceName');
- services.forEach(function (_service) {
- this.createService(_service);
- }, this);
- },
-
- createService: function (service) {
- var clusterName = this.get('clusterInfo').findProperty('config_name', 'cluster').config_value;
- var url = '/api/clusters/' + clusterName + '/services/' + service;
- $.ajax({
- type: 'PUT',
- url: url,
- async: false,
- dataType: 'text',
- timeout: 5000,
- success: function (data) {
- var jsonData = jQuery.parseJSON(data);
- console.log("TRACE: STep8 -> In success function for the createService call");
- console.log("TRACE: STep8 -> value of the url is: " + url);
- console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
-
- },
-
- error: function (request, ajaxOptions, error) {
- console.log('Step8: In Error ');
- console.log('Step8: Error message is: ' + request.responseText);
- },
-
- statusCode: require('data/statusCodes')
- });
- },
-
- createComponents: function () {
- var serviceComponents = require('data/service_components');
- var services = this.get('selectedServices').mapProperty('serviceName');
- services.forEach(function (_service) {
- var components = serviceComponents.filterProperty('service_name', _service);
- components.forEach(function (_component) {
- console.log("value of component is: " + _component.component_name);
- this.createComponent(_service, _component.component_name);
- }, this);
- }, this);
-
- },
-
- createComponent: function (service, component) {
- var clusterName = this.get('clusterInfo').findProperty('config_name', 'cluster').config_value;
- var url = '/api/clusters/' + clusterName + '/services/' + service + '/components/' + component;
- $.ajax({
- type: 'PUT',
- url: url,
- async: false,
- dataType: 'text',
- timeout: 5000,
- success: function (data) {
- var jsonData = jQuery.parseJSON(data);
- console.log("TRACE: STep8 -> value of the url is: " + url);
- console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
-
- },
-
- error: function (request, ajaxOptions, error) {
- console.log('Step8: In Error ');
- console.log('Step8: Error message is: ' + request.responseText);
- },
-
- statusCode: require('data/statusCodes')
- });
- },
+ services.forEach(function (_service) {
+ var components = serviceComponents.filterProperty('service_name', _service);
+ components.forEach(function (_component) {
+ console.log("value of component is: " + _component.component_name);
+ this.createComponent(_service, _component.component_name);
+ }, this);
+ }, this);
+ //TODO: Remove below code after hooking up with all services.
+ /* this.createComponent('HDFS','NAMENODE');
+ this.createComponent('HDFS','DATANODE'); */
+
+ },
+
+ createComponent: function (service, component) {
+ var clusterName = this.get('clusterInfo').findProperty('config_name', 'cluster').config_value;
+ var url = '/api/clusters/' + clusterName + '/services/' + service + '/components/' + component;
+ $.ajax({
+ type: 'POST',
+ url: url,
+ async: false,
+ dataType: 'text',
+ timeout: 5000,
+ success: function (data) {
+ var jsonData = jQuery.parseJSON(data);
+ console.log("TRACE: STep8 -> In success function for createComponent");
+ console.log("TRACE: STep8 -> value of the url is: " + url);
+ console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
+
+ },
+
+ error: function (request, ajaxOptions, error) {
+ console.log('Step8: In Error ');
+ console.log('Step8: Error message is: ' + request.responseText);
+ },
+
+ statusCode: require('data/statusCodes')
+ });
+ },
+
+ registerHostsToCluster: function() {
+ this.get('totalHosts').forEach(function(_hostname){
+ this.registerHostToCluster(_hostname);
+ },this);
+ },
+
+ registerHostToCluster: function(hostname) {
+ var clusterName = this.get('clusterInfo').findProperty('config_name', 'cluster').config_value;
+ var url = '/api/clusters/' + clusterName + '/hosts/' + hostname;
+ $.ajax({
+ type: 'POST',
+ url: url,
+ async: false,
+ dataType: 'text',
+ timeout: 5000,
+ success: function (data) {
+ var jsonData = jQuery.parseJSON(data);
+ console.log("TRACE: STep8 -> In success function for registerHostToCluster");
+ console.log("TRACE: STep8 -> value of the url is: " + url);
+ console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
+
+ },
+
+ error: function (request, ajaxOptions, error) {
+ console.log('Step8: In Error ');
+ console.log('Step8: Error message is: ' + request.responseText);
+ },
+
+ statusCode: require('data/statusCodes')
+ });
+ },
+
+ createHostComponents: function () {
+ //TODO: Uncomment following after hooking up with all services.
- createHostComponents: function () {
var masterHosts = this.get('content.masterComponentHosts');
var slaveHosts = this.get('content.slaveComponentHosts');
- masterHosts.forEach(function (_masterHost) {
- this.createHostComponent(_masterHost);
- }, this);
- slaveHosts.forEach(function (_slaveHosts) {
- var slaveObj = {};
- slaveObj.component = _slaveHosts.componentName;
- _slaveHosts.hosts.forEach(function (_slaveHost) {
- slaveObj.hostName = _slaveHost.hostname;
- this.createHostComponent(slaveObj);
- }, this);
- }, this);
- },
-
- createHostComponent: function (hostComponent) {
- var clusterName = this.get('clusterInfo').findProperty('config_name', 'cluster').config_value;
- var url = '/api/clusters/' + clusterName + '/hosts/' + hostComponent.hostName + '/host_components/' + hostComponent.component;
-
- $.ajax({
- type: 'PUT',
- url: url,
- async: false,
- dataType: 'text',
- timeout: 5000,
- success: function (data) {
- var jsonData = jQuery.parseJSON(data);
- console.log("TRACE: STep8 -> In success function for the createComponent with new host call");
- console.log("TRACE: STep8 -> value of the url is: " + url);
- console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
- },
-
- error: function (request, ajaxOptions, error) {
- console.log('Step8: In Error ');
- console.log('Step8: Error message is: ' + request.responseText);
- },
-
- statusCode: require('data/statusCodes')
- });
- }
+ masterHosts.forEach(function (_masterHost) {
+ this.createHostComponent(_masterHost);
+ }, this);
+ slaveHosts.forEach(function (_slaveHosts) {
+ var slaveObj = {};
+ if (_slaveHosts.componentName !== 'CLIENT') {
+ slaveObj.component = _slaveHosts.componentName;
+ _slaveHosts.hosts.forEach(function (_slaveHost) {
+ slaveObj.hostName = _slaveHost.hostname;
+ this.createHostComponent(slaveObj);
+ }, this);
+ } else {
+ this.get('content.clients').forEach(function (_client) {
+ slaveObj.component = _client.component_name;
+ _slaveHosts.hosts.forEach(function (_slaveHost) {
+ slaveObj.hostName = _slaveHost.hostname;
+ this.createHostComponent(slaveObj);
+ }, this);
+ }, this);
+ }
+ }, this);
+
+ //TODO: Remove following code after hooking up with all services
+ //this.createHostComponent({hostName:'localhost.localdomain',component:'NAMENODE'});
+ //this.createHostComponent({hostName:'localhost.localdomain',component:'DATANODE'});
+ },
+
+ createHostComponent: function (hostComponent) {
+ var clusterName = this.get('clusterInfo').findProperty('config_name', 'cluster').config_value;
+ var url = '/api/clusters/' + clusterName + '/hosts/' + hostComponent.hostName + '/host_components/' + hostComponent.component;
+
+ $.ajax({
+ type: 'POST',
+ url: url,
+ async: false,
+ dataType: 'text',
+ timeout: 5000,
+ success: function (data) {
+ var jsonData = jQuery.parseJSON(data);
+ console.log("TRACE: STep8 -> In success function for the createComponent with new host call");
+ console.log("TRACE: STep8 -> value of the url is: " + url);
+ console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
+ },
+
+ error: function (request, ajaxOptions, error) {
+ console.log('Step8: In Error ');
+ console.log('Step8: Error message is: ' + request.responseText);
+ },
+
+ statusCode: require('data/statusCodes')
+ });
+ },
+
+ createConfigurations: function () {
+ var selectedServices = this.get('selectedServices');
+ this.createConfigSite(this.createCoreSiteObj());
+ this.createConfigSite(this.createHdfsSiteObj('HDFS'));
+ if (selectedServices.someProperty('serviceName', 'MAPREDUCE')) {
+ this.createConfigSite(this.createMrSiteObj('MAPREDUCE'));
+ }
+ if (selectedServices.someProperty('serviceName', 'HBASE')) {
+ this.createConfigSite(this.createHbaseSiteObj('HBASE'));
+ }
+ if (selectedServices.someProperty('serviceName', 'HIVE')) {
+ this.createConfigSite(this.createHiveSiteObj('HIVE'));
+ }
+ },
+
+ createConfigSite: function (data) {
+ console.log("Inside createConfigSite");
+ var clusterName = this.get('clusterInfo').findProperty('config_name', 'cluster').config_value;
+ var url = '/api/clusters/' + clusterName + '/configurations';
+ $.ajax({
+ type: 'POST',
+ url: url,
+ data: data,
+ async: false,
+ dataType: 'text',
+ timeout: 5000,
+ success: function (data) {
+ var jsonData = jQuery.parseJSON(data);
+ console.log("TRACE: STep8 -> In success function for the createConfigSite");
+ console.log("TRACE: STep8 -> value of the url is: " + url);
+ console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
+ },
+
+ error: function (request, ajaxOptions, error) {
+ console.log('Step8: In Error ');
+ console.log('Step8: Error message is: ' + request.responseText);
+ console.log("TRACE: STep8 -> value of the url is: " + url);
+ },
+
+ statusCode: require('data/statusCodes')
+ });
+ console.log("Exiting createConfigSite");
+ },
+
+ createCoreSiteObj: function () {
+ return '{"type": "core-site", "tag": "version1", "properties": { "fs.default.name": "localhost:8020"}}';
+ },
+
+ createHdfsSiteObj: function (serviceName) {
+ var configs = App.db.getServiceConfigProperties().filterProperty('serviceName', serviceName);
+ var hdfsProperties = {};
+ configs.forEach(function (_configProperty) {
+ hdfsProperties[_configProperty.name] = _configProperty.value;
+ }, this);
+ hdfsProperties = {"dfs.datanode.data.dir.perm": "750"};
+ return '{"type": "hdfs-site", "tag": "version1", "properties":' + JSON.stringify(hdfsProperties) + '}';
+ },
+
+ createMrSiteObj: function (serviceName) {
+ var configs = App.db.getServiceConfigProperties().filterProperty('serviceName', serviceName);
+ var mrProperties = {};
+ configs.forEach(function (_configProperty) {
+ mrProperties[_configProperty.name] = _configProperty.value;
+ }, this);
+ return{type: 'mapred-site', tag: 'version1', properties: mrProperties};
+ },
+
+ createHbaseSiteObj: function (serviceName) {
+ var configs = App.db.getServiceConfigProperties().filterProperty('serviceName', serviceName);
+ var hbaseProperties = {};
+ configs.forEach(function (_configProperty) {
+ hbaseProperties[_configProperty.name] = _configProperty.value;
+ }, this);
+ return{type: 'hbase-site', tag: 'version1', properties: hbaseProperties};
+ },
+
+ createHiveSiteObj: function (serviceName) {
+ var configs = App.db.getServiceConfigProperties().filterProperty('serviceName', serviceName);
+ var hiveProperties = {};
+ configs.forEach(function (_configProperty) {
+ hiveProperties[_configProperty.name] = _configProperty.value;
+ }, this);
+ return{type: 'hbase-site', tag: 'version1', properties: hiveProperties};
+ },
+
+ applyCreatedConfToServices: function () {
+ var services = this.get('selectedServices').mapProperty('serviceName');
+ services.forEach(function (_service) {
+ var data = this.getDataForHdfs();
+ this.applyCreatedConfToService(_service, 'PUT', data);
+ }, this);
+ },
+
+ applyCreatedConfToService: function (service, httpMethod, data) {
+ console.log("Inside applyCreatedConfToService");
+ var clusterName = this.get('clusterInfo').findProperty('config_name', 'cluster').config_value;
+ var data = data;
+ var url = '/api/clusters/' + clusterName + '/services/' + service;
+ $.ajax({
+ type: httpMethod,
+ url: url,
+ async: false,
+ dataType: 'text',
+ timeout: 5000,
+ success: function (data) {
+ var jsonData = jQuery.parseJSON(data);
+ console.log("TRACE: STep8 -> In success function for the applyCreatedConfToService call");
+ console.log("TRACE: STep8 -> value of the url is: " + url);
+ console.log("TRACE: STep8 -> value of the received data is: " + jsonData);
+
+ },
+
+ error: function (request, ajaxOptions, error) {
+ console.log('Step8: In Error ');
+ console.log('Step8: Error message is: ' + request.responseText);
+ },
+
+ statusCode: require('data/statusCodes')
+ });
+ console.log("Exiting applyCreatedConfToService");
+ },
+
+ getDataForHdfs: function () {
+ return {config: {'core-site': 'version1', 'hdfs-site': 'version1'}};
+ }
+
})
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step9_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step9_controller.js?rev=1406442&r1=1406441&r2=1406442&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step9_controller.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step9_controller.js Wed Nov 7 04:00:21 2012
@@ -16,21 +16,22 @@
* limitations under the License.
*/
var App = require('app');
+
App.WizardStep9Controller = Em.Controller.extend({
- name:'wizardStep9Controller',
- hosts:[],
- progress:'0',
- isStepCompleted:false,
- isSubmitDisabled:function () {
- return !this.get('isStepCompleted');
+ name: 'wizardStep9Controller',
+ hosts: [],
+ progress: '0',
+ isStepCompleted: false,
+ isSubmitDisabled: function () {
+ return !this.get('isStepCompleted'); //TODO: uncomment after the hook up
+ return false;
}.property('isStepCompleted'),
- mockHostData:require('data/mock/step9_hosts'),
- pollData_1:require('data/mock/step9_pollData_1'),
- pollData_2:require('data/mock/step9_pollData_2'),
- pollDataCounter:0,
+ mockHostData: require('data/mock/step9_hosts'),
+ pollDataCounter: 0,
+ polledData: [],
- status:function () {
+ status: function () {
if (this.hosts.everyProperty('status', 'success')) {
return 'success';
} else if (this.hosts.someProperty('status', 'failed')) {
@@ -42,101 +43,273 @@ App.WizardStep9Controller = Em.Controlle
}
}.property('hosts.@each.status'),
- navigateStep:function () {
- this.loadStep();
+ navigateStep: function () {
+
//TODO: uncomment following line after the hook up with the API call
if (this.get('content.cluster.isCompleted') === false) {
- //this.startPolling();
+ this.loadStep();
+ if (App.db.getClusterStatus().isInstallError === true) {
+ this.set('isStepCompleted', true);
+ this.set('status', 'failed');
+ this.set('progress', '100');
+ } else if (App.db.getClusterStatus().isStartError === true) {
+ this.launchStartServices();
+ } else {
+ this.startPolling();
+ }
} else {
this.set('isStepCompleted', true);
this.set('progress', '100');
}
},
- clearStep:function () {
+ clearStep: function () {
this.hosts.clear();
this.set('status', 'info');
this.set('progress', '0');
this.set('isStepCompleted', false);
},
- loadStep:function () {
+ loadStep: function () {
console.log("TRACE: Loading step9: Install, Start and Test");
this.clearStep();
this.renderHosts(this.loadHosts());
},
- loadHosts:function () {
+ loadHosts: function () {
var hostInfo = [];
- hostInfo = this.get('content.hostsInfo');
+ hostInfo = App.db.getHosts();
var hosts = new Ember.Set();
for (var index in hostInfo) {
hosts.add(hostInfo[index]);
console.log("TRACE: host name is: " + hostInfo[index].name);
}
- return hosts.filterProperty('bootStatus', 'success');
+ return hosts;
+ //return hosts.filterProperty('bootStatus', 'success'); //TODO: uncomment after actual hookup with bootstrap
},
- renderHosts:function (hostsInfo) {
- var self = this;
+ renderHosts: function (hostsInfo) {
hostsInfo.forEach(function (_hostInfo) {
var hostInfo = App.HostInfo.create({
- name:_hostInfo.name,
- status:_hostInfo.status,
- message:_hostInfo.message,
- progress:_hostInfo.progress
+ name: _hostInfo.name,
+ status: _hostInfo.status,
+ message: _hostInfo.message,
+ progress: _hostInfo.progress
});
console.log('pushing ' + hostInfo.name);
- self.hosts.pushObject(hostInfo);
+ this.hosts.pushObject(hostInfo);
+ }, this);
+ },
+
+ replacePolledData: function (polledData) {
+ this.polledData.clear;
+ this.set('polledData', polledData);
+ console.log('*******/ In replace PolledData function **********/');
+ console.log("The value of polleddata is: " + polledData);
+ console.log("2.The value of polleddata is: " + this.get('polledData'));
+ this.get('polledData').forEach(function (_data) {
+ console.log('The name of the host is: ' + _data.Tasks.host_name);
+ console.log('The status of the task is: ' + _data.Tasks.status);
+ }, this);
+ },
+
+ displayMessage: function (task) {
+ console.log("In display message with task command value: " + task.command);
+ switch (task.command) {
+ case 'INSTALL':
+ switch (task.status) {
+ case 'PENDING':
+ return 'Preparing to install ' + task.role;
+ case 'QUEUED' :
+ return task.role + ' is Queued for installation';
+ case 'IN_PROGRESS':
+ return 'Installing ' + task.role;
+ case 'COMPLETED' :
+ return 'Successfully installed ' + task.role;
+ case 'FAILED':
+ return 'Faliure in installing ' + task.role;
+ }
+ case 'UNINSTALL':
+ switch (task.status) {
+ case 'PENDING':
+ return 'Preparing to uninstall ' + task.role;
+ case 'QUEUED' :
+ return task.role + ' is Queued for uninstallation';
+ case 'IN_PROGRESS':
+ return 'Unnstalling ' + task.role;
+ case 'COMPLETED' :
+ return 'Successfully uninstalled ' + task.role;
+ case 'FAILED':
+ return 'Faliure in uninstalling ' + task.role;
+ }
+ case 'START' :
+ switch (task.status) {
+ case 'PENDING':
+ return 'Preparing to start ' + task.role;
+ case 'QUEUED' :
+ return task.role + ' is Queued for starting';
+ case 'IN_PROGRESS':
+ return 'Starting ' + task.role;
+ case 'COMPLETED' :
+ return task.role + ' started successfully';
+ case 'FAILED':
+ return task.role + ' failed to start';
+ }
+ case 'STOP' :
+ switch (task.status) {
+ case 'PENDING':
+ return 'Preparing to stop ' + role;
+ case 'QUEUED' :
+ return task.role + ' is Queued for stopping';
+ case 'IN_PROGRESS':
+ return 'Stopping ' + task.role;
+ case 'COMPLETED' :
+ return role + ' stoped successfully';
+ case 'FAILED':
+ return role + ' failed to stop';
+ }
+ case 'EXECUTE' :
+ switch (task.status) {
+ case 'PENDING':
+ return 'Preparing to execute' + task.role;
+ case 'QUEUED' :
+ return task.role + ' is Queued for execution';
+ case 'IN_PROGRESS':
+ return 'Execution of ' + task.role + ' in progress';
+ case 'COMPLETED' :
+ return task.role + ' executed successfully';
+ case 'FAILED':
+ return task.role + ' failed to execute';
+ }
+ case 'ABORT' :
+ switch (task.status) {
+ case 'PENDING':
+ return 'Preparing to abort ' + task.role;
+ case 'QUEUED' :
+ return task.role + ' is Queued for Aborting';
+ case 'IN_PROGRESS':
+ return 'Aborting ' + task.role;
+ case 'COMPLETED' :
+ return task.role + ' aborted successfully';
+ case 'FAILED':
+ return task.role + ' failed to abort';
+ }
+ }
+ },
+
+ launchStartServices: function () {
+ var self = this;
+ var clusterName = this.get('content.cluster.name');
+ var url = '/api/clusters/' + clusterName + '/services?state=INSTALLED';
+ var data = '{"ServiceInfo": {"state": "STARTED"}}';
+ $.ajax({
+ type: 'PUT',
+ url: url,
+ async: false,
+ data: data,
+ dataType: 'text',
+ timeout: 5000,
+ success: function (data) {
+ var jsonData = jQuery.parseJSON(data);
+ console.log("TRACE: Step9 -> In success function for the startService call");
+ console.log("TRACE: Step9 -> value of the url is: " + url);
+ console.log("TRACE: Step9 -> value of the received data is: " + jsonData);
+ var requestId = jsonData.href.match(/.*\/(.*)$/)[1];
+ console.log('requestId is: ' + requestId);
+ var clusterStatus = {
+ status: 'INSTALLED',
+ requestId: requestId,
+ isStartError: false,
+ isCompleted: false
+ };
+ App.router.get('installerController').saveClusterStatus(clusterStatus);
+ this.startPolling();
+ },
+
+ error: function () {
+ console.log("ERROR");
+ var clusterStatus = {
+ status: 'PENDING',
+ isStartError: true,
+ isCompleted: false
+ };
+
+ App.router.get('installerController').saveClusterStatus(clusterStatus);
+ },
+
+ statusCode: require('data/statusCodes')
});
},
- onSuccessPerHost:function (actions, contentHost) {
- if (actions.everyProperty('status', 'completed')) {
+
+ getCompletedTasksForHost: function (host) {
+ var hostname = host.get('name');
+ console.log("The hostname is: " + hostname);
+ },
+
+
+ onSuccessPerHost: function (actions, contentHost) {
+ if (actions.everyProperty('Tasks.status', 'COMPLETED') && this.get('content.cluster.status') === 'INSTALLED') {
contentHost.set('status', 'success');
}
},
- onWarningPerHost:function (actions, contentHost) {
- if (actions.findProperty('status', 'failed') || actions.findProperty('status', 'aborted')) {
+ onWarningPerHost: function (actions, contentHost) {
+ if (actions.findProperty('Tasks.status', 'FAILED') || actions.findProperty('Tasks.status', 'ABORTED') || actions.findProperty('Tasks.status', 'TIMEDOUT')) {
+ console.log('step9: In warning');
contentHost.set('status', 'warning');
this.set('status', 'warning');
}
},
- onInProgressPerHost:function (actions, contentHost) {
- var runningAction = actions.findProperty('status', 'inprogress');
+ onInProgressPerHost: function (tasks, contentHost) {
+ var runningAction = tasks.findProperty('Tasks.status', 'IN_PROGRESS');
+ if (runningAction === undefined || runningAction === null) {
+ runningAction = tasks.findProperty('Tasks.status', 'QUEUED');
+ }
+ if (runningAction === undefined || runningAction === null) {
+ runningAction = tasks.findProperty('Tasks.status', 'PENDING');
+ }
if (runningAction !== null && runningAction !== undefined) {
- contentHost.set('message', runningAction.message);
+ contentHost.set('message', this.displayMessage(runningAction.Tasks));
}
},
- progressPerHost:function (actions, contentHost) {
- var totalProgress = 0;
+ progressPerHost: function (actions, contentHost) {
+ var progress = 0;
var actionsPerHost = actions.length;
- var completedActions = actions.filterProperty('status', 'completed').length
- + actions.filterProperty('status', 'failed').length +
- actions.filterProperty('status', 'aborted').length;
- var progress = Math.floor((completedActions / actionsPerHost) * 100);
+ var completedActions = actions.filterProperty('Tasks.status', 'COMPLETED').length
+ + actions.filterProperty('Tasks.status', 'IN_PROGRESS').length
+ + actions.filterProperty('Tasks.status', 'FAILED').length
+ + actions.filterProperty('Tasks.status', 'ABORTED').length
+ + actions.filterProperty('Tasks.status', 'TIMEDOUT').length;
+ if (this.get('content.cluster.status') === 'PENDING') {
+ progress = Math.floor(((completedActions / actionsPerHost) * 100) / 3);
+ } else if (this.get('content.cluster.status') === 'INSTALLED') {
+ progress = 34 + Math.floor(((completedActions / actionsPerHost) * 100 * 2) / 3);
+ }
console.log('INFO: progressPerHost is: ' + progress);
contentHost.set('progress', progress.toString());
return progress;
},
- isSuccess:function (polledData) {
- return polledData.everyProperty('status', 'success');
+ isSuccess: function (polledData) {
+ return polledData.everyProperty('Tasks.status', 'COMPLETED');
},
- isStepFailed:function (polledData) {
+ isStepFailed: function (polledData) {
var self = this;
var result = false;
polledData.forEach(function (_polledData) {
- var successFactor = _polledData.sf;
- var actionsPerRole = polledData.filterProperty('role', _polledData.role);
- var actionsFailed = actionsPerRole.filterProperty('status', 'failed');
- var actionsAborted = actionsPerRole.filterProperty('status', 'aborted');
- if ((((actionsFailed.length + actionsAborted.length) / actionsPerRole.length) * 100) <= successFactor) {
+ _polledData.Tasks.sf = 100; //TODO: Remove this line after hook up with actual success factor
+ var successFactor = _polledData.Tasks.sf;
+ console.log("Step9: isStepFailed sf value: " + successFactor);
+ var actionsPerRole = polledData.filterProperty('Tasks.role', _polledData.Tasks.role);
+ var actionsFailed = actionsPerRole.filterProperty('Tasks.status', 'FAILED');
+ var actionsAborted = actionsPerRole.filterProperty('Tasks.status', 'ABORTED');
+ var actionsTimedOut = actionsPerRole.filterProperty('Tasks.status', 'TIMEDOUT');
+ if ((((actionsFailed.length + actionsAborted.length + actionsTimedOut.length) / actionsPerRole.length) * 100) > (100 - successFactor)) {
console.log('TRACE: Entering success factor and result is failed');
result = true;
}
@@ -144,130 +317,180 @@ App.WizardStep9Controller = Em.Controlle
return result;
},
- getFailedHostsForFailedRoles:function (polledData) {
+ getFailedHostsForFailedRoles: function (polledData) {
var hostArr = new Ember.Set();
polledData.forEach(function (_polledData) {
+ _polledData.sf = 100; //TODO: Remove this line after hook up with actual success factor
var successFactor = _polledData.sf;
- var actionsPerRole = polledData.filterProperty('role', _polledData.role);
- var actionsFailed = actionsPerRole.filterProperty('status', 'failed');
- var actionsAborted = actionsPerRole.filterProperty('status', 'aborted');
- if ((((actionsFailed.length + actionsAborted.length) / actionsPerRole.length) * 100) <= successFactor) {
+ var actionsPerRole = polledData.filterProperty('Tasks.role', _polledData.Tasks.role);
+ var actionsFailed = actionsPerRole.filterProperty('Tasks.status', 'FAILED');
+ var actionsAborted = actionsPerRole.filterProperty('Tasks.status', 'ABORTED');
+ var actionsTimedOut = actionsPerRole.filterProperty('Tasks.status', 'TIMEDOUT');
+ if ((((actionsFailed.length + actionsAborted.length + actionsTimedOut.length) / actionsPerRole.length) * 100) > (100 - successFactor)) {
actionsFailed.forEach(function (_actionFailed) {
- hostArr.add(_actionFailed.name);
+ hostArr.add(_actionFailed.Tasks.host_name);
});
actionsAborted.forEach(function (_actionFailed) {
- hostArr.add(_actionFailed.name);
+ hostArr.add(_actionFailed.Tasks.host_name);
+ });
+ actionsTimedOut.forEach(function (_actionFailed) {
+ hostArr.add(_actionFailed.Tasks.host_name);
});
}
});
return hostArr;
},
- setHostsStatus:function (hosts, status) {
- var self = this;
+ setHostsStatus: function (hosts, status) {
hosts.forEach(function (_host) {
- var host = self.hosts.findProperty('name', _host);
+ var host = this.hosts.findProperty('name', _host.Tasks.host_name);
host.set('status', status);
- });
+ host.set('progress', '100');
+ }, this);
},
- // polling from ui stops only when no action has 'pending', 'queued' or 'inprogress' status
+// polling from ui stops only when no action has 'pending', 'queued' or 'inprogress' status
- finishStep:function (polledData) {
- var self = this;
- if (!polledData.someProperty('status', 'pending') && !polledData.someProperty('status', 'queued') && !polledData.someProperty('status', 'inprogress')) {
- this.set('progress', '100');
- if (this.isSuccess(polledData)) {
- this.set('status', 'success');
- } else {
+ finishState: function (polledData) {
+ var clusterStatus = {};
+ var requestId = this.get('content.cluster.requestId');
+ if (this.get('content.cluster.status') === 'INSTALLED') {
+ if (!polledData.someProperty('Tasks.status', 'PENDING') && !polledData.someProperty('Tasks.status', 'QUEUED') && !polledData.someProperty('Tasks.status', 'IN_PROGRESS')) {
+ this.set('progress', '100');
+ clusterStatus = {
+ status: 'INSTALLED',
+ requestId: requestId,
+ isCompleted: true
+ }
+ if (this.isSuccess(polledData)) {
+ clusterStatus.status = 'STARTED';
+ this.set('status', 'success');
+ } else {
+ if (this.isStepFailed(polledData)) {
+ clusterStatus.status = 'FAILED';
+ this.set('status', 'failed');
+ this.setHostsStatus(this.getFailedHostsForFailedRoles(polledData));
+ }
+ }
+ App.router.get('installerController').saveClusterStatus(clusterStatus);
+ this.set('isStepCompleted', true);
+ }
+ } else if (this.get('content.cluster.status') === 'PENDING') {
+ if (!polledData.someProperty('Tasks.status', 'PENDING') && !polledData.someProperty('Tasks.status', 'QUEUED') && !polledData.someProperty('Tasks.status', 'IN_PROGRESS')) {
+ clusterStatus = {
+ status: 'PENDING',
+ requestId: requestId,
+ isCompleted: true
+ }
if (this.isStepFailed(polledData)) {
- self.set('status', 'failed');
+ clusterStatus.status = 'FAILED';
+ this.set('progress', '100');
+ this.set('status', 'failed');
this.setHostsStatus(this.getFailedHostsForFailedRoles(polledData), 'failed');
+ this.set('isStepCompleted', true);
+ } else {
+ clusterStatus.status = 'INSTALLED';
+ this.set('progress', '34');
+ // this.launchStartServices(); //TODO: uncomment after the actual hookup
}
+ App.router.get('installerController').saveClusterStatus(clusterStatus);
}
- this.set('isStepCompleted', true);
}
},
- parseHostInfo:function (polledData) {
+
+ parseHostInfo: function (polledData) {
console.log('TRACE: Entering host info function');
var self = this;
- var result = false;
- var totalProgress = 0;
+ var totalProgress;
+ /* if (this.get('content.cluster.status') === 'INSTALLED') {
+ totalProgress = 34;
+ } else {
+ totalProgress = 0;
+ } */
+ var tasksData = polledData.tasks;
+ console.log("The value of tasksData is: " + tasksData);
+ if (!tasksData) {
+ console.log("Step9: ERROR: NO tasks availaible to process");
+ }
+ tasksData.forEach(function (_host) {
+ console.log("The host name is " + _host.Tasks.host_name);
+ }, this);
+
+ this.replacePolledData(tasksData);
this.hosts.forEach(function (_content) {
- var actions = polledData.filterProperty('name', _content.name);
- if (actions.length === 0) {
+ var actionsPerHost = tasksData.filterProperty('Tasks.host_name', _content.name); // retrieved from polled Data
+ if (actionsPerHost.length === 0) {
alert('For testing with mockData follow the sequence: hit referesh,"mockData btn", "pollData btn", again "pollData btn"');
//exit();
}
- if (actions !== null && actions !== undefined && actions.length !== 0) {
- this.onSuccessPerHost(actions, _content); // every action should be a success
- this.onWarningPerHost(actions, _content); // any action should be a faliure
- this.onInProgressPerHost(actions, _content); // current running action for a host
- totalProgress = totalProgress + self.progressPerHost(actions, _content);
+ if (actionsPerHost !== null && actionsPerHost !== undefined && actionsPerHost.length !== 0) {
+ this.onSuccessPerHost(actionsPerHost, _content); // every action should be a success
+ this.onWarningPerHost(actionsPerHost, _content); // any action should be a faliure
+ this.onInProgressPerHost(actionsPerHost, _content); // current running action for a host
+ totalProgress = self.progressPerHost(actionsPerHost, _content);
}
}, this);
totalProgress = Math.floor(totalProgress / this.hosts.length);
this.set('progress', totalProgress.toString());
console.log("INFO: right now the progress is: " + this.get('progress'));
- this.finishStep(polledData);
+ this.finishState(tasksData);
return this.get('isStepCompleted');
},
-
- retry:function () {
- if (this.get('isSubmitDisabled')) {
- return;
- }
- this.hosts.clear();
- this.renderHosts(this.loadHosts());
- //this.startPolling();
- },
-
- startPolling:function () {
+ startPolling: function () {
this.set('isSubmitDisabled', true);
this.doPolling();
},
- doPolling:function () {
+ getUrl: function () {
+ var clusterName = this.get('content.cluster.name');
+ var requestId = App.db.getClusterStatus().requestId;
+ var url = '/api/clusters/' + clusterName + '/requests/' + requestId;
+ console.log("URL for step9 is: " + url);
+ return url;
+ },
+
+ doPolling: function () {
var self = this;
+ var url = this.getUrl();
$.ajax({
- type:'GET',
- url:'/ambari_server/api/polling',
- async:false,
- timeout:5000,
- success:function (data) {
+ type: 'GET',
+ url: url,
+ async: true,
+ timeout: 10000,
+ dataType: 'text',
+ success: function (data) {
console.log("TRACE: In success function for the GET bootstrap call");
- var result = self.parseHostInfo(data);
+ console.log("TRACE: STep9 -> The value is: " + jQuery.parseJSON(data));
+ var result = self.parseHostInfo(jQuery.parseJSON(data));
if (result !== true) {
- window.setTimeout(self.doPolling, 3000);
+ window.setTimeout(function () {
+ self.doPolling();
+ }, 4000);
} else {
self.stopPolling();
}
},
- error:function () {
- console.log("ERROR");
+ error: function (request, ajaxOptions, error) {
+ console.log("TRACE: STep9 -> In error function for the getService call");
+ console.log("TRACE: STep9 -> value of the url is: " + url);
+ console.log("TRACE: STep9 -> error code status is: " + request.status);
self.stopPolling();
},
- statusCode:{
- 404:function () {
- console.log("URI not found.");
- }
- },
-
- dataType:'application/json'
+ statusCode: require('data/statusCodes')
});
},
- stopPolling:function () {
+ stopPolling: function () {
//TODO: uncomment following line after the hook up with the API call
// this.set('isStepCompleted',true);
},
- submit:function () {
+ submit: function () {
if (!this.get('isSubmitDisabled')) {
this.set('content.cluster.status', this.get('status'));
this.set('content.cluster.isCompleted', true);
@@ -275,46 +498,64 @@ App.WizardStep9Controller = Em.Controlle
}
},
- back:function () {
+ back: function () {
if (!this.get('isSubmitDisabled')) {
App.router.send('back');
}
},
- hostLogPopup:function (event) {
- App.ModalPopup.show({
- header:Em.I18n.t('installer.step3.hostLog.popup.header'),
- onPrimary:function () {
- this.hide();
- },
- bodyClass:Ember.View.extend({
- templateName:require('templates/installer/step3HostLogPopup')
- })
- });
- },
- mockBtn:function () {
+ mockBtn: function () {
this.set('isSubmitDisabled', false);
this.hosts.clear();
var hostInfo = this.mockHostData;
this.renderHosts(hostInfo);
},
- pollBtn:function () {
+ pollBtn: function () {
this.set('isSubmitDisabled', false);
- var data1 = this.pollData_1;
- var data2 = this.pollData_2;
- if ((this.get('pollDataCounter') / 2) === 0) {
- console.log("TRACE: In pollBtn function data1");
- var counter = parseInt(this.get('pollDataCounter')) + 1;
- this.set('pollDataCounter', counter.toString());
- this.parseHostInfo(data1);
- } else {
- console.log("TRACE: In pollBtn function data2");
- var counter = parseInt(this.get('pollDataCounter')) + 1;
- this.set('pollDataCounter', counter.toString());
- this.parseHostInfo(data2);
+ var data1 = require('data/mock/step9PolledData/pollData_1');
+ var data2 = require('data/mock/step9PolledData/pollData_2');
+ var data3 = require('data/mock/step9PolledData/pollData_3');
+ var data4 = require('data/mock/step9PolledData/pollData_4');
+ var data5 = require('data/mock/step9PolledData/pollData_5');
+ var data6 = require('data/mock/step9PolledData/pollData_6');
+ var data7 = require('data/mock/step9PolledData/pollData_7');
+ var data8 = require('data/mock/step9PolledData/pollData_8');
+ var data9 = require('data/mock/step9PolledData/pollData_9');
+ console.log("TRACE: In pollBtn function data1");
+ var counter = parseInt(this.get('pollDataCounter')) + 1;
+ this.set('pollDataCounter', counter.toString());
+ switch (this.get('pollDataCounter')) {
+ case '1':
+ this.parseHostInfo(data1);
+ break;
+ case '2':
+ this.parseHostInfo(data2);
+ break;
+ case '3':
+ this.parseHostInfo(data3);
+ break;
+ case '4':
+ this.parseHostInfo(data4);
+ break;
+ case '5':
+ this.parseHostInfo(data5);
+ break;
+ case '6':
+ this.set('content.cluster.status', 'INSTALLED');
+ this.parseHostInfo(data6);
+ break;
+ case '7':
+ this.parseHostInfo(data7);
+ break;
+ case '8':
+ this.parseHostInfo(data8);
+ break;
+ case '9':
+ this.parseHostInfo(data9);
+ break;
+ default:
+ break;
}
-
}
-
-});
+});
\ No newline at end of file
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/data/config_properties.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/data/config_properties.js?rev=1406442&r1=1406441&r2=1406442&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/data/config_properties.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/data/config_properties.js Wed Nov 7 04:00:21 2012
@@ -308,6 +308,17 @@ module.exports =
"category": "DataNode"
},
{
+ "name": "dfs.datanode.data.dir.perm",
+ "displayName": "Directory Permission",
+ "description": "DataNode directories for HDFS to store the data blocks",
+ "defaultValue": "750",
+ "isReconfigurable": false,
+ "displayType": "int",
+ "isVisible": true,
+ "serviceName": "HDFS",
+ "category": "DataNode"
+ },
+ {
"name": "hdfs_log_dir_prefix",
"displayName": "Hadoop Log Dir Prefix",
"description": "The parent directory for Hadoop log files. The HDFS log directory will be ${hadoop_log_dir_prefix} / ${hdfs_user} and the MapReduce log directory will be ${hadoop_log_dir_prefix} / ${mapred_user}.",