ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/KillerServer.py
Revision: 1.17
Committed: Mon Jul 7 13:30:59 2008 UTC (16 years, 9 months ago) by spiga
Content type: text/x-python
Branch: MAIN
Changes since 1.16: +2 -3 lines
Log Message:
fixes for Status reporting while using the server. Plus some print adjustment

File Contents

# User Rev Content
1 corvo 1.1 from Actor import *
2 mcinquil 1.8 from crab_util import *
3 farinafa 1.11 import common
4     from ApmonIf import ApmonIf
5     import time
6    
7     import traceback
8     from xml.dom import minidom
9     from ServerCommunicator import ServerCommunicator
10 corvo 1.1
11    
12     class KillerServer(Actor):
13 farinafa 1.11 def __init__(self, cfg_params, range):
14 corvo 1.1 self.cfg_params = cfg_params
15 farinafa 1.2 self.range = range
16 farinafa 1.11
17 spiga 1.12 # init client server params...
18     CliServerParams(self)
19 farinafa 1.11
20 corvo 1.1 return
21    
22     def run(self):
23     """
24     The main method of the class: kill a complete task
25     """
26     common.logger.debug(5, "Killer::run() called")
27    
28 spiga 1.14 task = common._db.getTask(self.range)
29     toBeKilled = []
30     for job in task.jobs:
31 spiga 1.17 if job.runningJob['status'] in ['SS','R','SR','SW', 'SU']:
32 spiga 1.14 toBeKilled.append(job['jobId'])
33     else:
34     common.logger.message("Not possible to kill Job #"+str(job['jobId'])+" : Status is "+str(job.runningJob['statusScheduler']))
35     pass
36 farinafa 1.11
37 spiga 1.14 if len(toBeKilled)>0:
38     ## register proxy ##
39     csCommunicator = ServerCommunicator(self.server_name, self.server_port, self.cfg_params)
40    
41     taskuuid = str(common._db.queryTask('name'))
42     ret = csCommunicator.killJobs( taskuuid, toBeKilled)
43     del csCommunicator
44    
45     if ret != 0:
46     msg = "ClientServer ERROR: %d raised during the communication.\n"%ret
47     raise CrabException(msg)
48    
49     # update runningjobs status
50 farinafa 1.15 updList = [{'statusScheduler':'Killing', 'status':'KK'}] * len(toBeKilled)
51 spiga 1.14 common._db.updateRunJob_(toBeKilled, updList)
52    
53     # printout the command result
54 spiga 1.17 common.logger.message("Kill request for %d jobs succesfully sent to the server\n"%len(toBeKilled) )
55 farinafa 1.13
56 corvo 1.1 return
57