adding monalisa monitoring
authorjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 30 Jan 2007 17:52:42 +0000 (17:52 +0000)
committerjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 30 Jan 2007 17:52:42 +0000 (17:52 +0000)
SHUTTLE/AliShuttle.cxx
SHUTTLE/AliShuttle.h
SHUTTLE/Shuttle.C

index bcea5a6..3229400 100644 (file)
 
 /*
 $Log$
+Revision 1.26  2007/01/23 19:20:03  acolla
+Removed old ldif files, added TOF, MCH ldif files. Added some options in
+AliShuttleConfig::Print. Added in Ali Shuttle: SetShuttleTempDir and
+SetShuttleLogDir
+
 Revision 1.25  2007/01/15 19:13:52  acolla
 Moved some AliInfo to AliDebug in SendMail function
 
@@ -165,6 +170,8 @@ some docs added
 #include <TSQLRow.h>
 #include <TMutex.h>
 
+#include <TMonaLisaWriter.h>
+
 #include <fstream>
 
 #include <sys/types.h>
@@ -194,7 +201,8 @@ fStatusEntry(0),
 fGridError(kFALSE),
 fMonitoringMutex(0),
 fLastActionTime(0),
-fLastAction()
+fLastAction(),
+fMonaLisa(0)
 {
        //
        // config: AliShuttleConfig used
@@ -411,6 +419,8 @@ Bool_t AliShuttle::WriteShuttleStatus(AliShuttleStatus* status)
                AliError(Form("WriteShuttleStatus for %s, run %d failed", fCurrentDetector.Data(), run));
                return kFALSE;
        }
+       
+       SendMLInfo();
 
        return kTRUE;
 }
@@ -443,7 +453,34 @@ void AliShuttle::UpdateShuttleStatus(AliShuttleStatus::Status newStatus, Bool_t
        if (increaseCount) status->IncreaseCount();
 
        AliCDBManager::Instance()->GetStorage(fgkLocalCDB)->Put(fStatusEntry);
+
+       SendMLInfo();
+}
+
+//______________________________________________________________________________________________
+void AliShuttle::SendMLInfo()
+{
+       //
+       // sends ML information about the current status of the current detector being processed
+       //
+       
+       AliShuttleStatus* status = dynamic_cast<AliShuttleStatus*> (fStatusEntry->GetObject());
+       
+       if (!status){
+               AliError("UNEXPECTED: status could not be read from current CDB entry");
+               return;
+       }
+       
+       TMonaLisaText  mlStatus(Form("%s_status", fCurrentDetector.Data()), status->GetStatusName());
+       TMonaLisaValue mlRetryCount(Form("%s_count", fCurrentDetector.Data()), status->GetCount());
+
+       TList mlList;
+       mlList.Add(&mlStatus);
+       mlList.Add(&mlRetryCount);
+
+       fMonaLisa->SendParameters(&mlList);
 }
+
 //______________________________________________________________________________________________
 Bool_t AliShuttle::ContinueProcessing()
 {
@@ -514,6 +551,8 @@ Bool_t AliShuttle::ContinueProcessing()
                        Log("SHUTTLE",
                                Form("ContinueProcessing - %s: Grid storage failed again",
                                        fCurrentDetector.Data()));
+                       // trigger ML information manually because we do not had a status change
+                       SendMLInfo();
                }
                return kFALSE;
        }
@@ -527,6 +566,7 @@ Bool_t AliShuttle::ContinueProcessing()
                                "Updating Shuttle Logbook", fCurrentDetector.Data(),
                                status->GetCount(), status->GetStatusName()));
                UpdateShuttleLogbook(fCurrentDetector.Data(), "FAILED");
+               UpdateShuttleStatus(AliShuttleStatus::kFailed);
        } else {
                Log("SHUTTLE", Form("ContinueProcessing - %s: restarting. "
                                "Aborted before with %s. Retry number %d.", fCurrentDetector.Data(),
@@ -558,17 +598,31 @@ Bool_t AliShuttle::Process(AliShuttleLogbookEntry* entry)
 
        fLogbookEntry = entry;
 
-       if(fLogbookEntry->IsDone()){
+       if (fLogbookEntry->IsDone())
+       {
                Log("SHUTTLE","Process - Shuttle is already DONE. Updating logbook");
                UpdateShuttleLogbook("shuttle_done");
                fLogbookEntry = 0;
                return kTRUE;
        }
 
+       // create ML instance that monitors this run
+       fMonaLisa = new TMonaLisaWriter(Form("%d", GetCurrentRun()), "SHUTTLE", "aliendb1.cern.ch");
+       // disable monitoring of other parameters that come e.g. from TFile
+       gMonitoringWriter = 0;
 
        AliInfo(Form("\n\n \t\t\t^*^*^*^*^*^*^*^*^*^*^*^* run %d: START ^*^*^*^*^*^*^*^*^*^*^*^* \n",
                                        GetCurrentRun()));
 
+
+       // Send the information to ML
+       TMonaLisaText  mlStatus("SHUTTLE_status", "Processing");
+
+       TList mlList;
+       mlList.Add(&mlStatus);
+
+       fMonaLisa->SendParameters(&mlList);
+                       
        fLogbookEntry->Print("all");
 
        // Initialization
@@ -593,6 +647,7 @@ Bool_t AliShuttle::Process(AliShuttleLogbookEntry* entry)
                AliInfo(Form("\n\n \t\t\t****** run %d - %s: START  ******",
                                                GetCurrentRun(), aDetector->GetName()));
 
+               Log(fCurrentDetector.Data(), "Starting processing");
 
                Int_t pid = fork();
 
@@ -740,6 +795,10 @@ Bool_t AliShuttle::Process(AliShuttleLogbookEntry* entry)
                }
        }
 
+       // remove ML instance
+       delete fMonaLisa;
+       fMonaLisa = 0;
+
        fLogbookEntry = 0;
 
        return hasError == kFALSE;
@@ -1795,8 +1854,10 @@ Bool_t AliShuttle::UpdateHLTTable()
 //______________________________________________________________________________________________
 Bool_t AliShuttle::UpdateShuttleLogbook(const char* detector, const char* status)
 {
-// Update Shuttle logbook filling detector or shuttle_done column
-// ex. of usage: UpdateShuttleLogbook("PHOS", "DONE") or UpdateShuttleLogbook("shuttle_done")
+       //
+       // Update Shuttle logbook filling detector or shuttle_done column
+       // ex. of usage: UpdateShuttleLogbook("PHOS", "DONE") or UpdateShuttleLogbook("shuttle_done")
+       //
 
        // check connection, in case connect
        if(!Connect(3)){
@@ -1806,8 +1867,17 @@ Bool_t AliShuttle::UpdateShuttleLogbook(const char* detector, const char* status
 
        TString detName(detector);
        TString setClause;
-       if(detName == "shuttle_done") {
+       if(detName == "shuttle_done")
+       {
                setClause = "set shuttle_done=1";
+
+               // Send the information to ML
+               TMonaLisaText  mlStatus("SHUTTLE_status", "Done");
+
+               TList mlList;
+               mlList.Add(&mlStatus);
+
+               fMonaLisa->SendParameters(&mlList);
        } else {
                TString statusStr(status);
                if(statusStr.Contains("done", TString::kIgnoreCase) ||
@@ -1881,13 +1951,18 @@ void AliShuttle::Log(const char* detector, const char* message)
        }
 
        TString toLog = Form("%s (%d): %s - ", TTimeStamp(time(0)).AsString("s"), getpid(), detector);
-       if(GetCurrentRun()>=0 ) toLog += Form("run %d - ", GetCurrentRun());
+       if (GetCurrentRun() >= 0) 
+               toLog += Form("run %d - ", GetCurrentRun());
        toLog += Form("%s", message);
 
        AliInfo(toLog.Data());
 
        TString fileName;
-       fileName.Form("%s/%s.log", GetShuttleLogDir(), detector);
+       if (GetCurrentRun() >= 0) 
+               fileName.Form("%s/%s_%d.log", GetShuttleLogDir(), detector, GetCurrentRun());
+       else
+               fileName.Form("%s/%s.log", GetShuttleLogDir(), detector);
+       
        gSystem->ExpandPathName(fileName);
 
        ofstream logFile;
index 93f07a0..7e3a373 100644 (file)
@@ -30,6 +30,7 @@ class TSQLServer;
 class AliCDBEntry;
 class AliCDBPath;
 class TMutex;
+class TMonaLisaWriter;
 
 class AliShuttle: public AliShuttleInterface {
 public:
@@ -117,14 +118,16 @@ private:
        Bool_t TryToStoreAgain();
        Bool_t TryToStoreAgain(TString& storageType);
 
-       AliShuttleStatus* ReadShuttleStatus();
-       Bool_t WriteShuttleStatus(AliShuttleStatus* status);
-       Bool_t ContinueProcessing();
-       void UpdateShuttleStatus(AliShuttleStatus::Status newStatus, Bool_t increaseCount = kFALSE);
-       Bool_t UpdateShuttleLogbook(const char* detector, const char* status=0);
+       AliShuttleStatus* ReadShuttleStatus();
+       Bool_t WriteShuttleStatus(AliShuttleStatus* status);
+       Bool_t ContinueProcessing();
+       void UpdateShuttleStatus(AliShuttleStatus::Status newStatus, Bool_t increaseCount = kFALSE);
+       Bool_t UpdateShuttleLogbook(const char* detector, const char* status=0);
        Bool_t SendMail();
 
-       void SetLastAction(const char* action);
+       void SetLastAction(const char* action);
+       
+       void SendMLInfo();
 
        const AliShuttleConfig* fConfig;        // pointer to configuration object
 
@@ -156,6 +159,8 @@ private:
 
        Bool_t fFirstUnprocessed[AliShuttleInterface::kNDetectors];       // array of flags for first unprocessed dets
 
+       TMonaLisaWriter* fMonaLisa;  // ML instance that sends the processing information
+
        //TODO Test only, remove later !
        static Bool_t fgkProcessDCS; // flag to enable DCS archive data processing
 
index a6e40b4..1226c46 100644 (file)
@@ -5,9 +5,14 @@ Bool_t Shuttle(const char* param = "listen") {
        // loading LDAP libraries!!!
 
        gSystem->Load("libRLDAP.so");
+       gSystem->Load("libMonaLisa");
        gSystem->Load("libSHUTTLE");
        gSystem->Load("$ROOTSYS/lib/libThread");
        gSystem->Load("$ALICE_ROOT/SHUTTLE/test/libTest.so");
+       
+       // libRalien complains otherwise, weird...
+       //gSystem->Load("libNetx");
+
 
 //     AliLog::SetGlobalDebugLevel(1);