1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package psiprobe;
22
23 import java.util.Properties;
24
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27 import org.springframework.beans.factory.annotation.Autowired;
28 import org.springframework.context.annotation.Bean;
29 import org.springframework.context.annotation.Configuration;
30 import org.springframework.scheduling.quartz.SchedulerFactoryBean;
31
32 import psiprobe.scheduler.jobs.AppStatsJobDetail;
33 import psiprobe.scheduler.jobs.ClusterStatsJobDetail;
34 import psiprobe.scheduler.jobs.ConnectorStatsJobDetail;
35 import psiprobe.scheduler.jobs.DatasourceStatsJobDetail;
36 import psiprobe.scheduler.jobs.MemoryStatsJobDetail;
37 import psiprobe.scheduler.jobs.RuntimeStatsJobDetail;
38 import psiprobe.scheduler.jobs.StatsSerializerJobDetail;
39 import psiprobe.scheduler.triggers.AppStatsTrigger;
40 import psiprobe.scheduler.triggers.ClusterStatsTrigger;
41 import psiprobe.scheduler.triggers.ConnectorStatsTrigger;
42 import psiprobe.scheduler.triggers.DatasourceStatsTrigger;
43 import psiprobe.scheduler.triggers.MemoryStatsTrigger;
44 import psiprobe.scheduler.triggers.RuntimeStatsTrigger;
45 import psiprobe.scheduler.triggers.StatsSerializerTrigger;
46
47
48
49
50 @Configuration
51 public class ProbeConfigScheduler {
52
53
54 private static final Logger logger = LoggerFactory.getLogger(ProbeConfigScheduler.class);
55
56
57
58
59
60
61 @Bean(name = "connectorStatsJobDetail")
62 public ConnectorStatsJobDetail getConnectorStatsJobDetail() {
63 logger.debug("Instantiated connectorStatsJobDetail");
64 return new ConnectorStatsJobDetail();
65 }
66
67
68
69
70
71
72 @Bean(name = "clusterStatsJobDetail")
73 public ClusterStatsJobDetail getClusterStatsJobDetail() {
74 logger.debug("Instantiated clusterStatsJobDetail");
75 return new ClusterStatsJobDetail();
76 }
77
78
79
80
81
82
83 @Bean(name = "memoryStatsJobDetail")
84 public MemoryStatsJobDetail getMemoryStatsJobDetail() {
85 logger.debug("Instantiated memoryStatsJobDetail");
86 return new MemoryStatsJobDetail();
87 }
88
89
90
91
92
93
94 @Bean(name = "runtimeStatsJobDetail")
95 public RuntimeStatsJobDetail getRuntimeStatsJobDetail() {
96 logger.debug("Instantiated runtimeStatsJobDetail");
97 return new RuntimeStatsJobDetail();
98 }
99
100
101
102
103
104
105 @Bean(name = "appStatsJobDetail")
106 public AppStatsJobDetail getAppStatsJobDetail() {
107 logger.debug("Instantiated appStatsJobDetail");
108 return new AppStatsJobDetail();
109 }
110
111
112
113
114
115
116 @Bean(name = "datasourceStatsJobDetail")
117 public DatasourceStatsJobDetail getDatasourceStatsJobDetail() {
118 logger.debug("Instantiated datasourceStatsJobDetail");
119 return new DatasourceStatsJobDetail();
120 }
121
122
123
124
125
126
127 @Bean(name = "statsSerializerJobDetail")
128 public StatsSerializerJobDetail getStatsSerializerJobDetail() {
129 logger.debug("Instantiated statsSerializerJobDetail");
130 return new StatsSerializerJobDetail();
131 }
132
133
134
135
136
137
138 @Bean(name = "connectorStatsTrigger")
139 public ConnectorStatsTrigger getConnectorStatsTrigger() {
140 logger.debug("Instantiated connectorStatsTrigger");
141 ConnectorStatsTrigger trigger = new ConnectorStatsTrigger();
142 trigger.setJobDetail(getConnectorStatsJobDetail().getObject());
143 return trigger;
144 }
145
146
147
148
149
150
151 @Bean(name = "clusterStatsTrigger")
152 public ClusterStatsTrigger getClusterStatsTrigger() {
153 logger.debug("Instantiated clusterStatsTrigger");
154 ClusterStatsTrigger trigger = new ClusterStatsTrigger();
155 trigger.setJobDetail(getClusterStatsJobDetail().getObject());
156 return trigger;
157 }
158
159
160
161
162
163
164 @Bean(name = "memoryStatsTrigger")
165 public MemoryStatsTrigger getMemoryStatsTrigger() {
166 logger.debug("Instantiated memoryStatsTrigger");
167 MemoryStatsTrigger trigger = new MemoryStatsTrigger();
168 trigger.setJobDetail(getMemoryStatsJobDetail().getObject());
169 return trigger;
170 }
171
172
173
174
175
176
177 @Bean(name = "runtimeStatsTrigger")
178 public RuntimeStatsTrigger getRuntimeStatsTrigger() {
179 logger.debug("Instantiated runtimeStatsTrigger");
180 RuntimeStatsTrigger trigger = new RuntimeStatsTrigger();
181 trigger.setJobDetail(getRuntimeStatsJobDetail().getObject());
182 return trigger;
183 }
184
185
186
187
188
189
190 @Bean(name = "appStatsTrigger")
191 public AppStatsTrigger getAppStatsTrigger() {
192 logger.debug("Instantiated appStatsTrigger");
193 AppStatsTrigger trigger = new AppStatsTrigger();
194 trigger.setJobDetail(getAppStatsJobDetail().getObject());
195 return trigger;
196 }
197
198
199
200
201
202
203 @Bean(name = "datasourceStatsTrigger")
204 public DatasourceStatsTrigger getDatasourceStatsTrigger() {
205 logger.debug("Instantiated datasourceStatsTrigger");
206 DatasourceStatsTrigger trigger = new DatasourceStatsTrigger();
207 trigger.setJobDetail(getDatasourceStatsJobDetail().getObject());
208 return trigger;
209 }
210
211
212
213
214
215
216 @Bean(name = "statsSerializerTrigger")
217 public StatsSerializerTrigger getStatsSerializerTrigger() {
218 logger.debug("Instantiated statsSerializerTrigger");
219 StatsSerializerTrigger trigger = new StatsSerializerTrigger();
220 trigger.setJobDetail(getStatsSerializerJobDetail().getObject());
221 return trigger;
222 }
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237 @Bean(name = "scheduler")
238 public SchedulerFactoryBean getSchedulerFactoryBean(@Autowired AppStatsTrigger appStatsTrigger,
239 @Autowired ClusterStatsTrigger clusterStatsTrigger,
240 @Autowired ConnectorStatsTrigger connectorStatsTrigger,
241 @Autowired DatasourceStatsTrigger datasourceStatsTrigger,
242 @Autowired MemoryStatsTrigger memoryStatsTrigger,
243 @Autowired RuntimeStatsTrigger runtimeStatsTrigger,
244 @Autowired StatsSerializerTrigger statsSerializerTrigger) {
245
246 logger.debug("Instantiated scheduler");
247 SchedulerFactoryBean bean = new SchedulerFactoryBean();
248
249
250 bean.setTriggers(appStatsTrigger.getObject(), clusterStatsTrigger.getObject(),
251 connectorStatsTrigger.getObject(), datasourceStatsTrigger.getObject(),
252 memoryStatsTrigger.getObject(), runtimeStatsTrigger.getObject(),
253 statsSerializerTrigger.getObject());
254
255
256 Properties properties = new Properties();
257 properties.setProperty("org.quartz.scheduler.instanceName", "ProbeScheduler");
258 properties.setProperty("org.quartz.threadPool.threadCount", "5");
259 properties.setProperty("org.quartz.threadPool.threadNamePrefix", "Probe_Quartz");
260 bean.setQuartzProperties(properties);
261
262 return bean;
263 }
264
265 }