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 org.springframework.beans.factory.annotation.Value;
16
17 import psiprobe.TomcatContainer;
18 import psiprobe.beans.ClusterWrapperBean;
19 import psiprobe.beans.ContainerWrapperBean;
20 import psiprobe.model.jmx.Cluster;
21 import psiprobe.tools.TimeExpression;
22
23
24
25
26 public class ClusterStatsCollectorBean extends AbstractStatsCollectorBean {
27
28
29 @Inject
30 private ContainerWrapperBean containerWrapper;
31
32
33 @Inject
34 private ClusterWrapperBean clusterWrapper;
35
36
37
38
39
40
41 public ContainerWrapperBean getContainerWrapper() {
42 return containerWrapper;
43 }
44
45
46
47
48
49
50 public void setContainerWrapper(ContainerWrapperBean containerWrapper) {
51 this.containerWrapper = containerWrapper;
52 }
53
54
55
56
57
58
59 public ClusterWrapperBean getClusterWrapper() {
60 return clusterWrapper;
61 }
62
63
64
65
66
67
68 public void setClusterWrapper(ClusterWrapperBean clusterWrapper) {
69 this.clusterWrapper = clusterWrapper;
70 }
71
72 @Override
73 public void collect() throws Exception {
74
75
76 TomcatContainer container = containerWrapper.getTomcatContainer();
77 if (container != null) {
78 Cluster cluster =
79 clusterWrapper.getCluster(container.getName(), container.getHostName(), false);
80 if (cluster != null) {
81 buildDeltaStats("cluster.received", cluster.getTotalReceivedBytes());
82 buildDeltaStats("cluster.sent", cluster.getSenderTotalBytes());
83 buildDeltaStats("cluster.req.received", cluster.getNrOfMsgsReceived());
84 buildDeltaStats("cluster.req.sent", cluster.getSenderNrOfRequests());
85 }
86 }
87 }
88
89
90
91
92
93
94
95 public void setMaxSeries(@Value("${psiprobe.beans.stats.collectors.cluster.period}") long period,
96 @Value("${psiprobe.beans.stats.collectors.cluster.span}") long span) {
97 super.setMaxSeries((int) TimeExpression.dataPoints(period, span));
98 }
99
100 }