You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by rl...@apache.org on 2015/06/15 21:45:16 UTC

ambari git commit: AMBARI-11921. CapSched View does not write config file when cluster uses RM-HA (Erik Bergenholtz via rlevas)

Repository: ambari
Updated Branches:
  refs/heads/trunk 1800b0b21 -> e518ac33a


AMBARI-11921. CapSched View does not write config file when cluster uses RM-HA (Erik Bergenholtz via rlevas)


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

Branch: refs/heads/trunk
Commit: e518ac33ab2dc5734dc376695fb9b42157af375a
Parents: 1800b0b
Author: Erik Bergenholtz <eb...@hortonworks.com>
Authored: Mon Jun 15 15:44:56 2015 -0400
Committer: Robert Levas <rl...@hortonworks.com>
Committed: Mon Jun 15 15:45:05 2015 -0400

----------------------------------------------------------------------
 .../capacityscheduler/ConfigurationService.java | 25 ++++++++++++-----
 .../src/main/resources/ui/app/adapters.js       | 27 +++++++++----------
 .../main/resources/ui/app/controllers/queues.js | 28 +++++++++++++-------
 .../src/main/resources/ui/app/store.js          |  8 ++----
 .../main/resources/ui/app/templates/queues.hbs  | 22 ++++++++-------
 5 files changed, 63 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e518ac33/contrib/views/capacity-scheduler/src/main/java/org/apache/ambari/view/capacityscheduler/ConfigurationService.java
----------------------------------------------------------------------
diff --git a/contrib/views/capacity-scheduler/src/main/java/org/apache/ambari/view/capacityscheduler/ConfigurationService.java b/contrib/views/capacity-scheduler/src/main/java/org/apache/ambari/view/capacityscheduler/ConfigurationService.java
index c3e415a..968f212 100644
--- a/contrib/views/capacity-scheduler/src/main/java/org/apache/ambari/view/capacityscheduler/ConfigurationService.java
+++ b/contrib/views/capacity-scheduler/src/main/java/org/apache/ambari/view/capacityscheduler/ConfigurationService.java
@@ -23,7 +23,6 @@ import org.apache.ambari.view.capacityscheduler.utils.MisconfigurationFormattedE
 import org.apache.ambari.view.capacityscheduler.utils.ServiceFormattedException;
 import org.apache.ambari.view.utils.ambari.AmbariApi;
 import org.apache.commons.io.IOUtils;
-import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
 import org.json.simple.JSONValue;
 import org.slf4j.Logger;
@@ -240,7 +239,7 @@ public class ConfigurationService {
     Response response;
 
     try {
-      String url = String.format(RM_GET_NODE_LABEL_URL, getRMHost());
+      String url = String.format(RM_GET_NODE_LABEL_URL, getRMUrl());
 
       InputStream rmResponse = context.getURLStreamProvider().readFrom(
           url, "GET", (String) null, new HashMap<String, String>());
@@ -434,8 +433,8 @@ public class ConfigurationService {
         return Response.status(401).build();
       }
 
-      String rmHost = getRMHost();
-      JSONObject data = getJsonObject(String.format(REFRESH_RM_REQUEST_DATA, rmHost));
+      String rmHosts = getRMHosts();
+      JSONObject data = getJsonObject(String.format(REFRESH_RM_REQUEST_DATA, rmHosts));
 
       Map<String, String> headers = new HashMap<String, String>();
       headers.put("Content-Type", "application/x-www-form-urlencoded");
@@ -465,9 +464,9 @@ public class ConfigurationService {
         return Response.status(401).build();
       }
 
-      String rmHost = getRMHost();
+      String rmHosts = getRMHosts();
       JSONObject data = getJsonObject(String.format(RESTART_RM_REQUEST_DATA,
-          ambariApi.getCluster().getName(), rmHost, rmHost));
+          ambariApi.getCluster().getName(), rmHosts, rmHosts));
 
       Map<String, String> headers = new HashMap<String, String>();
       headers.put("Content-Type", "application/x-www-form-urlencoded");
@@ -481,8 +480,20 @@ public class ConfigurationService {
     return readLatestConfiguration();
   }
 
-  private String getRMHost() {
+  private String getRMUrl() {
     return ambariApi.getServices().getRMUrl();
   }
 
+  private String getRMHosts() {
+    StringBuilder hosts = new StringBuilder();
+    boolean first = true;
+    for (String host : ambariApi.getHostsWithComponent("RESOURCEMANAGER")) {
+      if (!first) {
+        hosts.append(",");
+      }
+      hosts.append(host);
+      first = false;
+    }
+    return hosts.toString();
+  }
 } // end ConfigurationService

http://git-wip-us.apache.org/repos/asf/ambari/blob/e518ac33/contrib/views/capacity-scheduler/src/main/resources/ui/app/adapters.js
----------------------------------------------------------------------
diff --git a/contrib/views/capacity-scheduler/src/main/resources/ui/app/adapters.js b/contrib/views/capacity-scheduler/src/main/resources/ui/app/adapters.js
index e7fb4fb..dd02587 100644
--- a/contrib/views/capacity-scheduler/src/main/resources/ui/app/adapters.js
+++ b/contrib/views/capacity-scheduler/src/main/resources/ui/app/adapters.js
@@ -83,18 +83,12 @@ App.QueueAdapter = DS.Adapter.extend({
   saveMark:'',
 
   updateRecord:function (store,type,record) {
-    var adapter = this;
-    var saveMark = this.get('saveMark'),
+    var adapter = this,
         uri = _getCapacitySchedulerViewUri(this),
         serializer = store.serializerFor('queue'),
         props = serializer.serializeConfig(record),
         new_tag = 'version' + Math.floor(+moment()),
-        postSaveUri,data;
-
-    if (saveMark) {
-      postSaveUri = [_getCapacitySchedulerViewUri(this),saveMark].join('/');
-      this.set('saveMark','');
-    }
+        data;
 
     data = JSON.stringify({'Clusters':
       {'desired_config':
@@ -114,16 +108,21 @@ App.QueueAdapter = DS.Adapter.extend({
       }, function(jqXHR) {
         jqXHR.then = null;
         Ember.run(null, reject, jqXHR);
-      }).then(function () {
-        if (postSaveUri) {
-          adapter.postSave(postSaveUri);
-        }
       });
     },'App: QueueAdapter#updateRecord save config woth ' + new_tag + ' tag');
   },
 
-  postSave:function(uri){
-    this.ajax(uri,'PUT',{contentType:'application/json; charset=utf-8',data:JSON.stringify({save:true})});
+  relaunchCapSched: function (opt) {
+    if (!opt) return;
+    var uri = [_getCapacitySchedulerViewUri(this),opt].join('/');
+    return new Ember.RSVP.Promise(function(resolve, reject) {
+      this.ajax(uri,'PUT',{contentType:'application/json; charset=utf-8',data:JSON.stringify({save:true})})
+      .then(function (data) {
+        resolve(data);
+      },function (error) {
+        reject(error);
+      });
+    }.bind(this),'App: QueueAdapter#relaunchCapSched ' + opt + ' capacity-scheduler');
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/e518ac33/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/queues.js
----------------------------------------------------------------------
diff --git a/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/queues.js b/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/queues.js
index 9a27b10..429832f 100644
--- a/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/queues.js
+++ b/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/queues.js
@@ -97,23 +97,30 @@ App.QueuesController = Ember.ArrayController.extend({
       }
     },
     saveConfig:function (mark) {
-      if (mark == 'restart') {
-        this.get('store').markForRestart();
-      } else if (mark == 'refresh') {
-        this.get('store').markForRefresh();
-      }
       var collectedLabels = this.get('model').reduce(function (prev,q) {
         return prev.pushObjects(q.get('labels.content'));
       },[]);
 
       var scheduler = this.get('scheduler').save(),
           model = this.get('model').save(),
-          labels = DS.ManyArray.create({content:collectedLabels}).save();
+          labels = DS.ManyArray.create({content:collectedLabels}).save(),
+          opt = '';
+
+      if (mark == 'restart') {
+        opt = 'saveAndRestart';
+      } else if (mark == 'refresh') {
+        opt = 'saveAndRefresh';
+      }
 
       Em.RSVP.Promise.all([labels,model,scheduler]).then(
         Em.run.bind(this,'saveSuccess'),
-        Em.run.bind(this,'saveError')
-      );
+        Em.run.bind(this,'saveConfigError','save')
+      ).then(function () {
+        if (opt) {
+          return this.get('store').relaunchCapSched(opt);
+        }
+      }.bind(this))
+      .catch(Em.run.bind(this,'saveConfigError',mark));
 
     },
     clearAlert:function () {
@@ -194,8 +201,9 @@ App.QueuesController = Ember.ArrayController.extend({
     this.set('store.deletedQueues',[]);
   },
 
-  saveError:function (error) {
-    var response = JSON.parse(error.responseText);
+  saveConfigError:function (operation, error) {
+    var response = error.responseJSON;
+    response.simpleMessage = operation.capitalize() + ' failed!';
     this.set('alertMessage',response);
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/e518ac33/contrib/views/capacity-scheduler/src/main/resources/ui/app/store.js
----------------------------------------------------------------------
diff --git a/contrib/views/capacity-scheduler/src/main/resources/ui/app/store.js b/contrib/views/capacity-scheduler/src/main/resources/ui/app/store.js
index c7a7e6a..4297b17 100644
--- a/contrib/views/capacity-scheduler/src/main/resources/ui/app/store.js
+++ b/contrib/views/capacity-scheduler/src/main/resources/ui/app/store.js
@@ -303,12 +303,8 @@ App.ApplicationStore = DS.Store.extend({
 
   isInitialized: Ember.computed.and('tag', 'clusterName'),
 
-  markForRefresh:function () {
-    this.set('defaultAdapter.saveMark','saveAndRefresh');
-  },
-
-  markForRestart:function () {
-    this.set('defaultAdapter.saveMark','saveAndRestart');
+  relaunchCapSched: function (opt) {
+    return this.get('defaultAdapter').relaunchCapSched(opt);
   },
 
   flushPendingSave: function() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/e518ac33/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/queues.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/queues.hbs b/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/queues.hbs
index f785a62..94cb421 100644
--- a/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/queues.hbs
+++ b/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/queues.hbs
@@ -57,6 +57,18 @@
         </div>
       {{/if}}
   </div>
+  {{!-- ALERT --}}
+  {{#if alertMessage}}
+  <div class="alert alert-danger">
+    <button {{action 'clearAlert'}}type="button" class="close" aria-hidden="true">&times;</button>
+    <strong> {{alertMessage.status}} </strong> {{alertMessage.simpleMessage}}
+    <div>
+      <small>{{alertMessage.message}}</small>
+    </div>
+    <br>
+    {{#link-to 'trace' class="alert-link"}}Trace{{/link-to}}
+  </div>
+  {{/if}}
   {{!-- QUEUE LIST --}}
   <div class="list-group queue-list">
     {{recurce-queues depth=0}}
@@ -97,16 +109,6 @@
       </div>
     </div>
   </div>
-
-  {{!-- ALERT --}}
-  {{#if alertMessage}}
-  <div class="alert alert-danger">
-    <button {{action 'clearAlert'}}type="button" class="close" aria-hidden="true">&times;</button>
-    <strong> {{alertMessage.status}} </strong> {{alertMessage.message}}
-    <br>
-    {{#link-to 'trace' class="alert-link"}}Trace{{/link-to}}
-  </div>
-  {{/if}}
 </div>
 
 {{!-- QUEUE --}}