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
22 package org.miloss.fgsms.auxsrv;
23
24 import org.miloss.fgsms.common.DBSettingsLoader;
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.apache.log4j.*;
30 import org.miloss.fgsms.dependency.DependencyScanner;
31 import org.quartz.*;
32 import org.quartz.JobExecutionContext;
33 import org.quartz.JobExecutionException;
34
35 /**
36 **Quartz Job that kicks off the DependencyScanner
37 *
38 * @author AO
39 */
40 public class DependencyScannerScheduler implements StatefulJob {
41
42 public void execute(JobExecutionContext jec) throws JobExecutionException {
43 try {
44 /*
45 * KeyNameValueEnc interval =
46 * DBSettingsLoader.GetPropertiesFromDB(true, "DependencyScanner",
47 * "Interval"); long intinterval = 60000; if (interval != null) {
48 * try { intinterval =
49 * Long.parseLong(interval.getKeyNameValue().getPropertyValue()); if
50 * (intinterval < 60000) { intinterval = 60000; } } catch (Exception
51 * ex) { } }
52 */
53 DependencyScanner ds = new DependencyScanner();
54 Object get = jec.getJobDetail().getJobDataMap().get("LastRanAt");
55 if (get == null) {
56 ds.go(true, 0);
57 } else {
58 ds.go(true, (Long) get);
59 }
60 jec.getJobDetail().getJobDataMap().put("LastRanAt", Long.valueOf(System.currentTimeMillis()));
61
62 AuxHelper.TryUpdateStatus(true, "urn:fgsms:DependencyScanner:" + SLACommon.GetHostName(), "OK", true, PolicyType.STATUS, AuxHelper.UNSPECIFIED, SLACommon.GetHostName());
63 } catch (Exception ex) {
64 Logger.getLogger(DependencyScannerScheduler.class.getName()).log(Level.ERROR, null, ex);
65 AuxHelper.TryUpdateStatus(false, "urn:fgsms:DependencyScanner:" + SLACommon.GetHostName(), ex.getMessage(), true, PolicyType.STATUS, AuxHelper.UNSPECIFIED, SLACommon.GetHostName());
66 }
67
68 //no need to reschedule this
69 }
70 }