1
2
3
4
5
6
7
8
9
10
11 package psiprobe.beans.stats.collectors;
12
13 import jakarta.inject.Inject;
14
15 import java.util.List;
16
17 import org.springframework.beans.factory.annotation.Autowired;
18 import org.springframework.beans.factory.annotation.Value;
19
20 import psiprobe.beans.JvmMemoryInfoAccessorBean;
21 import psiprobe.beans.stats.listeners.StatsCollectionListener;
22 import psiprobe.model.jmx.MemoryPool;
23 import psiprobe.tools.TimeExpression;
24
25
26
27
28 public class JvmMemoryStatsCollectorBean extends AbstractStatsCollectorBean {
29
30
31 @Inject
32 private JvmMemoryInfoAccessorBean jvmMemoryInfoAccessor;
33
34
35
36
37
38
39 public JvmMemoryInfoAccessorBean getJvmMemoryInfoAccessor() {
40 return jvmMemoryInfoAccessor;
41 }
42
43
44
45
46
47
48 public void setJvmMemoryInfoAccessor(JvmMemoryInfoAccessorBean jvmMemoryInfoAccessor) {
49 this.jvmMemoryInfoAccessor = jvmMemoryInfoAccessor;
50 }
51
52 @Override
53 public void collect() throws Exception {
54 List<MemoryPool> pools = jvmMemoryInfoAccessor.getPools();
55 long time = System.currentTimeMillis();
56 for (MemoryPool pool : pools) {
57 buildAbsoluteStats("memory.pool." + pool.getName(), pool.getUsed(), time);
58 }
59 }
60
61
62
63
64
65
66
67 public void setMaxSeries(@Value("${psiprobe.beans.stats.collectors.memory.period}") long period,
68 @Value("${psiprobe.beans.stats.collectors.memory.span}") long span) {
69 super.setMaxSeries((int) TimeExpression.dataPoints(period, span));
70 }
71
72 @Autowired
73 @Override
74 public void setListeners(List<StatsCollectionListener> listeners) {
75 super.setListeners(listeners);
76 }
77
78 }