changeset 269:a0ae36ed4a9a

Perform "dense" update queries Reviewed-by: jkang Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-October/025371.html
author Andrew Azores <aazores@redhat.com>
date Wed, 11 Oct 2017 14:59:09 -0400
parents 597d7d7e0aff
children 4023b79e4d58
files src/app/components/jvm-info/jvm-memory/jvm-memory.controller.js src/app/components/jvm-info/jvm-memory/jvm-memory.service.js src/app/components/jvm-info/jvm-memory/jvm-memory.service.spec.js
diffstat 3 files changed, 15 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/app/components/jvm-info/jvm-memory/jvm-memory.controller.js	Wed Oct 11 15:38:34 2017 -0400
+++ b/src/app/components/jvm-info/jvm-memory/jvm-memory.controller.js	Wed Oct 11 14:59:09 2017 -0400
@@ -110,6 +110,7 @@
 
     this._refreshRate = 2000;
     this._dataAgeLimit = 10 * 60 * 1000;
+    this._lastUpdate = this._getCurrentTimestamp();
   }
 
   getLineConfig (genIndex, spaceIndex) {
@@ -212,7 +213,8 @@
   }
 
   _update () {
-    this._jvmMemoryService.getJvmMemory(this.jvmId).then(resp => {
+    this._jvmMemoryService.getJvmMemory(this.jvmId, this._lastUpdate).then(resp => {
+      this._lastUpdate = this._getCurrentTimestamp();
       let keys = [];
       resp.forEach(update => {
         for (let i = 0; i < update.generations.length; i++) {
@@ -256,7 +258,7 @@
   }
 
   _trimData () {
-    let now = Date.now();
+    let now = this._getCurrentTimestamp();
     let limit = now - this._dataAgeLimit;
 
     let metaspaceSpliceCount = 0;
@@ -373,6 +375,10 @@
     return this._sanitizeService.sanitize(str);
   }
 
+  _getCurrentTimestamp () {
+    return Date.now();
+  }
+
 }
 
 export default angular
--- a/src/app/components/jvm-info/jvm-memory/jvm-memory.service.js	Wed Oct 11 15:38:34 2017 -0400
+++ b/src/app/components/jvm-info/jvm-memory/jvm-memory.service.js	Wed Oct 11 14:59:09 2017 -0400
@@ -35,11 +35,12 @@
     this.gatewayUrl = gatewayUrl;
   }
 
-  getJvmMemory (jvmId) {
+  getJvmMemory (jvmId, since) {
     return this.http.get(urlJoin(this.gatewayUrl, 'jvm-memory', '0.0.3', 'jvms', jvmId), {
       params: {
-        limit: 1,
-        sort: '-timeStamp'
+        limit: 0,
+        sort: '+timeStamp',
+        query: `timeStamp>=${since}`
       }
     }).then(res => res.data.response);
   }
--- a/src/app/components/jvm-info/jvm-memory/jvm-memory.service.spec.js	Wed Oct 11 15:38:34 2017 -0400
+++ b/src/app/components/jvm-info/jvm-memory/jvm-memory.service.spec.js	Wed Oct 11 14:59:09 2017 -0400
@@ -63,13 +63,13 @@
           }
         ]
       };
-      httpBackend.when('GET', 'http://example.com:1234/jvm-memory/0.0.3/jvms/foo-jvmId?limit=1&sort=-timeStamp')
+      httpBackend.when('GET', 'http://example.com:1234/jvm-memory/0.0.3/jvms/foo-jvmId?limit=0&query=timeStamp%3E%3D1234&sort=%2BtimeStamp')
         .respond(expected);
-      svc.getJvmMemory('foo-jvmId').then(res => {
+      svc.getJvmMemory('foo-jvmId', 1234).then(res => {
         res.should.deepEqual(expected.response);
         done();
       });
-      httpBackend.expectGET('http://example.com:1234/jvm-memory/0.0.3/jvms/foo-jvmId?limit=1&sort=-timeStamp');
+      httpBackend.expectGET('http://example.com:1234/jvm-memory/0.0.3/jvms/foo-jvmId?limit=0&query=timeStamp%3E%3D1234&sort=%2BtimeStamp');
       httpBackend.flush();
       scope.$apply();
     });