View Javadoc
1   /*
2    * Licensed under the GPL License. You may not use this file except in compliance with the License.
3    * You may obtain a copy of the License at
4    *
5    *   https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
6    *
7    * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
8    * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
9    * PURPOSE.
10   */
11  package psiprobe;
12  
13  import java.util.ArrayList;
14  import java.util.List;
15  
16  import org.slf4j.Logger;
17  import org.slf4j.LoggerFactory;
18  import org.springframework.context.annotation.Bean;
19  import org.springframework.context.annotation.Configuration;
20  
21  import psiprobe.beans.stats.collectors.AppStatsCollectorBean;
22  import psiprobe.beans.stats.collectors.ClusterStatsCollectorBean;
23  import psiprobe.beans.stats.collectors.ConnectorStatsCollectorBean;
24  import psiprobe.beans.stats.collectors.DatasourceStatsCollectorBean;
25  import psiprobe.beans.stats.collectors.JvmMemoryStatsCollectorBean;
26  import psiprobe.beans.stats.collectors.RuntimeStatsCollectorBean;
27  import psiprobe.beans.stats.listeners.MemoryPoolMailingListener;
28  import psiprobe.beans.stats.listeners.StatsCollectionListener;
29  import psiprobe.beans.stats.providers.ConnectorSeriesProvider;
30  import psiprobe.beans.stats.providers.MultipleSeriesProvider;
31  import psiprobe.beans.stats.providers.StandardSeriesProvider;
32  import psiprobe.model.stats.StatsCollection;
33  
34  /**
35   * The Class ProbeConfigStats.
36   */
37  @Configuration
38  public class ProbeConfigStats {
39  
40    /** The Constant logger. */
41    private static final Logger logger = LoggerFactory.getLogger(ProbeConfigStats.class);
42  
43    /**
44     * Gets the stats collection.
45     *
46     * @return the stats collection
47     */
48    @Bean(name = "statsCollection")
49    public StatsCollection getStatsCollection() {
50      logger.debug("Instantiated statsCollection");
51      return new StatsCollection();
52    }
53  
54    /**
55     * Gets the connector stats collector bean.
56     *
57     * @return the connector stats collector bean
58     */
59    @Bean(name = "connectorStatsCollector")
60    public ConnectorStatsCollectorBean getConnectorStatsCollectorBean() {
61      logger.debug("Instantiated connectorStatsCollector");
62      return new ConnectorStatsCollectorBean();
63    }
64  
65    /**
66     * Gets the cluster stats collector bean.
67     *
68     * @return the cluster stats collector bean
69     */
70    @Bean(name = "clusterStatsCollector")
71    public ClusterStatsCollectorBean getClusterStatsCollectorBean() {
72      logger.debug("Instantiated clusterStatsCollector");
73      return new ClusterStatsCollectorBean();
74    }
75  
76    /**
77     * Gets the runtime stats collector bean.
78     *
79     * @return the runtime stats collector bean
80     */
81    @Bean(name = "runtimeStatsCollector")
82    public RuntimeStatsCollectorBean getRuntimeStatsCollectorBean() {
83      logger.debug("Instantiated runtimeStatsCollector");
84      return new RuntimeStatsCollectorBean();
85    }
86  
87    /**
88     * Gets the app stats collector bean.
89     *
90     * @return the app stats collector bean
91     */
92    @Bean(name = "appStatsCollector")
93    public AppStatsCollectorBean getAppStatsCollectorBean() {
94      logger.debug("Instantiated appStatsCollector");
95      return new AppStatsCollectorBean();
96    }
97  
98    /**
99     * Gets the jvm memory stats collector bean.
100    *
101    * @return the jvm memory stats collector bean
102    */
103   @Bean(name = "memoryStatsCollector")
104   public JvmMemoryStatsCollectorBean getJvmMemoryStatsCollectorBean() {
105     logger.debug("Instantiated memoryStatsCollector");
106     return new JvmMemoryStatsCollectorBean();
107   }
108 
109   /**
110    * Gets the datasource stats collector bean.
111    *
112    * @return the datasource stats collector bean
113    */
114   @Bean(name = "datasourceStatsCollector")
115   public DatasourceStatsCollectorBean getDatasourceStatsCollectorBean() {
116     logger.debug("Instantiated datasourceStatsCollector");
117     return new DatasourceStatsCollectorBean();
118   }
119 
120   /**
121    * Gets the memory pool mailing listener.
122    *
123    * @return the memory pool mailing listener
124    */
125   @Bean(name = "listeners")
126   public List<StatsCollectionListener> getMemoryPoolMailingListener() {
127     logger.debug("Instantiated listeners");
128     List<StatsCollectionListener> list = new ArrayList<>();
129     list.add(new MemoryPoolMailingListener());
130     return list;
131   }
132 
133   /**
134    * Gets the connector series provider.
135    *
136    * @return the connector series provider
137    */
138   @Bean(name = "rcn")
139   public ConnectorSeriesProvider getConnectorSeriesProvider() {
140     logger.debug("Instantiated rcn");
141     return new ConnectorSeriesProvider();
142   }
143 
144   /**
145    * Gets the cl traffic.
146    *
147    * @return the cl traffic
148    */
149   @Bean(name = "cl_traffic")
150   public StandardSeriesProvider getClTraffic() {
151     logger.debug("Instantiated cl_traffic");
152     List<String> list = new ArrayList<>();
153     list.add("cluster.sent");
154     list.add("cluster.received");
155 
156     StandardSeriesProvider provider = new StandardSeriesProvider();
157     provider.setStatNames(list);
158     return provider;
159   }
160 
161   /**
162    * Gets the cl request.
163    *
164    * @return the cl request
165    */
166   @Bean(name = "cl_request")
167   public StandardSeriesProvider getClRequest() {
168     logger.debug("Instantiated cl_request");
169     List<String> list = new ArrayList<>();
170     list.add("cluster.req.sent");
171     list.add("cluster.req.received");
172 
173     StandardSeriesProvider provider = new StandardSeriesProvider();
174     provider.setStatNames(list);
175     return provider;
176   }
177 
178   /**
179    * Gets the connector.
180    *
181    * @return the connector
182    */
183   @Bean(name = "connector")
184   public StandardSeriesProvider getConnector() {
185     logger.debug("Instantiated connector");
186     List<String> list = new ArrayList<>();
187     list.add("stat.connector.{0}.requests");
188     list.add("stat.connector.{0}.errors");
189 
190     StandardSeriesProvider provider = new StandardSeriesProvider();
191     provider.setStatNames(list);
192     return provider;
193   }
194 
195   /**
196    * Gets the traffic.
197    *
198    * @return the traffic
199    */
200   @Bean(name = "traffic")
201   public StandardSeriesProvider getTraffic() {
202     logger.debug("Instantiated traffic");
203     List<String> list = new ArrayList<>();
204     list.add("stat.connector.{0}.sent");
205     list.add("stat.connector.{0}.received");
206 
207     StandardSeriesProvider provider = new StandardSeriesProvider();
208     provider.setStatNames(list);
209     return provider;
210   }
211 
212   /**
213    * Gets the connector proc time.
214    *
215    * @return the connector proc time
216    */
217   @Bean(name = "connector_proc_time")
218   public StandardSeriesProvider getConnectorProcTime() {
219     logger.debug("Instantiated connector_proc_time");
220     List<String> list = new ArrayList<>();
221     list.add("stat.connector.{0}.proc_time");
222 
223     StandardSeriesProvider provider = new StandardSeriesProvider();
224     provider.setStatNames(list);
225     return provider;
226   }
227 
228   /**
229    * Gets the memory usage.
230    *
231    * @return the memory usage
232    */
233   @Bean(name = "memory_usage")
234   public StandardSeriesProvider getMemoryUsage() {
235     logger.debug("Instantiated memory_usage");
236     List<String> list = new ArrayList<>();
237     list.add("memory.pool.{0}");
238 
239     StandardSeriesProvider provider = new StandardSeriesProvider();
240     provider.setStatNames(list);
241     return provider;
242   }
243 
244   /**
245    * Gets the os memory.
246    *
247    * @return the os memory
248    */
249   @Bean(name = "os_memory")
250   public StandardSeriesProvider getOsMemory() {
251     logger.debug("Instantiated os_memory");
252     List<String> list = new ArrayList<>();
253     list.add("os.memory.physical");
254     list.add("os.memory.committed");
255 
256     StandardSeriesProvider provider = new StandardSeriesProvider();
257     provider.setStatNames(list);
258     return provider;
259   }
260 
261   /**
262    * Gets the swap usage.
263    *
264    * @return the swap usage
265    */
266   @Bean(name = "swap_usage")
267   public StandardSeriesProvider getSwapUsage() {
268     logger.debug("Instantiated swap_usage");
269     List<String> list = new ArrayList<>();
270     list.add("os.memory.swap");
271 
272     StandardSeriesProvider provider = new StandardSeriesProvider();
273     provider.setStatNames(list);
274     return provider;
275   }
276 
277   /**
278    * Gets the cpu usage.
279    *
280    * @return the cpu usage
281    */
282   @Bean(name = "cpu_usage")
283   public StandardSeriesProvider getCpuUsage() {
284     logger.debug("Instantiated cpu_usage");
285     List<String> list = new ArrayList<>();
286     list.add("os.cpu");
287 
288     StandardSeriesProvider provider = new StandardSeriesProvider();
289     provider.setStatNames(list);
290     return provider;
291   }
292 
293   /**
294    * Gets the fd usage.
295    *
296    * @return the fd usage
297    */
298   @Bean(name = "fd_usage")
299   public StandardSeriesProvider getFdUsage() {
300     logger.debug("Instantiated fd_usage");
301     List<String> list = new ArrayList<>();
302     list.add("os.fd.open");
303     list.add("os.fd.max");
304 
305     StandardSeriesProvider provider = new StandardSeriesProvider();
306     provider.setStatNames(list);
307     return provider;
308   }
309 
310   /**
311    * Gets the app req.
312    *
313    * @return the app req
314    */
315   @Bean(name = "app_req")
316   public StandardSeriesProvider getAppReq() {
317     logger.debug("Instantiated app_req");
318     List<String> list = new ArrayList<>();
319     list.add("app.requests.{0}");
320     list.add("app.errors.{0}");
321 
322     StandardSeriesProvider provider = new StandardSeriesProvider();
323     provider.setStatNames(list);
324     return provider;
325   }
326 
327   /**
328    * Gets the app avg proc time.
329    *
330    * @return the app avg proc time
331    */
332   @Bean(name = "app_avg_proc_time")
333   public StandardSeriesProvider getAppAvgProcTime() {
334     logger.debug("Instantiated app_avg_proc_time");
335     List<String> list = new ArrayList<>();
336     list.add("app.avg_proc_time.{0}");
337 
338     StandardSeriesProvider provider = new StandardSeriesProvider();
339     provider.setStatNames(list);
340     return provider;
341   }
342 
343   /**
344    * Gets the total avg proc time.
345    *
346    * @return the total avg proc time
347    */
348   @Bean(name = "total_avg_proc_time")
349   public StandardSeriesProvider getTotalAvgProcTime() {
350     logger.debug("Instantiated total_avg_proc_time");
351     List<String> list = new ArrayList<>();
352     list.add("total.avg_proc_time");
353 
354     StandardSeriesProvider provider = new StandardSeriesProvider();
355     provider.setStatNames(list);
356     return provider;
357   }
358 
359   /**
360    * Gets the total req.
361    *
362    * @return the total req
363    */
364   @Bean(name = "total_req")
365   public StandardSeriesProvider getTotalReq() {
366     logger.debug("Instantiated total_req");
367     List<String> list = new ArrayList<>();
368     list.add("total.requests");
369     list.add("total.errors");
370 
371     StandardSeriesProvider provider = new StandardSeriesProvider();
372     provider.setStatNames(list);
373     return provider;
374   }
375 
376   /**
377    * Gets the datasource usage.
378    *
379    * @return the datasource usage
380    */
381   @Bean(name = "datasource_usage")
382   public StandardSeriesProvider getDatasourceUsage() {
383     logger.debug("Instantiated datasource_usage");
384     List<String> list = new ArrayList<>();
385     list.add("ds.est.{0}");
386     list.add("ds.busy.{0}");
387 
388     StandardSeriesProvider provider = new StandardSeriesProvider();
389     provider.setStatNames(list);
390     return provider;
391   }
392 
393   /**
394    * Gets the all app avg proc time.
395    *
396    * @return the all app avg proc time
397    */
398   @Bean(name = "all_app_avg_proc_time")
399   public MultipleSeriesProvider getAllAppAvgProcTime() {
400     logger.debug("Instantiated all_app_avg_proc_time");
401     MultipleSeriesProvider provider = new MultipleSeriesProvider();
402     provider.setMovingAvgFrame(10);
403     provider.setStatNamePrefix("app.avg_proc_time.");
404     provider.setTop(4);
405     return provider;
406   }
407 
408   /**
409    * Gets the all app req.
410    *
411    * @return the all app req
412    */
413   @Bean(name = "all_app_req")
414   public MultipleSeriesProvider getAllAppReq() {
415     logger.debug("Instantiated all_app_req");
416     MultipleSeriesProvider provider = new MultipleSeriesProvider();
417     provider.setMovingAvgFrame(10);
418     provider.setStatNamePrefix("app.requests.");
419     provider.setTop(4);
420     return provider;
421   }
422 
423 }