ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srima...@apache.org
Subject [4/4] git commit: Revert "AMBARI-5199. Replace $.ajax with App.ajax anywhere where it's possible. (onechiporenko)"
Date Tue, 25 Mar 2014 23:40:21 GMT
Revert "AMBARI-5199. Replace $.ajax with App.ajax anywhere where it's possible. (onechiporenko)"

This reverts commit 0d61aba20ee232d68b9a66babcbb6b46d787b64f.


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

Branch: refs/heads/branch-1.5.0
Commit: 5cb3d9c3cc015a336c6e2f37eabda6febe2614ae
Parents: 28da755
Author: Srimanth Gunturi <sgunturi@hortonworks.com>
Authored: Tue Mar 25 16:39:56 2014 -0700
Committer: Srimanth Gunturi <sgunturi@hortonworks.com>
Committed: Tue Mar 25 16:39:56 2014 -0700

----------------------------------------------------------------------
 ambari-web/app/assets/test/tests.js             |    3 +-
 ambari-web/app/controllers/main/admin/user.js   |   73 +-
 ambari-web/app/controllers/main/host/details.js |  553 ++---
 .../main/service/reassign_controller.js         |    2 +-
 .../app/controllers/wizard/step8_controller.js  |  303 +--
 .../app/controllers/wizard/step9_controller.js  |  159 +-
 ambari-web/app/initialize.js                    |    3 +-
 ambari-web/app/mixins/common/userPref.js        |   34 +-
 ambari-web/app/models/cluster_states.js         |  140 +-
 ambari-web/app/utils/ajax.js                    | 1965 ++++++++++++++++
 ambari-web/app/utils/ajax/ajax.js               | 2227 ------------------
 ambari-web/app/utils/ajax/ajax_queue.js         |  182 --
 ambari-web/app/utils/helper.js                  |    6 +-
 ambari-web/app/utils/polling.js                 |    2 +-
 ambari-web/app/views/main/admin/user/create.js  |   70 +-
 ambari-web/app/views/main/admin/user/edit.js    |   78 +-
 ambari-web/app/views/wizard/step8_view.js       |   48 +-
 .../global/background_operations_test.js        |    2 +-
 ambari-web/test/installer/step8_test.js         |    1 -
 ambari-web/test/installer/step9_test.js         |   14 +-
 ambari-web/test/utils/ajax/ajax_queue_test.js   |  111 -
 ambari-web/test/utils/ajax/ajax_test.js         |  148 --
 ambari-web/test/utils/ajax_test.js              |  148 ++
 23 files changed, 2868 insertions(+), 3404 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5cb3d9c3/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index 5901ac2..d4436d9 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -68,8 +68,7 @@ require('test/utils/configs/defaults_providers/yarn_defaults_provider_test');
 require('test/utils/configs/defaults_providers/tez_defaults_provider_test');
 require('test/utils/configs/defaults_providers/hive_defaults_provider_test');
 require('test/utils/configs/validators/service_configs_validator_test');
-require('test/utils/ajax/ajax_test');
-require('test/utils/ajax/ajax_queue_test');
+require('test/utils/ajax_test');
 require('test/utils/batch_scheduled_requests_test');
 require('test/utils/config_test');
 require('test/utils/date_test');

http://git-wip-us.apache.org/repos/asf/ambari/blob/5cb3d9c3/ambari-web/app/controllers/main/admin/user.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/user.js b/ambari-web/app/controllers/main/admin/user.js
index 21f32ec..327b9f7 100644
--- a/ambari-web/app/controllers/main/admin/user.js
+++ b/ambari-web/app/controllers/main/admin/user.js
@@ -23,7 +23,7 @@ App.MainAdminUserController = Em.Controller.extend({
 
   /**
    * send request to the server to delete user if selected user is not current user
-   * @param {object} event
+   * @param event
    */
   deleteRecord:function (event) {
     var self = this;
@@ -31,8 +31,12 @@ App.MainAdminUserController = Em.Controller.extend({
       App.ModalPopup.show({
         header:Em.I18n.t('admin.users.delete.yourself.header'),
         body:Em.I18n.t('admin.users.delete.yourself.message'),
+        onPrimary:function (event) {
+          this.hide();
+        },
         secondary:false
       });
+
       return;
     }
 
@@ -43,24 +47,63 @@ App.MainAdminUserController = Em.Controller.extend({
       secondary:Em.I18n.t('no'),
 
       onPrimary:function () {
-        App.ajax.send({
-          name: 'admin.user.delete',
-          sender: self,
-          data: {
-            user: event.context.get("userName"),
-            event: event
-          },
-          success: 'deleteUserSuccessCallback'
-        });
+        self.sendCommandToServer('/users/' +  event.context.get("userName"), "DELETE" ,{},
+          function (success) {
+
+            if (!success) {
+              return;
+            }
+
+            event.context.deleteRecord();
+
+            try {
+              App.store.commit();
+            } catch (err) {
+
+            }
+          });
+        this.hide();
+      },
+      onSecondary:function () {
         this.hide();
       }
     });
   },
 
-  deleteUserSuccessCallback: function(data, opt, params) {
-    params.event.context.deleteRecord();
-    try {
-      App.store.commit();
-    } catch (err) {}
+  /**
+   * send request to the server and call callback function with true if request was success or false if request was failed
+   * @param url
+   * @param method
+   * @param postData
+   * @param callback
+   */
+  sendCommandToServer : function(url, method, postData, callback){
+    if (App.testMode) {
+      url = '/data/users/users.json';
+      method = 'GET';
+      postData = undefined;
+    } else {
+      url = App.apiPrefix + url;
+    }
+
+    $.ajax({
+      type: method,
+      url: url,
+      data: JSON.stringify(postData),
+      dataType: 'json',
+      timeout: App.timeout,
+      success: function(data){
+          callback(true, '');
+      },
+
+      error: function (request, ajaxOptions, error) {
+        var message = $.parseJSON(request.responseText).message;
+        message = message.substr(message.lastIndexOf(':') + 1);
+        callback(false, message);
+        console.log(message);
+      },
+
+      statusCode: require('data/statusCodes')
+    });
   }
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/5cb3d9c3/ambari-web/app/controllers/main/host/details.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/details.js b/ambari-web/app/controllers/main/host/details.js
index 2b5d608..95ac8e2 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -52,9 +52,44 @@ App.MainHostDetailsController = Em.Controller.extend({
     return this.get('serviceActiveComponents').filterProperty('isClient',false);
   }.property('serviceActiveComponents'),
 
-  ajaxErrorCallback: function (request, ajaxOptions, error, opt, params) {
-    console.log('error on change component host status');
-    App.ajax.defaultErrorHandler(request, opt.url, opt.method);
+
+  /**
+   * Send specific command to server
+   * @param url
+   * @param _method
+   * @param postData
+   * @param callback
+   */
+  sendCommandToServer : function(url, postData, _method, callback){
+    var url =  (App.testMode) ?
+      '/data/wizard/deploy/poll_1.json' : //content is the same as ours
+      App.apiPrefix + '/clusters/' + App.router.getClusterName() + url;
+
+    var method = App.testMode ? 'GET' : _method;
+
+    $.ajax({
+      type: method,
+      url: url,
+      data: JSON.stringify(postData),
+      dataType: 'json',
+      timeout: App.timeout,
+      success: function(data){
+        if(data && data.Requests){
+          callback(data.Requests.id);
+        } else{
+          callback(null);
+          console.log('cannot get request id from ', data);
+        }
+      },
+
+      error: function (request, ajaxOptions, error) {
+        //do something
+        console.log('error on change component host status');
+        App.ajax.defaultErrorHandler(request, url, method);
+      },
+
+      statusCode: require('data/statusCodes')
+    });
   },
 
   /**
@@ -76,74 +111,57 @@ App.MainHostDetailsController = Em.Controller.extend({
    * @param component  When <code>null</code> all startable components are started. 
    * @param context  Context under which this command is beign sent. 
    */
-  sendStartComponentCommand: function(component, context) {
-
+  sendStartComponentCommand: function(components, context) {
+    var url = Em.isArray(components) ?
+        '/hosts/' + this.get('content.hostName') + '/host_components' :
+        '/hosts/' + this.get('content.hostName') + '/host_components/' + components.get('componentName').toUpperCase();
     var dataToSend = {
       RequestInfo : {
         "context" : context
       },
       Body:{
-        HostRoles: {
+        HostRoles:{
           state: 'STARTED'
         }
       }
     };
-    if (Em.isArray(component)) {
-      dataToSend.RequestInfo.query = "HostRoles/component_name.in(" + component.mapProperty('componentName').join(',') + ")";
-      App.ajax.send({
-        name: 'host.host_components.stop',
-        sender: this,
-        data: {
-          data: JSON.stringify(dataToSend),
-          hostName: this.get('content.hostName'),
-          component: component
-        },
-        success: 'stopComponentSuccessCallback',
-        error: 'ajaxErrorCallback'
-      });
-    }
-    else {
-      App.ajax.send({
-        name: 'host.host_component.stop',
-        sender: this,
-        data: {
-          data: JSON.stringify(dataToSend),
-          hostName: this.get('content.hostName'),
-          componentName: component.get('componentName').toUpperCase(),
-          component: component
-        },
-        success: 'startComponentSuccessCallback',
-        error: 'ajaxErrorCallback'
-      });
+    if (Em.isArray(components)) {
+      dataToSend.RequestInfo.query = "HostRoles/component_name.in(" + components.mapProperty('componentName').join(',') + ")";
     }
-  },
+    this.sendCommandToServer(url, dataToSend, 'PUT',
+      function(requestId){
+
+      if(!requestId){
+        return;
+      }
 
-  startComponentSuccessCallback: function(data, opt, params) {
-    console.log('Send request for STARTING successfully');
+      console.log('Send request for STARTING successfully');
 
-    if (App.testMode) {
-      if(Em.isArray(params.component)){
-        var allComponents = this.get('content.hostComponents');
-        allComponents.forEach(function(c){
-          c.set('workStatus', App.HostComponentStatus.stopping);
+      if (App.testMode) {
+        if(Em.isArray(components)){
+          var allComponents = this.get('content.hostComponents');
+          allComponents.forEach(function(component){
+            component.set('workStatus', App.HostComponentStatus.stopping);
+            setTimeout(function(){
+              component.set('workStatus', App.HostComponentStatus.stopped);
+            },App.testModeDelayForActions);
+          });
+        } else {
+          components.set('workStatus', App.HostComponentStatus.starting);
           setTimeout(function(){
-            c.set('workStatus', App.HostComponentStatus.stopped);
+            components.set('workStatus', App.HostComponentStatus.started);
           },App.testModeDelayForActions);
-        });
+        }
       } else {
-        params.component.set('workStatus', App.HostComponentStatus.starting);
-        setTimeout(function(){
-          params.component.set('workStatus', App.HostComponentStatus.started);
-        },App.testModeDelayForActions);
-      }
-    } else {
-      App.router.get('clusterController').loadUpdatedStatusDelayed(500);
-    }
-    // load data (if we need to show this background operations popup) from persist
-    App.router.get('applicationController').dataLoading().done(function (initValue) {
-      if (initValue) {
-        App.router.get('backgroundOperationsController').showPopup();
+        App.router.get('clusterController').loadUpdatedStatusDelayed(500);
       }
+      // load data (if we need to show this background operations popup) from persist
+      App.router.get('applicationController').dataLoading().done(function (initValue) {
+        if (initValue) {
+          App.router.get('backgroundOperationsController').showPopup();
+        }
+      });
+
     });
   },
 
@@ -209,46 +227,28 @@ App.MainHostDetailsController = Em.Controller.extend({
    *          when components failed to get deleted. 
    */
   _doDeleteHostComponent: function(component) {
-    if (component === null) {
-      App.ajax.send({
-        name: 'host.host_components.delete',
-        sender: this,
-        data: {
-          hostName:  this.get('content.hostName')
-        },
-        success: '_doDeleteHostComponentSuccessCallback',
-        error: '_doDeleteHostComponentErrorCallback'
-      });
-    }
-    else {
-      App.ajax.send({
-        name: 'host.host_component.delete',
-        sender: this,
-        data: {
-          componentName: component.get('componentName').toUpperCase(),
-          hostName:  this.get('content.hostName')
-        },
-        success: '_doDeleteHostComponentSuccessCallback',
-        error: '_doDeleteHostComponentErrorCallback'
+    var url = component !== null ? 
+        '/hosts/' + this.get('content.hostName') + '/host_components/' + component.get('componentName').toUpperCase() : 
+        '/hosts/' + this.get('content.hostName') + '/host_components';
+    url = App.apiPrefix + '/clusters/' + App.router.getClusterName() + url;
+    var deleted = null;
+    $.ajax({
+      type: 'DELETE',
+      url: url,
+      timeout: App.timeout,
+      async: false,
+      success: function (data) {
+        deleted = null;
+      },
+      error: function (xhr, textStatus, errorThrown) {
+        console.log('Error deleting host component');
+        console.log(textStatus);
+        console.log(errorThrown);
+        deleted = {xhr: xhr, url: url, method: 'DELETE'};
+      },
+      statusCode: require('data/statusCodes')
       });
-    }
-    return this.get('_deletedHostComponentResult');
-  },
-
-  /**
-   * @type {object}
-   */
-  _deletedHostComponentResult: null,
-
-  _doDeleteHostComponentSuccessCallback: function() {
-    this.set('_deletedHostComponentResult', null);
-  },
-
-  _doDeleteHostComponentErrorCallback: function(xhr, textStatus, errorThrown) {
-    console.log('Error deleting host component');
-    console.log(textStatus);
-    console.log(errorThrown);
-    this.set('_deletedHostComponentResult', {xhr: xhr, url: url, method: 'DELETE'});
+    return deleted;
   },
 
   /**
@@ -259,15 +259,7 @@ App.MainHostDetailsController = Em.Controller.extend({
     var self = this;
     var component = event.context;
     App.showConfirmationPopup(function() {
-
-      App.ajax.send({
-        name: 'host.host_component.upgrade',
-        sender: self,
-        data: {
-          component: component,
-          hostName: self.get('content.hostName'),
-          componentName: component.get('componentName').toUpperCase(),
-          data: JSON.stringify({
+      self.sendCommandToServer('/hosts/' + self.get('content.hostName') + '/host_components/' + component.get('componentName').toUpperCase(),{
             RequestInfo : {
               "context" : Em.I18n.t('requestInfo.upgradeHostComponent') + " " + component.get('displayName')
             },
@@ -277,34 +269,33 @@ App.MainHostDetailsController = Em.Controller.extend({
                 state: 'INSTALLED'
               }
             }
-          })
-        },
-        success: 'upgradeComponentSuccessCallback',
-        error: 'ajaxErrorCallback'
-      });
-    });
-  },
+          }, 'PUT',
+          function(requestId){
+            if(!requestId){
+              return;
+            }
 
-  upgradeComponentSuccessCallback: function(data, opt, params) {
-    console.log('Send request for UPGRADE successfully');
+            console.log('Send request for UPGRADE successfully');
 
-    if (App.testMode) {
-      params.component.set('workStatus', App.HostComponentStatus.starting);
-      setTimeout(function(){
-        params.component.set('workStatus', App.HostComponentStatus.started);
-      },App.testModeDelayForActions);
-    } else {
-      App.router.get('clusterController').loadUpdatedStatusDelayed(500);
-    }
+            if (App.testMode) {
+              component.set('workStatus', App.HostComponentStatus.starting);
+              setTimeout(function(){
+                component.set('workStatus', App.HostComponentStatus.started);
+              },App.testModeDelayForActions);
+            } else {
+              App.router.get('clusterController').loadUpdatedStatusDelayed(500);
+            }
 
-    // load data (if we need to show this background operations popup) from persist
-    App.router.get('applicationController').dataLoading().done(function (initValue) {
-      if (initValue) {
-        App.router.get('backgroundOperationsController').showPopup();
-      }
+            // load data (if we need to show this background operations popup) from persist
+            App.router.get('applicationController').dataLoading().done(function (initValue) {
+              if (initValue) {
+                App.router.get('backgroundOperationsController').showPopup();
+              }
+            });
+
+          });
     });
   },
-
   /**
    * send command to server to stop selected host component
    * @param event
@@ -321,76 +312,59 @@ App.MainHostDetailsController = Em.Controller.extend({
   /**
    * PUTs a command to server to stop a component. If no 
    * specific component is provided, all components are stopped.
-   * @param component  When <code>null</code> all components are stopped.
+   * @param component  When <code>null</code> all components are stopped. 
    * @param context  Context under which this command is beign sent. 
    */
-  sendStopComponentCommand: function(component, context) {
+  sendStopComponentCommand: function(components, context){
+    var url = Em.isArray(components) ?
+        '/hosts/' + this.get('content.hostName') + '/host_components' :
+        '/hosts/' + this.get('content.hostName') + '/host_components/' + components.get('componentName').toUpperCase();
     var dataToSend = {
       RequestInfo : {
         "context" : context
       },
       Body:{
-        HostRoles: {
+        HostRoles:{
           state: 'INSTALLED'
         }
       }
     };
-    if (Em.isArray(component)) {
-      dataToSend.RequestInfo.query = "HostRoles/component_name.in(" + component.mapProperty('componentName').join(',') + ")";
-      App.ajax.send({
-        name: 'host.host_components.stop',
-        sender: this,
-        data: {
-          data: JSON.stringify(dataToSend),
-          hostName: this.get('content.hostName'),
-          component: component
-        },
-        success: 'stopComponentSuccessCallback'
-      });
-    }
-    else {
-      App.ajax.send({
-        name: 'host.host_component.stop',
-        sender: this,
-        data: {
-          data: JSON.stringify(dataToSend),
-          hostName: this.get('content.hostName'),
-          componentName: component.get('componentName').toUpperCase(),
-          component: component
-        },
-        success: 'stopComponentSuccessCallback',
-        error: 'ajaxErrorCallback'
-      });
+    if (Em.isArray(components)) {
+      dataToSend.RequestInfo.query = "HostRoles/component_name.in(" + components.mapProperty('componentName').join(',') + ")";
     }
-  },
+    this.sendCommandToServer( url, dataToSend, 'PUT',
+      function(requestId){
+      if(!requestId){
+        return;
+      }
 
-  stopComponentSuccessCallback: function(data, opt, params) {
-    console.log('Send request for STOPPING successfully');
+      console.log('Send request for STOPPING successfully');
 
-    if (App.testMode) {
-      if(Em.isArray(params.component)) {
-        params.component.forEach(function(c){
-          c.set('workStatus', App.HostComponentStatus.stopping);
+      if (App.testMode) {
+        if(Em.isArray(components)){
+          components.forEach(function(component){
+            component.set('workStatus', App.HostComponentStatus.stopping);
+            setTimeout(function(){
+              component.set('workStatus', App.HostComponentStatus.stopped);
+            },App.testModeDelayForActions);
+          });
+        } else {
+          components.set('workStatus', App.HostComponentStatus.stopping);
           setTimeout(function(){
-            c.set('workStatus', App.HostComponentStatus.stopped);
+            components.set('workStatus', App.HostComponentStatus.stopped);
           },App.testModeDelayForActions);
-        });
-      }
-      else {
-        params.component.set('workStatus', App.HostComponentStatus.stopping);
-        setTimeout(function() {
-          params.component.set('workStatus', App.HostComponentStatus.stopped);
-        },App.testModeDelayForActions);
-      }
-    }
-    else {
-      App.router.get('clusterController').loadUpdatedStatusDelayed(500);
-    }
-    // load data (if we need to show this background operations popup) from persist
-    App.router.get('applicationController').dataLoading().done(function (initValue) {
-      if (initValue) {
-        App.router.get('backgroundOperationsController').showPopup();
+        }
+
+      } else {
+        App.router.get('clusterController').loadUpdatedStatusDelayed(500);
       }
+
+      // load data (if we need to show this background operations popup) from persist
+      App.router.get('applicationController').dataLoading().done(function (initValue) {
+        if (initValue) {
+          App.router.get('backgroundOperationsController').showPopup();
+        }
+      });
     });
   },
 
@@ -437,19 +411,15 @@ App.MainHostDetailsController = Em.Controller.extend({
         App.ModalPopup.show({
           primary: Em.I18n.t('hosts.host.addComponent.popup.confirm'),
           header: Em.I18n.t('popup.confirmation.commonHeader'),
-
           addComponentMsg: function() {
             return Em.I18n.t('hosts.host.addComponent.msg').format(dn);
           }.property(),
-
-          bodyClass: Em.View.extend({
+          bodyClass: Ember.View.extend({
             templateName: require('templates/main/host/details/addComponentPopup')
           }),
-
-          restartNagiosMsg: Em.View.extend({
-            template: Em.Handlebars.compile(Em.I18n.t('hosts.host.addComponent.note').format(dn))
+          restartNagiosMsg : Em.View.extend({
+            template: Ember.Handlebars.compile(Em.I18n.t('hosts.host.addComponent.note').format(dn))
           }),
-
           onPrimary: function () {
             this.hide();
             if (component.get('componentName') === 'CLIENTS') {
@@ -461,11 +431,10 @@ App.MainHostDetailsController = Em.Controller.extend({
                   displayName: App.format.role(sc),
                   componentName: sc
                 });
-                self.primary(c);
+                self.primary(c, scs.length - index === 1);
               });
-            }
-            else {
-              self.primary(component);
+            } else {
+              self.primary(component, true);
             }
           }
         });
@@ -473,92 +442,71 @@ App.MainHostDetailsController = Em.Controller.extend({
     }
   },
 
-  primary: function(component) {
+  primary: function(component, showPopup) {
     var self = this;
-    var componentName = component.get('componentName').toUpperCase();
+    var componentName = component.get('componentName').toUpperCase().toString();
     var displayName = component.get('displayName');
 
-    App.ajax.send({
-      name: 'host.host_component.add_new_component',
-      sender: self,
-      data: {
-        hostName: self.get('content.hostName'),
-        component: component,
-        data: JSON.stringify({
-          RequestInfo: {
-            "context": Em.I18n.t('requestInfo.installHostComponent') + " " + displayName
-          },
-          Body: {
-            host_components: [
-              {
-                HostRoles: {
-                  component_name: componentName
-                }
+    self.sendCommandToServer('/hosts?Hosts/host_name=' + self.get('content.hostName'), {
+        RequestInfo: {
+          "context": Em.I18n.t('requestInfo.installHostComponent') + " " + displayName
+        },
+        Body: {
+          host_components: [
+            {
+              HostRoles: {
+                component_name: componentName
               }
-            ]
-          }
-        })
+            }
+          ]
+        }
       },
-      success: 'addNewComponentSuccessCallback',
-      error: 'ajaxErrorCallback'
-    });
-  },
+      'POST',
+      function (requestId) {
 
-  addNewComponentSuccessCallback: function(data, opt, params) {
-    console.log('Send request for ADDING NEW COMPONENT successfully');
-    App.ajax.send({
-      name: 'host.host_component.install_new_component',
-      sender: this,
-      data: {
-        hostName: this.get('content.hostName'),
-        componentName: params.componentName,
-        component: params.component,
-        data: JSON.stringify({
-          RequestInfo: {
-            "context": Em.I18n.t('requestInfo.installNewHostComponent') + " " + params.displayName
+        console.log('Send request for ADDING NEW COMPONENT successfully');
+
+        self.sendCommandToServer('/host_components?HostRoles/host_name=' + self.get('content.hostName') + '\&HostRoles/component_name=' + componentName + '\&HostRoles/state=INIT', {
+            RequestInfo: {
+              "context": Em.I18n.t('requestInfo.installNewHostComponent') + " " + displayName
+            },
+            Body: {
+              HostRoles: {
+                state: 'INSTALLED'
+              }
+            }
           },
-          Body: {
-            HostRoles: {
-              state: 'INSTALLED'
+          'PUT',
+          function (requestId) {
+            if (!requestId) {
+              return;
             }
-          }
-        })
-      },
-      success: 'installNewComponentSuccessCallback',
-      error: 'ajaxErrorCallback'
-    });
-  },
 
-  installNewComponentSuccessCallback: function(data, opt, params) {
-    if (!data.Requests || !data.Requests.id) {
-      return;
-    }
-    var self = this;
-    console.log('Send request for INSTALLING NEW COMPONENT successfully');
+            console.log('Send request for INSTALLING NEW COMPONENT successfully');
 
-    if (App.testMode) {
-      params.component.set('workStatus', App.HostComponentStatus.installing);
-      setTimeout(function () {
-        params.component.set('workStatus', App.HostComponentStatus.stopped);
-      }, App.testModeDelayForActions);
-    }
-    else {
-      App.router.get('clusterController').loadUpdatedStatusDelayed(500);
-    }
+            if (App.testMode) {
+              component.set('workStatus', App.HostComponentStatus.installing);
+              setTimeout(function () {
+                component.set('workStatus', App.HostComponentStatus.stopped);
+              }, App.testModeDelayForActions);
+            } else {
+              App.router.get('clusterController').loadUpdatedStatusDelayed(500);
+            }
 
-    // load data (if we need to show this background operations popup) from persist
-    App.router.get('applicationController').dataLoading().done(function (initValue) {
-      if (initValue) {
-        App.router.get('backgroundOperationsController').showPopup();
-      }
-      if (params.componentName === 'ZOOKEEPER_SERVER') {
-        self.set('zkRequestId', data.Requests.id);
-        self.addObserver('App.router.backgroundOperationsController.serviceTimestamp', self, self.checkZkConfigs);
-        self.checkZkConfigs();
-      }
-    });
+            // load data (if we need to show this background operations popup) from persist
+            App.router.get('applicationController').dataLoading().done(function (initValue) {
+              if (initValue) {
+                App.router.get('backgroundOperationsController').showPopup();
+              }
+              if (componentName === 'ZOOKEEPER_SERVER') {
+                self.set('zkRequestId', requestId);
+                self.addObserver('App.router.backgroundOperationsController.serviceTimestamp', self, self.checkZkConfigs);
+                self.checkZkConfigs();
+              }
+            });
+          });
+      });
   },
-
   /**
    * Load tags
    */
@@ -660,12 +608,13 @@ App.MainHostDetailsController = Em.Controller.extend({
 
   /**
    * send command to server to install selected host component
-   * @param {Object} event
+   * @param event
+   * @param context
    */
-  installComponent: function (event) {
+  installComponent: function (event, context) {
     var self = this;
     var component = event.context;
-    var componentName = component.get('componentName').toUpperCase();
+    var componentName = component.get('componentName').toUpperCase().toString();
     var displayName = component.get('displayName');
 
     App.ModalPopup.show({
@@ -675,53 +624,47 @@ App.MainHostDetailsController = Em.Controller.extend({
         return Em.I18n.t('hosts.host.installComponent.msg').format(displayName);
       }.property(),
       restartNagiosMsg : Em.View.extend({
-        template: Em.Handlebars.compile(Em.I18n.t('hosts.host.addComponent.note').format(displayName))
+        template: Ember.Handlebars.compile(Em.I18n.t('hosts.host.addComponent.note').format(displayName))
       }),
-      bodyClass: Em.View.extend({
+      bodyClass: Ember.View.extend({
         templateName: require('templates/main/host/details/installComponentPopup')
       }),
       onPrimary: function () {
         this.hide();
-
-        App.ajax.send({
-          name: 'host.host_component.install',
-          sender: self,
-          data: {
-            componentName: componentName,
-            component: component,
-            data: JSON.stringify({
-              RequestInfo: {
-                "context": Em.I18n.t('requestInfo.installHostComponent') + " " + displayName
-              },
-              Body: {
-                HostRoles: {
-                  state: 'INSTALLED'
-                }
+        self.sendCommandToServer('/hosts/' + self.get('content.hostName') + '/host_components/' + component.get('componentName').toUpperCase(), {
+            RequestInfo: {
+              "context": Em.I18n.t('requestInfo.installHostComponent') + " " + displayName
+            },
+            Body: {
+              HostRoles: {
+                state: 'INSTALLED'
               }
-            })
+            }
           },
-          success: 'installComponentSuccessCallback',
-          error: 'ajaxErrorCallback'
-        });
-      }
-    });
-  },
+          'PUT',
+          function (requestId) {
+            if (!requestId) {
+              return;
+            }
 
-  installComponentSuccessCallback: function(data, opt, params) {
-    console.log('Send request for REINSTALL COMPONENT successfully');
-    if (App.testMode) {
-      params.component.set('workStatus', App.HostComponentStatus.installing);
-      setTimeout(function () {
-        params.component.set('workStatus', App.HostComponentStatus.stopped);
-      }, App.testModeDelayForActions);
-    } else {
-      App.router.get('clusterController').loadUpdatedStatusDelayed(500);
-    }
+            console.log('Send request for REINSTALL COMPONENT successfully');
+
+            if (App.testMode) {
+              component.set('workStatus', App.HostComponentStatus.installing);
+              setTimeout(function () {
+                component.set('workStatus', App.HostComponentStatus.stopped);
+              }, App.testModeDelayForActions);
+            } else {
+              App.router.get('clusterController').loadUpdatedStatusDelayed(500);
+            }
 
-    // load data (if we need to show this background operations popup) from persist
-    App.router.get('applicationController').dataLoading().done(function (initValue) {
-      if (initValue) {
-        App.router.get('backgroundOperationsController').showPopup();
+            // load data (if we need to show this background operations popup) from persist
+            App.router.get('applicationController').dataLoading().done(function (initValue) {
+              if (initValue) {
+                App.router.get('backgroundOperationsController').showPopup();
+              }
+            });
+          });
       }
     });
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/5cb3d9c3/ambari-web/app/controllers/main/service/reassign_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/reassign_controller.js b/ambari-web/app/controllers/main/service/reassign_controller.js
index dc01ffd..811b30b 100644
--- a/ambari-web/app/controllers/main/service/reassign_controller.js
+++ b/ambari-web/app/controllers/main/service/reassign_controller.js
@@ -143,7 +143,7 @@ App.ReassignMasterController = App.WizardController.extend({
   loadConfirmedHosts: function () {
     var hosts = App.db.getHosts();
     if (!hosts || !hosts.length) {
-      hosts = {};
+      var hosts = {};
 
       App.Host.find().forEach(function (item) {
         hosts[item.get('id')] = {

http://git-wip-us.apache.org/repos/asf/ambari/blob/5cb3d9c3/ambari-web/app/controllers/wizard/step8_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js
index 0e7c356..bb2e3ba 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -56,6 +56,12 @@ App.WizardStep8Controller = Em.Controller.extend({
   globals: [],
 
   /**
+   * List of ajax-request to be executed
+   * @type {Array}
+   */
+  ajaxQueue: [],
+
+  /**
    * All configs
    * @type {Array}
    */
@@ -100,12 +106,6 @@ App.WizardStep8Controller = Em.Controller.extend({
   serviceConfigTags: [],
 
   /**
-   * Ajax-requests queue
-   * @type {App.ajaxQueue}
-   */
-  ajaxRequestsQueue: null,
-
-  /**
    * Is cluster security enabled
    * @type {bool}
    */
@@ -164,9 +164,6 @@ App.WizardStep8Controller = Em.Controller.extend({
     this.get('clusterInfo').clear();
     this.get('serviceConfigTags').clear();
     this.set('servicesInstalled', false);
-    this.set('ajaxQueueLength', 0);
-    this.set('ajaxRequestsQueue', App.ajaxQueue.create());
-    this.set('ajaxRequestsQueue.finishedCallback', this.ajaxQueueFinished);
   },
 
   /**
@@ -208,96 +205,80 @@ App.WizardStep8Controller = Em.Controller.extend({
   loadGlobals: function () {
     var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
     if (globals.someProperty('name', 'hive_database')) {
-      globals = this.removeHiveConfigs(globals);
-    }
-    if (globals.someProperty('name', 'oozie_database')) {
-      globals = this.removeOozieConfigs(globals);
-    }
-    this.set('globals', globals);
-  },
-
-  /**
-   * Remove unused Hive configs
-   * @param {Ember.Enumerable} globals
-   * @returns {Ember.Enumerable}
-   */
-  removeHiveConfigs: function(globals) {
-    var hiveDb = globals.findProperty('name', 'hive_database');
-    var hiveDbType = {name: 'hive_database_type', value: 'mysql'};
-    var hiveJdbcDriver = {name: 'hive_jdbc_driver'};
-
-    var hive_properties = Em.A([]);
-
-    if (hiveDb.value === 'New MySQL Database') {
-      if (globals.someProperty('name', 'hive_ambari_host')) {
-        globals.findProperty('name', 'hive_hostname').value = globals.findProperty('name', 'hive_ambari_host').value;
-        hiveDbType.value = 'mysql';
-        hiveJdbcDriver.value = 'com.mysql.jdbc.Driver';
-      }
-      hive_properties.pushObjects(Em.A(['hive_existing_mysql_host','hive_existing_mysql_database','hive_existing_oracle_host','hive_existing_oracle_database']));
-    }
-    else {
-      if (hiveDb.value === 'Existing MySQL Database') {
+      var hiveDb = globals.findProperty('name', 'hive_database');
+      var hiveDbType = {name: 'hive_database_type', value: 'mysql'};
+      var hiveJdbcDriver = {name: 'hive_jdbc_driver'};
+
+      if (hiveDb.value === 'New MySQL Database') {
+        if (globals.someProperty('name', 'hive_ambari_host')) {
+          globals.findProperty('name', 'hive_hostname').value = globals.findProperty('name', 'hive_ambari_host').value;
+          hiveDbType.value = 'mysql';
+          hiveJdbcDriver.value = 'com.mysql.jdbc.Driver';
+        }
+        globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_host'));
+        globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_database'));
+        globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_host'));
+        globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_database'));
+      } else if (hiveDb.value === 'Existing MySQL Database'){
         globals.findProperty('name', 'hive_hostname').value = globals.findProperty('name', 'hive_existing_mysql_host').value;
         hiveDbType.value = 'mysql';
         hiveJdbcDriver.value = 'com.mysql.jdbc.Driver';
-        hive_properties.pushObjects(Em.A(['hive_ambari_host','hive_ambari_database','hive_existing_oracle_host','hive_existing_oracle_database']));
-      }
-      else { //existing oracle database
+        globals = globals.without(globals.findProperty('name', 'hive_ambari_host'));
+        globals = globals.without(globals.findProperty('name', 'hive_ambari_database'));
+        globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_host'));
+        globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_database'));
+      } else { //existing oracle database
         globals.findProperty('name', 'hive_hostname').value = globals.findProperty('name', 'hive_existing_oracle_host').value;
         hiveDbType.value = 'oracle';
         hiveJdbcDriver.value = 'oracle.jdbc.driver.OracleDriver';
-        hive_properties.pushObjects(Em.A(['hive_ambari_host','hive_ambari_database','hive_existing_mysql_host','hive_existing_mysql_database']));
+        globals = globals.without(globals.findProperty('name', 'hive_ambari_host'));
+        globals = globals.without(globals.findProperty('name', 'hive_ambari_database'));
+        globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_host'));
+        globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_database'));
       }
+      globals.push(hiveDbType);
+      globals.push(hiveJdbcDriver);
     }
 
-    hive_properties.forEach(function(property) {
-      globals = globals.without(globals.findProperty('name', property));
-    });
-
-    globals.pushObjects([hiveDbType, hiveJdbcDriver]);
-    return globals;
-  },
-
-  /**
-   * Remove unused Oozie configs
-   * @param {Ember.Enumerable} globals
-   * @returns {Ember.Enumerable}
-   */
-  removeOozieConfigs: function(globals) {
-    var oozieDb = globals.findProperty('name', 'oozie_database');
-    var oozieDbType = {name:'oozie_database_type'};
-    var oozieJdbcDriver = {name: 'oozie_jdbc_driver'};
-
-    var oozie_properties = Em.A(['oozie_ambari_host','oozie_ambari_database']);
-
-    if (oozieDb.value === 'New Derby Database') {
-      globals.findProperty('name', 'oozie_hostname').value = globals.findProperty('name', 'oozie_ambari_host').value;
-      oozieDbType.value = 'derby';
-      oozieJdbcDriver.value = 'org.apache.derby.jdbc.EmbeddedDriver';
-      oozie_properties.pushObjects(Em.A(['oozie_existing_mysql_host','oozie_existing_mysql_database','oozie_existing_oracle_host','oozie_existing_oracle_database']));
-    }
-    else {
-      if (oozieDb.value === 'Existing MySQL Database') {
+    if (globals.someProperty('name', 'oozie_database')) {
+      var oozieDb = globals.findProperty('name', 'oozie_database');
+      var oozieDbType = {name:'oozie_database_type'};
+      var oozieJdbcDriver = {name: 'oozie_jdbc_driver'};
+
+      if (oozieDb.value === 'New Derby Database') {
+        globals.findProperty('name', 'oozie_hostname').value = globals.findProperty('name', 'oozie_ambari_host').value;
+        oozieDbType.value = 'derby';
+        oozieJdbcDriver.value = 'org.apache.derby.jdbc.EmbeddedDriver';
+        globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
+        globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
+        globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_host'));
+        globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_database'));
+        globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_host'));
+        globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_database'));
+      } else if (oozieDb.value === 'Existing MySQL Database') {
         globals.findProperty('name', 'oozie_hostname').value = globals.findProperty('name', 'oozie_existing_mysql_host').value;
         oozieDbType.value = 'mysql';
         oozieJdbcDriver.value = 'com.mysql.jdbc.Driver';
-        oozie_properties.pushObjects(Em.A(['oozie_existing_oracle_host','oozie_existing_oracle_database','oozie_derby_database']));
-      }
-      else { // existing oracle database
+        globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
+        globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
+        globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_host'));
+        globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_database'));
+        globals = globals.without(globals.findProperty('name', 'oozie_derby_database'));
+      } else { // existing oracle database
         globals.findProperty('name', 'oozie_hostname').value = globals.findProperty('name', 'oozie_existing_oracle_host').value;
         oozieDbType.value = 'oracle';
         oozieJdbcDriver.value = 'oracle.jdbc.driver.OracleDriver';
-        oozie_properties.pushObjects(Em.A(['oozie_existing_mysql_host','oozie_existing_mysql_database','oozie_derby_database']));
+        globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
+        globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
+        globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_host'));
+        globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_database'));
+        globals = globals.without(globals.findProperty('name', 'oozie_derby_database'));
       }
+      globals.push(oozieDbType);
+      globals.push(oozieJdbcDriver);
     }
 
-    oozie_properties.forEach(function(property) {
-      globals = globals.without(globals.findProperty('name', property));
-    });
-
-    globals.pushObjects([oozieDbType, oozieJdbcDriver]);
-    return globals;
+    this.set('globals', globals);
   },
 
   /**
@@ -549,7 +530,7 @@ App.WizardStep8Controller = Em.Controller.extend({
         stackVersion: stackVersion
       },
       success: 'loadRepoInfoSuccessCallback',
-      error: 'loadRepoInfoErrorCallback'
+      error: 'loadRepositoriesErrorCallback'
     });
   },
 
@@ -792,27 +773,25 @@ App.WizardStep8Controller = Em.Controller.extend({
     this.createSlaveAndClientsHostComponents();
     this.createAdditionalHostComponents();
 
-    this.set('ajaxQueueLength', this.get('ajaxRequestsQueue.queue.length'));
-    this.get('ajaxRequestsQueue').start();
+    this.doNextAjaxCall();
   },
 
   /**
    * Used in progress bar
    */
-  ajaxQueueLength: 0,
+  ajaxQueueLength: function () {
+    return this.get('ajaxQueue').length;
+  }.property('ajaxQueue.length'),
 
   /**
-   * Current cluster name
-   * @type {string}
+   * Used in progress bar
    */
+  ajaxQueueLeft: 0,
+
   clusterName: function () {
     return this.get('content.cluster.name');
   }.property('content.cluster.name'),
 
-  /**
-   * List of existing cluster names
-   * @type {string[]}
-   */
   clusterNames: [],
 
   /**
@@ -879,17 +858,13 @@ App.WizardStep8Controller = Em.Controller.extend({
         if (os.baseUrl !== os.originalBaseUrl) {
           console.log("Updating local repository URL from " + os.originalBaseUrl + " -> " + os.baseUrl + ". ", os);
           self.addRequestToAjaxQueue({
-            name: 'wizard.step8.set_local_repos',
-            data: {
-              osType: os.osType,
-              name: stack.name,
-              stack2VersionURL: App.get('stack2VersionURL'),
-              data: JSON.stringify({
-                "Repositories": {
-                  "base_url": os.baseUrl
-                }
-              })
-            }
+            type: 'PUT',
+            url: App.apiPrefix + App.get('stack2VersionURL') + "/operatingSystems/" + os.osType + "/repositories/" + stack.name,
+            data: JSON.stringify({
+              "Repositories": {
+                "base_url": os.baseUrl
+              }
+            })
           });
         }
       });
@@ -911,10 +886,9 @@ App.WizardStep8Controller = Em.Controller.extend({
     if (this.get('content.controllerName') !== 'installerController') return;
     var stackVersion = (this.get('content.installOptions.localRepo')) ? App.currentStackVersion.replace(/(-\d+(\.\d)*)/ig, "Local$&") : App.currentStackVersion;
     this.addRequestToAjaxQueue({
-      name: 'wizard.step8.create_cluster',
-      data: {
-        data: JSON.stringify({ "Clusters": {"version": stackVersion }})
-      }
+      type: 'POST',
+      url: App.apiPrefix + '/clusters/' + this.get('clusterName'),
+      data: JSON.stringify({ "Clusters": {"version": stackVersion }})
     });
 
   },
@@ -928,10 +902,9 @@ App.WizardStep8Controller = Em.Controller.extend({
     var data = this.createSelectedServicesData();
     if (!data.length) return;
     this.addRequestToAjaxQueue({
-      name: 'wizard.step8.create_selected_services',
-      data: {
-        data:JSON.stringify(data)
-      }
+      type: 'POST',
+      url: App.apiPrefix + '/clusters/' + this.get('clusterName') + '/services',
+      data: JSON.stringify(data)
     });
   },
 
@@ -961,11 +934,9 @@ App.WizardStep8Controller = Em.Controller.extend({
       // Service must be specified in terms of a query for creating multiple components at the same time.
       // See AMBARI-1018.
       this.addRequestToAjaxQueue({
-        name: 'wizard.step8.create_components',
-        data: {
-          data: JSON.stringify({"components": componentsData}),
-          serviceName: serviceName
-        }
+        type: 'POST',
+        url: App.apiPrefix + '/clusters/' + this.get('clusterName') + '/services?ServiceInfo/service_name=' + serviceName,
+        data: JSON.stringify({"components": componentsData})
       });
     }, this);
 
@@ -979,10 +950,9 @@ App.WizardStep8Controller = Em.Controller.extend({
     var data = this.createRegisterHostData();
     if (!data.length) return;
     this.addRequestToAjaxQueue({
-      name: 'wizard.step8.register_host_to_cluster',
-      data: {
-        data: JSON.stringify(data)
-      }
+      type: 'POST',
+      url: App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts',
+      data: JSON.stringify(data)
     });
   },
 
@@ -1135,10 +1105,9 @@ App.WizardStep8Controller = Em.Controller.extend({
     };
 
     this.addRequestToAjaxQueue({
-      name: 'wizard.step8.register_host_to_component',
-      data: {
-        data: JSON.stringify(data)
-      }
+      type: 'POST',
+      url: App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts',
+      data: JSON.stringify(data)
     });
   },
 
@@ -1221,10 +1190,9 @@ App.WizardStep8Controller = Em.Controller.extend({
     }, this).toString();
 
     this.addRequestToAjaxQueue({
-      name: 'wizard.step8.apply_configuration_to_cluster',
-      data: {
-        data: '[' + configData + ']'
-      }
+      type: 'PUT',
+      url: App.apiPrefix + '/clusters/' + this.get('clusterName'),
+      data: '[' + configData + ']'
     });
   },
 
@@ -1291,10 +1259,9 @@ App.WizardStep8Controller = Em.Controller.extend({
    */
   applyConfigurationGroups: function (sendData) {
     this.addRequestToAjaxQueue({
-      name: 'wizard.step8.apply_configuration_groups',
-      data: {
-        data: JSON.stringify(sendData)
-      }
+      type: 'POST',
+      url: App.apiPrefix + '/clusters/' + this.get('clusterName') + '/config_groups',
+      data: JSON.stringify(sendData)
     });
   },
 
@@ -1462,33 +1429,77 @@ App.WizardStep8Controller = Em.Controller.extend({
   },
 
   /**
+   * Do ajax-call with data in <code>ajaxQueue[0]</code> and shift <code>ajaxQueue</code>
+   */
+  doNextAjaxCall: function () {
+    if (this.get('ajaxBusy')) return;
+
+    var queue = this.get('ajaxQueue');
+    if (!queue.length) {
+      this.ajaxQueueFinished();
+      return;
+    }
+
+    var first = queue[0];
+    this.set('ajaxQueue', queue.slice(1));
+    this.set('ajaxQueueLeft', this.get('ajaxQueue').length);
+    this.set('ajaxBusy', true);
+
+    $.ajax(first);
+  },
+
+  /**
    * We need to do a lot of ajax calls async in special order. To do this,
    * generate array of ajax objects and then send requests step by step. All
-   * ajax objects are stored in <code>ajaxRequestsQueue</code>
+   * ajax objects are stored in <code>ajaxQueue</code>
+   *
+   * Each ajax-request success callback contains call of <code>doNextAjaxCall</code>
    *
    * @param {Object} params object with ajax-request parameters like url, type, data etc
    */
   addRequestToAjaxQueue: function (params) {
     if (App.testMode) return;
 
+    var self = this;
     params = jQuery.extend({
-      sender: this,
-      error: 'ajaxQueueRequestErrorCallback'
+      async: true,
+      dataType: 'text',
+      statusCode: require('data/statusCodes'),
+      timeout: App.timeout,
+      error: function () {
+        console.log('Step8: In Error ');
+      },
+      success: function () {
+        console.log("TRACE: Step8 -> In success function");
+      }
     }, params);
-    params.data['cluster'] = this.get('clusterName');
 
-    this.get('ajaxRequestsQueue').addRequest(params);
-  },
+    var success = params.success;
+    var error = params.error;
 
-  ajaxQueueRequestErrorCallback: function(xhr, status, error) {
-    var responseText = JSON.parse(xhr.responseText);
-    var controller = App.router.get(App.clusterStatus.wizardControllerName);
-    controller.registerErrPopup(Em.I18n.t('common.error'), responseText.message);
-    this.set('hasErrorOccurred', true);
-    // an error will break the ajax call chain and allow submission again
-    this.set('isSubmitDisabled', false);
-    this.set('isBackBtnDisabled', false);
-    App.router.get(this.get('content.controllerName')).setStepsEnable();
+    params.success = function () {
+      if (success) {
+        success();
+      }
+
+      self.set('ajaxBusy', false);
+      self.doNextAjaxCall();
+    };
+
+    params.error = function (xhr, status, error) {
+      var responseText = JSON.parse(xhr.responseText);
+      var controller = App.router.get(App.clusterStatus.wizardControllerName);
+      controller.registerErrPopup(Em.I18n.t('common.error'), responseText.message);
+      self.set('hasErrorOccurred', true);
+      // an error will break the ajax call chain and allow submission again
+      self.set('isSubmitDisabled', false);
+      self.set('isBackBtnDisabled', false);
+      App.router.get(self.get('content.controllerName')).setStepsEnable();
+      self.get('ajaxQueue').clear();
+      self.set('ajaxBusy', false);
+    };
+
+    this.get('ajaxQueue').pushObject(params);
   }
 
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/5cb3d9c3/ambari-web/app/controllers/wizard/step9_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step9_controller.js b/ambari-web/app/controllers/wizard/step9_controller.js
index 3166635..7df8661 100644
--- a/ambari-web/app/controllers/wizard/step9_controller.js
+++ b/ambari-web/app/controllers/wizard/step9_controller.js
@@ -125,13 +125,12 @@ App.WizardStep9Controller = Em.Controller.extend({
    * Observer function: Enables previous steps link if install task failed in installer wizard.
    */
   togglePreviousSteps: function () {
-    if (!App.testMode) {
-      if ('INSTALL FAILED' === this.get('content.cluster.status') && this.get('content.controllerName') == 'installerController') {
-        App.router.get('installerController').setStepsEnable();
-      }
-      else {
-        App.router.get('installerController').setLowerStepsDisable(9);
-      }
+    if (App.testMode) {
+      return;
+    } else if ('INSTALL FAILED' === this.get('content.cluster.status') && this.get('content.controllerName') == 'installerController') {
+      App.router.get('installerController').setStepsEnable();
+    } else {
+      App.router.get('installerController').setLowerStepsDisable(9);
     }
   }.observes('content.cluster.status', 'content.controllerName'),
 
@@ -318,17 +317,14 @@ App.WizardStep9Controller = Em.Controller.extend({
       if (clusterStatus === 'INSTALL FAILED') {
         this.loadStep();
         this.loadLogData(this.get('content.cluster.requestId'));
+      } else if (clusterStatus === 'START FAILED') {
+        this.loadStep();
+        this.loadLogData(this.get('content.cluster.requestId'));
       } else {
-        if (clusterStatus === 'START FAILED') {
-          this.loadStep();
-          this.loadLogData(this.get('content.cluster.requestId'));
-        }
-        else {
-          // handle PENDING, INSTALLED
-          this.loadStep();
-          this.loadLogData(this.get('content.cluster.requestId'));
-          this.startPolling();
-        }
+        // handle PENDING, INSTALLED
+        this.loadStep();
+        this.loadLogData(this.get('content.cluster.requestId'));
+        this.startPolling();
       }
     } else {
       // handle STARTED
@@ -610,7 +606,7 @@ App.WizardStep9Controller = Em.Controller.extend({
   /**
    * Error callback function for start services task.
    */
-  launchStartServicesErrorCallback: function (jqXHR, ajaxOptions, error, opt) {
+  launchStartServicesErrorCallback: function (jqXHR) {
     console.log("ERROR");
     this.set('startCallFailed',true);
     var clusterStatus = {
@@ -624,7 +620,18 @@ App.WizardStep9Controller = Em.Controller.extend({
     });
     this.set('progress','100');
 
-    App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.method, jqXHR.status);
+    var params = {
+      cluster: this.get('content.cluster.name')
+    };
+
+    if (this.get('content.controllerName') === 'addHostController') {
+      params.name = 'wizard.step9.add_host.launch_start_services';
+    } else {
+      params.name = 'wizard.step9.installer.launch_start_services';
+    }
+
+    var opt = App.formatRequest.call(App.urls[params.name], params);
+    App.ajax.defaultErrorHandler(jqXHR,opt.url,opt.type);
   },
 
   /**
@@ -946,15 +953,36 @@ App.WizardStep9Controller = Em.Controller.extend({
   },
 
   /**
+   *
+   * @param requestId {Int} Request Id received on triggering install/start command successfully
+   * @returns {string} URL to poll to track the result of the triggered command
+   */
+  getUrl: function (requestId) {
+    var clusterName = this.get('content.cluster.name');
+    var requestId = requestId || this.get('content.cluster.requestId');
+    var url = App.apiPrefix + '/clusters/' + clusterName + '/requests/' + requestId + '?fields=tasks/Tasks/command,tasks/Tasks/exit_code,tasks/Tasks/start_time,tasks/Tasks/end_time,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status&minimal_response=true';
+    console.log("URL for step9 is: " + url);
+    return url;
+  },
+
+  /**
    * This function calls API just once to fetch log data of all tasks.
+   * @param requestId {Int} Request Id received on triggering install/start command successfully
    */
-  loadLogData: function () {
+  loadLogData: function (requestId) {
+    var url = this.getUrl(requestId);
     var requestsId = this.get('wizardController').getDBProperty('cluster').oldRequestsId;
+    if (App.testMode) {
+      this.POLL_INTERVAL = 1;
+    }
+
     requestsId.forEach(function (requestId) {
+      url = this.getUrl(requestId);
       if (App.testMode) {
         this.POLL_INTERVAL = 1;
+        url = this.get('mockDataPrefix') + '/poll_' + this.numPolls + '.json';
       }
-      this.getLogsByRequest(false, requestId);
+      this.getLogsByRequest(url, false);
     }, this);
   },
   /**
@@ -1019,66 +1047,65 @@ App.WizardStep9Controller = Em.Controller.extend({
 
   /**
    * Function polls the API to retrieve data for the request.
-   * @param {bool} polling whether to continue polling for status or not
-   * @param {number} requestId
+   * @param url {string} url to poll
+   * @param polling  {Boolean} whether to continue polling for status or not
    */
-  getLogsByRequest: function (polling, requestId) {
-    App.ajax.send({
-      name: 'wizard.step9.load_log',
-      sender: this,
-      data: {
-        polling: polling,
-        cluster: this.get('content.cluster.name'),
-        requestId: requestId,
-        numPolls: this.get('numPolls')
+  getLogsByRequest: function (url, polling) {
+    var self = this;
+    $.ajax({
+      type: 'GET',
+      url: url,
+      async: true,
+      timeout: App.timeout,
+      dataType: 'text',
+      success: function (data) {
+        var parsedData = jQuery.parseJSON(data);
+        console.log("TRACE: In success function for the GET logs data");
+        console.log("TRACE: Step9 -> The value is: ", parsedData);
+        var result = self.parseHostInfo(parsedData);
+        if (!polling) {
+          if (self.get('content.cluster.status') === 'INSTALL FAILED') {
+            self.isAllComponentsInstalled();
+          }
+          return;
+        }
+        if (result !== true) {
+          window.setTimeout(function () {
+            if (self.get('currentOpenTaskId')) {
+              self.loadCurrentTaskLog();
+            }
+            self.doPolling();
+          }, self.POLL_INTERVAL);
+        }
+      },
+
+      error: function (request, ajaxOptions, error) {
+        console.log("TRACE: STep9 -> In error function for the GET logs data");
+        console.log("TRACE: STep9 -> value of the url is: " + url);
+        console.log("TRACE: STep9 -> error code status is: " + request.status);
       },
-      success: 'getLogsByRequestSuccessCallback',
-      error: 'getLogsByRequestErrorCallback'
+
+      statusCode: require('data/statusCodes')
     }).retry({times: App.maxRetries, timeout: App.timeout}).then(null,
-      function() {
+      function () {
         App.showReloadPopup();
         console.log('Install services all retries failed');
       }
     );
   },
 
-  getLogsByRequestSuccessCallback: function(data, opt, params) {
-    var self = this;
-    var parsedData = jQuery.parseJSON(data);
-    console.log("TRACE: In success function for the GET logs data");
-    console.log("TRACE: Step9 -> The value is: ", parsedData);
-    var result = this.parseHostInfo(parsedData);
-    if (!params.polling) {
-      if (this.get('content.cluster.status') === 'INSTALL FAILED') {
-        this.isAllComponentsInstalled();
-      }
-      return;
-    }
-    if (result !== true) {
-      window.setTimeout(function () {
-        if (self.get('currentOpenTaskId')) {
-          self.loadCurrentTaskLog();
-        }
-        self.doPolling();
-      }, this.POLL_INTERVAL);
-    }
-  },
-
-  getLogsByRequestErrorCallback: function(request, ajaxOptions, error) {
-    console.log("TRACE: STep9 -> In error function for the GET logs data");
-    console.log("TRACE: STep9 -> value of the url is: " + url);
-    console.log("TRACE: STep9 -> error code status is: " + request.status);
-  },
-
   /**
    * Delegates the function call to {getLogsByRequest} with appropriate params
    */
   doPolling: function () {
-    var requestId = this.get('content.cluster.requestId');
+    var url = this.getUrl();
+
     if (App.testMode) {
-      this.incrementProperty('numPolls');
+      this.numPolls++;
+      url = this.get('mockDataPrefix') + '/poll_' + this.get('numPolls') + '.json';
+
     }
-    this.getLogsByRequest(true, requestId);
+    this.getLogsByRequest(url, true);
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/5cb3d9c3/ambari-web/app/initialize.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/initialize.js b/ambari-web/app/initialize.js
index db8b397..777779a 100644
--- a/ambari-web/app/initialize.js
+++ b/ambari-web/app/initialize.js
@@ -33,8 +33,7 @@ require('templates');
 require('views');
 require('router');
 
-require('utils/ajax/ajax');
-require('utils/ajax/ajax_queue');
+require('utils/ajax');
 require('utils/updater');
 
 require('mappers/server_data_mapper');

http://git-wip-us.apache.org/repos/asf/ambari/blob/5cb3d9c3/ambari-web/app/mixins/common/userPref.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/userPref.js b/ambari-web/app/mixins/common/userPref.js
index 58e8197..ea8c358 100644
--- a/ambari-web/app/mixins/common/userPref.js
+++ b/ambari-web/app/mixins/common/userPref.js
@@ -25,8 +25,6 @@ var App = require('app');
  * <ul>
  *   <li>getUserPrefSuccessCallback</li>
  *   <li>getUserPrefErrorCallback</li>
- *   <li>postuserPrefSuccessCallback</li>
- *   <li>postuserPrefErrorCallback</li>
  * </ul>
  * @type {Em.Mixin}
  */
@@ -39,12 +37,6 @@ App.UserPref = Em.Mixin.create({
   makeRequestAsync: true,
 
   /**
-   * Additional to request data
-   * @type {object}
-   */
-  additionalData: {},
-
-  /**
    * Get persist value from server with persistKey
    * @param {String} key
    */
@@ -54,8 +46,7 @@ App.UserPref = Em.Mixin.create({
       sender: this,
       data: {
         key: key,
-        async: this.get('makeRequestAsync'),
-        data: this.get('additionalData')
+        async: this.get('makeRequestAsync')
       },
       success: 'getUserPrefSuccessCallback',
       error: 'getUserPrefErrorCallback'
@@ -94,30 +85,11 @@ App.UserPref = Em.Mixin.create({
       'data': {
         'async': this.get('makeRequestAsync'),
         'keyValuePair': keyValuePair
-      },
-      'success': 'postUserPrefSuccessCallback',
-      'error': 'postUserPrefErrorCallback'
+      }
     });
   },
 
   /**
-   * Should be redeclared in objects that use this mixin
-   * @param {*} response
-   * @param {Object} request
-   * @param {Object} data
-   * @returns {*}
-   */
-  postUserPrefSuccessCallback: function (response, request, data) {},
-
-  /**
-   * Should be redeclared in objects that use this mixin
-   * @param {Object} request
-   * @param {Object} ajaxOptions
-   * @param {String} error
-   */
-  postUserPrefErrorCallback: function(request, ajaxOptions, error) {},
-
-  /**
    * Little log before post request
    * @param {Object} request
    * @param {Object} ajaxOptions
@@ -127,4 +99,4 @@ App.UserPref = Em.Mixin.create({
     console.log('BeforeSend to persist: persistKeyValues', data.keyValuePair);
   }
 
-});
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/5cb3d9c3/ambari-web/app/models/cluster_states.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/cluster_states.js b/ambari-web/app/models/cluster_states.js
index 76f5206..fae426e 100644
--- a/ambari-web/app/models/cluster_states.js
+++ b/ambari-web/app/models/cluster_states.js
@@ -16,9 +16,8 @@
  * limitations under the License.
  */
 var App = require('app');
-require('mixins/common/userPref');
 
-App.clusterStatus = Em.Object.create(App.UserPref, {
+App.clusterStatus = Ember.Object.create({
   clusterName: '',
   validStates: [
     'DEFAULT',
@@ -60,60 +59,68 @@ App.clusterStatus = Em.Object.create(App.UserPref, {
    */
   updateFromServer: function(isAsync, overrideLocaldb) {
     // if isAsync is undefined, set it to false
-    this.set('makeRequestAsync', isAsync || false);
+    isAsync = isAsync || false;
     // if overrideLocaldb is undefined, set it to true
-    this.set('additionalData', {
-      user: App.db.getUser(),
-      login: App.db.getLoginName(),
-      overrideLocaldb: overrideLocaldb || true
-    });
-    return this.getUserPref(this.get('key'));
-  },
-
-  getUserPrefSuccessCallback: function (response, opt, params) {
-    if (response) {
-      if (response.clusterState) {
-        this.set('clusterState', response.clusterState);
-      }
-      if (response.clusterName) {
-        this.set('clusterName', response.clusterName);
-      }
-      if (response.wizardControllerName) {
-        this.set('wizardControllerName', response.wizardControllerName);
-      }
-      if (response.localdb) {
-        this.set('localdb', response.localdb);
-        // restore HAWizard data if process was started
-        var isHAWizardStarted = App.get('isAdmin') && !App.isEmptyObject(response.localdb.HighAvailabilityWizard);
-        if (params.overrideLocaldb || isHAWizardStarted) {
-          App.db.data = response.localdb;
-          App.db.setLocalStorage();
-          App.db.setUser(params.user);
-          App.db.setLoginName(params.login);
-        }
-      }
-    }
-    // this is to ensure that the local storage namespaces are initialized with all expected namespaces.
-    // after upgrading ambari, loading local storage data from the "persist" data saved via an older version of
-    // Ambari can result in missing namespaces that are defined in the new version of Ambari.
-    App.db.mergeStorage();
-  },
-
-  getUserPrefErrorCallback: function (request, ajaxOptions, error) {
-    if (request.status == 404) {
-      // default status already set
-      console.log('Persist API did NOT find the key CLUSTER_CURRENT_STATUS');
-      return;
+    if(typeof overrideLocaldb == "undefined"){
+      overrideLocaldb =  true;
     }
-    App.ModalPopup.show({
-      header: Em.I18n.t('common.error'),
-      secondary: false,
-      bodyClass: Em.View.extend({
-        template: Em.Handlebars.compile('<p>{{t common.update.error}}</p>')
-      })
-    });
+    var user = App.db.getUser();
+    var login = App.db.getLoginName();
+    var url = App.apiPrefix + '/persist/' + this.get('key');
+    return jQuery.ajax(
+      {
+        url: url,
+        context: this,
+        async: isAsync,
+        success: function (response) {
+          if (response) {
+            var newValue = jQuery.parseJSON(response);
+            if (newValue.clusterState) {
+              this.set('clusterState', newValue.clusterState);
+            }
+            if (newValue.clusterName) {
+              this.set('clusterName', newValue.clusterName);
+            }
+            if (newValue.wizardControllerName) {
+              this.set('wizardControllerName', newValue.wizardControllerName);
+            }
+            if (newValue.localdb) {
+              this.set('localdb', newValue.localdb);
+              // restore HAWizard data if process was started
+              var isHAWizardStarted = App.get('isAdmin') && !App.isEmptyObject(newValue.localdb.HighAvailabilityWizard);
+              if (overrideLocaldb || isHAWizardStarted) {
+                App.db.data = newValue.localdb;
+                App.db.setLocalStorage();
+                App.db.setUser(user);
+                App.db.setLoginName(login);
+              }
+            }
+          } else {
+            // default status already set
+          }
+          // this is to ensure that the local storage namespaces are initialized with all expected namespaces.
+          // after upgrading ambari, loading local storage data from the "persist" data saved via an older version of
+          // Ambari can result in missing namespaces that are defined in the new version of Ambari.
+          App.db.mergeStorage();
+        },
+        error: function (xhr) {
+          if (xhr.status == 404) {
+            // default status already set
+            console.log('Persist API did NOT find the key CLUSTER_CURRENT_STATUS');
+            return;
+          }
+          App.ModalPopup.show({
+            header: Em.I18n.t('common.error'),
+            secondary: false,
+            bodyClass: Ember.View.extend({
+              template: Ember.Handlebars.compile('<p>{{t common.update.error}}</p>')
+            })
+          });
+        },
+        statusCode: require('data/statusCodes')
+      }
+    );
   },
-
   /**
    * update cluster status and post it on server
    * @param newValue
@@ -154,15 +161,28 @@ App.clusterStatus = Em.Object.create(App.UserPref, {
         App.db.setLoginName(login);
       }
 
-      this.set('makeRequestAsync', false);
-      this.postUserPref(this.get('key'), val);
+      var keyValuePair = {};
+
+      keyValuePair[this.get('key')] = JSON.stringify(val);
+
+      App.ajax.send({
+        name: 'cluster.state',
+        sender: this,
+        data: {
+          keyValuePair: keyValuePair
+        },
+        beforeSend: 'clusterStatusBeforeSend',
+        error: 'clusterStatusErrorCallBack'
+      });
       return newValue;
     }
   },
-
-  postUserPrefErrorCallback: function(request, ajaxOptions, error) {
+  clusterStatusBeforeSend: function (keyValuePair) {
+    console.log('BeforeSend: persistKeyValues', keyValuePair);
+  },
+  clusterStatusErrorCallBack: function(request, ajaxOptions, error, opt) {
     console.log("ERROR");
-    var msg = '', doc;
+    var msg, doc;
     try {
       msg = 'Error ' + (request.status) + ' ';
       doc = $.parseXML(request.responseText);
@@ -175,8 +195,8 @@ App.clusterStatus = Em.Object.create(App.UserPref, {
       header: Em.I18n.t('common.error'),
       secondary: false,
       response: msg,
-      bodyClass: Em.View.extend({
-        template: Em.Handlebars.compile('<p>{{t common.persist.error}} {{response}}</p>')
+      bodyClass: Ember.View.extend({
+        template: Ember.Handlebars.compile('<p>{{t common.persist.error}} {{response}}</p>')
       })
     });
   },


Mime
View raw message