]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - SHUTTLE/AliShuttle.cxx
Fixed some pedantic errors
[u/mrichter/AliRoot.git] / SHUTTLE / AliShuttle.cxx
index 9afceb51aee438aeb9eb7252ce26c0d63693e007..e252310363e2b5123eaec1ddb787c09c75f49a3f 100644 (file)
 
 /*
 $Log$
+Revision 1.55  2007/08/06 12:26:40  acolla
+Function Bool_t GetHLTStatus added to preprocessor. It returns the status of HLT
+read from the run logbook.
+
+Revision 1.54  2007/07/12 09:51:25  jgrosseo
+removed duplicated log message in GetFile
+
+Revision 1.53  2007/07/12 09:26:28  jgrosseo
+updating hlt fxs base path
+
+Revision 1.52  2007/07/12 08:06:45  jgrosseo
+adding log messages in getfile... functions
+adding not implemented copy constructor in alishuttleconfigholder
+
+Revision 1.51  2007/07/03 17:24:52  acolla
+root moved to v5-16-00. TFileMerger->Cp moved to TFile::Cp.
+
+Revision 1.50  2007/07/02 17:19:32  acolla
+preprocessor is run in a temp directory that is removed when process is finished.
+
+Revision 1.49  2007/06/29 10:45:06  acolla
+Number of columns in MySql Shuttle logbook increased by one (HLT added)
+
+Revision 1.48  2007/06/21 13:06:19  acolla
+GetFileSources returns dummy list with 1 source if system=DCS (better than
+returning error as it was)
+
 Revision 1.47  2007/06/19 17:28:56  acolla
 HLT updated; missing map bug removed.
 
@@ -246,6 +273,7 @@ some docs added
 #include <TMutex.h>
 #include <TSystemDirectory.h>
 #include <TSystemFile.h>
+#include <TFile.h>
 #include <TFileMerger.h>
 #include <TGrid.h>
 #include <TGridResult.h>
@@ -841,7 +869,7 @@ Bool_t AliShuttle::StoreRefFilesToGrid()
                fullGridPath.Form("alien://%s/%s", alienDir.Data(), fileName.Data());
 
                TFileMerger fileMerger;
-               Bool_t result = fileMerger.Cp(fullLocalPath, fullGridPath);
+               Bool_t result = TFile::Cp(fullLocalPath, fullGridPath);
                
                if (result)
                {
@@ -1400,12 +1428,24 @@ Bool_t AliShuttle::Process(AliShuttleLogbookEntry* entry)
                                
                        }
                        
+                       TString wd = gSystem->WorkingDirectory();
+                       TString tmpDir = Form("%s/%s_process",GetShuttleTempDir(),fCurrentDetector.Data());
+                       
+                       gSystem->mkdir(tmpDir.Data());
+                       gSystem->ChangeDirectory(tmpDir.Data());
+                       
                        Bool_t success = ProcessCurrentDetector();
+                       
+                       gSystem->ChangeDirectory(wd.Data());
+                       
+                       gSystem->Exec(Form("rm -rf %s",tmpDir.Data()));
+                       
                        if (success) // Preprocessor finished successfully!
                        { 
                                // Update time_processed field in FXS DB
                                if (UpdateTable() == kFALSE)
-                                       Log("SHUTTLE", Form("Process - %s: Could not update FXS databases!"));
+                                       Log("SHUTTLE", Form("Process - %s: Could not update FXS databases!", 
+                                                       fCurrentDetector.Data()));
 
                                // Transfer the data from local storage to main storage (Grid)
                                UpdateShuttleStatus(AliShuttleStatus::kStoreStarted);
@@ -1628,7 +1668,7 @@ Bool_t AliShuttle::QueryShuttleLogbook(const char* whereClause,
        }
 
        // TODO Check field count!
-       const UInt_t nCols = 22;
+       const UInt_t nCols = 23;
        if (aResult->GetFieldCount() != (Int_t) nCols) {
                AliError("Invalid SQL result field number!");
                delete aResult;
@@ -1776,67 +1816,31 @@ TMap* AliShuttle::GetValueSet(const char* host, Int_t port, const TSeqCollection
        // type: kAlias or kDP
        // returns TMap of values, 0 when failure
 
-       const Int_t kSplit = 100; // maximum number of DPs at a time
-       
-       Int_t totalEntries = entries->GetEntries();
-       
+       AliDCSClient client(host, port, fTimeout, fRetries);
+
        TMap* result = 0;
-       
-       for (Int_t index=0; index < totalEntries; index += kSplit)
+       if (type == kAlias)
        {
-               Int_t endIndex = index + kSplit;
-       
-               AliDCSClient client(host, port, fTimeout, fRetries);
-               if (!client.IsConnected())
-                       return 0;
-
-               TMap* partialResult = 0;
+               result = client.GetAliasValues(entries, GetCurrentStartTime(), 
+                       GetCurrentEndTime());
+       } 
+       else if (type == kDP)
+       {
+               result = client.GetDPValues(entries, GetCurrentStartTime(), 
+                       GetCurrentEndTime());
+       }
 
-               if (type == kAlias)
-               {
-                       partialResult = client.GetAliasValues(entries, GetCurrentStartTime(), 
-                               GetCurrentEndTime(), index, endIndex);
-               } 
-               else if (type == kDP)
-               {
-                       partialResult = client.GetDPValues(entries, GetCurrentStartTime(), 
-                               GetCurrentEndTime(), index, endIndex);
-               }
+       if (result == 0)
+       {
+               Log(fCurrentDetector.Data(), Form("GetValueSet - Can't get entries! Reason: %s",
+                       client.GetServerError().Data()));
 
-               if (partialResult == 0)
-               {
-                       Log(fCurrentDetector.Data(), Form("GetValueSet - Can't get entries (%d...%d)! Reason: %s",
-                               index, endIndex, client.GetServerError().Data()));
-       
-                       if (result)
-                               delete result;
-                               
-                       return 0;
-               }
-               
-               AliInfo(Form("Retrieved entries %d..%d (total %d); E.g. %s has %d values collected",
-                                       index, endIndex, totalEntries, entries->At(index)->GetName(), ((TObjArray*)
-                                       partialResult->GetValue(entries->At(index)->GetName()))->GetEntriesFast()));
-               
-               if (!result)
-               {
-                       result = partialResult;
-               }
-               else
-               {               
-                       TIter iter(partialResult);
-                       TObjString* key = 0;
-                       while ((key = (TObjString*) iter.Next()))
-                               result->Add(key, partialResult->GetValue(key->String()));
-                               
-                       partialResult->SetOwner(kFALSE);
-                       delete partialResult;
-               }
-       
+               return 0;
        }
-
+               
        return result;
 }
+
 //______________________________________________________________________________________________
 const char* AliShuttle::GetFile(Int_t system, const char* detector,
                const char* id, const char* source)
@@ -1961,11 +1965,7 @@ const char* AliShuttle::GetFile(Int_t system, const char* detector,
                        Log(detector, Form("GetFileName - Copy of file %s from %s FXS failed",
                                        filePath.Data(), GetSystemName(system)));
                        continue;
-               } else {
-                       AliInfo(Form("File %s copied from %s FXS into %s/%s",
-                                               filePath.Data(), GetSystemName(system),
-                                               GetShuttleTempDir(), localFileName.Data()));
-               }
+               } 
 
                if (fileChecksum.Length()>0)
                {
@@ -1994,12 +1994,11 @@ const char* AliShuttle::GetFile(Int_t system, const char* detector,
        fFXSlist[system].Add(fileParams);
 
        static TString fullLocalFileName;
-       fullLocalFileName = TString::Format("%s/%s", GetShuttleTempDir(), localFileName.Data());
+       fullLocalFileName.Form("%s/%s", GetShuttleTempDir(), localFileName.Data());
 
-       AliInfo(Form("fullLocalFileName = %s", fullLocalFileName.Data()));
+       Log(fCurrentDetector, Form("GetFile - Retrieved file with id %s and source %s from %s to %s", id, source, GetSystemName(system), fullLocalFileName.Data()));
 
        return fullLocalFileName.Data();
-
 }
 
 //______________________________________________________________________________________________
@@ -2035,7 +2034,7 @@ Bool_t AliShuttle::RetrieveFile(UInt_t system, const char* fxsFileName, const ch
        }
        else if (system == kHLT)
        {
-               baseFXSFolder = "/opt/FXS";
+               baseFXSFolder = "/opt/FXS/";
        }
 
 
@@ -2062,6 +2061,8 @@ TList* AliShuttle::GetFileSources(Int_t system, const char* detector, const char
        // Get sources producing the condition file Id from file exchange servers
        // if id is NULL all sources are returned (distinct)
        //
+
+       Log(detector, Form("GetFileSources - Retrieving sources with id %s from %s", id, GetSystemName(system)));
        
        // check if test mode should simulate a FXS error
        if (fTestMode & kErrorFXSSources)
@@ -2070,7 +2071,6 @@ TList* AliShuttle::GetFileSources(Int_t system, const char* detector, const char
                return 0;
        }
 
-
        if (system == kDCS)
        {
                AliWarning("DCS system has only one source of data!");
@@ -2125,8 +2125,9 @@ TList* AliShuttle::GetFileSources(Int_t system, const char* detector, const char
                return list;
        }
 
-       TSQLRow* aRow;
+       Log(detector, Form("GetFileSources - Found %d sources", aResult->GetRowCount()));
 
+       TSQLRow* aRow;
        while ((aRow = aResult->Next()))
        {
 
@@ -2148,6 +2149,8 @@ TList* AliShuttle::GetFileIDs(Int_t system, const char* detector, const char* so
        // Get all ids of condition files produced by a given source from file exchange servers
        //
        
+        Log(detector, Form("GetFileIDs - Retrieving ids with source %s with %s", source, GetSystemName(system)));
+
        // check if test mode should simulate a FXS error
        if (fTestMode & kErrorFXSSources)
        {
@@ -2200,6 +2203,8 @@ TList* AliShuttle::GetFileIDs(Int_t system, const char* detector, const char* so
                return list;
        }
 
+        Log(detector, Form("GetFileIDs - Found %d ids", aResult->GetRowCount()));
+
        TSQLRow* aRow;
 
        while ((aRow = aResult->Next()))
@@ -2873,6 +2878,24 @@ const char* AliShuttle::GetRunType()
        return fLogbookEntry->GetRunType();
 }
 
+//______________________________________________________________________________________________
+Bool_t AliShuttle::GetHLTStatus()
+{
+       // Return HLT status (ON=1 OFF=0)
+       // Converts the HLT status from the status string read in the run logbook (not just a bool)
+
+       if(!fLogbookEntry) {
+               AliError("No logbook entry!");
+               return 0;
+       }
+
+       // TODO implement when HLTStatus is inserted in run logbook
+       //TString hltStatus = fLogbookEntry->GetRunParameter("HLTStatus");
+       //if(hltStatus == "OFF") {return kFALSE};
+
+       return kTRUE;
+}
+
 //______________________________________________________________________________________________
 void AliShuttle::SetShuttleTempDir(const char* tmpDir)
 {