1 /**
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 *
6 * If it is not possible or desirable to put the notice in a particular
7 * file, then You may include the notice in a location (such as a LICENSE
8 * file in a relevant directory) where a recipient would be likely to look
9 * for such a notice.
10
11 *
12 */
13
14 /* ---------------------------------------------------------------------------
15 * U.S. Government, Department of the Army
16 * Army Materiel Command
17 * Research Development Engineering Command
18 * Communications Electronics Research Development and Engineering Center
19 * ---------------------------------------------------------------------------
20 */
21 package org.miloss.fgsms.auxsrv;
22
23 import java.util.Date;
24 import java.util.GregorianCalendar;
25 import org.miloss.fgsms.common.DBSettingsLoader;
26 import org.miloss.fgsms.services.interfaces.common.PolicyType;
27 import org.miloss.fgsms.services.interfaces.policyconfiguration.KeyNameValueEnc;
28 import org.miloss.fgsms.sla.AuxHelper;
29 import org.miloss.fgsms.sla.NonTransactionalSLAProcessor;
30 import org.miloss.fgsms.sla.SLACommon;
31 import org.miloss.fgsms.common.Logger;;
32 import org.quartz.*;
33
34 /**
35 **Quartz Job that kicks off the NT SLA Processor
36 *
37 * @author AO
38 */
39 public class NTSLAProcessorScheduler implements StatefulJob {
40
41 public void execute(JobExecutionContext jec) throws JobExecutionException {
42 try {
43 org.miloss.fgsms.sla.NonTransactionalSLAProcessor n = new NonTransactionalSLAProcessor();
44
45 n.run(true);
46 AuxHelper.TryUpdateStatus(true, "urn:fgsms:NTSLAProcessor:" + SLACommon.GetHostName(), "OK", true, PolicyType.STATUS, AuxHelper.UNSPECIFIED, SLACommon.GetHostName());
47 } catch (Exception ex) {
48 AuxHelper.TryUpdateStatus(false, "urn:fgsms:NTSLAProcessor:" + SLACommon.GetHostName(), "OK", true, PolicyType.STATUS, AuxHelper.UNSPECIFIED, SLACommon.GetHostName());
49 }
50
51
52 KeyNameValueEnc interval = DBSettingsLoader.GetPropertiesFromDB(true, "NTSLAProcessor", "Interval");
53 long intinterval = 10000;
54 if (interval != null) {
55 try {
56 intinterval = Long.parseLong(interval.getKeyNameValue().getPropertyValue());
57 if (intinterval < 1000) {
58 intinterval = 1000;
59 }
60 } catch (Exception ex) {
61 }
62 }/*
63 try {
64 Scheduler sc = jec.getScheduler();
65 if (sc.deleteJob(NTSLAStarter.JOB_NAME, AuxConstants.QUARTZ_GROUP_NAME)) {
66 JobDetail job = new JobDetail(NTSLAStarter.JOB_NAME, AuxConstants.QUARTZ_GROUP_NAME, this.getClass());
67 Trigger triger = TriggerUtils.makeSecondlyTrigger((int) (intinterval / 1000));
68 triger.setStartTime(new Date());
69 triger.setName(NTSLAStarter.TRIGGER_NAME);
70 triger.setGroup(AuxConstants.QUARTZ_TRIGGER_GROUP_NAME);
71 job.setRequestsRecovery(true);
72 GregorianCalendar gcal = new GregorianCalendar();
73 gcal.setTimeInMillis(System.currentTimeMillis() + intinterval);
74 triger.setStartTime(gcal.getTime());
75 Date scheduleJob = sc.scheduleJob(job, triger);
76 }
77 } catch (Exception ex) {
78 Logger.getLogger("NTSLA").log(org.apache.log4j.Level.WARN, "Error adjusting schedule for Qpid JMX Agent ", ex);
79 }*/
80
81 }
82 }