Browse Source

AMBARI-1895. Refactor ajax requests. (srimanth)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1467084 13f79535-47bb-0310-9956-ffa450edef68
Srimanth 12 years ago
parent
commit
1e0cf650d7
51 changed files with 1488 additions and 1132 deletions
  1. 2 0
      CHANGES.txt
  2. 20 20
      ambari-web/app/controllers/global/cluster_controller.js
  3. 8 6
      ambari-web/app/controllers/login_controller.js
  4. 71 88
      ambari-web/app/controllers/main/admin.js
  5. 38 40
      ambari-web/app/controllers/main/admin/cluster.js
  6. 61 67
      ambari-web/app/controllers/main/admin/security/add/step3.js
  7. 62 67
      ambari-web/app/controllers/main/admin/security/disable.js
  8. 51 46
      ambari-web/app/controllers/main/host/configs_service.js
  9. 26 37
      ambari-web/app/controllers/main/service.js
  10. 127 133
      ambari-web/app/controllers/wizard.js
  11. 104 94
      ambari-web/app/controllers/wizard/stack_upgrade/step3_controller.js
  12. 189 178
      ambari-web/app/controllers/wizard/step3_controller.js
  13. 33 27
      ambari-web/app/controllers/wizard/step8_controller.js
  14. 41 50
      ambari-web/app/controllers/wizard/step9_controller.js
  15. 111 122
      ambari-web/app/router.js
  16. 1 0
      ambari-web/app/routes/main.js
  17. 449 20
      ambari-web/app/utils/ajax.js
  18. 34 49
      ambari-web/app/views/common/chart/linear_time.js
  19. 0 22
      ambari-web/app/views/common/modal_popup.js
  20. 3 4
      ambari-web/app/views/main/dashboard/cluster_metrics/cpu.js
  21. 2 2
      ambari-web/app/views/main/dashboard/cluster_metrics/load.js
  22. 3 2
      ambari-web/app/views/main/dashboard/cluster_metrics/memory.js
  23. 3 2
      ambari-web/app/views/main/dashboard/cluster_metrics/network.js
  24. 1 2
      ambari-web/app/views/main/host/metrics/cpu.js
  25. 2 2
      ambari-web/app/views/main/host/metrics/disk.js
  26. 2 2
      ambari-web/app/views/main/host/metrics/load.js
  27. 2 2
      ambari-web/app/views/main/host/metrics/memory.js
  28. 2 2
      ambari-web/app/views/main/host/metrics/network.js
  29. 2 2
      ambari-web/app/views/main/host/metrics/processes.js
  30. 2 2
      ambari-web/app/views/main/service/info/metrics/hbase/cluster_requests.js
  31. 1 2
      ambari-web/app/views/main/service/info/metrics/hbase/hlog_split_size.js
  32. 1 2
      ambari-web/app/views/main/service/info/metrics/hbase/hlog_split_time.js
  33. 1 2
      ambari-web/app/views/main/service/info/metrics/hbase/regionserver_queuesize.js
  34. 1 2
      ambari-web/app/views/main/service/info/metrics/hbase/regionserver_regions.js
  35. 2 2
      ambari-web/app/views/main/service/info/metrics/hbase/regionserver_rw_requests.js
  36. 2 2
      ambari-web/app/views/main/service/info/metrics/hdfs/block_status.js
  37. 2 2
      ambari-web/app/views/main/service/info/metrics/hdfs/file_operations.js
  38. 1 2
      ambari-web/app/views/main/service/info/metrics/hdfs/gc.js
  39. 2 2
      ambari-web/app/views/main/service/info/metrics/hdfs/io.js
  40. 2 2
      ambari-web/app/views/main/service/info/metrics/hdfs/jvm_heap.js
  41. 2 2
      ambari-web/app/views/main/service/info/metrics/hdfs/jvm_threads.js
  42. 2 2
      ambari-web/app/views/main/service/info/metrics/hdfs/rpc.js
  43. 1 2
      ambari-web/app/views/main/service/info/metrics/hdfs/space_utilization.js
  44. 2 2
      ambari-web/app/views/main/service/info/metrics/mapreduce/gc.js
  45. 2 2
      ambari-web/app/views/main/service/info/metrics/mapreduce/jobs_status.js
  46. 2 2
      ambari-web/app/views/main/service/info/metrics/mapreduce/jvm_heap.js
  47. 2 2
      ambari-web/app/views/main/service/info/metrics/mapreduce/jvm_threads.js
  48. 2 2
      ambari-web/app/views/main/service/info/metrics/mapreduce/map_slots.js
  49. 2 2
      ambari-web/app/views/main/service/info/metrics/mapreduce/reduce_slots.js
  50. 2 2
      ambari-web/app/views/main/service/info/metrics/mapreduce/rpc.js
  51. 2 2
      ambari-web/app/views/main/service/info/metrics/mapreduce/tasks_running_waiting.js

+ 2 - 0
CHANGES.txt

@@ -12,6 +12,8 @@ Trunk (unreleased changes):
 
  NEW FEATURES
 
+ AMBARI-1895. Refactor ajax requests. (srimanth)
+
  AMBARI-1868. Include stack version as a parameter in manifest. (swagle)
 
  AMBARI-1847. Make single PUT call for multiple host overrides. (srimanth)

+ 20 - 20
ambari-web/app/controllers/global/cluster_controller.js

@@ -64,30 +64,30 @@ App.ClusterController = Em.Controller.extend({
     if (this.get('clusterName') && !reload) {
       return;
     }
-    var self = this;
-    var url = (App.testMode) ? '/data/clusters/info.json' : App.apiPrefix + '/clusters';
-    $.ajax({
-      async:false,
-      type:"GET",
-      url:url,
-      dataType:'json',
-      timeout:App.timeout,
-      success:function (data) {
-        self.set('cluster', data.items[0]);
-        App.set('clusterName', data.items[0].Clusters.cluster_name);
-        App.set('currentStackVersion', data.items[0].Clusters.version);
-      },
-      error:function (request, ajaxOptions, error) {
-        console.log('failed on loading cluster name');
-        self.set('isLoaded', true);
-      },
-      statusCode:require('data/statusCodes')
+
+    App.ajax.send({
+      name: 'cluster.load_cluster_name',
+      sender: this,
+      success: 'loadClusterNameSuccessCallback',
+      error: 'loadClusterNameErrorCallback'
     });
+
     if(!App.get('currentStackVersion')){
       App.set('currentStackVersion', App.defaultStackVersion);
     }
   },
 
+  loadClusterNameSuccessCallback: function (data) {
+    this.set('cluster', data.items[0]);
+    App.set('clusterName', data.items[0].Clusters.cluster_name);
+    App.set('currentStackVersion', data.items[0].Clusters.version);
+  },
+
+  loadClusterNameErrorCallback: function (request, ajaxOptions, error) {
+    console.log('failed on loading cluster name');
+    this.set('isLoaded', true);
+  },
+
   getUrl:function (testUrl, url) {
     return (App.testMode) ? testUrl : App.apiPrefix + '/clusters/' + this.get('clusterName') + url;
   },
@@ -213,7 +213,7 @@ App.ClusterController = Em.Controller.extend({
       };
       App.HttpClient.get(dataUrl, App.alertsMapper, ajaxOptions);
     } else {
-      console.log("No Nagios URL provided.")
+      console.log("No Nagios URL provided.");
       callback();
     }
   },
@@ -363,4 +363,4 @@ App.ClusterController = Em.Controller.extend({
       complete:function(){}
     });
   }
-})
+});

+ 8 - 6
ambari-web/app/controllers/login_controller.js

@@ -32,12 +32,14 @@ App.LoginController = Em.Object.extend({
 
     var self = this;
 
-    App.get('router').login(function (isAuthenticated) {
-      if (!isAuthenticated) {
-        console.log('Failed to login as: ' + self.get('loginName'));
-        self.set('errorMessage', Em.I18n.t('login.error'));
-      }
-    });
+    App.get('router').login();
+  },
+
+  postLogin: function (isAuthenticated) {
+    if (!isAuthenticated) {
+      console.log('Failed to login as: ' + this.get('loginName'));
+      this.set('errorMessage', Em.I18n.t('login.error'));
+    }
   }
 
 });

+ 71 - 88
ambari-web/app/controllers/main/admin.js

@@ -24,113 +24,96 @@ App.MainAdminController = Em.Controller.extend({
   securityEnabled: false,
   serviceUsers: [],
 
+  deferred: null,
+
+  tag: null,
+
   /**
    * return true if security status is loaded and false otherwise
    */
   securityStatusLoading: function () {
-    var dfd = $.Deferred();
-    this.connectOutlet('loading');
+    var self = this;
+    this.set('deferred', $.Deferred());
     if (App.testMode) {
       window.setTimeout(function () {
-        dfd.resolve();
+        self.get('deferred').resolve();
       }, 50);
-    } else {
-      this.getSecurityStatusFromServer(dfd);
     }
-    return dfd.promise();
+    else {
+      //get Security Status From Server
+      App.ajax.send({
+        name: 'admin.security_status',
+        sender: this,
+        success: 'getSecurityStatusFromServerSuccessCallback',
+        error: 'errorCallback'
+      });
+    }
+    return this.get('deferred').promise();
   },
 
-  /**
-   * return true if security status is loaded and false otherwise
-   */
-  getSecurityStatusFromServer: function (dfd) { //TODO: this should be obtain from cluster level config rather than HDFS global config
-    var self = this;
-    var url = App.apiPrefix + '/clusters/' + App.router.getClusterName();
-    $.ajax({
-      type: 'GET',
-      url: url,
-      async: false,    // we are retrieving user information that is used ahead in addSecurity/apply stage
-      timeout: 10000,
-      dataType: 'text',
-      success: function (data) {
-        console.log("TRACE: The url is: " + url);
-        var jsonData = jQuery.parseJSON(data);
-        var configs = jsonData.Clusters.desired_configs;
-        if ('global' in configs) {
-          self.getServiceConfigsFromServer(dfd, 'global', configs['global'].tag);
-        } else {
-          if (dfd) {
-            dfd.reject();
-          }
-        }
-      },
-
-      error: function (request, ajaxOptions, error) {
-        if (dfd) {
-          dfd.reject();
-        }
-      },
-
-      statusCode: require('data/statusCodes')
-    });
+  errorCallback: function() {
+    this.get('deferred').reject();
   },
 
-  getServiceConfigsFromServer: function (dfd, siteName, tagName) {
-    var self = this;
-    var url = App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/configurations/?type=' + siteName + '&tag=' + tagName;
-    $.ajax({
-      type: 'GET',
-      url: url,
-      async: false, // we are retrieving user information that is used ahead in addSecurity/apply stage
-      timeout: 10000,
-      dataType: 'json',
-      success: function (data) {
-        console.log("TRACE: In success function for the GET getServiceConfigsFromServer call");
-        console.log("TRACE: The url is: " + url);
-        var configs = data.items.findProperty('tag', tagName).properties;
-        if (configs && configs['security_enabled'] === 'true') {
-          self.set('securityEnabled', true);
-        } else {
-          self.loadUsers(configs);
-          self.set('securityEnabled', false);
-        }
-        if (dfd) {
-          dfd.resolve();
-        }
-      },
+  getSecurityStatusFromServerSuccessCallback: function (data) {
+    var configs = data.Clusters.desired_configs;
+    if ('global' in configs) {
+      this.set('tag', configs['global'].tag);
+      this.getServiceConfigsFromServer();
+    }
+    else {
+      this.get('deferred').reject();
+    }
+  },
 
-      error: function (request, ajaxOptions, error) {
-        if (dfd) {
-          dfd.reject();
-        }
+  getServiceConfigsFromServer: function () {
+    App.ajax.send({
+      name: 'admin.service_config',
+      sender: this,
+      data: {
+        siteName: 'global',
+        tagName: this.get('tag')
       },
-
-      statusCode: require('data/statusCodes')
+      success: 'getServiceConfigsFromServerSuccessCallback',
+      error: 'errorCallback'
     });
   },
 
-  loadUsers: function (configs) {
-    var serviceUsers = this.get('serviceUsers');
-    if (configs['hdfs_user']) {
-      serviceUsers.pushObject({id: 'puppet var', name: 'hdfs_user', value: configs['hdfs_user']});
-    } else {
-      serviceUsers.pushObject({id: 'puppet var', name: 'hdfs_user', value: 'hdfs'});
-    }
-    if (configs['mapred_user']) {
-      serviceUsers.pushObject({id: 'puppet var', name: 'mapred_user', value: configs['mapred_user']});
-    } else {
-      serviceUsers.pushObject({id: 'puppet var', name: 'mapred_user', value: 'mapred'});
+  getServiceConfigsFromServerSuccessCallback: function (data) {
+    console.log("TRACE: In success function for the GET getServiceConfigsFromServer call");
+    var configs = data.items.findProperty('tag', this.get('tag')).properties;
+    if (configs && configs['security_enabled'] === 'true') {
+      this.set('securityEnabled', true);
     }
-    if (configs['hbase_user']) {
-      serviceUsers.pushObject({id: 'puppet var', name: 'hbase_user', value: configs['hbase_user']});
-    } else {
-      serviceUsers.pushObject({id: 'puppet var', name: 'hbase_user', value: 'hbase'});
-    }
-    if (configs['hive_user']) {
-      serviceUsers.pushObject({id: 'puppet var', name: 'hive_user', value: configs['hive_user']});
-    } else {
-      serviceUsers.pushObject({id: 'puppet var', name: 'hive_user', value: 'hive'});
+    else {
+      this.loadUsers(configs);
+      this.set('securityEnabled', false);
     }
+    this.get('deferred').resolve();
+  },
+
+  loadUsers: function (configs) {
+    var serviceUsers = this.get('serviceUsers');
+    serviceUsers.pushObject({
+      id: 'puppet var',
+      name: 'hdfs_user',
+      value: configs['hdfs_user'] ? configs['hdfs_user'] : 'hdfs'
+    });
+    serviceUsers.pushObject({
+      id: 'puppet var',
+      name: 'mapred_user',
+      value: configs['mapred_user'] ? configs['mapred_user'] : 'mapred'
+    });
+    serviceUsers.pushObject({
+      id: 'puppet var',
+      name: 'hbase_user',
+      value: configs['hbase_user'] ? configs['hbase_user'] : 'hbase'
+    });
+    serviceUsers.pushObject({
+      id: 'puppet var',
+      name: 'hive_user',
+      value: configs['hive_user'] ? configs['hive_user'] : 'hive'
+    });
   }
 
 });

+ 38 - 40
ambari-web/app/controllers/main/admin/cluster.js

@@ -27,49 +27,47 @@ App.MainAdminClusterController = Em.Controller.extend({
    */
   updateUpgradeVersion: function(){
     if(App.router.get('clusterController.isLoaded')){
-      var url = App.formatUrl(
-        App.apiPrefix + "/stacks2/HDP/versions?fields=stackServices/StackServices,Versions",
-        {},
-        '/data/wizard/stack/stacks.json'
-      );
-      var upgradeVersion = this.get('upgradeVersion') || App.defaultStackVersion;
-      var currentStack = {};
-      var upgradeStack = {};
-      $.ajax({
-        type: "GET",
-        url: url,
-        async: false,
-        dataType: 'json',
-        timeout: App.timeout,
-        success: function (data) {
-          var currentVersion = App.currentStackVersion.replace(/HDP-/, '');
-          var minUpgradeVersion = currentVersion;
-          upgradeVersion = upgradeVersion.replace(/HDP-/, '');
-          data.items.mapProperty('Versions.stack_version').forEach(function(version){
-            upgradeVersion = (upgradeVersion < version) ? version : upgradeVersion;
-          });
-          currentStack = data.items.findProperty('Versions.stack_version', currentVersion);
-          upgradeStack = data.items.findProperty('Versions.stack_version', upgradeVersion);
-          minUpgradeVersion = upgradeStack.Versions.min_upgrade_version;
-          if(minUpgradeVersion && (minUpgradeVersion > currentVersion)){
-            upgradeVersion = currentVersion;
-            upgradeStack = currentStack;
-          }
-          upgradeVersion = 'HDP-' + upgradeVersion;
-        },
-        error: function (request, ajaxOptions, error) {
-          console.log('Error message is: ' + request.responseText);
-        },
-        statusCode: require('data/statusCodes')
+      App.ajax.send({
+        name: 'cluster.update_upgrade_version',
+        sender: this,
+        success: 'updateUpgradeVersionSuccessCallback',
+        error: 'updateUpgradeVersionErrorCallback'
       });
-      this.set('upgradeVersion', upgradeVersion);
-      if(currentStack && upgradeStack){
-        this.parseServicesInfo(currentStack, upgradeStack);
-      } else {
-        console.log('HDP stack doesn\'t have services with defaultStackVersion');
-      }
     }
   }.observes('App.router.clusterController.isLoaded', 'App.currentStackVersion'),
+
+  updateUpgradeVersionSuccessCallback: function(data) {
+    var upgradeVersion = this.get('upgradeVersion') || App.defaultStackVersion;
+    var currentStack = {};
+    var upgradeStack = {};
+    var currentVersion = App.currentStackVersion.replace(/HDP-/, '');
+    var minUpgradeVersion = currentVersion;
+    upgradeVersion = upgradeVersion.replace(/HDP-/, '');
+    data.items.mapProperty('Versions.stack_version').forEach(function(version){
+      upgradeVersion = (upgradeVersion < version) ? version : upgradeVersion;
+    });
+    currentStack = data.items.findProperty('Versions.stack_version', currentVersion);
+    upgradeStack = data.items.findProperty('Versions.stack_version', upgradeVersion);
+    minUpgradeVersion = upgradeStack.Versions.min_upgrade_version;
+    if(minUpgradeVersion && (minUpgradeVersion > currentVersion)){
+      upgradeVersion = currentVersion;
+      upgradeStack = currentStack;
+    }
+    upgradeVersion = 'HDP-' + upgradeVersion;
+    this.set('upgradeVersion', upgradeVersion);
+    if(currentStack && upgradeStack) {
+      this.parseServicesInfo(currentStack, upgradeStack);
+    }
+    else {
+      console.log('HDP stack doesn\'t have services with defaultStackVersion');
+    }
+  },
+
+  updateUpgradeVersionErrorCallback: function(request, ajaxOptions, error) {
+    console.log('Error message is: ' + request.responseText);
+    console.log('HDP stack doesn\'t have services with defaultStackVersion');
+  },
+
   /**
    * parse services info(versions, description) by version
    */

+ 61 - 67
ambari-web/app/controllers/main/admin/security/add/step3.js

@@ -350,32 +350,30 @@ App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
   loadClusterConfigs: function () {
     var self = this;
     var url = App.apiPrefix + '/clusters/' + App.router.getClusterName();
-    $.ajax({
-      type: 'GET',
-      url: url,
-      timeout: 10000,
-      dataType: 'text',
-      success: function (data) {
-        var jsonData = jQuery.parseJSON(data);
-
-        //prepare tags to fetch all configuration for a service
-        self.get('content.services').forEach(function (_secureService) {
-          if (_secureService.serviceName !== 'GENERAL') {
-            self.setServiceTagNames(_secureService, jsonData.Clusters.desired_configs);
-          }
-        });
-        self.getAllConfigurations();
-      },
 
-      error: function (request, ajaxOptions, error) {
-        self.get('stages').findProperty('stage', 'stage3').set('isError', true);
-        console.log("TRACE: error code status is: " + request.status);
-      },
+    App.ajax.send({
+      name: 'admin.security.add.cluster_configs',
+      sender: this,
+      success: 'loadClusterConfigsSuccessCallback',
+      error: 'loadClusterConfigsErrorCallback'
+    });
+  },
 
-      statusCode: require('data/statusCodes')
+  loadClusterConfigsSuccessCallback: function (data) {
+    var self = this;
+    //prepare tags to fetch all configuration for a service
+    this.get('content.services').forEach(function (_secureService) {
+      if (_secureService.serviceName !== 'GENERAL') {
+        self.setServiceTagNames(_secureService, data.Clusters.desired_configs);
+      }
     });
+    this.getAllConfigurations();
   },
 
+  loadClusterConfigsErrorCallback: function (request, ajaxOptions, error) {
+    this.get('stages').findProperty('stage', 'stage3').set('isError', true);
+    console.log("TRACE: error code status is: " + request.status);
+  },
 
   /**
    * set tagnames for configuration of the *-site.xml
@@ -406,36 +404,34 @@ App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
   },
 
   applyConfigurationToCluster: function (data) {
-    var self = this;
-    var url = App.apiPrefix + '/clusters/' + App.router.getClusterName();
     var clusterData = {
       Clusters: {
         desired_config: data
       }
     };
-    $.ajax({
-      type: 'PUT',
-      url: url,
-      async: false,
-      dataType: 'text',
-      data: JSON.stringify(clusterData),
-      timeout: 5000,
-      success: function (data) {
-        self.set('noOfWaitingAjaxCalls', self.get('noOfWaitingAjaxCalls') - 1);
-        if (self.get('noOfWaitingAjaxCalls') == 0) {
-          var currentStage = self.get('stages').findProperty('stage', 'stage3');
-          currentStage.set('isSuccess', true);
-          currentStage.set('isCompleted', true);
-        }
-      },
-      error: function (request, ajaxOptions, error) {
-        self.get('stages').findProperty('stage', 'stage3').set('isError', true);
+    App.ajax.send({
+      name: 'admin.security.apply_configuration',
+      sender: this,
+      data: {
+        clusterData: clusterData
       },
-      statusCode: require('data/statusCodes')
+      success: 'applyConfigurationToClusterSuccessCallback',
+      error: 'applyConfigurationToClusterErrorCallback'
     });
+  },
 
+  applyConfigurationToClusterSuccessCallback: function (data) {
+    this.set('noOfWaitingAjaxCalls', this.get('noOfWaitingAjaxCalls') - 1);
+    if (this.get('noOfWaitingAjaxCalls') == 0) {
+      var currentStage = this.get('stages').findProperty('stage', 'stage3');
+      currentStage.set('isSuccess', true);
+      currentStage.set('isCompleted', true);
+    }
   },
 
+  applyConfigurationToClusterErrorCallback: function (request, ajaxOptions, error) {
+    this.get('stages').findProperty('stage', 'stage3').set('isError', true);
+  },
 
   /**
    * gets site config properties from server and sets it for every configuration
@@ -443,41 +439,38 @@ App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
    */
 
   getAllConfigurations: function () {
-    var self = this;
     var urlParams = [];
     this.get('serviceConfigTags').forEach(function (_tag) {
       urlParams.push('(type=' + _tag.siteName + '&tag=' + _tag.tagName + ')');
     }, this);
-    var url = App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/configurations?' + urlParams.join('|');
     if (urlParams.length > 0) {
-      $.ajax({
-        type: 'GET',
-        url: url,
-        async: true,
-        timeout: 10000,
-        dataType: 'json',
-        success: function (data) {
-          console.log("TRACE: In success function for the GET getServiceConfigsFromServer call");
-          console.log("TRACE: The url is: " + url);
-          self.get('serviceConfigTags').forEach(function (_tag) {
-            _tag.configs = data.items.findProperty('type', _tag.siteName).properties;
-          });
-          self.addSecureConfigs();
-          self.applyConfigurationsToCluster();
+      App.ajax.send({
+        name: 'admin.security.all_configurations',
+        sender: this,
+        data: {
+          urlParams: urlParams.join('|')
         },
-
-        error: function (request, ajaxOptions, error) {
-          self.get('stages').findProperty('stage', 'stage3').set('isError', true);
-          console.log("TRACE: In error function for the getServiceConfigsFromServer call");
-          console.log("TRACE: value of the url is: " + url);
-          console.log("TRACE: error code status is: " + request.status);
-        },
-
-        statusCode: require('data/statusCodes')
+        success: 'getAllConfigurationsSuccessCallback',
+        error: 'getAllConfigurationsErrorCallback'
       });
     }
   },
 
+  getAllConfigurationsSuccessCallback: function (data) {
+    console.log("TRACE: In success function for the GET getServiceConfigsFromServer call");
+    this.get('serviceConfigTags').forEach(function (_tag) {
+      _tag.configs = data.items.findProperty('type', _tag.siteName).properties;
+    });
+    this.addSecureConfigs();
+    this.applyConfigurationsToCluster();
+  },
+
+  getAllConfigurationsErrorCallback: function (request, ajaxOptions, error) {
+    this.get('stages').findProperty('stage', 'stage3').set('isError', true);
+    console.log("TRACE: In error function for the getServiceConfigsFromServer call");
+    console.log("TRACE: error code status is: " + request.status);
+  },
+
   addSecureConfigs: function () {
     this.get('serviceConfigTags').forEach(function (_serviceConfigTags, index) {
       _serviceConfigTags.newTagName = 'version' + (new Date).getTime();
@@ -485,7 +478,8 @@ App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
         this.get('globalProperties').forEach(function (_globalProperty) {
           _serviceConfigTags.configs[_globalProperty.name] = _globalProperty.value;
         }, this);
-      } else {
+      }
+      else {
         this.get('configs').filterProperty('id', 'site property').filterProperty('filename', _serviceConfigTags.siteName + '.xml').forEach(function (_config) {
           _serviceConfigTags.configs[_config.name] = _config.value;
         }, this);

+ 62 - 67
ambari-web/app/controllers/main/admin/security/disable.js

@@ -150,68 +150,63 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({
   },
 
   loadClusterConfigs: function () {
-    var self = this;
-    var url = App.apiPrefix + '/clusters/' + App.router.getClusterName();
-    $.ajax({
-      type: 'GET',
-      url: url,
-      timeout: 10000,
-      dataType: 'text',
-      success: function (data) {
-        var jsonData = jQuery.parseJSON(data);
-        //prepare tags to fetch all configuration for a service
-        self.get('secureServices').forEach(function (_secureService) {
-          self.setServiceTagNames(_secureService, jsonData.Clusters.desired_configs);
-        });
-        self.getAllConfigurations();
-      },
-
-      error: function (request, ajaxOptions, error) {
-        self.get('stages').findProperty('stage', 'stage3').set('isError', true);
-        console.log("TRACE: error code status is: " + request.status);
-      },
+    App.ajax.send({
+      name: 'admin.security.cluster_configs',
+      sender: this,
+      success: 'loadClusterConfigsSuccessCallback',
+      error: 'loadClusterConfigsErrorCallback'
+    });
+  },
 
-      statusCode: require('data/statusCodes')
+  loadClusterConfigsSuccessCallback: function (jsonData) {
+    var self = this;
+    //prepare tags to fetch all configuration for a service
+    this.get('secureServices').forEach(function (_secureService) {
+      self.setServiceTagNames(_secureService, jsonData.Clusters.desired_configs);
     });
+    this.getAllConfigurations();
+  },
+
+  loadClusterConfigsErrorCallback: function (request, ajaxOptions, error) {
+    this.get('stages').findProperty('stage', 'stage3').set('isError', true);
+    console.log("TRACE: error code status is: " + request.status);
   },
 
   getAllConfigurations: function () {
-    var self = this;
     var urlParams = [];
     this.get('serviceConfigTags').forEach(function (_tag) {
       urlParams.push('(type=' + _tag.siteName + '&tag=' + _tag.tagName + ')');
     }, this);
-    var url = App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/configurations?' + urlParams.join('|');
     if (urlParams.length > 0) {
-      $.ajax({
-        type: 'GET',
-        url: url,
-        async: true,
-        timeout: 10000,
-        dataType: 'json',
-        success: function (data) {
-          console.log("TRACE: In success function for the GET getServiceConfigsFromServer call");
-          console.log("TRACE: The url is: " + url);
-          self.get('serviceConfigTags').forEach(function (_tag) {
-            _tag.configs = data.items.findProperty('type', _tag.siteName).properties;
-          });
-          self.removeSecureConfigs();
-          self.applyConfigurationsToCluster();
-        },
-
-        error: function (request, ajaxOptions, error) {
-          self.get('stages').findProperty('stage', 'stage3').set('isError', true);
-          console.log("TRACE: In error function for the getServiceConfigsFromServer call");
-          console.log("TRACE: value of the url is: " + url);
-          console.log("TRACE: error code status is: " + request.status);
+      App.ajax.send({
+        name: 'admin.security.all_configurations',
+        sender: this,
+        data: {
+          urlParams: urlParams.join('|')
         },
-
-        statusCode: require('data/statusCodes')
+        success: 'getAllConfigurationsSuccessCallback',
+        error: 'getAllConfigurationsErrorCallback'
       });
     }
   },
 
-  loadSecureServices: function () {
+  getAllConfigurationsSuccessCallback: function(data) {
+    console.log("TRACE: In success function for the GET getServiceConfigsFromServer call");
+    this.get('serviceConfigTags').forEach(function (_tag) {
+      _tag.configs = data.items.findProperty('type', _tag.siteName).properties;
+    });
+    this.removeSecureConfigs();
+    this.applyConfigurationsToCluster();
+  },
+
+  getAllConfigurationsErrorCallback: function (request, ajaxOptions, error) {
+    this.get('stages').findProperty('stage', 'stage3').set('isError', true);
+    console.log("TRACE: In error function for the getServiceConfigsFromServer call");
+    console.log("TRACE: error code status is: " + request.status);
+  },
+
+
+loadSecureServices: function () {
     var secureServices = require('data/secure_configs');
     var installedServices = App.Service.find().mapProperty('serviceName');
     //General (only non service tab) tab is always displayed
@@ -231,35 +226,35 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({
   },
 
   applyConfigurationToCluster: function (data) {
-    var self = this;
-    var url = App.apiPrefix + '/clusters/' + App.router.getClusterName();
     var clusterData = {
       Clusters: {
         desired_config: data
       }
     };
-    $.ajax({
-      type: 'PUT',
-      url: url,
-      async: false,
-      dataType: 'text',
-      data: JSON.stringify(clusterData),
-      timeout: 5000,
-      success: function (data) {
-        self.set('noOfWaitingAjaxCalls', self.get('noOfWaitingAjaxCalls') - 1);
-        if (self.get('noOfWaitingAjaxCalls') == 0) {
-          var currentStage = self.get('stages').findProperty('stage', 'stage3');
-          currentStage.set('isSuccess', true);
-          currentStage.set('isCompleted', true);
-        }
-      },
-      error: function (request, ajaxOptions, error) {
-        self.get('stages').findProperty('stage', 'stage3').set('isError', true);
+    App.ajax.send({
+      name: 'admin.security.apply_configuration',
+      sender: this,
+      data: {
+        clusterData: clusterData
       },
-      statusCode: require('data/statusCodes')
+      success: 'applyConfigurationToClusterSuccessCallback',
+      error: 'applyConfigurationToClusterErrorCallback'
     });
   },
 
+  applyConfigurationToClusterSuccessCallback: function (data) {
+    this.set('noOfWaitingAjaxCalls', this.get('noOfWaitingAjaxCalls') - 1);
+    if (this.get('noOfWaitingAjaxCalls') == 0) {
+      var currentStage = this.get('stages').findProperty('stage', 'stage3');
+      currentStage.set('isSuccess', true);
+      currentStage.set('isCompleted', true);
+    }
+  },
+
+  applyConfigurationToClusterErrorCallback: function (request, ajaxOptions, error) {
+    this.get('stages').findProperty('stage', 'stage3').set('isError', true);
+  },
+
   getAllConfigsFromServer: function () {
     this.set('noOfWaitingAjaxCalls', this.get('serviceConfigTags').length - 1);
     this.get('serviceConfigTags').forEach(function (_serviceConfigTags) {

+ 51 - 46
ambari-web/app/controllers/main/host/configs_service.js

@@ -61,6 +61,10 @@ App.MainHostServiceConfigsController = App.MainServiceInfoConfigsController.exte
     this._super(newServiceConfigs);
   },
 
+  typeTagToHostMap: null,
+
+  configKeyToConfigMap: null,
+
   /**
    * This method will *not load* the overridden properties. However it will
    * replace the value shown for properties which this host has override for.
@@ -83,55 +87,56 @@ App.MainHostServiceConfigsController = App.MainServiceInfoConfigsController.exte
         }
       }
     }
+    this.set('typeTagToHostMap', typeTagToHostMap);
+    this.set('configKeyToConfigMap', configKeyToConfigMap);
     if (urlParams.length > 0) {
-      var hostOverridesConfigsUrl = this.getUrl('', '/configurations?' + urlParams.join('|'));
-      $.ajax({
-        type: 'GET',
-        url: hostOverridesConfigsUrl,
-        async: false,
-        timeout: 10000,
-        dataType: 'json',
-        success: function (data) {
-          console.debug("loadServiceConfigHostsOverrides(" + hostOverridesConfigsUrl + "): Data=", data);
-          data.items.forEach(function (config) {
-            var hostname = typeTagToHostMap[config.type + "///" + config.tag];
-            var properties = config.properties;
-            for ( var prop in properties) {
-              var serviceConfig = configKeyToConfigMap[prop];
-              var hostOverrideValue = properties[prop];
-              if (serviceConfig && serviceConfig.displayType === 'int') {
-                if (/\d+m$/.test(hostOverrideValue)) {
-                  hostOverrideValue = hostOverrideValue.slice(0, hostOverrideValue.length - 1);
-                }
-              } else if (serviceConfig && serviceConfig.displayType === 'checkbox') {
-                switch (hostOverrideValue) {
-                  case 'true':
-                    hostOverrideValue = true;
-                    break;
-                  case 'false':
-                    hostOverrideValue = false;
-                    break;
-                }
-              }
-              if (serviceConfig) {
-                // Value of this property is different for this host.
-                console.log("loadServiceConfigHostsOverrides(" + thisHostName + "): [" + hostname + "] OVERRODE(" + serviceConfig.name + "): " + serviceConfig.value + " -> " + hostOverrideValue);
-                serviceConfig.value = hostOverrideValue;
-                serviceConfig.defaultValue = hostOverrideValue;
-                serviceConfig.isOriginalSCP = false;
-                serviceConfig.selectedHostOptions = [thisHostName];
-              }
-            }
-          });
-          console.log("loadServiceConfigHostsOverrides(" + thisHostName + "): Finished loading.");
-        },
-        error: function (request, ajaxOptions, error) {
-          console.log("TRACE: loadServiceConfigHostsOverrides(" + thisHostName + "): ERROR");
-          console.log("TRACE: value of the url is: " + hostOverridesConfigsUrl);
-          console.log("TRACE: error code status is: " + request.status);
+      App.ajax.send({
+        name: 'host.service_config_hosts_overrides',
+        sender: this,
+        data: {
+          urlParams: urlParams.join('|')
         },
-        statusCode: require('data/statusCodes')
+        success: 'loadServiceConfigHostsOverridesSuccessCallback',
+        error: 'loadServiceConfigHostsOverridesErrorCallback'
       });
     }
+  },
+  loadServiceConfigHostsOverridesSuccessCallback: function (data) {
+    var typeTagToHostMap = this.get('typeTagToHostMap');
+    var configKeyToConfigMap = this.get('configKeyToConfigMap');
+    data.items.forEach(function (config) {
+      var hostname = typeTagToHostMap[config.type + "///" + config.tag];
+      var properties = config.properties;
+      for ( var prop in properties) {
+        var serviceConfig = configKeyToConfigMap[prop];
+        var hostOverrideValue = properties[prop];
+        if (serviceConfig && serviceConfig.displayType === 'int') {
+          if (/\d+m$/.test(hostOverrideValue)) {
+            hostOverrideValue = hostOverrideValue.slice(0, hostOverrideValue.length - 1);
+          }
+        } else if (serviceConfig && serviceConfig.displayType === 'checkbox') {
+          switch (hostOverrideValue) {
+            case 'true':
+              hostOverrideValue = true;
+              break;
+            case 'false':
+              hostOverrideValue = false;
+              break;
+          }
+        }
+        if (serviceConfig) {
+          // Value of this property is different for this host.
+          console.log("loadServiceConfigHostsOverrides(" + this.get('host.hostName') + "): [" + hostname + "] OVERRODE(" + serviceConfig.name + "): " + serviceConfig.value + " -> " + hostOverrideValue);
+          serviceConfig.value = hostOverrideValue;
+          serviceConfig.defaultValue = hostOverrideValue;
+          serviceConfig.isOriginalSCP = false;
+          serviceConfig.selectedHostOptions = [this.get('host.hostName')];
+        }
+      }
+    });
+    console.log("loadServiceConfigHostsOverrides(" + this.get('host.hostName') + "): Finished loading.");
+  },
+  loadServiceConfigHostsOverridesErrorCallback: function (request, ajaxOptions, error) {
+    console.log("TRACE: error code status is: " + request.status);
   }
 });

+ 26 - 37
ambari-web/app/controllers/main/service.js

@@ -74,8 +74,8 @@ App.MainServiceController = Em.ArrayController.extend({
       return;
     }
     var self = this;
-    App.showConfirmationPopup2(function() {
-      self.startAllServicesCall('startAllService');
+    App.showConfirmationPopup(function() {
+      self.allServicesCall('startAllService');
     });
   },
 
@@ -87,51 +87,40 @@ App.MainServiceController = Em.ArrayController.extend({
       return;
     }
     var self = this;
-    App.showConfirmationPopup2(function() {
-      self.startAllServicesCall('stopAllService');
+    App.showConfirmationPopup(function() {
+      self.allServicesCall('stopAllService');
     });
   },
 
-  startAllServicesCall: function(state){
-    var clusterName = App.router.get('applicationController').get('clusterName');
-    var method = 'PUT';
-    var url = App.apiPrefix + '/clusters/' + clusterName + '/services?ServiceInfo';
+  allServicesCall: function(state) {
     var data;
-    if(state == 'stopAllService'){
+    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 (App.testMode) {
-      url = this.get('mockDataPrefix') + '/poll_6.json';
-      method = 'GET';
-      this.numPolls = 6;
+    else {
+      data = '{"RequestInfo": {"context" :"'+ Em.I18n.t('requestInfo.startAllServices') +'"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}';
     }
 
-    $.ajax({
-      type: method,
-      url: url,
-      async: false,
-      data: data,
-      dataType: 'text',
-      timeout: App.timeout,
-      success: function (data) {
-        var jsonData = jQuery.parseJSON(data);
-        console.log("TRACE: Start/Stop all service -> In success function for the start/stop all Service call");
-        console.log("TRACE: Start/Stop all service -> value of the url is: " + url);
-        console.log("TRACE: Start/Stop all service -> value of the received data is: " + jsonData);
-        var requestId = jsonData.Requests.id;
-        console.log('requestId is: ' + requestId);
-
-        App.router.get('backgroundOperationsController').showPopup();
-      },
-      error: function () {
-        console.log("ERROR");
+    App.ajax.send({
+      name: 'service.start_stop',
+      sender: this,
+      data: {
+        data: data
       },
-
-      statusCode: require('data/statusCodes')
+      success: 'allServicesCallSuccessCallback',
+      error: 'allServicesCallErrorCallback'
     });
+  },
 
+  allServicesCallSuccessCallback: function(data) {
+    console.log("TRACE: Start/Stop all service -> In success function for the start/stop all Service call");
+    console.log("TRACE: Start/Stop all service -> value of the received data is: " + data);
+    var requestId = data.Requests.id;
+    console.log('requestId is: ' + requestId);
+
+    App.router.get('backgroundOperationsController').showPopup();
+  },
+  allServicesCallErrorCallback: function() {
+    console.log("ERROR");
   }
 })

+ 127 - 133
ambari-web/app/controllers/wizard.js

@@ -253,105 +253,103 @@ App.WizardController = Em.Controller.extend({
     this.set('content.cluster.oldRequestsId', []);
     this.set('content.cluster.requestId', null);
 
-    var self = this;
     var clusterName = this.get('content.cluster.name');
-    var url;
-    var method = (App.testMode) ? 'GET' : 'PUT';
     var data;
+    var name;
 
     switch (this.get('content.controllerName')) {
       case 'addHostController':
         if (isRetry) {
-          url = App.apiPrefix + '/clusters/' + clusterName + '/host_components?HostRoles/state=INSTALLED';
-        } else {
-          url = App.apiPrefix + '/clusters/' + clusterName + '/host_components?HostRoles/state=INIT';
+          name = 'wizard.install_services.add_host_controller.is_retry';
+        }
+        else {
+          name = 'wizard.install_services.add_host_controller.not_is_retry';
         }
         data = '{"RequestInfo": {"context" :"'+ Em.I18n.t('requestInfo.installComponents') +'"}, "Body": {"HostRoles": {"state": "INSTALLED"}}}';
         break;
       case 'installerController':
       default:
         if (isRetry) {
-          url = (App.testMode) ? '/data/wizard/deploy/2_hosts/poll_1.json' : App.apiPrefix + '/clusters/' + clusterName + '/host_components?HostRoles/state!=INSTALLED';
+          name = 'wizard.install_services.installer_controller.is_retry';
           data = '{"RequestInfo": {"context" :"'+ Em.I18n.t('requestInfo.installComponents') +'"}, "Body": {"HostRoles": {"state": "INSTALLED"}}}';
-        } else {
-          url = (App.testMode) ? '/data/wizard/deploy/2_hosts/poll_1.json' : App.apiPrefix + '/clusters/' + clusterName + '/services?ServiceInfo/state=INIT';
+        }
+        else {
+          name = 'wizard.install_services.installer_controller.not_is_retry';
           data = '{"RequestInfo": {"context" :"'+ Em.I18n.t('requestInfo.installServices') +'"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}';
         }
         break;
     }
 
-    $.ajax({
-      type: method,
-      url: url,
-      data: data,
-      async: false,
-      dataType: 'text',
-      timeout: App.timeout,
-      success: function (data) {
-        var jsonData = jQuery.parseJSON(data);
-        var installStartTime = new Date().getTime();
-        console.log("TRACE: In success function for the installService call");
-        console.log("TRACE: value of the url is: " + url);
-        if (jsonData) {
-          var requestId = jsonData.Requests.id;
-          console.log('requestId is: ' + requestId);
-          var clusterStatus = {
-            status: 'PENDING',
-            requestId: requestId,
-            isInstallError: false,
-            isCompleted: false,
-            installStartTime: installStartTime
-          };
-          self.saveClusterStatus(clusterStatus);
-        } else {
-          console.log('ERROR: Error occurred in parsing JSON data');
-        }
+    App.ajax.send({
+      name: name,
+      sender: this,
+      data: {
+        data: data,
+        cluster: clusterName
       },
+      success: 'installServicesSuccessCallback',
+      error: 'installServicesErrorCallback'
+    });
+  },
 
-      error: function (request, ajaxOptions, error) {
-        console.log("TRACE: In error function for the installService call");
-        console.log("TRACE: value of the url is: " + url);
-        console.log("TRACE: error code status is: " + request.status);
-        console.log('Error message is: ' + request.responseText);
-        var clusterStatus = {
-          status: 'PENDING',
-          isInstallError: false,
-          isCompleted: false
-        };
-
-        self.saveClusterStatus(clusterStatus);
-      },
+  installServicesSuccessCallback: function (jsonData) {
+    var installStartTime = new Date().getTime();
+    console.log("TRACE: In success function for the installService call");
+    if (jsonData) {
+      var requestId = jsonData.Requests.id;
+      console.log('requestId is: ' + requestId);
+      var clusterStatus = {
+        status: 'PENDING',
+        requestId: requestId,
+        isInstallError: false,
+        isCompleted: false,
+        installStartTime: installStartTime
+      };
+      this.saveClusterStatus(clusterStatus);
+    } else {
+      console.log('ERROR: Error occurred in parsing JSON data');
+    }
+  },
 
-      statusCode: require('data/statusCodes')
-    });
+  installServicesErrorCallback: function (request, ajaxOptions, error) {
+    console.log("TRACE: In error function for the installService call");
+    console.log("TRACE: error code status is: " + request.status);
+    console.log('Error message is: ' + request.responseText);
+    var clusterStatus = {
+      status: 'PENDING',
+      isInstallError: false,
+      isCompleted: false
+    };
+    this.saveClusterStatus(clusterStatus);
   },
 
+  bootstrapRequestId: null,
+
   /*
    Bootstrap selected hosts.
    */
   launchBootstrap: function (bootStrapData) {
-    var self = this;
-    var requestId = null;
-    var method = App.testMode ? 'GET' : 'POST';
-    var url = App.testMode ? '/data/wizard/bootstrap/bootstrap.json' : App.apiPrefix + '/bootstrap';
-    $.ajax({
-      type: method,
-      url: url,
-      async: false,
-      data: bootStrapData,
-      timeout: App.timeout,
-      contentType: 'application/json',
-      success: function (data) {
-        console.log("TRACE: POST bootstrap succeeded");
-        requestId = data.requestId;
+    App.ajax.send({
+      name: 'wizard.launch_bootstrap',
+      sender: this,
+      data: {
+        bootStrapData: bootStrapData
       },
-      error: function () {
-        console.log("ERROR: POST bootstrap failed");
-        alert('Bootstrap call failed.  Please try again.');
-      },
-      statusCode: require('data/statusCodes')
+      success: 'launchBootstrapSuccessCallback',
+      error: 'launchBootstrapErrorCallback'
     });
-    return requestId;
+
+    return this.get('bootstrapRequestId');
+  },
+
+  launchBootstrapSuccessCallback: function (data) {
+    console.log("TRACE: POST bootstrap succeeded");
+    this.set('bootstrapRequestId', data.requestId);
+  },
+
+  launchBootstrapErrorCallback: function () {
+    console.log("ERROR: POST bootstrap failed");
+    alert('Bootstrap call failed. Please try again.');
   },
 
   /**
@@ -423,77 +421,75 @@ App.WizardController = Em.Controller.extend({
     sshKey: "", //string
     bootRequestId: null //string
   },
+
+  loadedServiceComponents: null,
+
   /**
    * Generate serviceComponents as pr the stack definition  and save it to localdata
    * called form stepController step4WizardController
    */
-  loadServiceComponents: function (displayOrderConfig, apiUrl) {
-    var result = null;
-    var method = 'GET';
-    var testUrl = '/data/wizard/stack/hdp/version/1.3.0.json';
-    var url = (App.testMode) ? testUrl : App.apiPrefix + apiUrl + '?fields=stackServices/StackServices';
-    $.ajax({
-      type: method,
-      url: url,
-      async: false,
-      dataType: 'text',
-      timeout: App.timeout,
-      success: function (data) {
-        var jsonData = jQuery.parseJSON(data);
-        console.log("TRACE: getService ajax call  -> In success function for the getServiceComponents call");
-        console.log("TRACE: jsonData.services : " + jsonData.services);
-
-        // Creating Model
-        var Service = Ember.Object.extend({
-          serviceName: null,
-          displayName: null,
-          isDisabled: true,
+  loadServiceComponents: function () {
+    App.ajax.send({
+      name: 'wizard.service_components',
+      sender: this,
+      data: {
+        stackUrl: App.get('stackVersionURL')
+      },
+      success: 'loadServiceComponentsSuccessCallback',
+      error: 'loadServiceComponentsErrorCallback'
+    });
+    return this.get('loadedServiceComponents');
+  },
+
+  loadServiceComponentsSuccessCallback: function (jsonData) {
+    var displayOrderConfig = require('data/services');
+    console.log("TRACE: getService ajax call  -> In success function for the getServiceComponents call");
+    console.log("TRACE: jsonData.services : " + jsonData.services);
+
+    // Creating Model
+    var Service = Ember.Object.extend({
+      serviceName: null,
+      displayName: null,
+      isDisabled: true,
+      isSelected: true,
+      isInstalled: false,
+      description: null,
+      version: null
+    });
+
+    var data = [];
+
+    // loop through all the service components
+    for (var i = 0; i < displayOrderConfig.length; i++) {
+      var entry = jsonData.services.findProperty("name", displayOrderConfig[i].serviceName);
+      if (entry) {
+        var myService = Service.create({
+          serviceName: entry.name,
+          displayName: displayOrderConfig[i].displayName,
+          isDisabled: i === 0,
           isSelected: true,
           isInstalled: false,
-          description: null,
-          version: null
+          isHidden: displayOrderConfig[i].isHidden,
+          description: entry.comment,
+          version: entry.version
         });
 
-        var data = [];
-
-        // loop through all the service components
-        for (var i = 0; i < displayOrderConfig.length; i++) {
-          var entry = jsonData.stackServices.findProperty("StackServices.service_name", displayOrderConfig[i].serviceName);
-          if (entry) {
-            entry = entry.StackServices;
-            var myService = Service.create({
-              serviceName: entry.service_name,
-              displayName: displayOrderConfig[i].displayName,
-              isDisabled: i === 0,
-              isSelected: true,
-              isInstalled: false,
-              isHidden: displayOrderConfig[i].isHidden,
-              description: entry.comments,
-              version: entry.service_version
-            });
-
-            data.push(myService);
-          }
-          else {
-            console.warn('Service not found - ', displayOrderConfig[i].serviceName);
-          }
-        }
-
-        result = data;
-        console.log('TRACE: service components: ' + JSON.stringify(data));
+        data.push(myService);
+      }
+      else {
+        console.warn('Service not found - ', displayOrderConfig[i].serviceName);
+      }
+    }
 
-      },
+    this.set('loadedServiceComponents', data);
+    console.log('TRACE: service components: ' + JSON.stringify(data));
 
-      error: function (request, ajaxOptions, error) {
-        console.log("TRACE: STep5 -> In error function for the getServiceComponents call");
-        console.log("TRACE: STep5 -> value of the url is: " + url);
-        console.log("TRACE: STep5 -> error code status is: " + request.status);
-        console.log('Step8: Error message is: ' + request.responseText);
-      },
+  },
 
-      statusCode: require('data/statusCodes')
-    });
-    return result;
+  loadServiceComponentsErrorCallback: function (request, ajaxOptions, error) {
+    console.log("TRACE: STep5 -> In error function for the getServiceComponents call");
+    console.log("TRACE: STep5 -> error code status is: " + request.status);
+    console.log('Step8: Error message is: ' + request.responseText);
   },
 
   loadServicesFromServer: function() {
@@ -501,9 +497,7 @@ App.WizardController = Em.Controller.extend({
     if (services) {
       return;
     }
-    var displayOrderConfig = require('data/services');
-    var apiUrl = App.get('stack2VersionURL');
-    var apiService = this.loadServiceComponents(displayOrderConfig, apiUrl);
+    var apiService = this.loadServiceComponents();
     this.set('content.services', apiService);
     App.db.setService(apiService);
   },

+ 104 - 94
ambari-web/app/controllers/wizard/stack_upgrade/step3_controller.js

@@ -142,12 +142,7 @@ App.StackUpgradeStep3Controller = Em.Controller.extend({
    * run stop services
    */
   stopServices: function () {
-    var clusterName = this.get('content.cluster.name');
-    var url = App.apiPrefix + '/clusters/' + clusterName + '/services?ServiceInfo/state=STARTED';
-    var data = '{"RequestInfo": {"context": "'+ Em.I18n.t("requestInfo.stopAllServices") +'"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}';
-    var method = 'PUT';
     var process = this.get('processes').findProperty('name', 'STOP_SERVICES');
-    var self = this;
     process.set('isRunning', true);
     if (App.testMode) {
       this.startPolling();
@@ -156,43 +151,43 @@ App.StackUpgradeStep3Controller = Em.Controller.extend({
         status: 'STOPPING_SERVICES',
         isCompleted: false
       });
-    } else {
-      $.ajax({
-        type: method,
-        url: url,
-        async: false,
-        data: data,
-        dataType: 'text',
-        timeout: App.timeout,
-        success: function (data) {
-          var requestId = jQuery.parseJSON(data).Requests.id;
-          var clusterStatus = {
-            requestId: requestId,
-            status: 'STOPPING_SERVICES',
-            isCompleted: false
-          };
-          process.set('status', 'IN_PROGRESS');
-          self.saveClusterStatus(clusterStatus);
-          self.startPolling();
-          console.log('Call to stop service successful')
-        },
-        error: function () {
-          self.finishProcess(process, 'FAILED');
-          process.set('status', 'FAILED');
-          console.log("Call to stop services failed");
+    }
+    else {
+      var data = '{"RequestInfo": {"context": "'+ Em.I18n.t("requestInfo.stopAllServices") +'"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}';
+      App.ajax.send({
+        name: 'admin.stack_upgrade.stop_services',
+        sender: this,
+        data: {
+          data: data
         },
-        statusCode: require('data/statusCodes')
+        success: 'stopServicesSuccessCallback',
+        error: 'stopServicesErrorCallback'
       });
     }
   },
+  stopServicesSuccessCallback: function (data) {
+    var process = this.get('processes').findProperty('name', 'STOP_SERVICES');
+    var requestId = data.Requests.id;
+    var clusterStatus = {
+      requestId: requestId,
+      status: 'STOPPING_SERVICES',
+      isCompleted: false
+    };
+    process.set('status', 'IN_PROGRESS');
+    this.saveClusterStatus(clusterStatus);
+    this.startPolling();
+    console.log('Call to stop service successful')
+  },
+  stopServicesErrorCallback: function () {
+    var process = this.get('processes').findProperty('name', 'STOP_SERVICES');
+    this.finishProcess(process, 'FAILED');
+    process.set('status', 'FAILED');
+    console.log("Call to stop services failed");
+  },
   /**
    * send request to run upgrade all services
    */
   runUpgrade: function () {
-    var method = "PUT";
-    var url = App.apiPrefix + '/clusters/' + this.get('content.cluster.name');
-    var self = this;
-    var data = '{"Clusters": {"version" : "' + this.get('content.upgradeVersion') + '"}}';
     var process = this.get('processes').findProperty('name', 'UPGRADE_SERVICES');
     process.set('isRunning', true);
     if (App.testMode) {
@@ -202,34 +197,39 @@ App.StackUpgradeStep3Controller = Em.Controller.extend({
         status: 'STACK_UPGRADING',
         isCompleted: false
       });
-    } else {
-      $.ajax({
-        type: method,
-        url: url,
-        async: false,
-        data: data,
-        dataType: 'text',
-        timeout: App.timeout,
-        success: function (data) {
-          var jsonData = jQuery.parseJSON(data);
-          var requestId = jsonData.Requests.id;
-          var clusterStatus = {
-            status: 'STACK_UPGRADING',
-            requestId: requestId,
-            isCompleted: false
-          };
-          process.set('status', 'IN_PROGRESS');
-          self.saveClusterStatus(clusterStatus);
-          self.startPolling();
-        },
-        error: function (request, ajaxOptions, error) {
-          self.finishProcess(process, 'FAILED');
-          process.set('status', 'FAILED');
+    }
+    else {
+      var data = '{"Clusters": {"version" : "' + this.get('content.upgradeVersion') + '"}}';
+      App.ajax.send({
+        name: 'admin.stack_upgrade.run_upgrade',
+        sender: this,
+        data: {
+          data: data
         },
-        statusCode: require('data/statusCodes')
+        success: 'runUpgradeSuccessCallback',
+        error: 'runUpgradeErrorCallback'
       });
     }
   },
+  runUpgradeSuccessCallback: function (jsonData) {
+    var process = this.get('processes').findProperty('name', 'UPGRADE_SERVICES');
+    var requestId = jsonData.Requests.id;
+    var clusterStatus = {
+      status: 'STACK_UPGRADING',
+      requestId: requestId,
+      isCompleted: false
+    };
+    process.set('status', 'IN_PROGRESS');
+    this.saveClusterStatus(clusterStatus);
+    this.startPolling();
+  },
+
+  runUpgradeErrorCallback: function (request, ajaxOptions, error) {
+    var process = this.get('processes').findProperty('name', 'UPGRADE_SERVICES');
+    this.finishProcess(process, 'FAILED');
+    process.set('status', 'FAILED');
+  },
+
   /**
    * start polling tasks for current process
    */
@@ -253,17 +253,17 @@ App.StackUpgradeStep3Controller = Em.Controller.extend({
     var simulateAttempt = this.get('simulateAttempt');
     var process = this.get('processes').findProperty('isRunning', true);
     var upgradeURLs = [
-      '/data/wizard/upgrade/poll_1.json',
-      '/data/wizard/upgrade/poll_2.json',
-      '/data/wizard/upgrade/poll_3.json',
-      '/data/wizard/upgrade/poll_4.json',
-      '/data/wizard/upgrade/poll_5.json'
+      '/upgrade/poll_1.json',
+      '/upgrade/poll_2.json',
+      '/upgrade/poll_3.json',
+      '/upgrade/poll_4.json',
+      '/upgrade/poll_5.json'
     ];
     var stopURLs = [
-      '/data/wizard/stop_services/poll_1.json',
-      '/data/wizard/stop_services/poll_2.json',
-      '/data/wizard/stop_services/poll_3.json',
-      '/data/wizard/stop_services/poll_4.json'
+      '/stop_services/poll_1.json',
+      '/stop_services/poll_2.json',
+      '/stop_services/poll_3.json',
+      '/stop_services/poll_4.json'
     ];
     if(process.get('name') == 'STOP_SERVICES'){
       if(simulateAttempt < 4){
@@ -291,41 +291,51 @@ App.StackUpgradeStep3Controller = Em.Controller.extend({
    * poll server for tasks, which contain process progress data
    * @param interval
    */
-  doPoll: function(interval){
-    var url = this.getUrl();
+  doPoll: function(interval) {
     var self = this;
     var pollInterval = interval || self.POLL_INTERVAL;
     if (self.get('isPolling')) {
       setTimeout(function () {
-        $.ajax({
-          type: 'GET',
-          url: url,
-          async: true,
-          timeout: App.timeout,
-          dataType: 'json',
-          success: function (data) {
-            var result = self.parseTasks(data);
-            if(result){
-              if (App.testMode) {
-                self.simulatePolling();
-              } else {
-                self.doPoll();
-              }
-            }
-          },
-          error: function () {
-            console.log('ERROR: poll request failed')
+
+        App.ajax.send({
+          name: 'admin.stack_upgrade.do_poll',
+          sender: self,
+          data: {
+            cluster: self.get('content.cluster.name'),
+            requestId: self.get('content.cluster.requestId'),
+            mock: self.get('mockUrl')
           },
-          statusCode: require('data/statusCodes')
-        }).retry({times: App.maxRetries, timeout: App.timeout}).then(null,
-          function () {
-            App.showReloadPopup();
-            console.log('Install services all retries failed');
-          }
-        );
+          success: 'doPollSuccessCallback',
+          error: 'doPollErrorCallback'
+        }).retry({
+            times: App.maxRetries,
+            timeout: App.timeout
+          }).then(
+            null,
+            function () {
+              App.showReloadPopup();
+              console.log('Install services all retries failed');
+            });
       }, pollInterval);
     }
   },
+
+  doPollSuccessCallback: function (data) {
+    var result = this.parseTasks(data);
+    if(result){
+      if (App.testMode) {
+        this.simulatePolling();
+      }
+      else {
+        this.doPoll();
+      }
+    }
+  },
+
+  doPollErrorCallback: function () {
+    console.log('ERROR: poll request failed')
+  },
+
   /**
    * parse tasks from poll
    * change status, message, progress on services according to tasks

+ 189 - 178
ambari-web/app/controllers/wizard/step3_controller.js

@@ -290,61 +290,69 @@ App.WizardStep3Controller = Em.Controller.extend({
       return;
     }
     this.numPolls++;
-    var self = this;
-    var url = App.testMode ? '/data/wizard/bootstrap/poll_' + this.numPolls + '.json' : App.apiPrefix + '/bootstrap/' + this.get('content.installOptions.bootRequestId');
-    $.ajax({
-      type: 'GET',
-      url: url,
-      timeout: App.timeout,
-      success: function (data) {
-        if (data.hostsStatus !== null) {
-          // in case of bootstrapping just one host, the server returns an object rather than an array, so
-          // force into an array
-          if (!(data.hostsStatus instanceof Array)) {
-            data.hostsStatus = [ data.hostsStatus ];
-          }
-          console.log("TRACE: In success function for the GET bootstrap call");
-          var keepPolling = self.parseHostInfo(data.hostsStatus);
 
-          // Single host : if the only hostname is invalid (data.status == 'ERROR')
-          // Multiple hosts : if one or more hostnames are invalid
-          // following check will mark the bootStatus as 'FAILED' for the invalid hostname
-          if (data.status == 'ERROR' || data.hostsStatus.length != self.get('bootHosts').length) {
+    App.ajax.send({
+      name: 'wizard.step3.bootstrap',
+      sender: this,
+      data: {
+        bootRequestId: this.get('content.installOptions.bootRequestId'),
+        numPolls: this.numPolls
+      },
+      success: 'doBootstrapSuccessCallback'
+    }).
+      retry({
+        times: App.maxRetries,
+        timeout: App.timeout
+      }).
+      then(
+        null,
+        function () {
+          App.showReloadPopup();
+          console.log('Bootstrap failed');
+        }
+      );
+  },
 
-            var hosts = self.get('bootHosts');
+  doBootstrapSuccessCallback: function (data) {
+    if (data.hostsStatus !== null) {
+      // in case of bootstrapping just one host, the server returns an object rather than an array, so
+      // force into an array
+      if (!(data.hostsStatus instanceof Array)) {
+        data.hostsStatus = [ data.hostsStatus ];
+      }
+      console.log("TRACE: In success function for the GET bootstrap call");
+      var keepPolling = this.parseHostInfo(data.hostsStatus);
 
-            for (var i = 0; i < hosts.length; i++) {
+      // Single host : if the only hostname is invalid (data.status == 'ERROR')
+      // Multiple hosts : if one or more hostnames are invalid
+      // following check will mark the bootStatus as 'FAILED' for the invalid hostname
+      if (data.status == 'ERROR' || data.hostsStatus.length != this.get('bootHosts').length) {
 
-              var isValidHost = data.hostsStatus.someProperty('hostName', hosts[i].get('name'));
-              if(hosts[i].get('bootStatus') !== 'REGISTERED'){
-                if (!isValidHost) {
-                  hosts[i].set('bootStatus', 'FAILED');
-                  hosts[i].set('bootLog', Em.I18n.t('installer.step3.hosts.bootLog.failed'));
-                }
-              }
-            }
-          }
+        var hosts = this.get('bootHosts');
 
-          if (data.hostsStatus.someProperty('status', 'DONE') || data.hostsStatus.someProperty('status', 'FAILED')) {
-            // kicking off registration polls after at least one host has succeeded
-            self.startRegistration();
-          }
-          if (keepPolling) {
-            window.setTimeout(function () {
-              self.doBootstrap()
-            }, 3000);
-            return;
+        for (var i = 0; i < hosts.length; i++) {
+
+          var isValidHost = data.hostsStatus.someProperty('hostName', hosts[i].get('name'));
+          if(hosts[i].get('bootStatus') !== 'REGISTERED'){
+            if (!isValidHost) {
+              hosts[i].set('bootStatus', 'FAILED');
+              hosts[i].set('bootLog', Em.I18n.t('installer.step3.hosts.bootLog.failed'));
+            }
           }
         }
-      },
-      statusCode: require('data/statusCodes')
-    }).retry({times: App.maxRetries, timeout: App.timeout}).then(null,
-      function () {
-        App.showReloadPopup();
-        console.log('Bootstrap failed');
       }
-    );
 
+      if (data.hostsStatus.someProperty('status', 'DONE') || data.hostsStatus.someProperty('status', 'FAILED')) {
+        // kicking off registration polls after at least one host has succeeded
+        this.startRegistration();
+      }
+      if (keepPolling) {
+        var self = this;
+        window.setTimeout(function () {
+          self.doBootstrap()
+        }, 3000);
+      }
+    }
   },
 
   /*
@@ -368,88 +376,94 @@ App.WizardStep3Controller = Em.Controller.extend({
     if (this.get('stopBootstrap')) {
       return;
     }
-    var self = this;
+    App.ajax.send({
+      name: 'wizard.step3.is_hosts_registered',
+      sender: this,
+      success: 'isHostsRegisteredSuccessCallback'
+    }).
+      retry({
+        times: App.maxRetries,
+        timeout: App.timeout
+      }).
+        then(
+          null,
+          function () {
+            App.showReloadPopup();
+            console.log('Error: Getting registered host information from the server');
+          }
+        );
+  },
+
+  isHostsRegisteredSuccessCallback: function (data) {
+    console.log('registration attempt...');
     var hosts = this.get('bootHosts');
-    var url = App.testMode ? '/data/wizard/bootstrap/single_host_registration.json' : App.apiPrefix + '/hosts';
-
-    $.ajax({
-      type: 'GET',
-      url: url,
-      timeout: App.timeout,
-      success: function (data) {
-        console.log('registration attempt...');
-        var jsonData = App.testMode ? data : jQuery.parseJSON(data);
-        if (!jsonData) {
-          console.log("Error: jsonData is null");
-          return;
-        }
+    var jsonData = data;
+    if (!jsonData) {
+      console.warn("Error: jsonData is null");
+      return;
+    }
 
-        // keep polling until all hosts have registered/failed, or registrationTimeout seconds after the last host finished bootstrapping
-        var stopPolling = true;
-        hosts.forEach(function (_host, index) {
-          // Change name of first host for test mode.
-          if (App.testMode) {
-            if (index == 0) {
-              _host.set('name', 'localhost.localdomain');
-            }
-          }
-          // actions to take depending on the host's current bootStatus
-          // RUNNING - bootstrap is running; leave it alone
-          // DONE - bootstrap is done; transition to REGISTERING
-          // REGISTERING - bootstrap is done but has not registered; transition to REGISTERED if host found in polling API result
-          // REGISTERED - bootstrap and registration is done; leave it alone
-          // FAILED - either bootstrap or registration failed; leave it alone
-          console.log(_host.name + ' bootStatus=' + _host.get('bootStatus'));
-          switch (_host.get('bootStatus')) {
-            case 'DONE':
-              _host.set('bootStatus', 'REGISTERING');
-              _host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + Em.I18n.t('installer.step3.hosts.bootLog.registering'));
-              // update registration timestamp so that the timeout is computed from the last host that finished bootstrapping
-              self.set('registrationStartedAt', new Date().getTime());
-              stopPolling = false;
-              break;
-            case 'REGISTERING':
-              if (jsonData.items.someProperty('Hosts.host_name', _host.name)) {
-                console.log(_host.name + ' has been registered');
-                _host.set('bootStatus', 'REGISTERED');
-                _host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + Em.I18n.t('installer.step3.hosts.bootLog.registering'));
-              } else {
-                console.log(_host.name + ' is registering...');
-                stopPolling = false;
-              }
-              break;
-            case 'RUNNING':
-              stopPolling = false;
-              break;
-            case 'REGISTERED':
-            case 'FAILED':
-            default:
-              break;
-          }
-        }, this);
-
-        if (stopPolling) {
-          self.getHostInfo();
-        } else if (hosts.someProperty('bootStatus', 'RUNNING') || new Date().getTime() - self.get('registrationStartedAt') < self.get('registrationTimeoutSecs') * 1000) {
-          // we want to keep polling for registration status if any of the hosts are still bootstrapping (so we check for RUNNING).
-          window.setTimeout(function () {
-            self.isHostsRegistered();
-          }, 3000);
-        } else {
-          // registration timed out.  mark all REGISTERING hosts to FAILED
-          console.log('registration timed out');
-          hosts.filterProperty('bootStatus', 'REGISTERING').forEach(function (_host) {
-            _host.set('bootStatus', 'FAILED');
-            _host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + Em.I18n.t('installer.step3.hosts.bootLog.failed'));
-          });
-          self.getHostInfo();
+    // keep polling until all hosts have registered/failed, or registrationTimeout seconds after the last host finished bootstrapping
+    var stopPolling = true;
+    hosts.forEach(function (_host, index) {
+      // Change name of first host for test mode.
+      if (App.testMode) {
+        if (index == 0) {
+          _host.set('name', 'localhost.localdomain');
         }
-      },
-      statusCode: require('data/statusCodes')
-    }).retry({times: App.maxRetries, timeout: App.timeout}).then(null, function () {
-        App.showReloadPopup();
-        console.log('Error: Getting registered host information from the server');
+      }
+      // actions to take depending on the host's current bootStatus
+      // RUNNING - bootstrap is running; leave it alone
+      // DONE - bootstrap is done; transition to REGISTERING
+      // REGISTERING - bootstrap is done but has not registered; transition to REGISTERED if host found in polling API result
+      // REGISTERED - bootstrap and registration is done; leave it alone
+      // FAILED - either bootstrap or registration failed; leave it alone
+      console.log(_host.name + ' bootStatus=' + _host.get('bootStatus'));
+      switch (_host.get('bootStatus')) {
+        case 'DONE':
+          _host.set('bootStatus', 'REGISTERING');
+          _host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + Em.I18n.t('installer.step3.hosts.bootLog.registering'));
+          // update registration timestamp so that the timeout is computed from the last host that finished bootstrapping
+          this.set('registrationStartedAt', new Date().getTime());
+          stopPolling = false;
+          break;
+        case 'REGISTERING':
+          if (jsonData.items.someProperty('Hosts.host_name', _host.name)) {
+            console.log(_host.name + ' has been registered');
+            _host.set('bootStatus', 'REGISTERED');
+            _host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + Em.I18n.t('installer.step3.hosts.bootLog.registering'));
+          } else {
+            console.log(_host.name + ' is registering...');
+            stopPolling = false;
+          }
+          break;
+        case 'RUNNING':
+          stopPolling = false;
+          break;
+        case 'REGISTERED':
+        case 'FAILED':
+        default:
+          break;
+      }
+    }, this);
+
+    if (stopPolling) {
+      this.getHostInfo();
+    } else if (hosts.someProperty('bootStatus', 'RUNNING') || new Date().getTime() - this.get('registrationStartedAt') < this.get('registrationTimeoutSecs') * 1000) {
+      // we want to keep polling for registration status if any of the hosts are still bootstrapping (so we check for RUNNING).
+      var self = this;
+      window.setTimeout(function () {
+        self.isHostsRegistered();
+      }, 3000);
+    } else {
+      // registration timed out.  mark all REGISTERING hosts to FAILED
+      console.log('registration timed out');
+      hosts.filterProperty('bootStatus', 'REGISTERING').forEach(function (_host) {
+        _host.set('bootStatus', 'FAILED');
+        _host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + Em.I18n.t('installer.step3.hosts.bootLog.failed'));
       });
+      this.getHostInfo();
+    }
   },
 
   registerErrPopup: function (header, message) {
@@ -470,44 +484,39 @@ App.WizardStep3Controller = Em.Controller.extend({
    * Get disk info and cpu count of booted hosts from server
    */
   getHostInfo: function () {
-    var self = this;
-    var kbPerGb = 1024;
-    var hosts = this.get('bootHosts');
-    var url = App.testMode ? '/data/wizard/bootstrap/two_hosts_information.json' : App.apiPrefix + '/hosts?fields=Hosts/total_mem,Hosts/cpu_count,Hosts/disk_info,Hosts/last_agent_env';
-    var method = 'GET';
-    $.ajax({
-      type: 'GET',
-      url: url,
-      contentType: 'application/json',
-      timeout: App.timeout,
-      success: function (data) {
-        var jsonData = (App.testMode) ? data : jQuery.parseJSON(data);
-        self.parseWarnings(jsonData);
-        hosts.forEach(function (_host) {
-          var host = (App.testMode) ? jsonData.items[0] : jsonData.items.findProperty('Hosts.host_name', _host.name);
-          if (App.skipBootstrap) {
-            _host.cpu = 2;
-            _host.memory = ((parseInt(2000000))).toFixed(2);
-            _host.disk_info = [{"mountpoint": "/", "type":"ext4"},{"mountpoint": "/grid/0", "type":"ext4"}, {"mountpoint": "/grid/1", "type":"ext4"}, {"mountpoint": "/grid/2", "type":"ext4"}];
-          } else if (host) {
-            _host.cpu = host.Hosts.cpu_count;
-            _host.memory = ((parseInt(host.Hosts.total_mem))).toFixed(2);
-            _host.disk_info = host.Hosts.disk_info;
-
-            console.log("The value of memory is: " + _host.memory);
-          }
-        });
-        self.set('bootHosts', hosts);
-        console.log("The value of hosts: " + JSON.stringify(hosts));
-        self.stopRegistration();
-      },
+    App.ajax.send({
+      name: 'wizard.step3.host_info',
+      sender: this,
+      success: 'getHostInfoSuccessCallback',
+      error: 'getHostInfoErrorCallback'
+    });
+  },
 
-      error: function () {
-        console.log('INFO: Getting host information(cpu_count and total_mem) from the server failed');
-        self.registerErrPopup(Em.I18n.t('installer.step3.hostInformation.popup.header'), Em.I18n.t('installer.step3.hostInformation.popup.body'));
-      },
-      statusCode: require('data/statusCodes')
+  getHostInfoSuccessCallback: function (jsonData) {
+    var hosts = this.get('bootHosts');
+    this.parseWarnings(jsonData);
+    hosts.forEach(function (_host) {
+      var host = (App.testMode) ? jsonData.items[0] : jsonData.items.findProperty('Hosts.host_name', _host.name);
+      if (App.skipBootstrap) {
+        _host.cpu = 2;
+        _host.memory = ((parseInt(2000000))).toFixed(2);
+        _host.disk_info = [{"mountpoint": "/", "type":"ext4"},{"mountpoint": "/grid/0", "type":"ext4"}, {"mountpoint": "/grid/1", "type":"ext4"}, {"mountpoint": "/grid/2", "type":"ext4"}];
+      } else if (host) {
+        _host.cpu = host.Hosts.cpu_count;
+        _host.memory = ((parseInt(host.Hosts.total_mem))).toFixed(2);
+        _host.disk_info = host.Hosts.disk_info;
+
+        console.log("The value of memory is: " + _host.memory);
+      }
     });
+    this.set('bootHosts', hosts);
+    console.log("The value of hosts: " + JSON.stringify(hosts));
+    this.stopRegistration();
+  },
+
+  getHostInfoErrorCallback: function () {
+    console.log('INFO: Getting host information(cpu_count and total_mem) from the server failed');
+    this.registerErrPopup(Em.I18n.t('installer.step3.hostInformation.popup.header'), Em.I18n.t('installer.step3.hostInformation.popup.body'));
   },
 
   stopRegistration: function () {
@@ -593,27 +602,29 @@ App.WizardStep3Controller = Em.Controller.extend({
     }, 1000);
     setTimeout(function(){
       clearInterval(interval);
-      $.ajax({
-        type: 'GET',
-        url: url,
-        contentType: 'application/json',
-        timeout: App.timeout,
-        success: function (data) {
-          var jsonData = (App.testMode) ? data : jQuery.parseJSON(data);
-          self.set('checksUpdateProgress', 100);
-          self.set('checksUpdateStatus', 'SUCCESS');
-          self.parseWarnings(jsonData);
-        },
-        error: function () {
-          self.set('checksUpdateProgress', 100);
-          self.set('checksUpdateStatus', 'FAILED');
-          console.log('INFO: Getting host information(last_agent_env) from the server failed');
-        },
-        statusCode: require('data/statusCodes')
-      })
+      App.ajax.send({
+        name: 'wizard.step3.rerun_checks',
+        sender: this,
+        success: 'rerunChecksSuccessCallback',
+        error: 'rerunChecksErrorCallback'
+      });
     }, this.get('warningsTimeInterval'));
 
   },
+
+  rerunChecksSuccessCallback: function (data) {
+    var jsonData = (App.testMode) ? data : jQuery.parseJSON(data);
+    this.set('checksUpdateProgress', 100);
+    this.set('checksUpdateStatus', 'SUCCESS');
+    this.parseWarnings(jsonData);
+  },
+
+  rerunChecksErrorCallback: function () {
+    this.set('checksUpdateProgress', 100);
+    this.set('checksUpdateStatus', 'FAILED');
+    console.log('INFO: Getting host information(last_agent_env) from the server failed');
+  },
+
   warnings: [],
   warningsTimeInterval: 60000,
   /**

+ 33 - 27
ambari-web/app/controllers/wizard/step8_controller.js

@@ -878,49 +878,55 @@ App.WizardStep8Controller = Em.Controller.extend({
     return this.get('content.cluster.name');
   }.property('content.cluster.name'),
 
+  clusterNames: [],
+
   // returns an array of existing cluster names.
   // returns an empty array if there are no existing clusters.
   getExistingClusterNames: function () {
     var url = App.apiPrefix + '/clusters';
 
-    var clusterNames = [];
-
-    $.ajax({
-      type: 'GET',
-      url: url,
-      async: false,
-      success: function (data) {
-        var jsonData = jQuery.parseJSON(data);
-        clusterNames = jsonData.items.mapProperty('Clusters.cluster_name');
-        console.log("Got existing cluster names: " + clusterNames);
-      },
-      error: function () {
-        console.log("Failed to get existing cluster names");
-      }
+    App.ajax.send({
+      name: 'wizard.step8.existing_cluster_names',
+      sender: this,
+      success: 'getExistingClusterNamesSuccessCallBack',
+      error: 'getExistingClusterNamesErrorCallback'
     });
 
-    return clusterNames;
+    return this.get('clusterNames');
   },
 
-  deleteClusters: function (clusterNames) {
-    clusterNames.forEach(function (clusterName) {
+  getExistingClusterNamesSuccessCallBack: function (data) {
+    var clusterNames = data.items.mapProperty('Clusters.cluster_name');
+    console.log("Got existing cluster names: " + clusterNames);
+    this.set('clusterNames', clusterNames);
+  },
 
-      var url = App.apiPrefix + '/clusters/' + clusterName;
+  getExistingClusterNamesErrorCallback: function () {
+    console.log("Failed to get existing cluster names");
+    this.set('clusterNames', []);
+  },
 
-      $.ajax({
-        type: 'DELETE',
-        url: url,
-        async: false,
-        success: function () {
-          console.log('DELETE cluster ' + clusterName + ' succeeded');
+  deleteClusters: function (clusterNames) {
+    clusterNames.forEach(function (clusterName) {
+      App.ajax.send({
+        name: 'wizard.step8.delete_cluster',
+        sender: this,
+        data: {
+          name: clusterName
         },
-        error: function () {
-          console.log('DELETE cluster ' + clusterName + ' failed');
-        }
+        success: 'deleteClustersSuccessCallback',
+        error: 'deleteClustersErrorCallback'
       });
     });
   },
 
+  deleteClustersSuccessCallback: function(data, opt) {
+    console.log('DELETE cluster ' + opt.data.name + ' succeeded');
+  },
+  deleteClustersErrorCallback: function(request, ajaxOptions, error, opt) {
+    console.log('DELETE cluster ' + opt.data.name + ' failed');
+  },
+
   /**
    *  The following create* functions are called upon submitting Step 8.
    */

+ 41 - 50
ambari-web/app/controllers/wizard/step9_controller.js

@@ -331,68 +331,59 @@ App.WizardStep9Controller = Em.Controller.extend({
    * run start/check services after installation phase
    */
   launchStartServices: function () {
-    var self = this;
-    var clusterName = this.get('content.cluster.name');
-    var url = App.apiPrefix + '/clusters/' + clusterName + '/services?ServiceInfo/state=INSTALLED';
     var data = '{"RequestInfo": {"context": "'+Em.I18n.t("requestInfo.serviceStartCheck")+'"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}';
-    var method = 'PUT';
-
+    var name = 'wizard.step9.installer.launch_start_services';
     if (this.get('content.controllerName') === 'addHostController') {
-      url = App.apiPrefix + '/clusters/' + clusterName + '/host_components?(HostRoles/component_name=GANGLIA_MONITOR|HostRoles/component_name=HBASE_REGIONSERVER|HostRoles/component_name=DATANODE|HostRoles/component_name=TASKTRACKER)&(HostRoles/state=INSTALLED)';
       data = '{"HostRoles": {"state": "STARTED"}}';
+      name = 'wizard.step9.add_host.launch_start_services';
     }
-
     if (App.testMode) {
-      url = this.get('mockDataPrefix') + '/poll_6.json';
-      method = 'GET';
       this.numPolls = 6;
     }
 
-    $.ajax({
-      type: method,
-      url: url,
-      async: false,
-      data: data,
-      dataType: 'text',
-      timeout: App.timeout,
-      success: function (data) {
-        var jsonData = jQuery.parseJSON(data);
-        console.log("TRACE: Step9 -> In success function for the startService call");
-        console.log("TRACE: Step9 -> value of the url is: " + url);
-        console.log("TRACE: Step9 -> value of the received data is: " + jsonData);
-        var requestId = jsonData.Requests.id;
-        console.log('requestId is: ' + requestId);
-        var clusterStatus = {
-          status: 'INSTALLED',
-          requestId: requestId,
-          isStartError: false,
-          isCompleted: false
-        };
-
-        App.router.get(self.get('content.controllerName')).saveClusterStatus(clusterStatus);
-
-        // We need to do recovery if there is a browser crash
-        App.clusterStatus.setClusterStatus({
-          clusterState: 'SERVICE_STARTING_3',
-          localdb: App.db.data
-        });
-
-        self.startPolling();
+    App.ajax.send({
+      name: name,
+      sender: this,
+      data: {
+        data: data,
+        cluster: this.get('content.cluster.name')
       },
+      success: 'launchStartServicesSuccessCallback',
+      error: 'launchStartServicesErrorCallback'
+    });
+  },
 
-      error: function () {
-        console.log("ERROR");
-        var clusterStatus = {
-          status: 'START FAILED',
-          isStartError: true,
-          isCompleted: false
-        };
+  launchStartServicesSuccessCallback: function (jsonData) {
+    console.log("TRACE: Step9 -> In success function for the startService call");
+    console.log("TRACE: Step9 -> value of the received data is: " + jsonData);
+    var requestId = jsonData.Requests.id;
+    console.log('requestId is: ' + requestId);
+    var clusterStatus = {
+      status: 'INSTALLED',
+      requestId: requestId,
+      isStartError: false,
+      isCompleted: false
+    };
+
+    App.router.get(this.get('content.controllerName')).saveClusterStatus(clusterStatus);
+
+    // We need to do recovery if there is a browser crash
+    App.clusterStatus.setClusterStatus({
+      clusterState: 'SERVICE_STARTING_3',
+      localdb: App.db.data
+    });
 
-        App.router.get(self.get('content.controllerName')).saveClusterStatus(clusterStatus);
-      },
+    this.startPolling();
+  },
 
-      statusCode: require('data/statusCodes')
-    });
+  launchStartServicesErrorCallback: function () {
+    console.log("ERROR");
+    var clusterStatus = {
+      status: 'START FAILED',
+      isStartError: true,
+      isCompleted: false
+    };
+    App.router.get(this.get('content.controllerName')).saveClusterStatus(clusterStatus);
   },
 
   // marks a host's status as "success" if all tasks are in COMPLETED state

+ 111 - 122
ambari-web/app/router.js

@@ -133,121 +133,121 @@ App.Router = Em.Router.extend({
     return authenticated;
   },
 
-  login: function (postLogin) {
+  login: function () {
     var controller = this.get('loginController');
     var loginName = controller.get('loginName').toLowerCase();
     controller.set('loginName', loginName);
     var hash = window.btoa(loginName + ":" + controller.get('password'));
-    var router = this;
-    var url = '';
+    var usr = '';
 
     if (App.testMode) {
       if (loginName === "admin" && controller.get('password') === 'admin') {
-        url = '/data/users/user_admin.json';
+        usr = 'admin';
       } else if (loginName === 'user' && controller.get('password') === 'user') {
-        url = '/data/users/user_user.json';
+        usr = 'user';
       }
     }
 
-    $.ajax({
-      url: (App.testMode) ? url : App.apiPrefix + '/users/' + loginName,
-      dataType: 'json',
-      type: 'GET',
-      beforeSend: function (xhr) {
-        xhr.setRequestHeader("Authorization", "Basic " + hash);
+    App.ajax.send({
+      name: 'router.login',
+      sender: this,
+      data: {
+        auth: "Basic " + hash,
+        usr: usr,
+        loginName: loginName
       },
-      statusCode: {
-        200: function () {
-          console.log("Status code 200: Success.");
-        },
-        401: function () {
-          console.log("Error code 401: Unauthorized.");
-        },
-        403: function () {
-          console.log("Error code 403: Forbidden.");
-        }
-      },
-      success: function (data) {
-        console.log('login success');
-
-        var resp = data;
-        var isAdmin = resp.Users.roles.indexOf('admin') >= 0;
-        if (isAdmin) {
-          router.setAuthenticated(true);
-          router.setLoginName(loginName);
-          App.usersMapper.map({"items": [data]});
-          router.setUser(App.User.find(loginName));
-          router.transitionTo(router.getSection());
-          postLogin(true);
-        } else {
-          $.ajax({
-            url: (App.testMode) ? '/data/clusters/info.json' : App.apiPrefix + '/clusters',
-            dataType: 'text',
-            type: 'GET',
-            success: function (data) {
-              var clusterResp = $.parseJSON(data);
-              if (clusterResp.items.length) {
-                router.setAuthenticated(true);
-                router.setLoginName(loginName);
-                App.usersMapper.map({"items": [resp]});
-                router.setUser(App.User.find(loginName));
-                router.transitionTo(router.getSection());
-                postLogin(true);
-              } else {
-                controller.set('errorMessage', Em.I18n.t('router.hadoopClusterNotSetUp'));
-              }
-            },
-            error: function (req) {
-              console.log("Server not responding: " + req.statusCode);
-            }
-          });
-        }
-      },
-      error: function (req) {
-        console.log("login error: " + req.statusCode);
-        router.setAuthenticated(false);
-        postLogin(false);
-      }
+      beforeSend: 'authBeforeSend',
+      success: 'loginSuccessCallback',
+      error: 'loginErrorCallback'
     });
 
   },
 
-  setAmbariStacks: function () {
-    var self = this;
-    var method = 'GET';
-    var url = (App.testMode) ? '/data/wizard/stack/stacks.json' : App.apiPrefix + '/stacks';
-    $.ajax({
-      type: method,
-      url: url,
-      async: false,
-      dataType: 'text',
-      timeout: App.timeout,
-      success: function (data) {
-        var jsonData = jQuery.parseJSON(data);
-        console.log("TRACE: In success function for the setAmbariStacks call");
-        console.log("TRACE: value of the url is: " + url);
-        var stacks = [];
-        jsonData.forEach(function (_stack) {
-          stacks.pushObject({
-            name: _stack.name,
-            version: _stack.version
-          });
-        }, this);
-        App.db.setAmbariStacks(stacks);
-        console.log('TRACEIINNGG: ambaristacks: ' + JSON.stringify(App.db.getAmbariStacks()));
-      },
+  authBeforeSend: function(opt, xhr, data) {
+    xhr.setRequestHeader("Authorization", data.auth);
+  },
 
-      error: function (request, ajaxOptions, error) {
-        console.log("TRACE: In error function for the setAmbariStacks call");
-        console.log("TRACE: value of the url is: " + url);
-        console.log("TRACE: error code status is: " + request.status);
-        console.log('Error message is: ' + request.responseText);
-      },
+  loginSuccessCallback: function(data, opt, params) {
+    console.log('login success');
+    var d = data;
+    var isAdmin = data.Users.roles.indexOf('admin') >= 0;
+    if (isAdmin) {
+      var controller = this.get('loginController');
+      this.setAuthenticated(true);
+      this.setLoginName(params.loginName);
+      App.usersMapper.map({"items": [data]});
+      this.setUser(App.User.find(params.loginName));
+      this.transitionTo(this.getSection());
+      controller.postLogin(true);
+    }
+    else {
+      App.ajax.send({
+        name: 'router.login2',
+        sender: this,
+        data: {
+          loginName: params.loginName,
+          loginData: data
+        },
+        success: 'login2SuccessCallback',
+        error: 'login2ErrorCallback'
+      });
+    }
+  },
 
-      statusCode: require('data/statusCodes')
+  loginErrorCallback: function(request, ajaxOptions, error, opt) {
+    var controller = this.get('loginController');
+    console.log("login error: " + error);
+    this.setAuthenticated(false);
+    controller.postLogin(false);
+  },
+
+  login2SuccessCallback: function (clusterResp, opt, params) {
+    var controller = this.get('loginController');
+    if (clusterResp.items.length) {
+      this.setAuthenticated(true);
+      this.setLoginName(params.loginName);
+      App.usersMapper.map({"items": [params.loginData]});
+      this.setUser(App.User.find(params.loginName));
+      this.transitionTo(this.getSection());
+      controller.postLogin(true);
+    }
+    else {
+      controller.set('errorMessage', Em.I18n.t('router.hadoopClusterNotSetUp'));
+    }
+  },
+
+  login2ErrorCallback: function (req) {
+    console.log("Server not responding: " + req.statusCode);
+  },
+
+  setAmbariStacks: function () {
+    App.ajax.send({
+      name: 'router.set_ambari_stacks',
+      sender: this,
+      success: 'setAmbariStacksSuccessCallback',
+      error: 'setAmbariStacksErrorCallback'
     });
   },
 
+  setAmbariStacksSuccessCallback: function (jsonData) {
+    console.log("TRACE: In success function for the setAmbariStacks call");
+    var stacks = [];
+    jsonData.forEach(function (_stack) {
+      stacks.pushObject({
+        name: _stack.name,
+        version: _stack.version
+      });
+    }, this);
+    App.db.setAmbariStacks(stacks);
+    console.log('TRACEIINNGG: ambaristacks: ' + JSON.stringify(App.db.getAmbariStacks()));
+  },
+
+  setAmbariStacksErrorCallback: function (request, ajaxOptions, error) {
+    console.log("TRACE: In error function for the setAmbariStacks call");
+    console.log("TRACE: error code status is: " + request.status);
+    console.log('Error message is: ' + request.responseText);
+  },
+
   getSection: function () {
     if (App.testMode) {
       if (App.alwaysGoToInstaller) {
@@ -294,39 +294,28 @@ App.Router = Em.Router.extend({
     this.set('loginController.password', '');
 
     if (!App.testMode) {
-      $.ajax({
-        url: App.apiPrefix + '/logout',
-        dataType: 'json',
-        type: 'GET',
-        beforeSend: function (xhr) {
-          xhr.setRequestHeader("Authorization", "Basic " + hash);
-        },
-        statusCode: {
-          200: function () {
-            console.log("Status code 200: Success.");
-          },
-          401: function () {
-            console.log("Error code 401: Unauthorized.");
-          },
-          403: function () {
-            console.log("Error code 403: Forbidden.");
-          }
-        },
-        success: function (data) {
-          console.log("invoked logout on the server successfully");
+      App.ajax.send({
+        name: 'router.logoff',
+        sender: this,
+        data: {
+          auth: "Basic " + hash
         },
-        error: function (data) {
-          console.log("failed to invoke logout on the server");
-        },
-        complete: function () {
-          console.log('done');
-        }
+        beforeSend: 'authBeforeSend',
+        success: 'logOffSuccessCallback',
+        error:'logOffErrorCallback'
       });
     }
-
     this.transitionTo('login', context);
   },
 
+  logOffSuccessCallback: function (data) {
+    console.log("invoked logout on the server successfully");
+  },
+
+  logOffErrorCallback: function (req) {
+    console.log("failed to invoke logout on the server");
+  },
+
   root: Em.Route.extend({
     index: Em.Route.extend({
       route: '/',
@@ -366,4 +355,4 @@ App.Router = Em.Router.extend({
     }
 
   })
-})
+});

+ 1 - 0
ambari-web/app/routes/main.js

@@ -614,6 +614,7 @@ module.exports = Em.Route.extend({
         connectOutlets: function (router, context) {
           var controller = router.get('mainAdminController');
           controller.set('category', "security");
+          controller.connectOutlet('loading');
           var securityStatus = controller.securityStatusLoading();
           securityStatus.done(function () {
             controller.connectOutlet('mainAdminSecurity');

+ 449 - 20
ambari-web/app/utils/ajax.js

@@ -31,23 +31,23 @@ var App = require('app');
  */
 var urls = {
   'background_operations': {
-    'mock': '/data/background_operations/list_on_start.json',
     'real': '/clusters/{clusterName}/requests/?fields=tasks/*',
+    'mock': '/data/background_operations/list_on_start.json',
     'testInProduction': true
   },
   'background_operations.update_task': {
-    'mock': '/data/background_operations/one_task.json',
     'real': '/clusters/{clusterName}/requests/{requestId}/tasks/{taskId}',
+    'mock': '/data/background_operations/one_task.json',
     'testInProduction': true
   },
   'background_operations.get_most_recent': {
-    'mock': '/data/background_operations/list_on_start.json',
     'real': '/clusters/{clusterName}/requests?fields=*,tasks/Tasks/*',
+    'mock': '/data/background_operations/list_on_start.json',
     'testInProduction': true
   },
   'service.item.start_stop': {
-    'mock': '/data/wizard/deploy/poll_1.json',
     'real': '/clusters/{clusterName}/services/{serviceName}',
+    'mock': '/data/wizard/deploy/poll_1.json',
     'format': function (data, opt) {
       return {
         type: 'PUT',
@@ -65,8 +65,8 @@ var urls = {
     }
   },
   'service.item.smoke': {
-    'mock': '/data/wizard/deploy/poll_1.json',
     'real': '/clusters/{clusterName}/services/{serviceName}/actions/{serviceName}_SERVICE_CHECK',
+    'mock': '/data/wizard/deploy/poll_1.json',
     'format': function () {
       return {
         'type': 'POST',
@@ -174,6 +174,7 @@ var urls = {
   'reassign.get_logs': {
     'real': '/clusters/{clusterName}/requests/{requestId}?fields=tasks/*',
     'type': 'GET'
+
   },
   'reassign.create_configs': {
     'real': '/clusters/{clusterName}/configurations',
@@ -237,6 +238,429 @@ var urls = {
         async: false
       };
     }
+  },
+  'service.metrics.hbase.cluster_requests': {
+    'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/cluster_requests[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/services/metrics/hbase/cluster_requests.json',
+    'testInProduction': true
+  },
+  'service.metrics.hbase.hlog_split_size': {
+    'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitSize_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/services/metrics/hbase/hlog_split_size.json',
+    'testInProduction': true
+  },
+  'service.metrics.hbase.hlog_split_time': {
+    'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/services/metrics/hbase/hlog_split_time.json',
+    'testInProduction': true
+  },
+  'service.metrics.hbase.regionserver_queuesize': {
+    'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/flushQueueSize[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/compactionQueueSize[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/services/metrics/hbase/regionserver_queuesize.json',
+    'testInProduction': true
+  },
+  'service.metrics.hbase.regionserver_regions': {
+    'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/regions[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/services/metrics/hbase/regionserver_regions.json',
+    'testInProduction': true
+  },
+  'service.metrics.hbase.regionserver_rw_requests': {
+    'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/readRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/writeRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/services/metrics/hbase/regionserver_rw_requests.json',
+    'testInProduction': true
+  },
+  'service.metrics.mapreduce.gc': {
+    'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/services/metrics/mapreduce/gc.json',
+    'testInProduction': true
+  },
+  'service.metrics.mapreduce.jobs_status': {
+    'real': '/clusters/{clusterName}/services/MAPREDUCE/components/JOBTRACKER?fields=metrics/mapred/jobtracker/jobs_completed[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_preparing[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_failed[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_submitted[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_failed[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_running[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/services/metrics/mapreduce/jobs_status.json',
+    'testInProduction': true
+  },
+  'service.metrics.mapreduce.jobs_heap': {
+    'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/memNonHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memNonHeapCommittedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memHeapCommittedM[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/services/metrics/mapreduce/jvm_heap.json',
+    'testInProduction': true
+  },
+  'service.metrics.mapreduce.jobs_threads': {
+    'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsBlocked[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsWaiting[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsTimedWaiting[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/services/metrics/mapreduce/jvm_threads.json',
+    'testInProduction': true
+  },
+  'service.metrics.mapreduce.map_slots': {
+    'real': '/clusters/{clusterName}/services/MAPREDUCE/components/JOBTRACKER?fields=metrics/mapred/jobtracker/occupied_map_slots[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/reserved_map_slots[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/services/metrics/mapreduce/map_slots.json',
+    'testInProduction': true
+  },
+  'service.metrics.mapreduce.reduce_slots': {
+    'real': '/clusters/{clusterName}/services/MAPREDUCE/components/JOBTRACKER?fields=metrics/mapred/jobtracker/occupied_reduce_slots[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/reserved_reduce_slots[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/services/metrics/mapreduce/reduce_slots.json',
+    'testInProduction': true
+  },
+  'service.metrics.mapreduce.rpc': {
+    'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/services/metrics/mapreduce/rpc.json',
+    'testInProduction': true
+  },
+  'service.metrics.mapreduce.tasks_running_waiting': {
+    'real': '/clusters/{clusterName}/services/MAPREDUCE/components/JOBTRACKER?fields=metrics/mapred/jobtracker/running_maps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/running_reduces[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/waiting_maps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/waiting_reduces[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/services/metrics/mapreduce/tasks_running_waiting.json',
+    'testInProduction': true
+  },
+  'service.metrics.hdfs.block_status': {
+    'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/FSNamesystem/PendingReplicationBlocks[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/UnderReplicatedBlocks[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/services/metrics/hdfs/block_status.json',
+    'testInProduction': true
+  },
+  'service.metrics.hdfs.file_operations': {
+    'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/namenode/FileInfoOps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/namenode/CreateFileOps[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/services/metrics/hdfs/file_operations.json',
+    'testInProduction': true
+  },
+  'service.metrics.hdfs.gc': {
+    'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/services/metrics/hdfs/gc.json',
+    'testInProduction': true
+  },
+  'service.metrics.hdfs.io': {
+    'real': '/clusters/{clusterName}/services/HDFS/components/DATANODE?fields=metrics/dfs/datanode/bytes_written[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/datanode/bytes_read[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/services/metrics/hdfs/io.json',
+    'testInProduction': true
+  },
+  'service.metrics.hdfs.jvm_heap': {
+    'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/memNonHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memNonHeapCommittedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memHeapCommittedM[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/services/metrics/hdfs/jvm_heap.json',
+    'testInProduction': true
+  },
+  'service.metrics.hdfs.jvm_threads': {
+    'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsBlocked[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsWaiting[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsTimedWaiting[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/services/metrics/hdfs/jvm_threads.json',
+    'testInProduction': true
+  },
+  'service.metrics.hdfs.rpc': {
+    'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/services/metrics/hdfs/rpc.json',
+    'testInProduction': true
+  },
+  'service.metrics.hdfs.space_utilization': {
+    'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/FSNamesystem/CapacityRemainingGB[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/CapacityUsedGB[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/CapacityTotalGB[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/services/metrics/hdfs/space_utilization.json',
+    'testInProduction': true
+  },
+  'dashboard.cluster_metrics.cpu': {
+    'real': '/clusters/{clusterName}/?fields=metrics/cpu[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/cluster_metrics/cpu_1hr.json',
+    'testInProduction': true
+  },
+  'dashboard.cluster_metrics.load': {
+    'real': '/clusters/{clusterName}/?fields=metrics/load[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/cluster_metrics/load_1hr.json',
+    'testInProduction': true
+  },
+  'dashboard.cluster_metrics.memory': {
+    'real': '/clusters/{clusterName}/?fields=metrics/memory[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/cluster_metrics/memory_1hr.json',
+    'testInProduction': true
+  },
+  'dashboard.cluster_metrics.network': {
+    'real': '/clusters/{clusterName}/?fields=metrics/network[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/cluster_metrics/network_1hr.json',
+    'testInProduction': true
+  },
+  'host.metrics.cpu': {
+    'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/cpu/cpu_user[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/cpu_wio[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/cpu_nice[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/cpu_aidle[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/cpu_system[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/cpu_idle[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/hosts/metrics/cpu.json',
+    'testInProduction': true
+  },
+  'host.metrics.disk': {
+    'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/disk/disk_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/disk/disk_free[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/hosts/metrics/disk.json',
+    'testInProduction': true
+  },
+  'host.metrics.load': {
+    'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/load/load_fifteen[{fromSeconds},{toSeconds},{stepSeconds}],metrics/load/load_one[{fromSeconds},{toSeconds},{stepSeconds}],metrics/load/load_five[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/hosts/metrics/load.json',
+    'testInProduction': true
+  },
+  'host.metrics.memory': {
+    'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/memory/swap_free[{fromSeconds},{toSeconds},{stepSeconds}],metrics/memory/mem_shared[{fromSeconds},{toSeconds},{stepSeconds}],metrics/memory/mem_free[{fromSeconds},{toSeconds},{stepSeconds}],metrics/memory/mem_cached[{fromSeconds},{toSeconds},{stepSeconds}],metrics/memory/mem_buffers[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/hosts/metrics/memory.json',
+    'testInProduction': true
+  },
+  'host.metrics.network': {
+    'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/network/bytes_in[{fromSeconds},{toSeconds},{stepSeconds}],metrics/network/bytes_out[{fromSeconds},{toSeconds},{stepSeconds}],metrics/network/pkts_in[{fromSeconds},{toSeconds},{stepSeconds}],metrics/network/pkts_out[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/hosts/metrics/network.json',
+    'testInProduction': true
+  },
+  'host.metrics.processes': {
+    'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/process/proc_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/process/proc_run[{fromSeconds},{toSeconds},{stepSeconds}]',
+    'mock': '/data/hosts/metrics/processes.json',
+    'testInProduction': true
+  },
+  'admin.security_status': {
+    'real': '/clusters/{clusterName}',
+    'format': function (data, opt) {
+      return {
+        timeout: 10000,
+        async: false
+      };
+    }
+  },
+  'admin.service_config': {
+    'real': '/clusters/{clusterName}/configurations/?type={siteName}&tag={tagName}',
+    'format': function (data, opt) {
+      return {
+        timeout: 10000,
+        async: false
+      };
+    }
+  },
+  'router.set_ambari_stacks': {
+    'real': '/stacks',
+    'mock': '/data/wizard/stack/stacks.json',
+    'format': function (data, opt) {
+      return {
+        async: false
+      };
+    }
+  },
+  'cluster.load_cluster_name': {
+    'real': '/clusters',
+    'mock': '/data/clusters/info.json',
+    'format': function (data, opt) {
+      return {
+        async: false
+      };
+    }
+  },
+  'cluster.update_upgrade_version': {
+    'real': '/stacks2/HDP/versions?fields=stackServices/StackServices,Versions',
+    'mock': '/data/wizard/stack/stacks.json',
+    'format': function (data, opt) {
+      return {
+        async: false
+      };
+    }
+  },
+  'wizard.launch_bootstrap': {
+    'real': '/bootstrap',
+    'mock': '/data/wizard/bootstrap/bootstrap.json',
+    'format': function (data) {
+      return {
+        type: 'POST',
+        async: false,
+        contentType: 'application/json',
+        data: data.bootStrapData
+      }
+    }
+  },
+  'admin.security.cluster_configs': {
+    'real': '/clusters/{clusterName}',
+    'format': function (data, opt) {
+      return {
+        timeout: 10000
+      };
+    }
+  },
+  'admin.security.all_configurations': {
+    'real': '/clusters/{clusterName}/configurations?{urlParams}',
+    'format': function (data, opt) {
+      return {
+        timeout: 10000
+      };
+    }
+  },
+  'admin.security.apply_configuration': {
+    'real': '/clusters/{clusterName}',
+    'format': function (data, opt) {
+      return {
+        type: 'PUT',
+        async: false,
+        timeout: 5000,
+        data: JSON.stringify(data.clusterData)
+      };
+    }
+  },
+  'admin.security.add.cluster_configs': {
+    'real': '/clusters/{clusterName}',
+    'format': function (data, opt) {
+      return {
+        timeout: 10000
+      };
+    }
+  },
+  'service.start_stop': {
+    'real': '/clusters/{clusterName}/services?ServiceInfo',
+    'mock': '/data/mirroring/poll/poll_6.json',
+    'format': function (data, opt) {
+      return {
+        type: 'PUT',
+        async: false,
+        data: data.data
+      };
+    }
+  },
+  'admin.stack_upgrade.run_upgrade': {
+    'real':'/clusters/{clusterName}',
+    'format': function (data, opt) {
+      return {
+        type: 'PUT',
+        async: false,
+        data: data.data
+      };
+    }
+  },
+  'admin.stack_upgrade.stop_services': {
+    'real': '/clusters/{clusterName}/services?ServiceInfo/state=STARTED',
+    'format': function (data, opt) {
+      return {
+        type: 'PUT',
+        async: false,
+        data: data.data
+      };
+    }
+  },
+  'admin.stack_upgrade.do_poll': {
+    'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/*',
+    'mock': '/data/wizard/{mock}'
+  },
+  'host.service_config_hosts_overrides': {
+    'real': '/clusters/{clusterName}/configurations?{urlParams}',
+    'format': function (data, opt) {
+      return {
+        async: false,
+        timeout: 10000
+      };
+    }
+  },
+  'wizard.install_services.add_host_controller.is_retry': {
+    'real': '/clusters/{cluster}/host_components?HostRoles/state=INSTALLED',
+    'format': function (data, opt) {
+      return {
+        type: 'PUT',
+        async: false,
+        data: data.data
+      };
+    }
+  },
+  'wizard.install_services.add_host_controller.not_is_retry': {
+    'real': '/clusters/{cluster}/host_components?HostRoles/state=INIT',
+    'format': function (data, opt) {
+      return {
+        type: 'PUT',
+        async: false,
+        data: data.data
+      };
+    }
+  },
+  'wizard.install_services.installer_controller.is_retry': {
+    'real': '/clusters/{cluster}/host_components?HostRoles/state!=INSTALLED',
+    'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
+    'format': function (data, opt) {
+      return {
+        type: 'PUT',
+        async: false,
+        data: data.data
+      };
+    }
+  },
+  'wizard.install_services.installer_controller.not_is_retry': {
+    'real': '/clusters/{cluster}/services?ServiceInfo/state=INIT',
+    'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
+    'format': function (data, opt) {
+      return {
+        type: 'PUT',
+        async: false,
+        data: data.data
+      };
+    }
+  },
+  'wizard.service_components': {
+    'real': '{stackUrl}',
+    'mock': '/data/wizard/stack/hdp/version/1.3.0.json',
+    'format': function (data, opt) {
+      return {
+        async: false
+      };
+    }
+  },
+  'wizard.step9.installer.launch_start_services': {
+    'real': '/clusters/{cluster}/services?ServiceInfo/state=INSTALLED',
+    'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
+    'format': function (data, opt) {
+      return {
+        type: 'PUT',
+        async: false,
+        data: data.data
+      };
+    }
+  },
+  'wizard.step9.add_host.launch_start_services': {
+    'real': '/clusters/{cluste}/host_components?(HostRoles/component_name=GANGLIA_MONITOR|HostRoles/component_name=HBASE_REGIONSERVER|HostRoles/component_name=DATANODE|HostRoles/component_name=TASKTRACKER)&(HostRoles/state=INSTALLED)',
+    'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
+    'format': function (data, opt) {
+      return {
+        type: 'PUT',
+        async: false,
+        data: data.data
+      };
+    }
+  },
+  'wizard.step8.delete_cluster': {
+    'real': '/clusters/{name}',
+    'format': function (data, opt) {
+      return {
+        type: 'DELETE',
+        async: false
+      };
+    }
+  },
+  'wizard.step8.existing_cluster_names': {
+    'real': '/clusters',
+    'format': function (data, opt) {
+      return {
+        async: false
+      };
+    }
+  },
+  'wizard.step3.host_info': {
+    'real': '/hosts?fields=Hosts/total_mem,Hosts/cpu_count,Hosts/disk_info,Hosts/last_agent_env',
+    'mock': '/data/wizard/bootstrap/two_hosts_information.json',
+    'format': function (data, opt) {
+      return {
+        contentType: 'application/json'
+      };
+    }
+  },
+  'wizard.step3.rerun_checks': {
+    'real': '/hosts?fields=Hosts/last_agent_env',
+    'mock': '/data/wizard/bootstrap/two_hosts_information.json',
+    'format': function (data, opt) {
+      return {
+        contentType: 'application/json'
+      };
+    }
+  },
+  'wizard.step3.bootstrap': {
+    'real': '/bootstrap/{bootRequestId}',
+    'mock': '/data/wizard/bootstrap/poll_{numPolls}.json'
+  },
+  'wizard.step3.is_hosts_registered': {
+    'real': '/hosts',
+    'mock': '/data/wizard/bootstrap/single_host_registration.json'
+  },
+  'router.login': {
+    'real': '/users/{loginName}',
+    'mock': '/data/users/user_{usr}.json'
+  },
+  'router.login2': {
+    'real': '/clusters',
+    'mock': '/data/clusters/info.json'
+  },
+  'router.logoff': {
+    'real': '/logout'
   }
 };
 /**
@@ -249,17 +673,19 @@ var urls = {
 var formatUrl = function(url, data) {
   var keys = url.match(/\{\w+\}/g);
   keys = (keys === null) ? [] :  keys;
-  keys.forEach(function(key){
-    var raw_key = key.substr(1, key.length - 2);
-    var replace;
-    if (!data[raw_key]) {
-      replace = '';
-    }
-    else {
-      replace = data[raw_key];
-    }
-    url = url.replace(new RegExp(key, 'g'), replace);
-  });
+  if (keys) {
+    keys.forEach(function(key){
+      var raw_key = key.substr(1, key.length - 2);
+      var replace;
+      if (!data[raw_key]) {
+        replace = '';
+      }
+      else {
+        replace = data[raw_key];
+      }
+      url = url.replace(new RegExp(key, 'g'), replace);
+    });
+  }
   return url;
 };
 
@@ -310,6 +736,9 @@ App.ajax = {
    *  callback - callback from <code>App.updater.run</code> library
    */
   send: function(config) {
+
+    console.warn('============== ajax ==============', config.name, config.data);
+
     if (!config.sender) {
       console.warn('Ajax sender should be defined!');
       return null;
@@ -329,12 +758,13 @@ App.ajax = {
     opt = formatRequest.call(urls[config.name], params);
 
     // object sender should be provided for processing beforeSend, success and error responses
-    opt.beforeSend = function() {
+    opt.beforeSend = function(xhr) {
       if(config.beforeSend) {
-        config.sender[config.beforeSend](opt);
+        config.sender[config.beforeSend](opt, xhr, params);
       }
     };
     opt.success = function(data) {
+      console.log("TRACE: The url is: " + opt.url);
       if(config.success) {
         config.sender[config.success](data, opt, params);
       }
@@ -352,7 +782,6 @@ App.ajax = {
     if($.mocho){
       opt.url = 'http://' + $.hostName + opt.url;
     }
-
     return $.ajax(opt);
   }
-}
+}

+ 34 - 49
ambari-web/app/views/common/chart/linear_time.js

@@ -142,26 +142,41 @@ App.ChartLinearTimeView = Ember.View.extend({
   },
 
   loadData: function() {
-    var validUrl = this.getFormattedUrl();
-    if (validUrl) {
-      var hash = {};
-      hash.url = validUrl;
-      hash.type = 'GET';
-      hash.dataType = 'json';
-      hash.contentType = 'application/json; charset=utf-8';
-      hash.context = this;
-      hash.success = this._refreshGraph,
-       hash.error = function(xhr, textStatus, errorThrown){
-        this.set('isReady', true);
-        if (xhr.readyState == 4 && xhr.status) {
-          textStatus = xhr.status + " " + textStatus;
-        }
-        this._showMessage('warn', this.t('graphs.error.title'), this.t('graphs.error.message').format(textStatus, errorThrown));
-        this.set('isPopup', false);
-        this.set('hasData', false);
-      }
-      jQuery.ajax(hash);
+    App.ajax.send({
+      name: this.get('ajaxIndex'),
+      sender: this,
+      data: this.getDataForAjaxRequest(),
+      success: '_refreshGraph',
+      error: 'loadDataErrorCallback'
+    });
+  },
+
+  getDataForAjaxRequest: function() {
+    var toSeconds = Math.round(new Date().getTime() / 1000);
+    var hostName = (this.get('content')) ? this.get('content.hostName') : "";
+
+    var HDFSService = App.HDFSService.find().objectAt(0);
+    var nameNodeName = HDFSService ? HDFSService.get('nameNode.hostName') : "";
+    var MapReduceService = App.MapReduceService.find().objectAt(0);
+    var jobTrackerNode = MapReduceService ? MapReduceService.get('jobTracker.hostName') : "";
+    var timeUnit = this.get('timeUnitSeconds');
+    return {
+      toSeconds: toSeconds,
+      fromSeconds: toSeconds - timeUnit,
+      stepSeconds: 15,
+      hostName: hostName,
+      nameNodeName: nameNodeName,
+      jobTrackerNode: jobTrackerNode
+    };
+  },
+  loadDataErrorCallback: function(xhr, textStatus, errorThrown){
+    this.set('isReady', true);
+    if (xhr.readyState == 4 && xhr.status) {
+      textStatus = xhr.status + " " + textStatus;
     }
+    this._showMessage('warn', this.t('graphs.error.title'), this.t('graphs.error.message').format(textStatus, errorThrown));
+    this.set('isPopup', false);
+    this.set('hasData', false);
   },
 
   /**
@@ -738,36 +753,6 @@ App.ChartLinearTimeView = Ember.View.extend({
       self.set('isPopupReady', false);
     });
   },
-  /**
-   * return formatted URL that depends on timeUnit
-   * on host metrics depends on host name
-   * on MapReduce metrics depends on  jobTracker Node
-   * @return {String}
-   */
-  getFormattedUrl:function(){
-    var toSeconds = Math.round(new Date().getTime() / 1000);
-    var hostName = (this.get('content')) ? this.get('content.hostName') : "";
-    var nameNodeName = (App.HDFSService.find().objectAt(0)) ?
-      App.HDFSService.find().objectAt(0).get('nameNode').get('hostName') :
-      "";
-    var jobTrackerNode = (App.MapReduceService.find().objectAt(0))
-      ? App.MapReduceService.find().objectAt(0).get('jobTracker').get('hostName')
-      : "";
-    var timeUnit = this.get('timeUnitSeconds');
-
-    return App.formatUrl(
-      this.get('urlPrefix') + this.get('sourceUrl'),
-      {
-        toSeconds: toSeconds,
-        fromSeconds: toSeconds - timeUnit,
-        stepSeconds: 15,
-        hostName: hostName,
-        nameNodeName: nameNodeName,
-        jobTrackerNode: jobTrackerNode
-      },
-      this.get('mockUrl')
-    );
-  },
   //60 minute interval on X axis.
   timeUnitSeconds: 3600
 });

+ 0 - 22
ambari-web/app/views/common/modal_popup.js

@@ -130,28 +130,6 @@ App.showReloadPopup = function(){
  * @return {*}
  */
 App.showConfirmationPopup = function(primary, body) {
-  if (!primary) {
-    return false;
-  }
-  return App.ModalPopup.show({
-    primary: Em.I18n.t('yes'),
-    secondary: Em.I18n.t('no'),
-    header: Em.I18n.t('popup.confirmation.commonHeader'),
-    body: Em.I18n.t('question.sure').format(body || ''),
-    onPrimary: function() {
-      primary();
-      this.hide();
-    }
-  });
-}
-/**
- * Show confirmation popup - hide the popup first then run the function
- *
- * @param {Function} primary - "OK" button click handler
- * @param {String} body - additional text constant. Will be placed in the popup-body
- * @return {*}
- */
-App.showConfirmationPopup2 = function(primary, body) {
   if (!primary) {
     return false;
   }

+ 3 - 4
ambari-web/app/views/main/dashboard/cluster_metrics/cpu.js

@@ -28,8 +28,8 @@ var App = require('app');
  */
 App.ChartClusterMetricsCPU = App.ChartLinearTimeView.extend({
   id: "cluster-metrics-cpu",
-  sourceUrl: "?fields=metrics/cpu[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/cluster_metrics/cpu_1hr.json",
+
+  ajaxIndex: 'dashboard.cluster_metrics.cpu',
 
   title: Em.I18n.t('dashboard.clusterMetrics.cpu'),
   yAxisFormatter: App.ChartLinearTimeView.PercentageFormatter,
@@ -39,10 +39,9 @@ App.ChartClusterMetricsCPU = App.ChartLinearTimeView.extend({
     if (jsonData && jsonData.metrics && jsonData.metrics.cpu) {
       var cpu_idle;
       for ( var name in jsonData.metrics.cpu) {
-        var displayName = name;
         var seriesData = jsonData.metrics.cpu[name];
         if (seriesData) {
-          var s = this.transformData(seriesData, displayName);
+          var s = this.transformData(seriesData, name);
           if (Em.I18n.t('dashboard.clusterMetrics.cpu.displayNames.idle') == s.name) {
             cpu_idle = s;
           }

+ 2 - 2
ambari-web/app/views/main/dashboard/cluster_metrics/load.js

@@ -29,8 +29,8 @@ var App = require('app');
  */
 App.ChartClusterMetricsLoad = App.ChartLinearTimeView.extend({
   id: "cluster-metrics-load",
-  sourceUrl: "?fields=metrics/load[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/cluster_metrics/load_1hr.json",
+
+  ajaxIndex: 'dashboard.cluster_metrics.load',
   isTimePagingDisable: true,
   renderer: 'line',
   title: Em.I18n.t('dashboard.clusterMetrics.load'),

+ 3 - 2
ambari-web/app/views/main/dashboard/cluster_metrics/memory.js

@@ -28,8 +28,9 @@ var App = require('app');
  */
 App.ChartClusterMetricsMemory = App.ChartLinearTimeView.extend({
   id: "cluster-metrics-memory",
-  sourceUrl: "?fields=metrics/memory[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/cluster_metrics/memory_1hr.json",
+
+  ajaxIndex: 'dashboard.cluster_metrics.memory',
+
   isTimePagingDisable: true,
   title: Em.I18n.t('dashboard.clusterMetrics.memory'),
   yAxisFormatter: App.ChartLinearTimeView.BytesFormatter,

+ 3 - 2
ambari-web/app/views/main/dashboard/cluster_metrics/network.js

@@ -29,8 +29,9 @@ var App = require('app');
  */
 App.ChartClusterMetricsNetwork = App.ChartLinearTimeView.extend({
   id: "cluster-metrics-network",
-  sourceUrl: "?fields=metrics/network[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/cluster_metrics/network_1hr.json",
+
+  ajaxIndex: 'dashboard.cluster_metrics.network',
+
   isTimePagingDisable: true,
   title: Em.I18n.t('dashboard.clusterMetrics.network'),
   yAxisFormatter: App.ChartLinearTimeView.BytesFormatter,

+ 1 - 2
ambari-web/app/views/main/host/metrics/cpu.js

@@ -31,8 +31,7 @@ App.ChartHostMetricsCPU = App.ChartLinearTimeView.extend({
   title: Em.I18n.t('hosts.host.metrics.cpu'),
   yAxisFormatter: App.ChartLinearTimeView.PercentageFormatter,
 
-  sourceUrl: "/hosts/{hostName}?fields=metrics/cpu/cpu_user[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/cpu_wio[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/cpu_nice[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/cpu_aidle[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/cpu_system[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/cpu_idle[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/hosts/metrics/cpu.json",
+  ajaxIndex: 'host.metrics.cpu',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 2 - 2
ambari-web/app/views/main/host/metrics/disk.js

@@ -31,8 +31,8 @@ App.ChartHostMetricsDisk = App.ChartLinearTimeView.extend({
   title: Em.I18n.t('hosts.host.metrics.disk'),
   yAxisFormatter: App.ChartLinearTimeView.BytesFormatter,
   renderer: 'line',
-  sourceUrl: "/hosts/{hostName}?fields=metrics/disk/disk_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/disk/disk_free[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/hosts/metrics/disk.json",
+
+  ajaxIndex: 'host.metrics.disk',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 2 - 2
ambari-web/app/views/main/host/metrics/load.js

@@ -30,8 +30,8 @@ App.ChartHostMetricsLoad = App.ChartLinearTimeView.extend({
   id: "host-metrics-load",
   title: Em.I18n.t('hosts.host.metrics.load'),
   renderer: 'line',
-  sourceUrl: "/hosts/{hostName}?fields=metrics/load/load_fifteen[{fromSeconds},{toSeconds},{stepSeconds}],metrics/load/load_one[{fromSeconds},{toSeconds},{stepSeconds}],metrics/load/load_five[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/hosts/metrics/load.json",
+
+  ajaxIndex: 'host.metrics.load',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 2 - 2
ambari-web/app/views/main/host/metrics/memory.js

@@ -31,8 +31,8 @@ App.ChartHostMetricsMemory = App.ChartLinearTimeView.extend({
   title: Em.I18n.t('hosts.host.metrics.memory'),
   yAxisFormatter: App.ChartLinearTimeView.BytesFormatter,
   renderer: 'line',
-  sourceUrl: "/hosts/{hostName}?fields=metrics/memory/swap_free[{fromSeconds},{toSeconds},{stepSeconds}],metrics/memory/mem_shared[{fromSeconds},{toSeconds},{stepSeconds}],metrics/memory/mem_free[{fromSeconds},{toSeconds},{stepSeconds}],metrics/memory/mem_cached[{fromSeconds},{toSeconds},{stepSeconds}],metrics/memory/mem_buffers[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/hosts/metrics/memory.json",
+
+  ajaxIndex: 'host.metrics.memory',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 2 - 2
ambari-web/app/views/main/host/metrics/network.js

@@ -31,8 +31,8 @@ App.ChartHostMetricsNetwork = App.ChartLinearTimeView.extend({
   title: Em.I18n.t('hosts.host.metrics.network'),
   yAxisFormatter: App.ChartLinearTimeView.BytesFormatter,
   renderer: 'line',
-  sourceUrl: "/hosts/{hostName}?fields=metrics/network/bytes_in[{fromSeconds},{toSeconds},{stepSeconds}],metrics/network/bytes_out[{fromSeconds},{toSeconds},{stepSeconds}],metrics/network/pkts_in[{fromSeconds},{toSeconds},{stepSeconds}],metrics/network/pkts_out[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/hosts/metrics/network.json",
+
+  ajaxIndex: 'host.metrics.network',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 2 - 2
ambari-web/app/views/main/host/metrics/processes.js

@@ -30,8 +30,8 @@ App.ChartHostMetricsProcesses = App.ChartLinearTimeView.extend({
   id: "host-metrics-processes",
   title: Em.I18n.t('hosts.host.metrics.processes'),
   renderer: 'line',
-  sourceUrl: "/hosts/{hostName}?fields=metrics/process/proc_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/process/proc_run[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/hosts/metrics/processes.json",
+
+  ajaxIndex: 'host.metrics.processes',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 2 - 2
ambari-web/app/views/main/service/info/metrics/hbase/cluster_requests.js

@@ -29,8 +29,8 @@ var App = require('app');
 App.ChartServiceMetricsHBASE_ClusterRequests = App.ChartLinearTimeView.extend({
   id: "service-metrics-hbase-cluster-requests",
   title: Em.I18n.t('services.service.info.metrics.hbase.clusterRequests'),
-  sourceUrl: "/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/cluster_requests[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/services/metrics/hbase/cluster_requests.json",
+
+  ajaxIndex: 'service.metrics.hbase.cluster_requests',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 1 - 2
ambari-web/app/views/main/service/info/metrics/hbase/hlog_split_size.js

@@ -31,8 +31,7 @@ App.ChartServiceMetricsHBASE_HlogSplitSize = App.ChartLinearTimeView.extend({
   title: Em.I18n.t('services.service.info.metrics.hbase.hlogSplitSize'),
   yAxisFormatter: App.ChartLinearTimeView.BytesFormatter,
 
-  sourceUrl: "/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitSize_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/services/metrics/hbase/hlog_split_size.json",
+  ajaxIndex: 'service.metrics.hbase.hlog_split_size',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 1 - 2
ambari-web/app/views/main/service/info/metrics/hbase/hlog_split_time.js

@@ -31,8 +31,7 @@ App.ChartServiceMetricsHBASE_HlogSplitTime = App.ChartLinearTimeView.extend({
   title: Em.I18n.t('services.service.info.metrics.hbase.hlogSplitTime'),
   yAxisFormatter: App.ChartLinearTimeView.TimeElapsedFormatter,
 
-  sourceUrl: "/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/services/metrics/hbase/hlog_split_time.json",
+  ajaxIndex: 'service.metrics.hbase.hlog_split_time',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 1 - 2
ambari-web/app/views/main/service/info/metrics/hbase/regionserver_queuesize.js

@@ -30,8 +30,7 @@ App.ChartServiceMetricsHBASE_RegionServerQueueSize = App.ChartLinearTimeView.ext
   id: "service-metrics-hbase-regionserver-queuesize",
   title: Em.I18n.t('services.service.info.metrics.hbase.regionServerQueueSize'),
   renderer: 'line',
-  sourceUrl: "/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/flushQueueSize[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/compactionQueueSize[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/services/metrics/hbase/regionserver_queuesize.json",
+  ajaxIndex: 'service.metrics.hbase.regionserver_queuesize',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 1 - 2
ambari-web/app/views/main/service/info/metrics/hbase/regionserver_regions.js

@@ -30,8 +30,7 @@ App.ChartServiceMetricsHBASE_RegionServerRegions = App.ChartLinearTimeView.exten
   id: "service-metrics-hbase-regionserver-regions",
   title: Em.I18n.t('services.service.info.metrics.hbase.regionServerRegions'),
 
-  sourceUrl: "/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/regions[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/services/metrics/hbase/regionserver_regions.json",
+  ajaxIndex: 'service.metrics.hbase.regionserver_regions',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 2 - 2
ambari-web/app/views/main/service/info/metrics/hbase/regionserver_rw_requests.js

@@ -30,8 +30,8 @@ App.ChartServiceMetricsHBASE_RegionServerReadWriteRequests = App.ChartLinearTime
   id: "service-metrics-hbase-regionserver-rw-requests",
   title: Em.I18n.t('services.service.info.metrics.hbase.regionServerRequests'),
   renderer: 'line',
-  sourceUrl: "/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/readRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/writeRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/services/metrics/hbase/regionserver_rw_requests.json",
+
+  ajaxIndex: 'service.metrics.hbase.regionserver_rw_requests',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 2 - 2
ambari-web/app/views/main/service/info/metrics/hdfs/block_status.js

@@ -30,8 +30,8 @@ App.ChartServiceMetricsHDFS_BlockStatus = App.ChartLinearTimeView.extend({
   id: "service-metrics-hdfs-block-status",
   title: Em.I18n.t('services.service.info.metrics.hdfs.blockStatus'),
   renderer: 'line',
-  sourceUrl: "/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/FSNamesystem/PendingReplicationBlocks[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/UnderReplicatedBlocks[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl:"/data/services/metrics/hdfs/block_status.json",
+
+  ajaxIndex: 'service.metrics.hdfs.block_status',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 2 - 2
ambari-web/app/views/main/service/info/metrics/hdfs/file_operations.js

@@ -30,8 +30,8 @@ App.ChartServiceMetricsHDFS_FileOperations = App.ChartLinearTimeView.extend({
   id: "service-metrics-hdfs-file-operations",
   title: Em.I18n.t('services.service.info.metrics.hdfs.fileOperations'),
   renderer: 'line',
-  sourceUrl: "/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/namenode/FileInfoOps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/namenode/CreateFileOps[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/services/metrics/hdfs/file_operations.json",
+
+  ajaxIndex: 'service.metrics.hdfs.file_operations',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 1 - 2
ambari-web/app/views/main/service/info/metrics/hdfs/gc.js

@@ -31,8 +31,7 @@ App.ChartServiceMetricsHDFS_GC = App.ChartLinearTimeView.extend({
   title: Em.I18n.t('services.service.info.metrics.hdfs.gc'),
   yAxisFormatter: App.ChartLinearTimeView.TimeElapsedFormatter,
 
-  sourceUrl: "/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/services/metrics/hdfs/gc.json",
+  ajaxIndex: 'service.metrics.hdfs.gc',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 2 - 2
ambari-web/app/views/main/service/info/metrics/hdfs/io.js

@@ -31,8 +31,8 @@ App.ChartServiceMetricsHDFS_IO = App.ChartLinearTimeView.extend({
   title: Em.I18n.t('services.service.info.metrics.hdfs.io'),
   yAxisFormatter: App.ChartLinearTimeView.BytesFormatter,
   renderer: 'line',
-  sourceUrl: "/services/HDFS/components/DATANODE?fields=metrics/dfs/datanode/bytes_written[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/datanode/bytes_read[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/services/metrics/hdfs/io.json",
+
+  ajaxIndex: 'service.metrics.hdfs.io',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 2 - 2
ambari-web/app/views/main/service/info/metrics/hdfs/jvm_heap.js

@@ -31,8 +31,8 @@ App.ChartServiceMetricsHDFS_JVMHeap = App.ChartLinearTimeView.extend({
   title: Em.I18n.t('services.service.info.metrics.hdfs.jvmHeap'),
   yAxisFormatter: App.ChartLinearTimeView.BytesFormatter,
   renderer: 'line',
-  sourceUrl:"/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/memNonHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memNonHeapCommittedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memHeapCommittedM[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/services/metrics/hdfs/jvm_heap.json",
+
+  ajaxIndex: 'service.metrics.hdfs.jvm_heap',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 2 - 2
ambari-web/app/views/main/service/info/metrics/hdfs/jvm_threads.js

@@ -30,8 +30,8 @@ App.ChartServiceMetricsHDFS_JVMThreads = App.ChartLinearTimeView.extend({
   id: "service-metrics-hdfs-jvm-threads",
   title: Em.I18n.t('services.service.info.metrics.hdfs.jvmThreads'),
   renderer: 'line',
-  sourceUrl: "/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsBlocked[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsWaiting[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsTimedWaiting[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/services/metrics/hdfs/jvm_threads.json",
+
+  ajaxIndex: 'service.metrics.hdfs.jvm_threads',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 2 - 2
ambari-web/app/views/main/service/info/metrics/hdfs/rpc.js

@@ -30,8 +30,8 @@ App.ChartServiceMetricsHDFS_RPC = App.ChartLinearTimeView.extend({
   id: "service-metrics-hdfs-rpc",
   title: Em.I18n.t('services.service.info.metrics.hdfs.rpc'),
   yAxisFormatter: App.ChartLinearTimeView.TimeElapsedFormatter,
-  sourceUrl: "/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/services/metrics/hdfs/rpc.json",
+
+  ajaxIndex: 'service.metrics.hdfs.rpc',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 1 - 2
ambari-web/app/views/main/service/info/metrics/hdfs/space_utilization.js

@@ -31,8 +31,7 @@ App.ChartServiceMetricsHDFS_SpaceUtilization = App.ChartLinearTimeView.extend({
   title: Em.I18n.t('services.service.info.metrics.hdfs.spaceUtilization'),
   yAxisFormatter: App.ChartLinearTimeView.BytesFormatter,
   renderer: 'line',
-  sourceUrl: "/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/FSNamesystem/CapacityRemainingGB[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/CapacityUsedGB[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/CapacityTotalGB[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/services/metrics/hdfs/space_utilization.json",
+  ajaxIndex: 'service.metrics.hdfs.space_utilization',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 2 - 2
ambari-web/app/views/main/service/info/metrics/mapreduce/gc.js

@@ -30,8 +30,8 @@ App.ChartServiceMetricsMapReduce_GC = App.ChartLinearTimeView.extend({
   id: "service-metrics-mapreduce-gc",
   title: Em.I18n.t('services.service.info.metrics.mapreduce.gc'),
   yAxisFormatter: App.ChartLinearTimeView.TimeElapsedFormatter,
-  sourceUrl: "/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/services/metrics/mapreduce/gc.json",
+
+  ajaxIndex: 'service.metrics.mapreduce.gc',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 2 - 2
ambari-web/app/views/main/service/info/metrics/mapreduce/jobs_status.js

@@ -30,8 +30,8 @@ App.ChartServiceMetricsMapReduce_JobsStatus = App.ChartLinearTimeView.extend({
   id: "service-metrics-mapreduce-jobs-status",
   title: Em.I18n.t('services.service.info.metrics.mapreduce.jobsStatus'),
   renderer: 'line',
-  sourceUrl: "/services/MAPREDUCE/components/JOBTRACKER?fields=metrics/mapred/jobtracker/jobs_completed[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_preparing[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_failed[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_submitted[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_failed[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_running[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/services/metrics/mapreduce/jobs_status.json",
+
+  ajaxIndex: 'service.metrics.mapreduce.jobs_status',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 2 - 2
ambari-web/app/views/main/service/info/metrics/mapreduce/jvm_heap.js

@@ -31,8 +31,8 @@ App.ChartServiceMetricsMapReduce_JVMHeap = App.ChartLinearTimeView.extend({
   title: Em.I18n.t('services.service.info.metrics.mapreduce.jvmHeap'),
   yAxisFormatter: App.ChartLinearTimeView.BytesFormatter,
   renderer: 'line',
-  sourceUrl: "/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/memNonHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memNonHeapCommittedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memHeapCommittedM[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/services/metrics/mapreduce/jvm_heap.json",
+
+  ajaxIndex: 'service.metrics.mapreduce.jobs_heap',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 2 - 2
ambari-web/app/views/main/service/info/metrics/mapreduce/jvm_threads.js

@@ -30,8 +30,8 @@ App.ChartServiceMetricsMapReduce_JVMThreads = App.ChartLinearTimeView.extend({
   id: "service-metrics-mapreduce-jvm-threads",
   title: Em.I18n.t('services.service.info.metrics.mapreduce.jvmThreads'),
   renderer: 'line',
-  sourceUrl: "/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsBlocked[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsWaiting[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsTimedWaiting[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/services/metrics/mapreduce/jvm_threads.json",
+
+  ajaxIndex: 'service.metrics.mapreduce.jobs_threads',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 2 - 2
ambari-web/app/views/main/service/info/metrics/mapreduce/map_slots.js

@@ -30,8 +30,8 @@ App.ChartServiceMetricsMapReduce_MapSlots = App.ChartLinearTimeView.extend({
   id: "service-metrics-mapreduce-map-slots",
   title: Em.I18n.t('services.service.info.metrics.mapreduce.mapSlots'),
   renderer: 'line',
-  sourceUrl: "/services/MAPREDUCE/components/JOBTRACKER?fields=metrics/mapred/jobtracker/occupied_map_slots[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/reserved_map_slots[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/services/metrics/mapreduce/map_slots.json",
+
+  ajaxIndex: 'service.metrics.mapreduce.map_slots',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 2 - 2
ambari-web/app/views/main/service/info/metrics/mapreduce/reduce_slots.js

@@ -30,8 +30,8 @@ App.ChartServiceMetricsMapReduce_ReduceSlots = App.ChartLinearTimeView.extend({
   id: "service-metrics-mapreduce-reduce-slots",
   title: Em.I18n.t('services.service.info.metrics.mapreduce.reduceSlots'),
   renderer: 'line',
-  sourceUrl: "/services/MAPREDUCE/components/JOBTRACKER?fields=metrics/mapred/jobtracker/occupied_reduce_slots[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/reserved_reduce_slots[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/services/metrics/mapreduce/reduce_slots.json",
+
+  ajaxIndex: 'service.metrics.mapreduce.reduce_slots',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 2 - 2
ambari-web/app/views/main/service/info/metrics/mapreduce/rpc.js

@@ -30,8 +30,8 @@ App.ChartServiceMetricsMapReduce_RPC = App.ChartLinearTimeView.extend({
   id: "service-metrics-mapreduce-rpc",
   title: Em.I18n.t('services.service.info.metrics.mapreduce.rpc'),
   yAxisFormatter: App.ChartLinearTimeView.TimeElapsedFormatter,
-  sourceUrl: "/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/services/metrics/mapreduce/rpc.json",
+
+  ajaxIndex: 'service.metrics.mapreduce.rpc',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];

+ 2 - 2
ambari-web/app/views/main/service/info/metrics/mapreduce/tasks_running_waiting.js

@@ -30,8 +30,8 @@ App.ChartServiceMetricsMapReduce_TasksRunningWaiting = App.ChartLinearTimeView.e
   id: "service-metrics-mapreduce-tasks-running-waiting",
   title: Em.I18n.t('services.service.info.metrics.mapreduce.tasksRunningWaiting'),
   renderer: 'line',
-  sourceUrl: "/services/MAPREDUCE/components/JOBTRACKER?fields=metrics/mapred/jobtracker/running_maps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/running_reduces[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/waiting_maps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/waiting_reduces[{fromSeconds},{toSeconds},{stepSeconds}]",
-  mockUrl: "/data/services/metrics/mapreduce/tasks_running_waiting.json",
+
+  ajaxIndex: 'service.metrics.mapreduce.tasks_running_waiting',
 
   transformToSeries: function (jsonData) {
     var seriesArray = [];