Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 70b4ba403 -> dd7f46f10


AMBARI-20429 - Warn users about pending requests while trying to enable 
Interactive Query immediately after disabling it (Vivek Subramanian via rzang)


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

Branch: refs/heads/branch-2.5
Commit: dd7f46f10df8b31476bb17e427775c4acf8c303d
Parents: 70b4ba4
Author: Richard Zang <rz...@apache.org>
Authored: Fri Mar 24 11:52:22 2017 -0700
Committer: Richard Zang <rz...@apache.org>
Committed: Fri Mar 24 11:53:53 2017 -0700

----------------------------------------------------------------------
 .../wizard/step7/assign_master_controller.js    | 75 ++++++++++++++++++--
 ambari-web/app/messages.js                      |  2 +
 ambari-web/app/utils/ajax/ajax.js               |  4 ++
 .../configs/widgets/config_widget_view.js       |  3 +
 4 files changed, 78 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/dd7f46f1/ambari-web/app/controllers/wizard/step7/assign_master_controller.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/app/controllers/wizard/step7/assign_master_controller.js 
b/ambari-web/app/controllers/wizard/step7/assign_master_controller.js
index e2c5fa6..b1e3397 100644
--- a/ambari-web/app/controllers/wizard/step7/assign_master_controller.js
+++ b/ambari-web/app/controllers/wizard/step7/assign_master_controller.js
@@ -62,15 +62,13 @@ App.AssignMasterOnStep7Controller = 
Em.Controller.extend(App.BlueprintMixin, App
     this.set('configWidgetContext', context);
     this.set('content', context.get('controller.content'));
     this.set('configActionComponent', hostComponent);
-    var missingDependentServices = this.getAllMissingDependentServices();
-    var isNonWizardPage = !this.get('content.controllerName');
+    
     switch (action) {
       case 'ADD':
-        if (missingDependentServices.length && isNonWizardPage) {
-          this.showInstallServicesPopup(missingDependentServices);
+        if (hostComponent.componentName == "HIVE_SERVER_INTERACTIVE") {
+          this.getPendingBatchRequests(hostComponent);  
         } else {
-          this.set('mastersToCreate', [hostComponent.componentName]);
-          this.showAssignComponentPopup();
+          this.showPopup(hostComponent);
         }
         break;
       case 'DELETE':
@@ -80,6 +78,71 @@ App.AssignMasterOnStep7Controller = 
Em.Controller.extend(App.BlueprintMixin, App
     }
   },
 
+  getPendingBatchRequests: function(hostComponent) {
+    var self = this;
+    // Send Ajax request to get status of pending batch requests
+    App.ajax.send({
+      name : 'request_schedule.get.pending',
+      sender: self,
+      error : 'pendingBatchRequestsAjaxError',
+      success: 'pendingBatchRequestsAjaxSuccess',
+      data: {
+        hostComponent: hostComponent
+      }
+    });
+  },
+
+  pendingBatchRequestsAjaxError: function(data) {
+    var error = 
Em.I18n.t('services.service.actions.run.yarnRefreshQueues.error');
+    if(data && data.responseText){
+      try {
+        var json = $.parseJSON(data.responseText);
+        error += json.message;
+      } catch (err) {}
+    }
+    
App.showAlertPopup(Em.I18n.t('services.service.actions.run.yarnRefreshQueues.error'),
 error, null);
+  },
+
+  pendingBatchRequestsAjaxSuccess : function(data, opt, params) {
+    var self = this;
+    var showAlert = false;
+    if (data.hasOwnProperty('items') && data.items.length > 0) {
+      data.items.forEach( function(_item) {
+        _item.RequestSchedule.batch.batch_requests.forEach( 
function(batchRequest) {
+          // Check if a DELETE request on HIVE_SERVER_INTERACTIVE is in 
progress
+          if (batchRequest.request_type == "DELETE" && 
batchRequest.request_uri.indexOf("HIVE_SERVER_INTERACTIVE") > -1) {
+            showAlert = true;
+          }
+        });
+      });
+    }
+    if (showAlert) {
+      
App.showAlertPopup(Em.I18n.t('services.service.actions.hsi.alertPopup.header'), 
Em.I18n.t('services.service.actions.hsi.alertPopup.body'), function() {
+        var configWidgetContext = self.get('configWidgetContext');
+        var config = self.get('configWidgetContext.config');
+        configWidgetContext.toggleProperty('controller.forceUpdateBoundaries');
+        var value = config.get('initialValue');
+        config.set('value', value);
+        configWidgetContext.setValue(value);
+        configWidgetContext.sendRequestRorDependentConfigs(config);
+        this.hide();
+      });
+    } else {
+      this.showPopup(params.hostComponent);
+    }
+  },
+  
+  showPopup: function(hostComponent) {
+    var missingDependentServices = this.getAllMissingDependentServices();
+    var isNonWizardPage = !this.get('content.controllerName');
+    if (missingDependentServices.length && isNonWizardPage) {
+      this.showInstallServicesPopup(missingDependentServices);
+    } else {
+      this.set('mastersToCreate', [hostComponent.componentName]);
+      this.showAssignComponentPopup();
+    }  
+  },
+  
   /**
    * Used to set showAddControl/showRemoveControl flag
    * @param componentName

http://git-wip-us.apache.org/repos/asf/ambari/blob/dd7f46f1/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index a2a9d60..8173ca3 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1963,6 +1963,8 @@ Em.I18n.translations = {
   'services.service.actions.run.runHawqCheck.label':'Run HAWQ Config Check',
   'services.service.actions.manage_configuration_groups.short':'Manage Config 
Groups',
   'services.service.actions.serviceActions':'Service Actions',
+  'services.service.actions.hsi.alertPopup.header':'Cannot enable Interactive 
Query',
+  'services.service.actions.hsi.alertPopup.body':'You cannot enable 
Interactive Query now because Interactive Query is in the process of being 
disabled. This may take a few minutes. Try again later.',
 
   'services.service.delete.popup.header': 'Delete Service',
   'services.service.delete.popup.kerberos': 'The Kerberos Service <i>cannot be 
deleted</i> because Kerberos is ' +

http://git-wip-us.apache.org/repos/asf/ambari/blob/dd7f46f1/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js 
b/ambari-web/app/utils/ajax/ajax.js
index 8be3b62..70ecb23 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -2326,6 +2326,10 @@ var urls = {
     'real': '/clusters/{clusterName}/request_schedules/{request_schedule_id}',
     'mock': ''
   },
+  'request_schedule.get.pending': {
+    'real': 
'/clusters/{clusterName}/request_schedules?fields=*&(RequestSchedule/status.in(SCHEDULED,IN_PROGRESS))',
+    'mock': ''
+  },
   'restart.hostComponents': {
     'real': '/clusters/{clusterName}/requests',
     'mock': '',

http://git-wip-us.apache.org/repos/asf/ambari/blob/dd7f46f1/ambari-web/app/views/common/configs/widgets/config_widget_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/widgets/config_widget_view.js 
b/ambari-web/app/views/common/configs/widgets/config_widget_view.js
index cb5d5b9..3a1e24d 100644
--- a/ambari-web/app/views/common/configs/widgets/config_widget_view.js
+++ b/ambari-web/app/views/common/configs/widgets/config_widget_view.js
@@ -482,6 +482,9 @@ App.ConfigWidgetView = 
Em.View.extend(App.SupportsDependentConfigs, App.WidgetPo
           this.set('controller.saveInProgress', true);
           assignMasterOnStep7Controller.execute(this, 'ADD', hostComponent);
         } else {
+          if(hostComponent.componentName == "HIVE_SERVER_INTERACTIVE") {
+            assignMasterOnStep7Controller.execute(this, 'ADD', hostComponent);
+          }
           
assignMasterOnStep7Controller.clearComponentsToBeDeleted(hostComponent.componentName);
         }
         break;

Reply via email to