]> git.uio.no Git - u/mrichter/AliRoot.git/blob - SHUTTLE/AliShuttle.h
.so cleanup: more gSystem->Load()
[u/mrichter/AliRoot.git] / SHUTTLE / AliShuttle.h
1 #ifndef ALI_SHUTTLE_H
2 #define ALI_SHUTTLE_H
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6
7 /* $Id$ */
8
9
10 //
11 // This class is the main manager for 
12 // AliShuttle. It organizes the data retrieval
13 // from DCS and call the interface methods of
14 // AliPreprocessor.
15 //
16
17 #include <TMap.h>
18 #include <TString.h>
19 #include <TList.h>
20
21 #include "AliShuttleInterface.h"
22 #include "AliShuttleStatus.h"
23
24 class TObject;
25 class AliShuttleConfig;
26 class AliShuttleLogbookEntry;
27 class AliPreprocessor;
28 class TSQLServer;
29 class TMutex;
30 class TMonaLisaWriter;
31
32 class AliShuttle: public AliShuttleInterface {
33 public:
34         enum DCSType {kAlias=0, kDP};
35         enum TestMode { kNone = 0, kSkipDCS = 1, kErrorDCS = 2, kErrorFXSSources = 4, kErrorFXSFiles = 8, kErrorOCDB = 16, kErrorStorage = 32, kErrorGrid = 64 };
36         enum EMailTarget { kDCSEMail = 0, kFXSEMail, kPPEMail };
37
38         AliShuttle(const AliShuttleConfig* config, UInt_t timeout = 5000, Int_t retries = 5);
39         virtual ~AliShuttle();
40
41         virtual void RegisterPreprocessor(AliPreprocessor* preprocessor);
42
43         Bool_t Collect(Int_t run = -1);
44
45         Bool_t Process(AliShuttleLogbookEntry* entry);
46
47         // monitoring functions
48         ULong_t GetTimeOfLastAction() const;
49         const TString GetLastAction() const;
50
51         Int_t GetCurrentRun() const;
52         UInt_t GetCurrentStartTime() const;
53         UInt_t GetCurrentEndTime() const;
54         UInt_t GetCurrentYear() const;
55         
56         const char* GetLHCPeriod() const;
57
58         virtual Bool_t Store(const AliCDBPath& path, TObject* object, AliCDBMetaData* metaData,
59                         Int_t validityStart = 0, Bool_t validityInfinite = kFALSE);
60         virtual Bool_t StoreReferenceData(const AliCDBPath& path, TObject* object, AliCDBMetaData* metaData);
61         virtual Bool_t StoreReferenceFile(const char* detector, const char* localFile, const char* gridFileName);
62         virtual Bool_t StoreRunMetadataFile(const char* localFile, const char* gridFileName);
63         virtual const char* GetFile(Int_t system, const char* detector,
64                 const char* id, const char* source);
65         virtual TList* GetFileSources(Int_t system, const char* detector, const char* id = 0);
66         virtual TList* GetFileIDs(Int_t system, const char* detector, const char* source);
67         virtual const char* GetRunParameter(const char* lbEntry);
68         virtual UInt_t GetStartTimeDCSQuery();
69         virtual UInt_t GetEndTimeDCSQuery();
70         virtual AliCDBEntry* GetFromOCDB(const char* detector, const AliCDBPath& path);
71         virtual const char* GetRunType();
72         virtual Bool_t GetHLTStatus();
73         virtual const char* GetTriggerConfiguration(); 
74         virtual const char* GetCTPTimeParams(); 
75         virtual const char* GetTriggerDetectorMask(); 
76         virtual void Log(const char* detector, const char* message, UInt_t level=3);
77
78         void SetLogbookEntry(AliShuttleLogbookEntry* entry) {fLogbookEntry=entry;}
79         
80         void SetTestMode(TestMode testMode) { fTestMode = testMode; }
81         void SetReadTestModeFromLog(Bool_t flag) { fReadTestMode = flag; }
82
83         Bool_t Connect(Int_t system);
84
85         static void SetMainCDB (TString mainCDB) {fgkMainCDB = mainCDB;}
86         static void SetLocalCDB (TString localCDB) {fgkLocalCDB = localCDB;}
87
88         static void SetMainRefStorage (TString mainRefStorage) {fgkMainRefStorage = mainRefStorage;}
89         static void SetLocalRefStorage (TString localRefStorage) {fgkLocalRefStorage = localRefStorage;}
90         static void SetMirrorSEs (TString mirrors) {fgkMirrorSEs = mirrors;}
91
92         static void SetShuttleTempDir (const char* tmpDir);
93         static void SetShuttleLogDir (const char* logDir);
94
95         virtual void SendMLFromDet(const char* value);
96         virtual TString* GetLTUConfig(const char* det);
97
98 private:
99         AliShuttle(const AliShuttle& other);
100         AliShuttle& operator= (const AliShuttle& other);
101
102         Int_t ProcessCurrentDetector();
103
104         AliShuttleLogbookEntry* QueryRunParameters(Int_t run);
105         Bool_t QueryShuttleLogbook(const char* whereClause, TObjArray& entries);
106         void CountOpenRuns();
107         Bool_t RetrieveConditionsData(const TObjArray& shuttleLogbookEntries);
108
109         TMap* GetValueSet(const char* host, Int_t port, const TSeqCollection* entries,
110                               DCSType type, Int_t valueSet);
111
112         Bool_t RetrieveFile(UInt_t system, const char* daqFileName, const char* localFileName);
113
114         Bool_t UpdateTable();
115         Bool_t UpdateTableSkippedCase(const char* detector="ALL");
116         Bool_t UpdateTableFailCase();
117
118         Bool_t StoreLocally(const TString& localUri, const AliCDBPath& path, TObject* object,
119                                 AliCDBMetaData* metaData, Int_t validityStart = 0, Bool_t validityInfinite = kFALSE);
120
121         Bool_t StoreOCDB();
122         Int_t StoreOCDB(const TString& uri);
123         Bool_t CopyFileLocally(const char* localFile, const TString& target);
124         Bool_t CopyFilesToGrid(const char* type);
125         void CleanLocalStorage(const TString& uri);
126         Bool_t CleanReferenceStorage(const char* detector);
127         void RemoveFile(const char* filename);
128         const char* GetRefFilePrefix(const char* base, const char* detector);
129
130         AliShuttleStatus* ReadShuttleStatus();
131         Bool_t WriteShuttleStatus(AliShuttleStatus* status);
132         Bool_t ContinueProcessing();
133         void UpdateShuttleStatus(AliShuttleStatus::Status newStatus, Bool_t increaseCount = kFALSE);
134         Bool_t UpdateShuttleLogbook(const char* detector, const char* status=0);
135         Bool_t SendMail(EMailTarget target, Int_t system = -1);
136         Int_t GetMem(Int_t pid);
137         
138         TString GetLogFileName(const char* detector) const;
139
140         void SetLastAction(const char* action);
141         
142         void SendAlive();
143         void SendMLDetInfo();
144         void SendMLRunInfo(const char* status);
145         virtual Bool_t TouchFile();
146
147         const AliShuttleConfig* fConfig;        // pointer to configuration object
148
149         UInt_t fTimeout;        // DCS server connection timeout parameter
150         Int_t fRetries;         // Number of DCS server connection retries
151
152         TMap fPreprocessorMap;  // list of detector Preprocessors ("DET", "Preprocessor")
153
154         AliShuttleLogbookEntry* fLogbookEntry;   //! current Shuttle logbook entry
155         TString fCurrentDetector; // current detector
156         Bool_t fFirstProcessing;  // processing this detector the first time in this run
157
158         TSQLServer *fServer[5];         // pointer to the four FXS + Run & Shuttle logbook servers
159         Bool_t fFXSCalled[4];           // FXS call status
160         TList  fFXSlist[4];             // List of files retrieved from each FXS
161         Int_t  fFXSError;               // Variable to keep track of any FXS errors; contains -1 for no error, kDAQ, kDCS, kHLT otherwise
162
163         AliCDBEntry* fStatusEntry; // last CDB entry containing a AliShuttleStatus retrieved
164
165         TMutex* fMonitoringMutex;   // mutex to lock the monitoring class members
166         UInt_t fLastActionTime;    // time of last action for monitoring
167         TString fLastAction;       // string description for last action
168
169         Bool_t fFirstUnprocessed[AliShuttleInterface::kNDetectors];       // array of flags for first unprocessed dets
170
171         TMonaLisaWriter* fMonaLisa;  // ML instance that sends the processing information
172
173         TestMode fTestMode;          // sets test mode flags, that e.g. simulate a dcs error etc.
174         Bool_t fReadTestMode;        // Reads the test mode from the log entry of the given run (only for test)
175         
176         Bool_t fOutputRedirected;    // is the output redirected to a file
177
178         ClassDef(AliShuttle, 0);
179 };
180
181 #endif