You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2016/02/15 16:47:22 UTC

ambari git commit: AMBARI-15049 Sometimes background operations have incorrect order. (atkach)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 2c34af6fb -> 1a772e67f


AMBARI-15049 Sometimes background operations have incorrect order. (atkach)


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

Branch: refs/heads/branch-2.2
Commit: 1a772e67f6a06e764d359f6c1b4fc3a08ddfb536
Parents: 2c34af6
Author: Andrii Tkach <at...@hortonworks.com>
Authored: Mon Feb 15 17:18:59 2016 +0200
Committer: Andrii Tkach <at...@hortonworks.com>
Committed: Mon Feb 15 17:18:59 2016 +0200

----------------------------------------------------------------------
 .../global/background_operations_controller.js      | 15 +++++++++++----
 ambari-web/app/utils/host_progress_popup.js         | 10 ++++++----
 .../global/background_operations_test.js            | 16 ++++++++++++++++
 3 files changed, 33 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1a772e67/ambari-web/app/controllers/global/background_operations_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/background_operations_controller.js b/ambari-web/app/controllers/global/background_operations_controller.js
index 76c517c..4156e46 100644
--- a/ambari-web/app/controllers/global/background_operations_controller.js
+++ b/ambari-web/app/controllers/global/background_operations_controller.js
@@ -261,19 +261,26 @@ App.BackgroundOperationsController = Em.Controller.extend({
     this.set('isShowMoreAvailable', countGot >= countIssued);
     this.set('serviceTimestamp', App.dateTimeWithTimeZone());
   },
+
   isShowMoreAvailable: null,
+
   /**
    * remove old requests
    * as API returns 10, or  20 , or 30 ...etc latest request, the requests that absent in response should be removed
    * @param currentRequestIds
    */
   removeOldRequests: function (currentRequestIds) {
-    this.get('services').forEach(function (service, index, services) {
-      if (!currentRequestIds.contains(service.id)) {
-        services.splice(index, 1);
+    var services = this.get('services');
+
+    for (var i = 0, l = services.length; i < l; i++) {
+      if (!currentRequestIds.contains(services[i].id)) {
+        services.splice(i, 1);
+        i--;
+        l--;
       }
-    });
+    }
   },
+
   /**
    * identify whether request is running by task counters
    * @param request

http://git-wip-us.apache.org/repos/asf/ambari/blob/1a772e67/ambari-web/app/utils/host_progress_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/host_progress_popup.js b/ambari-web/app/utils/host_progress_popup.js
index d730f79..7ba3618 100644
--- a/ambari-web/app/utils/host_progress_popup.js
+++ b/ambari-web/app/utils/host_progress_popup.js
@@ -430,11 +430,13 @@ App.HostPopup = Em.Object.create({
    * @param currentServicesIds
    */
   removeOldServices: function (services, currentServicesIds) {
-    services.forEach(function (service, index, services) {
-      if (!currentServicesIds.contains(service.id)) {
-        services.removeAt(index, 1);
+    for (var i = 0, l = services.length; i < l; i++) {
+      if (!currentServicesIds.contains(services[i].id)) {
+        services.splice(i, 1);
+        i--;
+        l--;
       }
-    });
+    }
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/1a772e67/ambari-web/test/controllers/global/background_operations_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/global/background_operations_test.js b/ambari-web/test/controllers/global/background_operations_test.js
index adc02c9..e53f168 100644
--- a/ambari-web/test/controllers/global/background_operations_test.js
+++ b/ambari-web/test/controllers/global/background_operations_test.js
@@ -311,6 +311,22 @@ describe('App.BackgroundOperationsController', function () {
         result: [
           {id: 2}
         ]
+      },
+      {
+        title: 'two old request and two current',
+        content: {
+          currentRequestIds: [3, 4],
+          services: [
+            {id: 1},
+            {id: 2},
+            {id: 3},
+            {id: 4}
+          ]
+        },
+        result: [
+          {id: 3},
+          {id: 4}
+        ]
       }
     ];