View Javadoc

1   package fr.in2p3.jsaga.engine.job.monitor.poll;
2   
3   import fr.in2p3.jsaga.EngineProperties;
4   
5   import java.util.Timer;
6   import java.util.TimerTask;
7   
8   /* ***************************************************
9   * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
10  * ***             http://cc.in2p3.fr/             ***
11  * ***************************************************
12  * File:   JobStatusPollerTask
13  * Author: Sylvain Reynaud (sreynaud@in2p3.fr)
14  * Date:   28 oct. 2008
15  * ***************************************************
16  * Description:                                      */
17  /**
18   *
19   */
20  public class JobStatusPollerTask extends TimerTask {
21      private Timer m_timer;
22      private Runnable m_poller;
23  
24      public JobStatusPollerTask(Runnable poller) {
25          m_poller = poller;
26      }
27  
28      public synchronized void start() {
29          int pollPeriod = EngineProperties.getInteger(EngineProperties.JOB_MONITOR_POLL_PERIOD);
30          m_timer = new Timer();
31          m_timer.schedule(this, 0, pollPeriod);
32      }
33  
34      public synchronized void stop() {
35          m_timer.cancel();
36          m_timer = null;
37      }
38  
39      /** invoked by timer */
40      public void run() {
41          m_poller.run();
42      }
43  }