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.beans.ContainerListenerBean;
18 import psiprobe.model.Connector;
19 import psiprobe.tools.TimeExpression;
20
21
22
23
24 public class ConnectorStatsCollectorBean extends AbstractStatsCollectorBean {
25
26
27 @Inject
28 private ContainerListenerBean listenerBean;
29
30
31
32
33
34
35 public ContainerListenerBean getListenerBean() {
36 return listenerBean;
37 }
38
39
40
41
42
43
44 public void setListenerBean(ContainerListenerBean listenerBean) {
45 this.listenerBean = listenerBean;
46 }
47
48 @Override
49 public void collect() throws Exception {
50 for (Connector connector : listenerBean.getConnectors(false)) {
51 String statName = "stat.connector." + connector.getProtocolHandler();
52 buildDeltaStats(statName + ".requests", connector.getRequestCount());
53 buildDeltaStats(statName + ".errors", connector.getErrorCount());
54 buildDeltaStats(statName + ".sent", connector.getBytesSent());
55 buildDeltaStats(statName + ".received", connector.getBytesReceived());
56 buildDeltaStats(statName + ".proc_time", connector.getProcessingTime());
57 }
58 }
59
60
61
62
63
64
65 public void reset() throws Exception {
66 for (Connector connector : listenerBean.getConnectors(false)) {
67 reset(connector.getProtocolHandler());
68 }
69 }
70
71
72
73
74
75
76 public void reset(String connectorName) {
77 String statName = "stat.connector." + connectorName;
78 resetStats(statName + ".requests");
79 resetStats(statName + ".errors");
80 resetStats(statName + ".sent");
81 resetStats(statName + ".received");
82 resetStats(statName + ".proc_time");
83 }
84
85
86
87
88
89
90
91 public void setMaxSeries(
92 @Value("${psiprobe.beans.stats.collectors.connector.period}") long period,
93 @Value("${psiprobe.beans.stats.collectors.connector.span}") long span) {
94 super.setMaxSeries((int) TimeExpression.dataPoints(period, span));
95 }
96
97 }