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