You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2013/10/31 17:10:22 UTC
git commit: AMBARI-3641 Synchronize service start/stop buttons with
actual status. (atkach)
Updated Branches:
refs/heads/trunk 58c60c5e1 -> 0b9e3a872
AMBARI-3641 Synchronize service start/stop buttons with actual status. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/0b9e3a87
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/0b9e3a87
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/0b9e3a87
Branch: refs/heads/trunk
Commit: 0b9e3a87217e72af72c3c3c3f5a8a75ee0cf5a39
Parents: 58c60c5
Author: atkach <an...@gmail.com>
Authored: Thu Oct 31 18:10:05 2013 +0200
Committer: atkach <an...@gmail.com>
Committed: Thu Oct 31 18:10:17 2013 +0200
----------------------------------------------------------------------
.../global/background_operations_controller.js | 44 ++++++++++++--
ambari-web/app/controllers/main/service.js | 9 ++-
ambari-web/app/controllers/main/service/item.js | 30 +++++-----
ambari-web/app/messages.js | 7 ++-
ambari-web/app/models/service.js | 60 +++++++-------------
5 files changed, 82 insertions(+), 68 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/0b9e3a87/ambari-web/app/controllers/global/background_operations_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/background_operations_controller.js b/ambari-web/app/controllers/global/background_operations_controller.js
index dc54cd1..323834f 100644
--- a/ambari-web/app/controllers/global/background_operations_controller.js
+++ b/ambari-web/app/controllers/global/background_operations_controller.js
@@ -154,26 +154,28 @@ App.BackgroundOperationsController = Em.Controller.extend({
var isRunning = (request.Requests.task_count -
(request.Requests.aborted_task_count + request.Requests.completed_task_count + request.Requests.failed_task_count
+ request.Requests.timed_out_task_count - request.Requests.queued_task_count)) > 0;
+ var requestParams = this.parseRequestContext(request.Requests.request_context);
currentRequestIds.push(request.Requests.id);
if (rq) {
- rq.set('progress', Math.round(request.Requests.progress_percent));
+ rq.set('progress', Math.ceil(request.Requests.progress_percent));
rq.set('status', request.Requests.request_status);
rq.set('isRunning', isRunning);
} else {
rq = Em.Object.create({
id: request.Requests.id,
- name: request.Requests.request_context || 'Request name not specified',
- displayName: request.Requests.request_context || 'Request name not specified',
- progress: Math.round(request.Requests.progress_percent),
+ name: requestParams.requestContext,
+ displayName: requestParams.requestContext,
+ progress: Math.ceil(request.Requests.progress_percent),
status: request.Requests.request_status,
isRunning: isRunning,
hostsMap: {},
- tasks: []
+ tasks: [],
+ dependentService: requestParams.dependentService
});
self.get("services").unshift(rq);
}
runningServices += ~~isRunning;
- });
+ }, this);
//remove old request if it's absent in API response
self.get('services').forEach(function(service, index, services){
if(!currentRequestIds.contains(service.id)) {
@@ -184,6 +186,36 @@ App.BackgroundOperationsController = Em.Controller.extend({
self.set('serviceTimestamp', new Date().getTime());
},
+ /**
+ * parse request context and if keyword "_PARSE_" is present then format it
+ * @param requestContext
+ * @return {Object}
+ */
+ parseRequestContext: function (requestContext) {
+ var parsedRequestContext;
+ var service;
+ var command;
+ if (requestContext) {
+ if (requestContext.indexOf("_PARSE_") !== -1) {
+ command = requestContext.split('.')[1];
+ service = requestContext.split('.')[2];
+ if (service === 'ALL_SERVICES') {
+ parsedRequestContext = Em.I18n.t("requestInfo." + command.toLowerCase()).format(Em.I18n.t('common.allServices'));
+ } else {
+ parsedRequestContext = Em.I18n.t("requestInfo." + command.toLowerCase()).format(App.Service.DisplayNames[service]);
+ }
+ } else {
+ parsedRequestContext = requestContext;
+ }
+ } else {
+ parsedRequestContext = Em.I18n.t('requestInfo.unspecified');
+ }
+ return {
+ requestContext: parsedRequestContext,
+ dependentService: service
+ }
+ },
+
popupView: null,
/**
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/0b9e3a87/ambari-web/app/controllers/main/service.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service.js b/ambari-web/app/controllers/main/service.js
index 570409f..55e5fa8 100644
--- a/ambari-web/app/controllers/main/service.js
+++ b/ambari-web/app/controllers/main/service.js
@@ -86,11 +86,10 @@ App.MainServiceController = Em.ArrayController.extend({
allServicesCall: function(state) {
var data;
- if(state == 'stopAllService') {
- data = '{"RequestInfo": {"context" :"'+ Em.I18n.t('requestInfo.stopAllServices') +'"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}';
- }
- else {
- data = '{"RequestInfo": {"context" :"'+ Em.I18n.t('requestInfo.startAllServices') +'"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}';
+ if (state == 'stopAllService') {
+ data = '{"RequestInfo": {"context" :"_PARSE_.STOP.ALL_SERVICES"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}';
+ } else {
+ data = '{"RequestInfo": {"context" :"_PARSE_.START.ALL_SERVICES"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}';
}
App.ajax.send({
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/0b9e3a87/ambari-web/app/controllers/main/service/item.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/item.js b/ambari-web/app/controllers/main/service/item.js
index 64fb843..898d4ef 100644
--- a/ambari-web/app/controllers/main/service/item.js
+++ b/ambari-web/app/controllers/main/service/item.js
@@ -94,12 +94,12 @@ App.MainServiceItemController = Em.Controller.extend({
});
},
- startStopPopupPrimary: function(serviceHealth) {
+ startStopPopupPrimary: function (serviceHealth) {
var requestInfo = "";
- if(serviceHealth == "STARTED"){
- requestInfo = 'Start ' + this.get('content.displayName');
- }else{
- requestInfo = 'Stop ' + this.get('content.displayName');
+ if (serviceHealth == "STARTED") {
+ requestInfo = '_PARSE_.START.' + this.get('content.serviceName');
+ } else {
+ requestInfo = '_PARSE_.STOP.' + this.get('content.serviceName');
}
App.ajax.send({
@@ -107,13 +107,13 @@ App.MainServiceItemController = Em.Controller.extend({
'sender': this,
'success': 'ajaxSuccess',
'data': {
- 'requestInfo':requestInfo,
+ 'requestInfo': requestInfo,
'serviceName': this.get('content.serviceName').toUpperCase(),
'state': serviceHealth
}
});
- this.set('isStopDisabled',true);
- this.set('isStartDisabled',true);
+ this.set('isStopDisabled', true);
+ this.set('isStartDisabled', true);
},
/**
@@ -225,18 +225,14 @@ App.MainServiceItemController = Em.Controller.extend({
setStartStopState: function () {
var serviceName = this.get('content.serviceName');
- var components = service_components.filterProperty('service_name', serviceName).mapProperty('component_name');
var backgroundOperations = App.router.get('backgroundOperationsController.services');
if (backgroundOperations.length > 0) {
for (var i = 0; i < backgroundOperations.length; i++) {
- var logTasks = backgroundOperations[i].tasks;
- for (var k = 0; k < logTasks.length; k++) {
- if (components.contains(logTasks[k].Tasks.role)) {
- if (logTasks[k].Tasks.status == 'PENDING' || logTasks[k].Tasks.status == 'IN_PROGRESS' || logTasks[k].Tasks.status == 'QUEUED') {
- this.set('isPending', true);
- return;
- }
- }
+ if (backgroundOperations[i].isRunning &&
+ (backgroundOperations[i].dependentService === "ALL_SERVICES" ||
+ backgroundOperations[i].dependentService === serviceName)) {
+ this.set('isPending', true);
+ return;
}
}
this.set('isPending', false);
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/0b9e3a87/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 6a205b0..fe59675 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -150,6 +150,8 @@ Em.I18n.translations = {
'common.update.error' : 'Error in retrieving web client state from ambari server',
'common.tags': 'Tags',
'common.important': 'Important',
+ 'common.allServices':'All Services',
+
'requestInfo.installComponents':'Install Components',
'requestInfo.installServices':'Install Services',
'requestInfo.startServices':'Start Services',
@@ -161,8 +163,9 @@ Em.I18n.translations = {
'requestInfo.stopHostComponent':'Stop',
'requestInfo.installHostComponent':'Install',
'requestInfo.installNewHostComponent':'Install',
- 'requestInfo.stopService':'Stop',
- 'requestInfo.startService':'Start',
+ 'requestInfo.stop':'Stop {0}',
+ 'requestInfo.start':'Start {0}',
+ 'requestInfo.unspecified':'Request name not specified',
'hostPopup.noServicesToShow':'No services to show',
'hostPopup.noHostsToShow':'No hosts to show',
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/0b9e3a87/ambari-web/app/models/service.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service.js b/ambari-web/app/models/service.js
index a80a1c4..5319fc7 100644
--- a/ambari-web/app/models/service.js
+++ b/ambari-web/app/models/service.js
@@ -62,45 +62,9 @@ App.Service = DS.Model.extend({
}.property('serviceName'),
displayName: function () {
- switch (this.get('serviceName').toLowerCase()) {
- case 'hdfs':
- return 'HDFS';
- case 'yarn':
- return 'YARN';
- case 'mapreduce':
- return 'MapReduce';
- case 'mapreduce2':
- return 'MapReduce2';
- case 'tez':
- return 'Tez';
- case 'hbase':
- return 'HBase';
- case 'oozie':
- return 'Oozie';
- case 'hive':
- return 'Hive';
- case 'hcatalog':
- return 'HCat';
- case 'zookeeper':
- return 'ZooKeeper';
- case 'pig':
- return 'Pig';
- case 'sqoop':
- return 'Sqoop';
- case 'webhcat':
- return 'WebHCat';
- case 'ganglia':
- return 'Ganglia';
- case 'nagios':
- return 'Nagios';
- case 'hue':
- return 'Hue';
- case 'flume':
- return 'Flume';
- }
- return this.get('serviceName');
+ return App.Service.DisplayNames[this.get('serviceName')];
}.property('serviceName'),
-
+
/**
* For each host-component, if the desired_configs dont match the
* actual_configs, then a restart is required. Except for Global site
@@ -179,4 +143,24 @@ App.Service.Health = {
}
};
+App.Service.DisplayNames = {
+ 'HDFS': 'HDFS',
+ 'YARN': 'YARN',
+ 'MAPREDUCE': 'MapReduce',
+ 'MAPREDUCE2': 'MapReduce2',
+ 'TEZ': 'Tez',
+ 'HBASE': 'HBase',
+ 'OOZIE': 'Oozie',
+ 'HIVE': 'Hive',
+ 'HCATALOG': 'HCat',
+ 'ZOOKEEPER': 'ZooKeeper',
+ 'PIG': 'Pig',
+ 'SQOOP': 'Sqoop',
+ 'WEBHCAT': 'WebHCat',
+ 'GANGLIA': 'Ganglia',
+ 'NAGIOS': 'Nagios',
+ 'HUE': 'Hue',
+ 'FLUME': 'Flume'
+};
+
App.Service.FIXTURES = [];