]> git.uio.no Git - u/mrichter/AliRoot.git/blob - SHUTTLE/AliShuttle.h
Extending period for DCS DPs query to the time when the run number was created
[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 GetCurrentTimeCreated() const;
55         UInt_t GetCurrentYear() const;
56         
57         const char* GetLHCPeriod() const;
58
59         virtual Bool_t Store(const AliCDBPath& path, TObject* object, AliCDBMetaData* metaData,
60                         Int_t validityStart = 0, Bool_t validityInfinite = kFALSE);
61         virtual Bool_t StoreReferenceData(const AliCDBPath& path, TObject* object, AliCDBMetaData* metaData);
62         virtual Bool_t StoreReferenceFile(const char* detector, const char* localFile, const char* gridFileName);
63         virtual Bool_t StoreRunMetadataFile(const char* localFile, const char* gridFileName);
64         virtual const char* GetFile(Int_t system, const char* detector,
65                 const char* id, const char* source);
66         virtual TList* GetFileSources(Int_t system, const char* detector, const char* id = 0);
67         virtual TList* GetFileIDs(Int_t system, const char* detector, const char* source);
68         virtual const char* GetRunParameter(const char* lbEntry);
69         virtual AliCDBEntry* GetFromOCDB(const char* detector, const AliCDBPath& path);
70         virtual const char* GetRunType();
71         virtual Bool_t GetHLTStatus();
72         virtual const char* GetTriggerConfiguration(); 
73         virtual void Log(const char* detector, const char* message);
74
75         void SetLogbookEntry(AliShuttleLogbookEntry* entry) {fLogbookEntry=entry;}
76         
77         void SetTestMode(TestMode testMode) { fTestMode = testMode; }
78         void SetReadTestModeFromLog(Bool_t flag) { fReadTestMode = flag; }
79
80         Bool_t Connect(Int_t system);
81
82         static void SetMainCDB (TString mainCDB) {fgkMainCDB = mainCDB;}
83         static void SetLocalCDB (TString localCDB) {fgkLocalCDB = localCDB;}
84
85         static void SetMainRefStorage (TString mainRefStorage) {fgkMainRefStorage = mainRefStorage;}
86         static void SetLocalRefStorage (TString localRefStorage) {fgkLocalRefStorage = localRefStorage;}
87
88         static void SetShuttleTempDir (const char* tmpDir);
89         static void SetShuttleLogDir (const char* logDir);
90
91 private:
92         AliShuttle(const AliShuttle& other);
93         AliShuttle& operator= (const AliShuttle& other);
94
95         Int_t ProcessCurrentDetector();
96
97         AliShuttleLogbookEntry* QueryRunParameters(Int_t run);
98         Bool_t QueryShuttleLogbook(const char* whereClause, TObjArray& entries);
99         void CountOpenRuns();
100         Bool_t RetrieveConditionsData(const TObjArray& shuttleLogbookEntries);
101
102         TMap* GetValueSet(const char* host, Int_t port, const TSeqCollection* entries,
103                               DCSType type, Int_t valueSet);
104
105         Bool_t RetrieveFile(UInt_t system, const char* daqFileName, const char* localFileName);
106
107         Bool_t UpdateTable();
108         Bool_t UpdateTableSkippedCase(const char* detector="ALL");
109         Bool_t UpdateTableFailCase();
110
111         Bool_t StoreLocally(const TString& localUri, const AliCDBPath& path, TObject* object,
112                                 AliCDBMetaData* metaData, Int_t validityStart = 0, Bool_t validityInfinite = kFALSE);
113
114         Bool_t StoreOCDB();
115         Int_t StoreOCDB(const TString& uri);
116         Bool_t CopyFileLocally(const char* localFile, const TString& target);
117         Bool_t CopyFilesToGrid(const char* type);
118         void CleanLocalStorage(const TString& uri);
119         Bool_t CleanReferenceStorage(const char* detector);
120         void RemoveFile(const char* filename);
121         const char* GetRefFilePrefix(const char* base, const char* detector);
122
123         AliShuttleStatus* ReadShuttleStatus();
124         Bool_t WriteShuttleStatus(AliShuttleStatus* status);
125         Bool_t ContinueProcessing();
126         void UpdateShuttleStatus(AliShuttleStatus::Status newStatus, Bool_t increaseCount = kFALSE);
127         Bool_t UpdateShuttleLogbook(const char* detector, const char* status=0);
128         Bool_t SendMail(EMailTarget target, Int_t system = -1);
129         Int_t GetMem(Int_t pid);
130         
131         TString GetLogFileName(const char* detector) const;
132
133         void SetLastAction(const char* action);
134         
135         void SendAlive();
136         void SendMLDetInfo();
137         void SendMLRunInfo(const char* status);
138         virtual Bool_t TouchFile();
139
140         const AliShuttleConfig* fConfig;        // pointer to configuration object
141
142         UInt_t fTimeout;        // DCS server connection timeout parameter
143         Int_t fRetries;         // Number of DCS server connection retries
144
145         TMap fPreprocessorMap;  // list of detector Preprocessors ("DET", "Preprocessor")
146
147         AliShuttleLogbookEntry* fLogbookEntry;   //! current Shuttle logbook entry
148         TString fCurrentDetector; // current detector
149         Bool_t fFirstProcessing;  // processing this detector the first time in this run
150
151         TSQLServer *fServer[4];         // pointer to the three FXS + Run & Shuttle logbook servers
152         Bool_t fFXSCalled[3];           // FXS call status
153         TList  fFXSlist[3];             // List of files retrieved from each FXS
154         Int_t  fFXSError;               // Variable to keep track of any FXS errors; contains -1 for no error, kDAQ, kDCS, kHLT otherwise
155
156         AliCDBEntry* fStatusEntry; // last CDB entry containing a AliShuttleStatus retrieved
157
158         TMutex* fMonitoringMutex;   // mutex to lock the monitoring class members
159         UInt_t fLastActionTime;    // time of last action for monitoring
160         TString fLastAction;       // string description for last action
161
162         Bool_t fFirstUnprocessed[AliShuttleInterface::kNDetectors];       // array of flags for first unprocessed dets
163
164         TMonaLisaWriter* fMonaLisa;  // ML instance that sends the processing information
165
166         TestMode fTestMode;          // sets test mode flags, that e.g. simulate a dcs error etc.
167         Bool_t fReadTestMode;        // Reads the test mode from the log entry of the given run (only for test)
168         
169         Bool_t fOutputRedirected;    // is the output redirected to a file
170
171         ClassDef(AliShuttle, 0);
172 };
173
174 #endif