1
2
3
4
5
6
7
8
9
10
11 package org.astrogrid.jes.jobmonitor;
12
13 import org.astrogrid.component.descriptor.ComponentDescriptor;
14 import org.astrogrid.jes.jobscheduler.JobScheduler;
15 import org.astrogrid.jes.types.v1.cea.axis.JobIdentifierType;
16 import org.astrogrid.jes.types.v1.cea.axis.MessageType;
17
18 import org.apache.commons.logging.Log;
19 import org.apache.commons.logging.LogFactory;
20
21 import junit.framework.Test;
22
23
24 /*** Implementation of a component that notifies the scheduler when a task has completed
25 * <p>
26 Job Monitor is a greatly reduced from what it used to be. now just acts as a conduit into the job scheduler.
27 *@todo - maybe add synchronous service call, so clients that need to know can block until reaching confirmation?
28 * @author Jeff Lusted
29 * @version 1.0 28-May-2003
30 * @since AstroGrid 1.2
31 */
32 public class JobMonitor implements org.astrogrid.jes.delegate.v1.jobmonitor.JobMonitor, ComponentDescriptor{
33
34 private static Log
35 logger = LogFactory.getLog( JobMonitor.class ) ;
36
37
38 public JobMonitor(JobScheduler nudger) {
39 assert nudger != null;
40 this.nudger = nudger;
41
42 }
43
44 protected final JobScheduler
45 nudger;
46
47 /*** do a load of validity checks, then pass on to schedulerr
48 * @todo add validity checks*/
49 public void monitorJob(JobIdentifierType id,MessageType info ) {
50 if (id == null) {
51 logger.warn("Job monitor received a notification with a null object-identifier.");
52 return;
53 }
54 if (info == null) {
55 logger.warn("Job monitor received a notification with a null object-identifier.");
56 return;
57 }
58 logger.info("Job monitor was notified that job " + id +
59 " changed to state to " + info.getPhase());
60 try {
61 nudger.resumeJob(id,info);
62 } catch (Exception e) {
63 logger.error("Could not pass on notification",e);
64 }
65 }
66
67
68 /***
69 * @see org.astrogrid.jes.component.ComponentDescriptor#getName()
70 */
71 public String getName() {
72 return "Job Monitor";
73 }
74
75
76 /***
77 * @see org.astrogrid.jes.component.ComponentDescriptor#getDescription()
78 */
79 public String getDescription() {
80 return "Standard Job Monitor";
81 }
82
83
84 /***
85 * @see org.astrogrid.jes.component.ComponentDescriptor#getInstallationTest()
86 */
87 public Test getInstallationTest() {
88 return null;
89 }
90
91
92
93 }
94
95