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;
58 KV_CCIN2P3_GE::~KV_CCIN2P3_GE()
74 if (tmp ==
"") tmp = fDefJobTime;
77 fParList.SetValue(
"-l ct=", tmp);
94 if (tmp ==
"") tmp = fDefJobMem;
95 fParList.SetValue(
"-l vmem=", tmp);
112 if (tmp ==
"") tmp = fDefJobDisk;
113 fParList.SetValue(
"-l fsize=", tmp);
141 if (!fTimeSet) ChooseJobTime();
143 if (!fDiskSet) ChooseJobDisk();
145 if (!fMemSet) ChooseJobMemory();
157 cout <<
"Enter max CPU time per job (ss/mn:ss/hh:mn:ss) ["
158 << fDefJobTime <<
"] : ";
176 cout <<
"Enter max memory per job (xKB/xMB/xGB) ["
177 << fDefJobMem.
Data() <<
"] : ";
180 SetJobMemory(tmp.
Data());
190 cout <<
"Enter max scratch disk per job (xKB/xMB/xGB) ["
191 << fDefJobDisk.
Data() <<
"] : ";
194 SetJobDisk(tmp.
Data());
205 return fParList.GetStringValue(
"-l ct=");
216 return fParList.GetStringValue(
"-l vmem=");
227 return fParList.GetStringValue(
"-l fsize=");
242 env->
SetValue(
"BatchSystem.MultiJobs", MultiJobsMode());
243 if (MultiJobsMode()) env->
SetValue(
"BatchSystem.CurrentRunList", fCurrJobRunList.AsString());
244 env->
SetValue(
"BatchSystem.Time", GetJobTime());
245 env->
SetValue(
"BatchSystem.Memory", GetJobMemory());
246 env->
SetValue(
"BatchSystem.Disk", GetJobDisk());
249 env->
SetValue(
"SimDirAnalyser.CopyFilesToWorkingDirectory",
true);
265 if (MultiJobsMode()) fCurrJobRunList.SetList(env->
GetValue(
"BatchSystem.CurrentRunList",
""));
266 SetJobTime(env->
GetValue(
"BatchSystem.Time",
""));
267 SetJobMemory(env->
GetValue(
"BatchSystem.Memory",
""));
268 SetJobDisk(env->
GetValue(
"BatchSystem.Disk",
""));
282 if (!strcmp(
option,
"log")) {
284 cout <<
"* DISK_REQ: " << GetJobDisk() <<
" *" << endl;
285 cout <<
"* MEM_REQ: " << GetJobMemory() <<
" *" << endl;
328 KVString oldoptions(GetDefaultJobOptions());
332 if ((NeedToAddSPS || repIsSPS)) {
333 oldoptions +=
" -l sps=1";
334 SetDefaultJobOptions(oldoptions.
Data());
335 Info(
"ChangeDefJobOpt",
336 "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.");
359 fCurrJobName.ReplaceAll(
":",
"_");
380 for (
Int_t line_number = 0; line_number < nlines; line_number++) {
382 if (thisLine.
Contains(
"Full jobname:")) {
391 Int_t dd, MM, yyyy, hh, mm, ss;
392 sscanf(sdate.
Data(),
"%d/%d/%d", &MM, &dd, &yyyy);
393 sscanf(stime.
Data(),
"%d:%d:%d", &hh, &mm, &ss);
394 KVDatime submitted(yyyy, MM, dd, hh, mm, ss);
405 list_of_jobs->
Add(job);
410 if (!list_of_jobs->
GetEntries())
return list_of_jobs;
413 TIter next_job(list_of_jobs);
424 for (
Int_t line_number = 0; line_number < nlines; line_number++) {
429 Int_t dd, hh, mm, ss;
432 if (tmp->
GetEntries() == 4) sscanf(stime.
Data(),
"%d:%2d:%2d:%2d", &dd, &hh, &mm, &ss);
433 else sscanf(stime.
Data(),
"%2d:%2d:%2d", &hh, &mm, &ss);
435 job->
SetCPUusage((dd * 24 + hh) * 3600 + mm * 60 + ss);
440 else if (thisLine.
BeginsWith(
"hard resource_list:")) {
448 TIter next_res(bbits);
452 if (
g.BeginsWith(
"ct=")) {
456 else if (
g.BeginsWith(
"vmem=")) {
460 else if (
g.BeginsWith(
"fsize=")) {
484 fParList.SetValue(
"-m b",
"");
495 fParList.SetValue(
"-m e",
"");
506 fParList.SetValue(
"-M ", email);
522 if (!CheckJobParameters())
return;
524 if (MultiJobsMode()) {
525 if (fAnalyser->InheritsFrom(
"KVDataSetAnalyser")) {
531 fCurrJobRunList.Clear();
532 while (remaining_runs && !runs.
End()) {
535 fCurrJobRunList.Add(run);
536 if ((fCurrJobRunList.GetNValues() == GetRunsPerJob()) || runs.
End()) {
541 fCurrJobRunList.Clear();
546 else if (fAnalyser->InheritsFrom(
"KVSimDirAnalyser")) {
551 fCurrJobRunList.Clear();
556 while ((of = it())) {
557 cur_file_list.
Add(of);
558 fCurrJobRunList.Add(file_no);
561 if ((fCurrJobRunList.GetNValues() == GetRunsPerJob()) || (remaining_runs == 0)) {
565 fCurrJobRunList.Clear();
566 cur_file_list.
Clear();
610 nl.
SetValue(
"JobTime", fDefJobTime);
611 nl.
SetValue(
"JobMemory", fDefJobMem);
612 nl.
SetValue(
"JobDisk", fDefJobDisk);
613 nl.
SetValue(
"MultiJobsMode", MultiJobsMode());
614 nl.
SetValue(
"RunsPerJob", fRunsPerJob);
636 if (nl.
GetBoolValue(
"EMailOnStart")) SetSendMailOnJobStart();
637 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 *)
virtual void Print(Option_t *="") const
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.
virtual void GetBatchSystemParameterList(KVNameValueList &)
virtual void Clear(Option_t *opt="")
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 SetFullRunList(const KVNumberList &nl)
void SetRuns(const KVNumberList &nl, Bool_t check=kTRUE)
const KVNumberList & GetRunList() const
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.
virtual void Add(TObject *obj)
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.
virtual KVList * GetListOfJobs()
virtual void GetBatchSystemParameterList(KVNameValueList &)
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 PrintJobs(Option_t *opt="")
Print list of owner's jobs.
void SetJobMemory(const Char_t *h="")
void SetJobDisk(const Char_t *h="")
virtual void WriteBatchEnvFile(TEnv *)
virtual void SanitizeJobName() const
virtual void Print(Option_t *="") const
virtual Bool_t CheckJobParameters()
Checks the job and asks for any missing parameters.
void SetSendMailAddress(const char *)
set email address for notifications
const Char_t * GetJobDisk(void) const
returns the parameter string corresponding to the job Disk
virtual void Clear(Option_t *opt="")
Clear previously set parameters in order to create a new job submission command.
void ChooseJobMemory(void)
void SetJobTime(const Char_t *h="")
const Char_t * GetJobMemory(void) const
returns the parameter string corresponding to the job Memory
virtual void ChangeDefJobOpt(KVDataAnalyser *)
void SetSendMailOnJobStart()
add option to send mail when job starts
virtual void SetBatchSystemParameters(const KVNameValueList &)
Use the parameters in the list to set all relevant parameters for batch system.
virtual void ReadBatchEnvFile(TEnv *)
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)