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 org.miloss.fgsms.common.DBSettingsLoader;
24 import org.miloss.fgsms.common.Logger;
25 import org.miloss.fgsms.services.interfaces.common.PolicyType;
26 import org.miloss.fgsms.services.interfaces.policyconfiguration.KeyNameValueEnc;
27 import org.miloss.fgsms.sla.AuxHelper;
28 import org.miloss.fgsms.sla.SLACommon;
29 import org.quartz.*;
30
31
32
33
34
35
36
37 public class SMXJMXScheduler implements StatefulJob {
38
39 private static Logger log = Logger.getLogger("fgsms.Agents");
40
41 public void execute(JobExecutionContext jec) throws JobExecutionException {
42
43 AuxHelper.TryUpdateStatus(true, "urn:fgsms:ServiceMixJMXAgent:" + SLACommon.GetHostName(), "OK", true, PolicyType.STATUS, AuxHelper.UNSPECIFIED, SLACommon.GetHostName());
44
45 try {
46 KeyNameValueEnc item = DBSettingsLoader.GetPropertiesFromDB(true, "SMXJMXAgent", "URLs");
47 String t = null;
48 String[] urls = null;
49 try {
50 if (item != null) {
51 t = item.getKeyNameValue().getPropertyValue();
52 urls = t.split("\\|");
53 }
54 } catch (Exception ex) {
55 }
56
57 if (urls != null) {
58 for (int i = 0; i < urls.length; i++) {
59 String connecturl = urls[i];
60 String modifiedurl = org.miloss.fgsms.common.IpAddressUtility.modifyURL(connecturl, true);
61
62 org.miloss.fgsms.agents.smxviajmxagent.FgsmsSMXviaJMXAgent.Fire(true, connecturl, modifiedurl);
63
64 }
65 }
66 } catch (Exception ex) {
67 log.log(org.apache.log4j.Level.WARN, "Could not start the SMX JMX Agent ", ex);
68 }
69
70 try {
71 KeyNameValueEnc interval = DBSettingsLoader.GetPropertiesFromDB(true, "SMXJMXAgent", "Interval");
72 long intinterval = 30000;
73 if (interval != null) {
74 try {
75 intinterval = Long.parseLong(interval.getKeyNameValue().getPropertyValue());
76 if (intinterval < 1000) {
77 intinterval = 1000;
78 }
79 } catch (Exception ex) {
80 }
81 }
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96 } catch (Exception ex) {
97 log.log(org.apache.log4j.Level.WARN, "Error adjusting schedule for SMX JMX Agent ", ex);
98 }
99 }
100 }