1 /**
2 * This Source Code Form is subject to the terms of the Mozilla Public License,
3 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
4 * 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 file,
7 * then You may include the notice in a location (such as a LICENSE file in a
8 * relevant directory) where a recipient would be likely to look for such a
9 * notice.
10 *
11 *
12 */
13 /* ---------------------------------------------------------------------------
14 * U.S. Government, Department of the Army
15 * Army Materiel Command
16 * Research Development Engineering Command
17 * Communications Electronics Research Development and Engineering Center
18 * ---------------------------------------------------------------------------
19 */
20 package org.miloss.fgsms.sla;
21
22 import java.util.Queue;
23 import org.miloss.fgsms.plugins.sla.AlertContainer;
24 import org.miloss.fgsms.common.Logger;;
25
26 /**
27 * Performs alerting functions when not running in Jboss (i.e. thread
28 * pooling)
29 *
30 * @author AO
31 */
32 public class AlertRunner implements Runnable {
33
34 private Queue<AlertContainer> queue = null;
35
36 AlertRunner(Queue<AlertContainer> q) {
37 queue = q;
38 }
39 static final Logger log = Logger.getLogger("fgsms.SLAProcessor");
40
41 @Override
42 public void run() {
43 try {
44 AlertContainer poll = queue.poll();
45 if (poll != null) {
46 SLACommon slac = new SLACommon();
47 do {
48 slac.DoAlerts(poll);
49 poll = queue.poll();
50 } while (poll != null);
51 }
52 SLAProcessorSingleton.setRunning(false);
53 log.log(org.apache.log4j.Level.INFO, SLACommon.getBundleString("InternalAlertingSingletonStop"));
54 } catch (Throwable t) {
55 log.log(org.apache.log4j.Level.FATAL, SLACommon.getBundleString("InternalAlertingSingletonStop"), t);
56 t.printStackTrace();
57 }
58 }
59 }