8 Process all jobs specified in the job.list file
9 Concurent agents acces the list
10 Once starting to procces given job the jonb is locked
19 .L $ALICE_ROOT/TPC/macros/testTPC/AliTPCjobs.cxx+
23 jobs.fJobFile="job.list"
24 jobs.ProcessAllJobs();
28 class AliTPCJobs : public TNamed{
31 void ProcessAllJobs();
33 void ProcessJob(TString jobID, TString inputData, TString outputDir, TString action);
35 void SetLock(TString jobID);
36 void SetDone(TString jobID);
37 void SetFail(TString jobID);
39 Int_t Stage(TString inputData,TString jobID);
41 Bool_t IsLocked(TString jobID);
42 Bool_t IsFail(TString jobID);
43 Bool_t IsStaged(TString inputData);
44 Bool_t IsCastorFile(TString filename);
48 ClassDef(AliTPCJobs,0)
53 AliTPCJobs::AliTPCJobs(){
57 gSystem->Load("libXrdClient.so");
58 gSystem->Load("libNetx.so");
61 void AliTPCJobs::ProcessAllJobs(){
68 printf("PROCESSING JOB\t%d\n",counter);
70 if (!GetNextJob()) break;
75 Bool_t AliTPCJobs::GetNextJob(){
77 // GetNextJob - get job from the list which is not locked
91 if (!inputData.Contains(".root")) SetFail(id);
92 if (!IsStaged(inputData)){
96 if (IsFail(id)) continue;
102 printf("Process %s\n",id.Data());
103 if (hasJob) ProcessJob(id,inputData,outputDir, action);
108 void AliTPCJobs::SetLock(TString jobID){
109 printf("touch out/%s.lock\n",jobID.Data());
110 gSystem->Exec(Form("touch out/%s.lock",jobID.Data()));
113 void AliTPCJobs::SetDone(TString jobID){
114 printf("touch out/%s.done\n",jobID.Data());
115 gSystem->Exec(Form("touch out/%s.done", jobID.Data()));
118 void AliTPCJobs::SetFail(TString jobID){
119 printf("touch out/%s.fail\n",jobID.Data());
120 gSystem->Exec(Form("touch out/%s.fail", jobID.Data()));
123 void AliTPCJobs::Stage(TString inputData, TString jobID){
127 inputData.ReplaceAll("root://voalice04.cern.ch:1094/","");
128 if ( !IsCastorFile(inputData) ) return;
130 sprintf(command,"stager_get -M %s \| grep SUBREQUEST_FAILED ",inputData.Data());
131 FILE *pipe = gSystem->OpenPipe(command,"r");
134 gSystem->ClosePipe(pipe);
135 if ( result.Contains("SUBREQUEST_FAILED") ){
140 Bool_t AliTPCJobs::IsLocked(TString jobID){
141 TString path = "out/";
144 Long_t pid; Long_t psize; Long_t pflags; Long_t pmodtime;
145 Int_t status = gSystem->GetPathInfo(path,&pid,&psize,&pflags,&pmodtime);
149 Bool_t AliTPCJobs::IsFail(TString jobID){
150 TString path = "out/";
153 Long_t pid; Long_t psize; Long_t pflags; Long_t pmodtime;
154 Int_t status = gSystem->GetPathInfo(path,&pid,&psize,&pflags,&pmodtime);
158 Bool_t AliTPCJobs::IsStaged(TString inputData){
160 // check if file bname is staged
162 inputData.ReplaceAll("root://voalice04.cern.ch:1094/","");
163 if ( !IsCastorFile(inputData) ) return kTRUE;
165 sprintf(command,"stager_qry -M %s \| grep /castor \| gawk \'{ print $3;}\'",inputData.Data());
166 FILE *pipe = gSystem->OpenPipe(command,"r");
169 gSystem->ClosePipe(pipe);
170 if ( result.Contains("STAGED") ) return kTRUE;
175 Bool_t AliTPCJobs::IsCastorFile(TString filename){
177 // check if filename begins with 'castor'
179 return filename.BeginsWith("/castor/");
183 void AliTPCJobs::ProcessJob(TString jobID, TString inputData, TString outputDir, TString action){
186 // 1. Create lock file
189 // 4. Create Done file
191 if (action.Contains("COPY")){
193 sprintf(command,"xrdcp -DIFirstConnectMaxCnt 4 -DIConnectTimeout 4 -DIRequestTimeout 4 -DIMaxRedirectcount 4 -DIRedirCntTimeout 4 %s\t%s\n",inputData.Data(), outputDir.Data());
194 printf("Exec\t%s\n", command);
195 gSystem->Exec(command);
196 //TFile::Cp(inputData.Data(), outputDir.Data());
199 //sprintf(command,"$ALICE_ROOT/TPC/macros/testTPC/action.sh %s %s %s %s", jobID.Data(), inputData.Data(), outputDir.Data(), action.Data());
200 sprintf(command,"/afs/cern.ch/user/w/wiechula/SOURCE/aliroot/job_agend/action.sh %s %s %s %s", jobID.Data(), inputData.Data(), outputDir.Data(), action.Data());
201 printf("%s\n\n",command);
202 gSystem->Exec(command);
205 // create temp work dir
206 // TString processDir=fWorkDir+jobID+action;
207 // Int_t res = gSystem->mkdir(processDir,kTRUE);
209 // AliWarning(Form("Cannot create dir/already exists: '%s'",processDir.Data()));
223 jobs.fJobFile="job.list";
224 jobs.ProcessAllJobs();