changeset 132:349cb0c9bf64

jvm-memory per-space usage stats can be added to multicharts In addition to existing metaspace stats Reviewed-by: almac Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-July/024198.html
author Andrew Azores <aazores@redhat.com>
date Thu, 20 Jul 2017 11:37:29 -0400
parents 59e8facc27cb
children 35be935626f7
files src/app/components/jvm-info/jvm-memory/jvm-memory.controller.js src/app/components/jvm-info/jvm-memory/jvm-memory.controller.spec.js src/app/components/jvm-info/jvm-memory/jvm-memory.html
diffstat 3 files changed, 73 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/app/components/jvm-info/jvm-memory/jvm-memory.controller.js	Tue Jul 18 10:14:56 2017 -0400
+++ b/src/app/components/jvm-info/jvm-memory/jvm-memory.controller.js	Thu Jul 20 11:37:29 2017 -0400
@@ -83,14 +83,27 @@
     }
   }
 
-  multichartFn () {
+  multichartMetaspace () {
     return new Promise(resolve =>
-      this.jvmMemoryService.getJvmMemory(this.scope.systemId).then(resp =>
+      this.jvmMemoryService.getJvmMemory(this.jvmId).then(resp =>
         resolve(this.convertMemStat(resp.data.response[0].metaspaceUsed))
       )
     );
   }
 
+  multichartSpace (generationIndex, spaceIndex) {
+    return new Promise(resolve =>
+      this.jvmMemoryService.getJvmMemory(this.jvmId).then(resp => {
+        generationIndex = parseInt(generationIndex);
+        spaceIndex = parseInt(spaceIndex);
+        let data = resp.data.response[0];
+        let generation = data.generations[generationIndex];
+        let space = generation.spaces[spaceIndex];
+        resolve(this.convertMemStat(space.used));
+      })
+    );
+  }
+
   update () {
     this.jvmMemoryService.getJvmMemory(this.jvmId).then(resp => {
       let data = resp.data.response[0];
--- a/src/app/components/jvm-info/jvm-memory/jvm-memory.controller.spec.js	Tue Jul 18 10:14:56 2017 -0400
+++ b/src/app/components/jvm-info/jvm-memory/jvm-memory.controller.spec.js	Thu Jul 20 11:37:29 2017 -0400
@@ -243,15 +243,15 @@
     });
   });
 
-  describe('multichartFn', () => {
+  describe('multichartMetaspace', () => {
     it('should return a promise', () => {
-      let res = ctrl.multichartFn();
+      let res = ctrl.multichartMetaspace();
       res.should.be.a.Promise();
     });
 
     it('should resolve jvm-memory stat', done => {
       promise.then.should.be.calledOnce();
-      let res = ctrl.multichartFn();
+      let res = ctrl.multichartMetaspace();
       res.then(v => {
         v.should.equal(9001);
         done();
@@ -270,4 +270,56 @@
     });
   });
 
+  describe('multichartSpace', () => {
+    it('should return a promise', () => {
+      let res = ctrl.multichartSpace(0, 0);
+      res.should.be.a.Promise();
+    });
+
+    it('should resolve space used stat', done => {
+      promise.then.should.be.calledOnce();
+      let res = ctrl.multichartSpace(1, 1);
+      res.then(v => {
+        v.should.equal(400);
+        done();
+      });
+      promise.then.should.be.calledTwice();
+      let prom = promise.then.secondCall.args[0];
+      prom({
+        data: {
+          response: [
+            {
+              generations: [
+                {
+                  spaces: [
+                    {
+                      used: 100,
+                      total: 150
+                    },
+                    {
+                      used: 200,
+                      total: 250
+                    }
+                  ]
+                },
+                {
+                  spaces: [
+                    {
+                      used: 300,
+                      total: 350
+                    },
+                    {
+                      used: 400,
+                      total: 450
+                    }
+                  ]
+                }
+              ]
+            }
+          ]
+        }
+      });
+    });
+  });
+
 });
--- a/src/app/components/jvm-info/jvm-memory/jvm-memory.html	Tue Jul 18 10:14:56 2017 -0400
+++ b/src/app/components/jvm-info/jvm-memory/jvm-memory.html	Thu Jul 20 11:37:29 2017 -0400
@@ -23,6 +23,7 @@
             <label class="card-pf-title">Metaspace</label>
           </div>
           <div class="card-pf-body">
+            <mc-add class="pull-right" svc-name="{{ctrl.jvmId}}-metaspace" get-fn="ctrl.multichartMetaspace()"></mc-add>
             <div pf-donut-pct-chart id="metaspaceChart" config="ctrl.metaspaceConfig" data="ctrl.metaspaceData"></div>
           </div>
         </div>
@@ -39,11 +40,12 @@
           <div class="card-pf card-pf-view">
             <div class="card-pf-heading">
               <label class="card-pf-title">{{generation.name}} ({{generation.collector}})</label>
-              <mc-add class="pull-right" svc-name="{{ctrl.jvmId}}-{{sanitize(generation.name)}}-metaspace" get-fn="ctrl.multichartFn()"></mc-add>
             </div>
             <div ng-repeat="space in generation.spaces">
               <div class="card-pf-body text-center">
                 <label>Space {{space.index}}</label>
+                <mc-add class="pull-right" svc-name="{{ctrl.jvmId}}-{{sanitize(generation.name)}}-space{{space.index}}"
+                                           get-fn="ctrl.multichartSpace(index, space.index)"></mc-add>
                 <div pf-donut-pct-chart id="gen-{{gen.index}}-space-{{space.index}}"
                   config="ctrl.spaceConfigs['gen-' + generation.index + '-space-' + space.index]" data="space"></div>
               </div>