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