Package Ganga :: Package Lib :: Package MonitoringServices :: Package JobExecutionMonitorMS :: Module JobExecutionMonitorMS'
[hide private]
[frames] | no frames]

Source Code for Module Ganga.Lib.MonitoringServices.JobExecutionMonitorMS.JobExecutionMonitorMS'

  1  """ 
  2  This class implements the IMonitoringService-interface and thus can be activated in .gangarc; 
  3  it then gets instantiated and the object gets callbacks whenever a job state changes in some 
  4  well-defined way (see methods below). 
  5   
  6  The real functionality, though, is implemented in another object we're just delegating the 
  7  callbacks to; the reason for this is that this class here is also loaded on the WN by the 
  8  job-wrapper script and should have as little dependencies as possible. 
  9   
 10  @author: Tim Muenchen 
 11  @date: 06.08.09 
 12  @organization: University of Wuppertal, 
 13                 Faculty of mathematics and natural sciences, 
 14                 Department of physics. 
 15  @copyright: 2007-2009, University of Wuppertal, Department of physics. 
 16  @license: :: 
 17   
 18          Copyright (c) 2007-2009 University of Wuppertal, Department of physics 
 19   
 20      Permission is hereby granted, free of charge, to any person obtaining a copy of this  
 21      software and associated documentation files (the "Software"), to deal in the Software  
 22      without restriction, including without limitation the rights to use, copy, modify, merge,  
 23      publish, distribute, sublicense, and/or sell copies of the Software, and to permit  
 24      persons to whom the Software is furnished to do so, subject to the following conditions: 
 25       
 26      The above copyright notice and this permission notice shall be included in all copies  
 27      or substantial portions of the Software. 
 28       
 29      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,  
 30      INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR  
 31      PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE  
 32      LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  
 33      TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE  
 34      OR OTHER DEALINGS IN THE SOFTWARE.  
 35  """ 
 36  from Ganga.GPIDev.Adapters.IMonitoringService import IMonitoringService 
 37   
 38   
39 -class JobExecutionMonitorMS(IMonitoringService):
40
41 - def __init__(self, job_info):
42 IMonitoringService.__init__(self,job_info)
43
44 - def prepare(self,**opts):
45 try: 46 handler = self.__getJEMobject() 47 if handler: 48 handler.prepare(opts['subjobconfig']) 49 except: 50 self.__handleError()
51 52
53 - def submitting(self,**opts):
54 try: 55 self.__getJEMobject().submitting() 56 except: 57 self.__handleError()
58 59
60 - def submit(self,**opts):
61 try: 62 self.__getJEMobject().submit() 63 except: 64 self.__handleError()
65 66
67 - def complete(self,**opts):
68 try: 69 self.__getJEMobject().complete('finished') 70 except: 71 self.__handleError()
72 73
74 - def fail(self,**opts):
75 try: 76 self.__getJEMobject().complete('failed') 77 except: 78 self.__handleError()
79 80
81 - def kill(self,**opts):
82 try: 83 self.__getJEMobject().complete('failed') 84 except: 85 self.__handleError()
86 87
88 - def rollback(self,**opts):
89 try: 90 self.__getJEMobject().rollback() 91 except: 92 self.__handleError()
93 94
95 - def getSandboxModules(self):
104 105
106 - def __handleError(self):
107 import sys, traceback 108 from Ganga.Utility.logging import getLogger 109 l = getLogger() 110 ei = sys.exc_info() 111 l.error(str(ei[0]) + ": " + str(ei[1])) 112 l.error(str(traceback.format_tb(ei[2])))
113 114
115 - def __getJEMobject(self):
116 """ 117 Get the JEMMonitoringServiceHandler object that implements the callbacks defined 118 in IMonitoringService on a per-job basis 119 """ 120 from GangaJEM.Lib.JEM.JEMMonitoringServiceHandler import JEMMonitoringServiceHandler 121 122 # with the static method getInstance, passing a job object as key, the unique 123 # instance of the ServiceHandler for the given job is returned. 124 return JEMMonitoringServiceHandler.getInstance(self.job_info)
125