1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.miloss.fgsms.auxsrv;
22
23 import java.util.Date;
24 import java.util.GregorianCalendar;
25 import java.util.logging.Level;
26 import java.util.logging.Logger;
27 import org.miloss.fgsms.common.DBSettingsLoader;
28 import org.miloss.fgsms.services.interfaces.common.PolicyType;
29 import org.miloss.fgsms.services.interfaces.policyconfiguration.KeyNameValueEnc;
30 import org.miloss.fgsms.sla.AuxHelper;
31 import org.miloss.fgsms.sla.SLACommon;
32 import org.miloss.fgsms.statistics.FgsmsStatsv2;
33 import org.quartz.*;
34
35
36
37
38
39
40 public class StatisticsAggregatorScheduler implements StatefulJob {
41
42 public void execute(JobExecutionContext jec) throws JobExecutionException {
43 try {
44 org.miloss.fgsms.statistics.FgsmsStatsv2 s = new FgsmsStatsv2();
45 s.doWork(true);
46 AuxHelper.TryUpdateStatus(true, "urn:fgsms:StatisticsAggregator:" + SLACommon.GetHostName(), "OK", true, PolicyType.TRANSACTIONAL, AuxHelper.UNSPECIFIED, SLACommon.GetHostName());
47 } catch (Exception ex) {
48 AuxHelper.TryUpdateStatus(false, "urn:fgsms:StatisticsAggregator:" + SLACommon.GetHostName(), ex.getMessage(), true, PolicyType.TRANSACTIONAL, AuxHelper.UNSPECIFIED, SLACommon.GetHostName());
49 }
50
51 try {
52 KeyNameValueEnc interval = DBSettingsLoader.GetPropertiesFromDB(true, "StatisticsAggregator", "Interval");
53
54 long intinterval = 5 * 60 * 1000;
55 if (interval != null) {
56 try {
57 intinterval = Long.parseLong(interval.getKeyNameValue().getPropertyValue());
58 if (intinterval < 1000) {
59 intinterval = 5 * 60 * 1000;
60 }
61 } catch (Exception ex) {
62 }
63 }
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78 } catch (Exception ex) {
79 Logger.getLogger(StatisticsAggregatorScheduler.class.getName()).log(Level.WARNING, "Error adjusting schedule", ex);
80 }
81
82 }
83 }