Bladeren bron

AMBARI-1145. Cluster Management refactoring. (yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1431780 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako 12 jaren geleden
bovenliggende
commit
fd71cd58f2

+ 15 - 14
ambari-web/app/controllers/main/service/info/configs.js

@@ -227,17 +227,19 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
    * Render a custom conf-site box for entering properties that will be written in *-site.xml files of the services
    */
   loadCustomConfig: function (serviceConfigs) {
-    var customConfigs = this.get('customConfigs').findProperty('serviceName', this.get('content.serviceName'));
-    var customValue = '';
-    var length = this.get('customConfig').length;
-    this.get('customConfig').forEach(function (_config, index) {
-      customValue += _config.name + '=' + _config.value;
-      if (index !== length - 1) {
-        customValue += '\n';
-      }
-    }, this);
-    customConfigs.value = customValue;
-    serviceConfigs.pushObject(customConfigs);
+    if (this.get('customConfigs').findProperty('serviceName', this.get('content.serviceName'))) {
+      var customConfigs = this.get('customConfigs').findProperty('serviceName', this.get('content.serviceName'));
+      var customValue = '';
+      var length = this.get('customConfig').length;
+      this.get('customConfig').forEach(function (_config, index) {
+        customValue += _config.name + '=' + _config.value;
+        if (index !== length - 1) {
+          customValue += '\n';
+        }
+      }, this);
+      customConfigs.value = customValue;
+      serviceConfigs.pushObject(customConfigs);
+    }
   },
 
 
@@ -671,6 +673,8 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
         if (this.get('globalConfigs').someProperty('name', config.templateName[index])) {
           var globalValue = this.get('globalConfigs').findProperty('name', config.templateName[index]).value;
           config.value = config.value.replace(_value, globalValue);
+        } else {
+          config.value = null;
         }
       }, this);
     }
@@ -922,9 +926,6 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
         var oozieServerHost = serviceConfigs.findProperty('name', 'oozieserver_host');
         oozieServerHost.defaultValue = this.get('content.components').findProperty('componentName', 'OOZIE_SERVER').get('host.hostName');
         globalConfigs.push(oozieServerHost);
-        var oozieAmbariHost = serviceConfigs.findProperty('name', 'oozie_ambari_host'); //db hostname
-        oozieAmbariHost.defaultValue = this.get('content.components').findProperty('componentName', 'OOZIE_SERVER').get('host.hostName');
-        globalConfigs.push(oozieAmbariHost);
         break;
       case 'HBASE':
         var hbaseMasterHost = serviceConfigs.findProperty('name', 'hbasemaster_host');

+ 4 - 0
ambari-web/app/controllers/wizard/step2_controller.js

@@ -140,6 +140,10 @@ App.WizardStep2Controller = Em.Controller.extend({
       return false;
     }
 
+    if (this.get('sshKeyError')) {
+      return false;
+    }
+
     this.updateHostNameArr();
 
     if(this.isPattern)

+ 23 - 16
ambari-web/app/controllers/wizard/step8_controller.js

@@ -61,12 +61,12 @@ App.WizardStep8Controller = Em.Controller.extend({
       var hiveDb = globals.findProperty('name', 'hive_database');
       if (hiveDb.value === 'New MySQL Database') {
         if (globals.someProperty('name', 'hive_ambari_host')) {
-          globals.findProperty('name', 'hive_ambari_host').name = 'hive_mysql_host';
+          globals.findProperty('name', 'hive_ambari_host').name = 'hive_mysql_hostname';
         }
         globals = globals.without(globals.findProperty('name', 'hive_existing_host'));
         globals = globals.without(globals.findProperty('name', 'hive_existing_database'));
       } else {
-        globals.findProperty('name', 'hive_existing_host').name = 'hive_mysql_host';
+        globals.findProperty('name', 'hive_existing_host').name = 'hive_mysql_hostname';
         globals = globals.without(globals.findProperty('name', 'hive_ambari_host'));
         globals = globals.without(globals.findProperty('name', 'hive_ambari_database'));
       }
@@ -134,19 +134,23 @@ App.WizardStep8Controller = Em.Controller.extend({
         //console.log("The name of the variable is: " + this.get('content.serviceConfigProperties').findProperty('name', templateName[index]).name);
         var globValue = this.get('globals').findProperty('name', templateName[index]).value;
         // Hack for templeton.zookeeper.hosts
-        if (name === "templeton.zookeeper.hosts") {
-          var zooKeeperPort = '2181';
-          if(typeof globValue === 'string') {
-            var temp = [];
-            temp.push(globValue);
-            globValue = temp;
+        if (value !== null) {   // if the property depends on more than one template name like <templateName[0]>/<templateName[1]> then don't proceed to the next if the prior is null or not found in the global configs
+          if (name === "templeton.zookeeper.hosts" || name === 'hbase.zookeeper.quorum') {
+            var zooKeeperPort = '2181';
+            if (typeof globValue === 'string') {
+              var temp = [];
+              temp.push(globValue);
+              globValue = temp;
+            }
+            if (name === "templeton.zookeeper.hosts") {
+              globValue.forEach(function (_host, index) {
+                globValue[index] = globValue[index] + ':' + zooKeeperPort;
+              }, this);
+            }
+            value = value.replace(_express, globValue.toString());
+          } else {
+            value = value.replace(_express, globValue);
           }
-          globValue.forEach(function (_host,index) {
-            globValue[index] = globValue[index] + ':' + zooKeeperPort;
-          }, this);
-          value = value.replace(_express, globValue.toString());
-        } else {
-          value = value.replace(_express, globValue);
         }
       } else {
         /*
@@ -155,7 +159,7 @@ App.WizardStep8Controller = Em.Controller.extend({
          "content.serviceConfigProperties. Two possible reasons for the error could be: 1) The service is not selected. " +
          "and/OR 2) The service_config metadata file has no corresponding global var for the site property variable");
          */
-        //value = null;
+        value = null;
       }
     }, this);
     return value;
@@ -200,6 +204,7 @@ App.WizardStep8Controller = Em.Controller.extend({
       }, this);
     }
     //For properties in the configMapping file having foreignKey and templateName properties.
+
     var templateValue = config.value.match(/<(templateName.*?)>/g);
     if (templateValue) {
       templateValue.forEach(function (_value) {
@@ -207,6 +212,8 @@ App.WizardStep8Controller = Em.Controller.extend({
         if (this.get('globals').someProperty('name', config.templateName[index])) {
           var globalValue = this.get('globals').findProperty('name', config.templateName[index]).value;
           config.value = config.value.replace(_value, globalValue);
+        } else {
+          config.value = null;
         }
       }, this);
     }
@@ -1281,7 +1288,7 @@ App.WizardStep8Controller = Em.Controller.extend({
     }, this);
     hiveProperties['hive.metastore.uris'] = 'thrift://' + this.get('globals').findProperty('name', 'hivemetastore_host').value + ':9083';
     hiveProperties['javax.jdo.option.ConnectionURL'] =
-      'jdbc:mysql://' + this.get('globals').findProperty('name', 'hive_mysql_host').value +
+      'jdbc:mysql://' + this.get('globals').findProperty('name', 'hive_mysql_hostname').value +
         '/' + this.get('globals').findProperty('name', 'hive_database_name').value + '?createDatabaseIfNotExist=true';
     return {type: 'hive-site', tag: 'version1', properties: hiveProperties};
   },

+ 3 - 1
ambari-web/app/controllers/wizard/step9_controller.js

@@ -117,10 +117,12 @@ App.WizardStep9Controller = Em.Controller.extend({
 
   loadHosts: function () {
     var hostInfo = this.get('content.hosts');
-
     var hosts = new Ember.Set();
     for (var index in hostInfo) {
       var obj = Em.Object.create(hostInfo[index]);
+      obj.message = '';
+      obj.progress = 0;
+      obj.status = 'info';
       obj.tasks = [];
       obj.logTasks = [];
       hosts.add(obj);

+ 9 - 2
ambari-web/app/data/config_mapping.js

@@ -66,6 +66,13 @@ module.exports = [
     "value": "<templateName[0]>",
     "filename": "core-site.xml"
   },
+  {
+    "name": "hadoop.proxyuser.<foreignKey[0]>.hosts",
+    "templateName": ["oozieserver_host"],
+    "foreignKey": ["oozie_user"],
+    "value": "<templateName[0]>",
+    "filename": "core-site.xml"
+  },
   {
     "name": "hadoop.proxyuser.<foreignKey[0]>.groups",
     "templateName": ["proxyuser_group"],
@@ -75,8 +82,8 @@ module.exports = [
   },
   {
     "name": "hadoop.proxyuser.<foreignKey[0]>.hosts",
-    "templateName": ["oozieserver_host"],
-    "foreignKey": ["oozie_user"],
+    "templateName": ["hivemetastore_host"],
+    "foreignKey": ["webhcat_user"],
     "value": "<templateName[0]>",
     "filename": "core-site.xml"
   },

+ 71 - 126
ambari-web/app/mappers/service_mapper.js

@@ -145,41 +145,54 @@ App.servicesMapper = App.QuickDataMapper.create({
     }
 
     if (json.items) {
-
-      // Host components
       var result = [];
-      json.items.forEach(function(item){
-        item.components.forEach(function(component){
-          component.host_components.forEach(function(host_component){
-            result.push(this.parseIt(host_component, this.config3));
+      json.items.forEach(function (item) {
+        var finalConfig = jQuery.extend({}, this.config);
+        var finalJson = [];
+        item.host_components = [];
+//        var json = this.parseIt(item, this.config);
+//        if(App.Service.find().someProperty('id', json.id)){
+//          var fieldsToUpdate = [
+//            'work_status',
+//            'components',
+//            'host_components'
+//          ]
+//          this.updateRecord(App.Service.find().findProperty('id', json.id), json, fieldsToUpdate);
+//          return;
+//        }
+
+        if (this.get('model').find(item.ServiceInfo.service_name).get('isLoaded')) {
+          this.update(item);
+          return;
+        }
+        item.components.forEach(function (component) {
+          component.host_components.forEach(function (host_component) {
+            host_component.id = host_component.HostRoles.component_name + "_" + host_component.HostRoles.host_name;
+            item.host_components.push(host_component.id);
           }, this)
-        }, this)
-      }, this);
-      var newHostComponents = [];
-      result.forEach(function(hcJson){
-        hcJson.id = hcJson.component_name + '_' + hcJson.host_id;
-        var component = App.HostComponent.find(hcJson.id);
-        if (component && component.get('isLoaded')) { // UPDATE
-          if (hcJson.work_status) {
-            component.set('workStatus', hcJson.work_status);
-          }
-          if (hcJson.component_name) {
-            component.set('componentName', hcJson.component_name);
-          }
-          if (hcJson.host_id) {
-            component.set('host', App.Host.find(hcJson.host_id));
-          }
-          if (hcJson.service_id) {
-            component.set('service', App.Service.find(hcJson.service_id));
-          }
+        }, this);
+
+        if (item && item.ServiceInfo && item.ServiceInfo.service_name == "HDFS") {
+          // Change the JSON so that it is easy to map
+          finalJson = this.hdfsMapper(item);
+          result.push(finalJson);
+          App.store.load(App.HDFSService, finalJson);
+        } else if (item && item.ServiceInfo && item.ServiceInfo.service_name == "MAPREDUCE") {
+          finalJson = this.mapreduceMapper(item);
+          result.push(finalJson);
+          App.store.load(App.MapReduceService, finalJson);
+        } else if (item && item.ServiceInfo && item.ServiceInfo.service_name == "HBASE") {
+          finalJson = this.hbaseMapper(item);
+          result.push(finalJson);
+          App.store.load(App.HBaseService, finalJson);
         } else {
-          newHostComponents.push(hcJson);
+          result.push(this.parseIt(item, this.config));
         }
-      });
+      }, this);
 
-      if (newHostComponents.length > 0) {
-        App.store.loadMany(this.get('model3'), newHostComponents);
-      }
+
+      result = this.sortByOrder(this.get('servicesSortOrder'), result);
+      App.store.loadMany(this.get('model'), result);
 
       // Service components
       result = [];
@@ -202,110 +215,43 @@ App.servicesMapper = App.QuickDataMapper.create({
           newComponents.push(componentJson);
         }
       });
-
       if (newComponents.length > 0) {
         App.store.loadMany(this.get('model2'), newComponents);
       }
 
-      //Services
-      var newServices = [];
-      json.items.forEach(function (item) {
-        var finalJson = {};
-        var serviceJson = this.parseIt(item, this.config);
-        var serviceFields = [
-          'work_status',
-          'components',
-          'host_components'
-        ]
-        if (item && item.ServiceInfo && item.ServiceInfo.service_name == "HDFS") {
-          // Change the JSON so that it is easy to map
-          finalJson = this.hdfsMapper(item);
-          if(App.Service.find().someProperty('id', serviceJson.id)){
-            var hdfsFields = [
-              'version',
-              'name_node_start_time',
-              'jvm_memory_heap_committed',
-              'jvm_memory_heap_used',
-              'capacity_used',
-              'capacity_total',
-              'dfs_total_blocks',
-              'dfs_corrupt_blocks',
-              'dfs_missing_blocks',
-              'dfs_under_replicated_blocks',
-              'dfs_total_files',
-              'upgrade_status',
-              'safe_mode_status',
-              'decommission_data_nodes',
-              'live_data_nodes',
-              'dead_data_nodes'
-            ];
-            this.updateRecord(App.Service.find().findProperty('id', serviceJson.id), serviceJson, serviceFields);
-            this.updateRecord(App.HDFSService.find().findProperty('id', finalJson.id), finalJson, hdfsFields);
-          } else {
-            newServices.push(serviceJson);
-            App.store.load(App.HDFSService, finalJson);
+      // Host components
+      result = [];
+      json.items.forEach(function(item){
+        item.components.forEach(function(component){
+          component.host_components.forEach(function(host_component){
+            result.push(this.parseIt(host_component, this.config3));
+          }, this)
+        }, this)
+      }, this);
+      var newHostComponents = [];
+      result.forEach(function(hcJson){
+        hcJson.id = hcJson.component_name + '_' + hcJson.host_id;
+        var component = App.HostComponent.find(hcJson.id);
+        if (component && component.get('isLoaded')) { // UPDATE
+          if (hcJson.work_status) {
+            component.set('workStatus', hcJson.work_status);
           }
-        } else if (item && item.ServiceInfo && item.ServiceInfo.service_name == "MAPREDUCE") {
-          finalJson = this.mapreduceMapper(item);
-          if(App.Service.find().someProperty('id', serviceJson.id)){
-            var mapReduceFields = [
-              'version',
-              'job_tracker_start_time',
-              'job_tracker_heap_used)',
-              'job_tracker_heap_max',
-              'map_slots',
-              'reduce_slots',
-              'jobs_submitted',
-              'jobs_completed',
-              'map_slots_occupied',
-              'map_slots_reserved',
-              'reduce_slots_occupied',
-              'reduce_slots_reserved)',
-              'maps_running',
-              'maps_waiting',
-              'reduces_running',
-              'reduces_waiting',
-              'trackers_decommissioned'
-            ]
-            this.updateRecord(App.Service.find().findProperty('id', finalJson.id), serviceJson, serviceFields);
-            this.updateRecord(App.MapReduceService.find().findProperty('id', finalJson.id), finalJson, mapReduceFields);
-          } else {
-            newServices.push(serviceJson);
-            App.store.load(App.MapReduceService, finalJson);
+          if (hcJson.component_name) {
+            component.set('componentName', hcJson.component_name);
           }
-        } else if (item && item.ServiceInfo && item.ServiceInfo.service_name == "HBASE") {
-          finalJson = this.hbaseMapper(item);
-          if(App.Service.find().someProperty('id', serviceJson.id)){
-            var hbaseFields = [
-              'version',
-              'master_start_time',
-              'master_active_time',
-              'average_load',
-              'regions_in_transition',
-              'revision',
-              'heap_memory_used',
-              'heap_memory_max'
-            ]
-            this.updateRecord(App.Service.find().findProperty('id', serviceJson.id), serviceJson, serviceFields);
-            this.updateRecord(App.HBaseService.find().findProperty('id', finalJson.id), finalJson, hbaseFields);
-          } else {
-            newServices.push(serviceJson);
-            App.store.load(App.HBaseService, finalJson);
+          if (hcJson.host_id) {
+            component.set('host', App.Host.find(hcJson.host_id));
           }
-        } else {
-          if(App.Service.find().someProperty('id', serviceJson.id)){
-            this.updateRecord(App.Service.find().findProperty('id', serviceJson.id), serviceJson, serviceFields);
-          } else {
-            newServices.push(serviceJson);
+          if (hcJson.service_id) {
+            component.set('service', App.Service.find(hcJson.service_id));
           }
+        } else {
+          newHostComponents.push(hcJson);
         }
-      }, this);
-
-      if(newServices.length){
-        newServices = this.sortByOrder(this.get('servicesSortOrder'), newServices);
-        App.store.loadMany(this.get('model'), newServices);
+      });
+      if (newHostComponents.length > 0) {
+        App.store.loadMany(this.get('model3'), newHostComponents);
       }
-      //App.store.commit();
     }
   },
   update: function (service) {
@@ -531,8 +477,7 @@ App.servicesMapper = App.QuickDataMapper.create({
     return finalJson;
   },
   updateRecord: function (record, json, fieldsToUpdate) {
-    for (var i = 0; i < fieldsToUpdate.length; i++) {
-      var field = fieldsToUpdate[i];
+    for (var field in fieldsToUpdate) {
       if (json[field] !== undefined) {
         if(json[field] instanceof Array){
           this.updateHasMany(record, stringUtils.underScoreToCamelCase(field), json[field]);

+ 1 - 1
ambari-web/app/messages.js

@@ -153,7 +153,7 @@ Em.I18n.translations = {
   'installer.step9.host.status.success':'Success',
   'installer.step9.host.status.warning':'Warnings encountered',
   'installer.step9.host.status.failed':'Failures encountered',
-  'installer.step9.host.status.nothingToInstall':'Nothing to install',
+  'installer.step9.host.status.nothingToInstall':'Waiting (Nothing to install)',
   'installer.step9.hostLog.popup.header':'Tasks. executed on ',
 
   'installer.step10.header':'Summary',

+ 2 - 0
ambari-web/app/models/service.js

@@ -66,6 +66,7 @@ App.Service = DS.Model.extend({
       "HBASE",
       "OOZIE",
       "HIVE",
+      "WEBHCAT",
       "ZOOKEEPER",
       "PIG",
       "SQOOP"
@@ -81,6 +82,7 @@ App.Service = DS.Model.extend({
       "HBASE",
       "OOZIE",
       "HIVE",
+      "WEBHCAT",
       "ZOOKEEPER",
       "PIG",
       "SQOOP",

+ 1 - 2
ambari-web/app/views/main/service/info/summary.js

@@ -307,8 +307,7 @@ App.MainServiceInfoSummaryView = Em.View.extend({
       }
     }
     return graphs;
-    //we don't need to bind graphs to service property they update by themselves
-  }.property(),
+  }.property('service'),
 
   loadServiceSummary:function (serviceName) {