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