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/11 17:05:38 UTC

ambari git commit: AMBARI-11855. Capacity scheduler view, wrong queue rename behavior (Erik Bergenholtz via rlevas)

Repository: ambari
Updated Branches:
  refs/heads/trunk b314e8db0 -> 1b71e10c3


AMBARI-11855. Capacity scheduler view, wrong queue rename behavior (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/1b71e10c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1b71e10c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1b71e10c

Branch: refs/heads/trunk
Commit: 1b71e10c34f06d5a03749daa3b005c0691be38e7
Parents: b314e8d
Author: Erik Bergenholtz <eb...@hortonworks.com>
Authored: Thu Jun 11 11:05:29 2015 -0400
Committer: Robert Levas <rl...@hortonworks.com>
Committed: Thu Jun 11 11:05:29 2015 -0400

----------------------------------------------------------------------
 .../main/resources/ui/app/controllers/queue.js  | 47 +++++++++++++++++---
 .../src/main/resources/ui/app/store.js          |  9 ++--
 2 files changed, 48 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1b71e10c/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/queue.js
----------------------------------------------------------------------
diff --git a/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/queue.js b/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/queue.js
index 1720e56..77f8889 100644
--- a/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/queue.js
+++ b/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/queue.js
@@ -42,6 +42,7 @@ App.QueueController = Ember.ObjectController.extend({
           store = this.get('store'),
           queuesController = this.get('controllers.queues'),
           parentPath = queue.get('parentPath'),
+          skeletons = [],
           name, renamedQueueBackup;
 
       if (opt == 'ask') {
@@ -65,16 +66,28 @@ App.QueueController = Ember.ObjectController.extend({
 
         if (queue.get('isNewQueue')) {
           renamedQueueBackup = this.get('store').buildDeletedQueue(queue);
+
+          if (!Em.isEmpty(queue.get('queuesArray'))) {
+            this.recurceCreateChildrenSkeletons(queue,skeletons);
+          }
         }
 
         store.recurceRemoveQueue(queue).then(function (queue) {
           return (queue.get('isNewQueue')) ? renamedQueueBackup : store.get('deletedQueues').findBy('path',queue.get('path'));
-        }).then(function (deletedQueue) {
-          var targetDeleted =  store.get('deletedQueues').findBy('path',[parentPath,name].join('.')),
-              queuePrototype = (targetDeleted) ? store.createFromDeleted(targetDeleted) : store.copyFromDeleted(deletedQueue,parentPath,name);
+        })
+        .then(function (skeleton) {
+          return this.createQueueFromSkeleton(parentPath,name,skeleton);
+        }.bind(this))
+        .then(function (queue) {
+          this.transitionToRoute('queue',queue);
+          return queue;
+        }.bind(this))
+        .then(function (newParent) {
+          skeletons.forEach(function (skeleton) {
+            this.createQueueFromSkeleton(skeleton.parentPath.split('.').replace(newParent.get('depth'),1,newParent.get('name')).join('.'),skeleton.name,skeleton);
+          }.bind(this));
+        }.bind(this));
 
-          return store.saveAndUpdateQueue(queuePrototype,deletedQueue);
-        }).then(Em.run.bind(this,'transitionToRoute','queue'));
       }
 
     },
@@ -84,6 +97,30 @@ App.QueueController = Ember.ObjectController.extend({
     }
   },
 
+  createQueueFromSkeleton: function(parentPath,name,skeleton){
+    var targetDeleted =  this.store.get('deletedQueues').findBy('path',[parentPath,name].join('.')),
+        queueToSave = (targetDeleted) ? this.store.createFromDeleted(targetDeleted) : this.store.copyFromDeleted(skeleton,parentPath,name);
+
+    return this.store.saveAndUpdateQueue(queueToSave,skeleton);
+  },
+
+  recurceCreateChildrenSkeletons: function(queue,skeletonArray) {
+    if (!skeletonArray) {
+      return;
+    }
+    var childrenNames = queue.get('queuesArray');
+
+    childrenNames.forEach(function (childName) {
+      var queueRecord = queue.store.getById('queue',[queue.get('id'),childName.toLowerCase()].join('.'));
+
+      skeletonArray.push(queue.store.buildDeletedQueue(queueRecord));
+
+      if (!Em.isEmpty(queueRecord.get('queuesArray'))) {
+        this.recurceCreateChildrenSkeletons(queueRecord,skeletonArray);
+      }
+    }.bind(this));
+  },
+
   /**
    * Collection of modified fields in queue.
    * @type {Object} - { [fileldName] : {Boolean} }

http://git-wip-us.apache.org/repos/asf/ambari/blob/1b71e10c/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 61aa2db..c7a7e6a 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
@@ -150,12 +150,14 @@ App.ApplicationStore = DS.Store.extend({
   recurceRemoveQueue: function (queue) {
     if (Em.isEmpty(queue)) {
       return;
-    } else if (!queue.get('isNewQueue') && !queue.get('isNew')) {
+    } else {
       queue.get('queuesArray').forEach(function (queueName) {
         this.recurceRemoveQueue(this.getById('queue',[queue.get('path'),queueName].join('.').toLowerCase()));
       }.bind(this));
 
-      this.get('deletedQueues').pushObject(this.buildDeletedQueue(queue));
+      if (!queue.get('isNewQueue')){
+        this.get('deletedQueues').pushObject(this.buildDeletedQueue(queue));
+      }
 
     }
     this.all('queue').findBy('path',queue.get('parentPath')).set('queuesArray',{'exclude':queue.get('name')});
@@ -315,7 +317,8 @@ App.ApplicationStore = DS.Store.extend({
         notLabel = false,
         isDeleteOperation = false;
 
-    if (pending.length == 1) {
+
+    if (pending.length == 1 || pending.isEvery('firstObject.isNew',true)) {
       this._super();
       return;
     }