Explorar o código

HPCC-9240 Workunit monitoring is "lumpy" and too aggressive

Running workunits not created by the local user should not have the initial
"aggressive" polling pattern.
When polling is started on several WUs at once, the calls should be staggered
a bit to help performance.

Fixes HPCC-9240

Signed-off-by: Gordon Smith <gordon.smith@lexisnexis.com>
Gordon Smith %!s(int64=12) %!d(string=hai) anos
pai
achega
116d1e42de
Modificáronse 2 ficheiros con 11 adicións e 3 borrados
  1. 8 2
      esp/files/scripts/ESPUtil.js
  2. 3 1
      esp/files/scripts/ESPWorkunit.js

+ 8 - 2
esp/files/scripts/ESPUtil.js

@@ -63,8 +63,14 @@ define([
     });
 
     var Monitor = declare(null, {
-        startMonitor: function () {
-            this._timerTickCount = 0;
+        isMonitoring: function () {
+            return this._timer && this._timer > 0;
+        },
+        startMonitor: function (aggressive) {
+            if (this.isMonitoring()) 
+                return;
+
+            this._timerTickCount = aggressive ? 0 : Math.floor((Math.random() * 40) + 70);
             this._timer = 1000;
             this.onMonitor();
         },

+ 3 - 1
esp/files/scripts/ESPWorkunit.js

@@ -203,7 +203,9 @@ define([
             var context = this;
             WsWorkunits.WUCreate({
                 load: function (response) {
-                    _workunits[response.WUCreateResponse.Workunit.Wuid] = context
+                    _workunits[response.WUCreateResponse.Workunit.Wuid] = context;
+                    context.Wuid = response.WUCreateResponse.Workunit.Wuid;
+                    context.startMonitor(true);
                     context.updateData(response.WUCreateResponse.Workunit);
                     context.onCreate();
                 }