Function GetFromOCDB added to AliShuttle and AliTestShuttle.
authoracolla <acolla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 26 Feb 2007 14:16:20 +0000 (14:16 +0000)
committeracolla <acolla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 26 Feb 2007 14:16:20 +0000 (14:16 +0000)
Implementation of FXS database updates: fileChecksum, file size fields.
Setters to OCDB and reference storages, Shuttle log and temp dir in AliShuttle
and AliTestShuttle.
Small bugfixes.

SHUTTLE/AliShuttle.cxx
SHUTTLE/AliShuttle.h
SHUTTLE/libSHUTTLE.pkg

index bb3f990..fda9199 100644 (file)
 
 /*
 $Log$
+Revision 1.30  2007/02/13 11:23:21  acolla
+Moved getters and setters of Shuttle's main OCDB/Reference, local
+OCDB/Reference, temp and log folders to AliShuttleInterface
+
 Revision 1.27  2007/01/30 17:52:42  jgrosseo
 adding monalisa monitoring
 
@@ -1228,32 +1232,24 @@ const char* AliShuttle::GetFile(Int_t system, const char* detector,
        }
 
        // Query preparation
-       TString sqlQueryStart;
-       TString whereClause;
        TString sourceName(source);
-       Int_t nFields = 0;
+       Int_t nFields = 3;
+       TString sqlQueryStart = Form("select filePath,size,fileChecksum from %s where",
+                                                               fConfig->GetFXSdbTable(system));
+       TString whereClause = Form("run=%d and detector=\"%s\" and fileId=\"%s\"",
+                                                               GetCurrentRun(), detector, id);
+
        if (system == kDAQ)
        {
-               sqlQueryStart = Form("select filePath,size from %s where", fConfig->GetFXSdbTable(system));
-               whereClause = Form("run=%d and detector=\"%s\" and fileId=\"%s\" and DAQsource=\"%s\"",
-                               GetCurrentRun(), detector, id, source);
-               nFields = 2;
-
+               whereClause += Form(" and DAQsource=\"%s\"", source);
        }
        else if (system == kDCS)
        {
-               sqlQueryStart = Form("select filePath,size from %s where", fConfig->GetFXSdbTable(system));
-               whereClause = Form("run=%d and detector=\"%s\" and fileId=\"%s\"",
-                               GetCurrentRun(), detector, id);
-               nFields = 2;
                sourceName="none";
        }
        else if (system == kHLT)
        {
-               sqlQueryStart = Form("select filePath,fileSize,fileChecksum from %s where",
-                                                                               fConfig->GetFXSdbTable(system));
-               whereClause = Form("run=%d and detector=\"%s\" and fileId=\"%s\" and DDLnumbers=\"%s\"",
-                               GetCurrentRun(), detector, id, source);
+               whereClause += Form(" and DDLnumbers=\"%s\"", source);
                nFields = 3;
        }
 
@@ -1306,13 +1302,13 @@ const char* AliShuttle::GetFile(Int_t system, const char* detector,
 
        TString filePath(aRow->GetField(0), aRow->GetFieldLength(0));
        TString fileSize(aRow->GetField(1), aRow->GetFieldLength(1));
-       TString fileMd5Sum;
-       if(system == kHLT) fileMd5Sum = aRow->GetField(2);
+       TString fileChecksum(aRow->GetField(2), aRow->GetFieldLength(2));
 
        delete aResult;
        delete aRow;
 
-       AliDebug(2, Form("filePath = %s",filePath.Data()));
+       AliDebug(2, Form("filePath = %s; size = %s, fileChecksum = %s",
+                               filePath.Data(), fileSize.Data(), fileChecksum.Data()));
 
        // retrieved file is renamed to make it unique
        TString localFileName = Form("%s_%s_%d_%s_%s.shuttle",
@@ -1339,11 +1335,11 @@ const char* AliShuttle::GetFile(Int_t system, const char* detector,
                                                GetShuttleTempDir(), localFileName.Data()));
                }
 
-               if (system == kHLT)
+               if (fileChecksum.Length()>0)
                {
                        // compare md5sum of local file with the one stored in the FXS DB
                        Int_t md5Comp = gSystem->Exec(Form("md5sum %s/%s |grep %s 2>&1 > /dev/null",
-                                               GetShuttleTempDir(), localFileName.Data(), fileMd5Sum.Data()));
+                                               GetShuttleTempDir(), localFileName.Data(), fileChecksum.Data()));
 
                        if (md5Comp != 0)
                        {
@@ -1352,6 +1348,9 @@ const char* AliShuttle::GetFile(Int_t system, const char* detector,
                                result = kFALSE;
                                continue;
                        }
+               } else {
+                       Log(fCurrentDetector, Form("GetFile - md5sum of file %s not set in %s database, skipping comparison",
+                                                       filePath.Data(), GetSystemName(system)));
                }
                if (result) break;
        }
@@ -1450,7 +1449,7 @@ TList* AliShuttle::GetFileSources(Int_t system, const char* detector, const char
                sourceName = "DDLnumbers";
        }
 
-       TString sqlQueryStart = Form("select %s from %s where", sourceName.Data(), fConfig->GetFXSdbTable(kDAQ));
+       TString sqlQueryStart = Form("select %s from %s where", sourceName.Data(), fConfig->GetFXSdbTable(system));
        TString whereClause = Form("run=%d and detector=\"%s\" and fileId=\"%s\"",
                                GetCurrentRun(), detector, id);
        TString sqlQuery = Form("%s %s", sqlQueryStart.Data(), whereClause.Data());
@@ -1919,6 +1918,21 @@ const char* AliShuttle::GetRunParameter(const char* param)
 }
 
 //______________________________________________________________________________________________
+AliCDBEntry* AliShuttle::GetFromOCDB(const AliCDBPath& path)
+{
+// returns obiect from OCDB valid for current run
+
+       AliCDBStorage *sto = AliCDBManager::Instance()->GetStorage(fgkMainCDB);
+       if (!sto)
+       {
+               Log("SHUTTLE", "GetFromOCDB - Cannot activate main OCDB for query!");
+               return 0;
+       }
+
+       return dynamic_cast<AliCDBEntry*> (sto->Get(path, GetCurrentRun()));
+}
+
+//______________________________________________________________________________________________
 Bool_t AliShuttle::SendMail()
 {
 // sends a mail to the subdetector expert in case of preprocessor error
@@ -2013,3 +2027,19 @@ Bool_t AliShuttle::SendMail()
 
        return result == 0;
 }
+
+//______________________________________________________________________________________________
+void AliShuttle::SetShuttleTempDir(const char* tmpDir)
+{
+// sets Shuttle temp directory
+
+       fgkShuttleTempDir = gSystem->ExpandPathName(tmpDir);
+}
+
+//______________________________________________________________________________________________
+void AliShuttle::SetShuttleLogDir(const char* logDir)
+{
+// sets Shuttle log directory
+
+       fgkShuttleLogDir = gSystem->ExpandPathName(logDir);
+}
index 4188233..1f6ace4 100644 (file)
@@ -25,10 +25,7 @@ class TObject;
 class AliShuttleConfig;
 class AliShuttleLogbookEntry;
 class AliPreprocessor;
-class AliCDBMetaData;
 class TSQLServer;
-class AliCDBEntry;
-class AliCDBPath;
 class TMutex;
 class TMonaLisaWriter;
 
@@ -60,6 +57,7 @@ public:
                const char* id, const char* source);
        virtual TList* GetFileSources(Int_t system, const char* detector, const char* id);
        virtual const char* GetRunParameter(const char* lbEntry);
+       virtual AliCDBEntry* GetFromOCDB(const AliCDBPath& path);
        virtual void Log(const char* detector, const char* message);
 
        //TODO Test only, remove later !
@@ -68,6 +66,15 @@ public:
 
        Bool_t Connect(Int_t system);
 
+       static void SetMainCDB (TString mainCDB) {fgkMainCDB = mainCDB;}
+       static void SetLocalCDB (TString localCDB) {fgkLocalCDB = localCDB;}
+
+       static void SetMainRefStorage (TString mainRefStorage) {fgkMainRefStorage = mainRefStorage;}
+       static void SetLocalRefStorage (TString localRefStorage) {fgkLocalRefStorage = localRefStorage;}
+
+       static void SetShuttleTempDir (const char* tmpDir);
+       static void SetShuttleLogDir (const char* logDir);
+
 private:
        AliShuttle(const AliShuttle& other);
        AliShuttle& operator= (const AliShuttle& other);
index 5c09ac2..6ffe316 100644 (file)
@@ -12,7 +12,7 @@ EINCLUDE := $(DIMDIR)/dim
 ELIBS := dim
 ELIBSDIR := $(DIMDIR)/$(ODIR)
 
-EINCLUDE += $(ALIEN_ROOT)/api/include
+EINCLUDE += $(ALIEN)/api/include
 
 DHDR= SHUTTLELinkDef.h