Package Ganga :: Package Lib :: Package LCG :: Package GridSimulator :: Module simulator
[hide private]
[frames] | no frames]

Source Code for Module Ganga.Lib.LCG.GridSimulator.simulator

 1   
 2  # this is a ganga grid simulator driver script 
 3  # usage: 
 4  # env GANGA_GRID_SIMULATOR=1 ganga -o[LCG]GLITE_ENABLE=True -oGLITE_SETUP=/dev/null -o[PollThread]autostart=True simulator.py 
 5   
 6  # when the simulator is enabled it will produce data files in the current working directory 
 7  # these files may be further processed with the simulator-analyze.py script to extract timing data 
 8   
 9  # recommended way is to have the driver + simulation parameters + results all in one directory e.g. 
10  #  
11  # mkdir simu 
12  # cd simu 
13  # cp path/to/simulation.py . 
14  # run simulation.py as described above 
15   
16  config = config['GridSimulator'] 
17  config['submit_time']='0.2' 
18  config['submit_failure_rate']=0.0 
19  config['cancel_time']='random.uniform(0,1)' 
20  config['cancel_failure_rate']=0.0 
21  config['single_status_time']=0.0 # * number of subjobs 
22  config['master_status_time'] = 'random.uniform(2,5)' # constant 
23  config['get_output_time']='0.0' 
24  config['job_id_resolved_time']='random.uniform(10,50)' # up to 800s 
25  config['job_finish_time']= '10+random.uniform(10,10)' 
26  config['job_failure_rate']= 'random.uniform(0,0.05)' 
27   
28  # submit K parallel master jobs with N subjobs each 
29 -def submit(N,K):
30 jobs = [] 31 for i in range(K): 32 j = Job() 33 j.backend=LCG() 34 j.backend.middleware='GLITE' 35 j.splitter=GenericSplitter() 36 j.splitter.attribute='application.args' 37 j.splitter.values=[['x']]*N 38 j.submit() 39 jobs.append(j) 40 import time 41 42 def finished(): 43 for j in jobs: 44 if not j.status in ['failed','completed']: 45 return False 46 return True
47 48 while not finished(): 49 time.sleep(1) 50 51 return jobs 52 53 # repeat M times for better statistics (and repository scalability) 54 55 M = 5 56 57 for i in range(M): 58 print '*'*80 59 print 'starting %d out of %d'%(i,M) 60 print '*'*80 61 submit(50,10) 62 63 print 'finished!' 64