Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 be401e9b0 -> 209eb5650


AMBARI-16746. Changing and saving the llap percentage slider does not change 
the YARN queue configuration        (akovalenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/209eb565
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/209eb565
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/209eb565

Branch: refs/heads/branch-2.4
Commit: 209eb56505c20ef1b2ee1880b8c7e08cd1757839
Parents: be401e9
Author: Aleksandr Kovalenko <[email protected]>
Authored: Wed May 18 22:35:28 2016 +0300
Committer: Aleksandr Kovalenko <[email protected]>
Committed: Thu May 19 14:01:47 2016 +0300

----------------------------------------------------------------------
 ambari-web/app/controllers/main/service/item.js | 101 ++++++++++++++-----
 .../test/controllers/main/service/item_test.js  |  37 +++++++
 2 files changed, 115 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/209eb565/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 b65a4e1..77584ba 100644
--- a/ambari-web/app/controllers/main/service/item.js
+++ b/ambari-web/app/controllers/main/service/item.js
@@ -596,35 +596,90 @@ App.MainServiceItemController = 
Em.Controller.extend(App.SupportClientConfigsDow
     
App.showAlertPopup(Em.I18n.t('services.service.actions.run.yarnRefreshQueues.error'),
 error);
   },
 
-  restartLLAP: function(event) {
-    var context = Em.I18n.t('services.service.actions.run.restartLLAP');
-    this.manageLLAP('RESTART_LLAP', context);
+  restartLLAP: function () {
+    var isRefreshQueueRequired, self = this;
+    return App.showConfirmationPopup(function () {
+      // regresh queue request is sending only if YARN service has stale 
configs
+      isRefreshQueueRequired = App.Service.find().findProperty('serviceName', 
'YARN').get('isRestartRequired');
+      if (isRefreshQueueRequired) {
+        self.restartLLAPAndRefreshQueueRequest();
+      } else {
+        self.restartLLAPRequest();
+      }
+    });
   },
-  manageLLAP: function(command, context) {
-    var controller = this;
+
+  restartLLAPRequest: function () {
     var host = App.HostComponent.find().findProperty('componentName', 
'HIVE_SERVER_INTERACTIVE').get('hostName');
-    return App.showConfirmationPopup(function() {
-      App.ajax.send({
-        name: 'service.item.executeCustomCommand',
-        sender: controller,
-        data: {
-          command: command,
-          context: context,
-          hosts: host,
-          serviceName: "HIVE",
-          componentName: "HIVE_SERVER_INTERACTIVE"
+    App.ajax.send({
+      name: 'service.item.executeCustomCommand',
+      sender: this,
+      data: {
+        command: 'RESTART_LLAP',
+        context: Em.I18n.t('services.service.actions.run.restartLLAP'),
+        hosts: host,
+        serviceName: "HIVE",
+        componentName: "HIVE_SERVER_INTERACTIVE"
+      },
+      success: 'requestSuccessCallback',
+      error: 'requestErrorCallback'
+    });
+  },
+
+  restartLLAPAndRefreshQueueRequest: function () {
+    var hiveServerInteractiveHost = 
App.HostComponent.find().findProperty('componentName', 
'HIVE_SERVER_INTERACTIVE').get('hostName');
+    var resourceManagerHost = 
App.HostComponent.find().findProperty('componentName', 
'RESOURCEMANAGER').get('hostName');
+    var batches = [{
+      "order_id": 1,
+      "type": "POST",
+      "uri": App.apiPrefix + "/clusters/" + App.get('clusterName') + 
"/requests",
+      "RequestBodyInfo": {
+        "RequestInfo": {
+          "context": "Refresh YARN Capacity Scheduler",
+          "command": "REFRESHQUEUES",
+          "parameters/forceRefreshConfigTags": "capacity-scheduler"
         },
-        success: 'manageLLAPSuccessCallback',
-        error: 'manageLLAPErrorCallback'
-      });
+        "Requests/resource_filters": [{
+          "service_name": "YARN",
+          "component_name": "RESOURCEMANAGER",
+          "hosts": resourceManagerHost
+        }]
+      }
+    }, {
+      "order_id": 2,
+      "type": "POST",
+      "uri": App.apiPrefix + "/clusters/" + App.get('clusterName') + 
"/requests",
+      "RequestBodyInfo": {
+        "RequestInfo": {"context": "Restart LLAP", "command": "RESTART_LLAP"},
+        "Requests/resource_filters": [{
+          "service_name": "HIVE",
+          "component_name": "HIVE_SERVER_INTERACTIVE",
+          "hosts": hiveServerInteractiveHost
+        }]
+      }
+    }];
+    App.ajax.send({
+      name: 'common.batch.request_schedules',
+      sender: this,
+      data: {
+        intervalTimeSeconds: 1,
+        tolerateSize: 0,
+        batches: batches
+      },
+      success: 'requestSuccessCallback',
+      error: 'requestErrorCallback'
     });
   },
-  manageLLAPSuccessCallback : function(data, ajaxOptions, params) {
-    if (data.Requests.id) {
-      App.router.get('backgroundOperationsController').showPopup();
-    }
+
+  requestSuccessCallback: function () {
+    
App.router.get('userSettingsController').dataLoading('show_bg').done(function 
(initValue) {
+      if (initValue) {
+        App.router.get('backgroundOperationsController').showPopup();
+      }
+    });
   },
-  manageLLAPErrorCallback : function(data) {
+
+  requestErrorCallback : function(data) {
     var error = 
Em.I18n.t('services.service.actions.run.executeCustomCommand.error');
     if (data && data.responseText) {
       try {

http://git-wip-us.apache.org/repos/asf/ambari/blob/209eb565/ambari-web/test/controllers/main/service/item_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/item_test.js 
b/ambari-web/test/controllers/main/service/item_test.js
index 11908a4..0830d63 100644
--- a/ambari-web/test/controllers/main/service/item_test.js
+++ b/ambari-web/test/controllers/main/service/item_test.js
@@ -1552,4 +1552,41 @@ describe('App.MainServiceItemController', function () {
     });
   });
 
+  [
+    {
+      m: 'should call only restartLLAPRequest',
+      isRestartRequired: false,
+      toCall: 'restartLLAPRequest'
+    },
+    {
+      m: 'should call only restartLLAPAndRefreshQueueRequest',
+      isRestartRequired: true,
+      toCall: 'restartLLAPAndRefreshQueueRequest'
+    }
+  ].forEach(function (test) {
+        describe("#restartLLAP()", function () {
+          var mainServiceItemController;
+
+          beforeEach(function () {
+            mainServiceItemController = App.MainServiceItemController.create();
+            sinon.stub(mainServiceItemController, 
'restartLLAPAndRefreshQueueRequest', Em.K);
+            sinon.stub(mainServiceItemController, 'restartLLAPRequest', Em.K);
+            sinon.stub(App.Service, 'find').returns([Em.Object.create({
+                serviceName: 'YARN',
+                isRestartRequired: test.isRestartRequired
+              })]);
+          });
+          afterEach(function () {
+            
mainServiceItemController.restartLLAPAndRefreshQueueRequest.restore();
+            mainServiceItemController.restartLLAPRequest.restore();
+            App.Service.find.restore();
+          });
+
+          it(test.m, function () {
+            var confirmationPopup = mainServiceItemController.restartLLAP();
+            confirmationPopup.onPrimary();
+            
expect(mainServiceItemController[test.toCall].calledOnce).to.be.true;
+          });
+        });
+      });
 });

Reply via email to