4 #include "KV_CCIN2P3_GE.h"
8 #include "KVDataAnalyser.h"
9 #include "KVDataAnalysisTask.h"
10 #include "KVGEBatchJob.h"
11 #include "KVDataRepository.h"
12 #include "KVDataSetAnalyser.h"
13 #include "KVSimDirAnalyser.h"
30 fDefJobTime =
gEnv->
GetValue(
"GE.BatchSystem.DefaultJobTime",
"5:00");
31 fDefJobMem =
gEnv->
GetValue(
"GE.BatchSystem.DefaultJobMemory",
"2G");
32 fDefJobDisk =
gEnv->
GetValue(
"GE.BatchSystem.DefaultJobDisk",
"50M");
33 fTimeSet = fDiskSet = fMemSet =
kFALSE;
35 SetRunsPerJob(
gEnv->
GetValue(
"GE.BatchSystem.RunsPerJob", 1));
48 fTimeSet = fDiskSet = fMemSet =
kFALSE;
63 if (tmp ==
"") tmp = fDefJobTime;
66 fParList.SetValue(
"-l ct=", tmp);
83 if (tmp ==
"") tmp = fDefJobMem;
84 fParList.SetValue(
"-l vmem=", tmp);
101 if (tmp ==
"") tmp = fDefJobDisk;
102 fParList.SetValue(
"-l fsize=", tmp);
130 if (!fTimeSet) ChooseJobTime();
132 if (!fDiskSet) ChooseJobDisk();
134 if (!fMemSet) ChooseJobMemory();
146 cout <<
"Enter max CPU time per job (ss/mn:ss/hh:mn:ss) ["
147 << fDefJobTime <<
"] : ";
165 cout <<
"Enter max memory per job (xKB/xMB/xGB) ["
166 << fDefJobMem.
Data() <<
"] : ";
169 SetJobMemory(tmp.
Data());
179 cout <<
"Enter max scratch disk per job (xKB/xMB/xGB) ["
180 << fDefJobDisk.
Data() <<
"] : ";
183 SetJobDisk(tmp.
Data());
194 return fParList.GetStringValue(
"-l ct=");
205 return fParList.GetStringValue(
"-l vmem=");
216 return fParList.GetStringValue(
"-l fsize=");
231 env->
SetValue(
"BatchSystem.MultiJobs", MultiJobsMode());
232 if (MultiJobsMode()) env->
SetValue(
"BatchSystem.CurrentRunList", fCurrJobRunList.AsString());
233 env->
SetValue(
"BatchSystem.Time", GetJobTime());
234 env->
SetValue(
"BatchSystem.Memory", GetJobMemory());
235 env->
SetValue(
"BatchSystem.Disk", GetJobDisk());
238 env->
SetValue(
"SimDirAnalyser.CopyFilesToWorkingDirectory",
true);
254 if (MultiJobsMode()) fCurrJobRunList.SetList(env->
GetValue(
"BatchSystem.CurrentRunList",
""));
255 SetJobTime(env->
GetValue(
"BatchSystem.Time",
""));
256 SetJobMemory(env->
GetValue(
"BatchSystem.Memory",
""));
257 SetJobDisk(env->
GetValue(
"BatchSystem.Disk",
""));
271 if (!strcmp(
option,
"log")) {
273 cout <<
"* DISK_REQ: " << GetJobDisk() <<
" *" << endl;
274 cout <<
"* MEM_REQ: " << GetJobMemory() <<
" *" << endl;
317 KVString oldoptions(GetDefaultJobOptions());
321 if ((NeedToAddSPS || repIsSPS)) {
322 oldoptions +=
" -l sps=1";
323 SetDefaultJobOptions(oldoptions.
Data());
324 Info(
"ChangeDefJobOpt",
325 "Your job is being launched from /sps/... zone.\nTherefore the ressource 'sps' has been declared and the number of jobs which can be treated concurrently will be limited.");
348 fCurrJobName.ReplaceAll(
":",
"_");
369 for (
Int_t line_number = 0; line_number < nlines; line_number++) {
371 if (thisLine.
Contains(
"Full jobname:")) {
380 Int_t dd, MM, yyyy, hh, mm, ss;
381 sscanf(sdate.
Data(),
"%d/%d/%d", &MM, &dd, &yyyy);
382 sscanf(stime.
Data(),
"%d:%d:%d", &hh, &mm, &ss);
383 KVDatime submitted(yyyy, MM, dd, hh, mm, ss);
394 list_of_jobs->
Add(job);
399 if (!list_of_jobs->
GetEntries())
return list_of_jobs;
402 TIter next_job(list_of_jobs);
413 for (
Int_t line_number = 0; line_number < nlines; line_number++) {
418 Int_t dd, hh, mm, ss;
421 if (tmp->
GetEntries() == 4) sscanf(stime.
Data(),
"%d:%2d:%2d:%2d", &dd, &hh, &mm, &ss);
422 else sscanf(stime.
Data(),
"%2d:%2d:%2d", &hh, &mm, &ss);
424 job->
SetCPUusage((dd * 24 + hh) * 3600 + mm * 60 + ss);
429 else if (thisLine.
BeginsWith(
"hard resource_list:")) {
437 TIter next_res(bbits);
441 if (
g.BeginsWith(
"ct=")) {
445 else if (
g.BeginsWith(
"vmem=")) {
449 else if (
g.BeginsWith(
"fsize=")) {
473 fParList.SetValue(
"-m b",
"");
484 fParList.SetValue(
"-m e",
"");
495 fParList.SetValue(
"-M ", email);
511 if (!CheckJobParameters())
return;
513 if (MultiJobsMode()) {
514 if (fAnalyser->InheritsFrom(
"KVDataSetAnalyser")) {
520 fCurrJobRunList.Clear();
521 while (remaining_runs && !runs.
End()) {
524 fCurrJobRunList.Add(run);
525 if ((fCurrJobRunList.GetNValues() == GetRunsPerJob()) || runs.
End()) {
530 fCurrJobRunList.Clear();
535 else if (fAnalyser->InheritsFrom(
"KVSimDirAnalyser")) {
540 fCurrJobRunList.Clear();
545 while ((of = it())) {
546 cur_file_list.
Add(of);
547 fCurrJobRunList.Add(file_no);
550 if ((fCurrJobRunList.GetNValues() == GetRunsPerJob()) || (remaining_runs == 0)) {
554 fCurrJobRunList.Clear();
555 cur_file_list.
Clear();
599 nl.
SetValue(
"JobTime", fDefJobTime);
600 nl.
SetValue(
"JobMemory", fDefJobMem);
601 nl.
SetValue(
"JobDisk", fDefJobDisk);
602 nl.
SetValue(
"MultiJobsMode", MultiJobsMode());
603 nl.
SetValue(
"RunsPerJob", fRunsPerJob);
625 if (nl.
GetBoolValue(
"EMailOnStart")) SetSendMailOnJobStart();
626 if (nl.
GetBoolValue(
"EMailOnEnd")) SetSendMailOnJobEnd();
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t g
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
void SetSubmitted(KVDatime &m)
virtual void UpdateDiskUsedEventsRead()
const Char_t * GetStatus() const
void SetMemUsed(const Char_t *m)
void SetMemMax(const Char_t *m)
void SetCPUusage(Int_t m)
void SetDiskMax(const Char_t *m)
void SetStatus(const Char_t *s)
Base class for interface to a batch job management system.
virtual void WriteBatchEnvFile(TEnv *)
void Clear(Option_t *opt="") override
virtual void ChangeDefJobOpt(KVDataAnalyser *da)
virtual void ReadBatchEnvFile(TEnv *)
virtual void SetBatchSystemParameters(const KVNameValueList &)
Use the parameters in the list to set all relevant parameters for batch system.
void Print(Option_t *="") const override
virtual void GetBatchSystemParameterList(KVNameValueList &)
virtual Bool_t CheckJobParameters()
Checks the job and ask for the job name if needed.
Manager class which sets up and runs data analysis tasks.
virtual KVString GetRootDirectoryOfDataToAnalyse() const
KVDataAnalysisTask * GetAnalysisTask() const
Pilots user analysis of experimental data.
void SetRuns(const run_index_list &nl, Bool_t check=kTRUE)
const run_index_list & GetRunList() const
void SetFullRunList(const run_index_list &nl)
Extension of TDatime to handle various useful date formats.
Job handled by Grid Engine batch system at CC-IN2P3.
void SetResources(TString r)
Extended TList class which owns its objects by default.
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
Int_t GetIntValue(const Char_t *name) const
void SetValue(const Char_t *name, value_type value)
Bool_t GetBoolValue(const Char_t *name) const
const Char_t * GetStringValue(const Char_t *name) const
TString GetTStringValue(const Char_t *name) const
Strings used to represent a set of ranges of values.
void Add(TObject *obj) override
Class piloting analyses of simulated data.
void SetFileList(TList *l) override
Int_t GetNumberOfFilesToAnalyse() const override
TList * GetFileList() const
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Int_t GetNValues(TString delim) const
Interface to CCIN2P3 Grid Engine batch job management system.
void SetSendMailOnJobEnd()
add option to send mail when job ends
const Char_t * GetJobTime(void) const
returns the parameter string corresponding to the job CPU time
void SetJobMemory(const Char_t *h="")
Bool_t CheckJobParameters() override
Checks the job and asks for any missing parameters.
void GetBatchSystemParameterList(KVNameValueList &) override
void SetJobDisk(const Char_t *h="")
void PrintJobs(Option_t *opt="") override
Print list of owner's jobs.
KVList * GetListOfJobs() override
void SanitizeJobName() const override
void SetSendMailAddress(const char *)
set email address for notifications
void Clear(Option_t *opt="") override
Clear previously set parameters in order to create a new job submission command.
const Char_t * GetJobDisk(void) const
returns the parameter string corresponding to the job Disk
void ChooseJobMemory(void)
void ReadBatchEnvFile(TEnv *) override
void SetJobTime(const Char_t *h="")
const Char_t * GetJobMemory(void) const
returns the parameter string corresponding to the job Memory
void Print(Option_t *="") const override
void SetSendMailOnJobStart()
add option to send mail when job starts
void ChangeDefJobOpt(KVDataAnalyser *) override
void SetBatchSystemParameters(const KVNameValueList &) override
Use the parameters in the list to set all relevant parameters for batch system.
void WriteBatchEnvFile(TEnv *) override
void ls(Option_t *option="") const override
virtual Int_t GetEntries() const
virtual const char * GetValue(const char *name, const char *dflt) const
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=nullptr)
void Clear(Option_t *option="") override
void Add(TObject *obj) override
const char * GetName() const override
virtual void SetName(const char *name)
Int_t GetEntries() const override
std::istream & ReadToDelim(std::istream &str, char delim='\n')
const char * Data() const
TObjArray * Tokenize(const TString &delim) const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Prepend(char c, Ssiz_t rep=1)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TString & ReplaceAll(const char *s1, const char *s2)
virtual TString GetFromPipe(const char *command)
virtual const char * WorkingDirectory()
UInt_t GetListOfJobs(TFile *file, TList &jobdirs)