]> git.uio.no Git - u/mrichter/AliRoot.git/blob - SHUTTLE/AliShuttle.h
9731ae14297e0e012a29a62c5ad725c611c42e3b
[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 AliCDBMetaData;
29 class TSQLServer;
30 class AliCDBEntry;
31 class AliCDBPath;
32 class TMutex;
33 class TMonaLisaWriter;
34
35 class AliShuttle: public AliShuttleInterface {
36 public:
37         enum DCSType {kAlias=0, kDP};
38
39         AliShuttle(const AliShuttleConfig* config, UInt_t timeout = 5000, Int_t retries = 5);
40         virtual ~AliShuttle();
41
42         virtual void RegisterPreprocessor(AliPreprocessor* preprocessor);
43
44         Bool_t Collect(Int_t run = -1);
45
46         Bool_t Process(AliShuttleLogbookEntry* entry);
47
48         // monitoring functions
49         ULong_t GetTimeOfLastAction() const;
50         const TString GetLastAction() const;
51
52         Int_t GetCurrentRun() const;
53         UInt_t GetCurrentStartTime() const;
54         UInt_t GetCurrentEndTime() const;
55
56         virtual UInt_t Store(const AliCDBPath& path, TObject* object, AliCDBMetaData* metaData,
57                         Int_t validityStart = 0, Bool_t validityInfinite = kFALSE);
58         virtual UInt_t StoreReferenceData(const AliCDBPath& path, TObject* object, AliCDBMetaData* metaData);
59         virtual const char* GetFile(Int_t system, const char* detector,
60                 const char* id, const char* source);
61         virtual TList* GetFileSources(Int_t system, const char* detector, const char* id);
62         virtual const char* GetRunParameter(const char* lbEntry);
63         virtual void Log(const char* detector, const char* message);
64
65         static TString GetMainCDB () {return fgkMainCDB;}
66         static void SetMainCDB (TString mainCDB) {fgkMainCDB = mainCDB;}
67         static TString GetLocalCDB () {return fgkLocalCDB;}
68         static void SetLocalCDB (TString localCDB) {fgkLocalCDB = localCDB;}
69
70         static TString GetMainRefStorage() {return fgkMainRefStorage;}
71         static void SetMainRefStorage (TString mainRefStorage) {fgkMainRefStorage = mainRefStorage;}
72         static TString GetLocalRefStorage() {return fgkLocalRefStorage;}
73         static void SetLocalRefStorage (TString localRefStorage) {fgkLocalRefStorage = localRefStorage;}
74
75         //TODO Test only, remove later !
76         void SetProcessDCS(Bool_t process) {fgkProcessDCS = process;}
77         void SetLogbookEntry(AliShuttleLogbookEntry* entry) {fLogbookEntry=entry;}
78
79         static void SetShuttleTempDir (const char* tmpDir);
80         static const char* GetShuttleTempDir() {return fgkShuttleTempDir.Data();}
81         static void SetShuttleLogDir (const char* logDir);
82         static const char* GetShuttleLogDir() {return fgkShuttleLogDir.Data();}
83
84         Bool_t Connect(Int_t system);
85
86 private:
87         AliShuttle(const AliShuttle& other);
88         AliShuttle& operator= (const AliShuttle& other);
89
90         UInt_t ProcessCurrentDetector();
91
92         AliShuttleLogbookEntry* QueryRunParameters(Int_t run);
93         Bool_t QueryShuttleLogbook(const char* whereClause, TObjArray& entries);
94         Bool_t RetrieveConditionsData(const TObjArray& shuttleLogbookEntries);
95
96         Bool_t GetValueSet(const char* host, Int_t port, const char* alias,
97                                 TObjArray* result, DCSType type);
98
99         Bool_t RetrieveFile(UInt_t system, const char* daqFileName, const char* localFileName);
100
101         Bool_t UpdateTable();
102
103         UInt_t WriteToCDB(const char* mainUri, const char* localUri,
104                                 const AliCDBPath& path, TObject* object, AliCDBMetaData* metaData,
105                                 Int_t validityStart = 0, Bool_t validityInfinite = kFALSE);
106
107         Bool_t TryToStoreAgain();
108         Bool_t TryToStoreAgain(TString& storageType);
109
110         AliShuttleStatus* ReadShuttleStatus();
111         Bool_t WriteShuttleStatus(AliShuttleStatus* status);
112         Bool_t ContinueProcessing();
113         void UpdateShuttleStatus(AliShuttleStatus::Status newStatus, Bool_t increaseCount = kFALSE);
114         Bool_t UpdateShuttleLogbook(const char* detector, const char* status=0);
115         Bool_t SendMail();
116
117         void SetLastAction(const char* action);
118         
119         void SendMLInfo();
120
121         const AliShuttleConfig* fConfig;        // pointer to configuration object
122
123         static TString      fgkMainCDB;         // URI of the main (Grid) CDB storage
124         static TString      fgkLocalCDB;                //! URI of the local backup CDB storage
125         static TString      fgkMainRefStorage;  // URI of the main (Grid) REFERENCE storage
126         static TString      fgkLocalRefStorage; // URI of the local REFERENCE storage
127         static TString      fgkShuttleTempDir;  // base path of SHUTTLE temp folder
128         static TString      fgkShuttleLogDir;   // path of SHUTTLE log folder
129
130         UInt_t fTimeout;        // DCS server connection timeout parameter
131         Int_t fRetries;         // Number of DCS server connection retries
132
133         TMap fPreprocessorMap;  // list of detector Preprocessors ("DET", "Preprocessor")
134
135         AliShuttleLogbookEntry* fLogbookEntry;   //! current Shuttle logbook entry
136         TString fCurrentDetector; // current detector
137
138         TSQLServer *fServer[4];         // pointer to the three FXS + Run & Shuttle logbook servers
139         Bool_t fFXSCalled[3];           // FXS call status
140         TList  fFXSlist[3];             // List of files retrieved from each FXS
141
142         AliCDBEntry* fStatusEntry; // last CDB entry containing a AliShuttleStatus retrieved
143         Bool_t fGridError;         // Grid storage error flag
144
145         TMutex* fMonitoringMutex;   // mutex to lock the monitoring class members
146         UInt_t fLastActionTime;    // time of last action for monitoring
147         TString fLastAction;       // string description for last action
148
149         Bool_t fFirstUnprocessed[AliShuttleInterface::kNDetectors];       // array of flags for first unprocessed dets
150
151         TMonaLisaWriter* fMonaLisa;  // ML instance that sends the processing information
152
153         //TODO Test only, remove later !
154         static Bool_t fgkProcessDCS; // flag to enable DCS archive data processing
155
156         ClassDef(AliShuttle, 0);
157 };
158
159 #endif