View Javadoc

1   /*
2    * @(#)JobMonitor.java   1.0
3    *
4    * Copyright (C) AstroGrid. All rights reserved.
5    *
6    * This software is published under the terms of the AstroGrid 
7    * Software License version 1.2, a copy of which has been included 
8    * with this distribution in the LICENSE.txt file.  
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.info("Null id object encountered");
52              return;
53          }
54          if (info == null) {
55              logger.info("Null info object encountered");
56              return;
57          }
58  
59  		try {	
60              nudger.resumeJob(id,info);
61          } catch (Exception e) {
62              logger.error("Could not pass on notification",e);
63  
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