Run type field added in SHUTTLE framework. Run type is read from "run type" logbook...
[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;
57f50b3c 28class TSQLServer;
cb343cfd 29class TMutex;
e7f62f16 30class TMonaLisaWriter;
73abe331 31
b948db8d 32class AliShuttle: public AliShuttleInterface {
73abe331 33public:
2c15234c 34 enum DCSType {kAlias=0, kDP};
35
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);
d386d623 60 virtual AliCDBEntry* GetFromOCDB(const AliCDBPath& path);
441b0e9c 61 virtual const char* GetRunType(const char* detCode);
b948db8d 62 virtual void Log(const char* detector, const char* message);
63
4f0ab988 64 //TODO Test only, remove later !
2bb7b766 65 void SetProcessDCS(Bool_t process) {fgkProcessDCS = process;}
eba76848 66 void SetLogbookEntry(AliShuttleLogbookEntry* entry) {fLogbookEntry=entry;}
57f50b3c 67
57f50b3c 68 Bool_t Connect(Int_t system);
69
d386d623 70 static void SetMainCDB (TString mainCDB) {fgkMainCDB = mainCDB;}
71 static void SetLocalCDB (TString localCDB) {fgkLocalCDB = localCDB;}
72
73 static void SetMainRefStorage (TString mainRefStorage) {fgkMainRefStorage = mainRefStorage;}
74 static void SetLocalRefStorage (TString localRefStorage) {fgkLocalRefStorage = localRefStorage;}
75
76 static void SetShuttleTempDir (const char* tmpDir);
77 static void SetShuttleLogDir (const char* logDir);
78
73abe331 79private:
57f50b3c 80 AliShuttle(const AliShuttle& other);
81 AliShuttle& operator= (const AliShuttle& other);
82
2bb7b766 83 UInt_t ProcessCurrentDetector();
84
eba76848 85 AliShuttleLogbookEntry* QueryRunParameters(Int_t run);
2bb7b766 86 Bool_t QueryShuttleLogbook(const char* whereClause, TObjArray& entries);
87 Bool_t RetrieveConditionsData(const TObjArray& shuttleLogbookEntries);
88
2c15234c 89 Bool_t GetValueSet(const char* host, Int_t port, const char* alias,
90 TObjArray* result, DCSType type);
57f50b3c 91
9d733021 92 Bool_t RetrieveFile(UInt_t system, const char* daqFileName, const char* localFileName);
93
94 Bool_t UpdateTable();
57f50b3c 95
85a80aa9 96 UInt_t WriteToCDB(const char* mainUri, const char* localUri,
97 const AliCDBPath& path, TObject* object, AliCDBMetaData* metaData,
98 Int_t validityStart = 0, Bool_t validityInfinite = kFALSE);
99
2bb7b766 100 Bool_t TryToStoreAgain();
101 Bool_t TryToStoreAgain(TString& storageType);
102
e7f62f16 103 AliShuttleStatus* ReadShuttleStatus();
104 Bool_t WriteShuttleStatus(AliShuttleStatus* status);
105 Bool_t ContinueProcessing();
106 void UpdateShuttleStatus(AliShuttleStatus::Status newStatus, Bool_t increaseCount = kFALSE);
107 Bool_t UpdateShuttleLogbook(const char* detector, const char* status=0);
57c1a579 108 Bool_t SendMail();
109
e7f62f16 110 void SetLastAction(const char* action);
111
112 void SendMLInfo();
b948db8d 113
441b0e9c 114 void SetRunType();
115
2bb7b766 116 const AliShuttleConfig* fConfig; // pointer to configuration object
73abe331 117
2bb7b766 118 UInt_t fTimeout; // DCS server connection timeout parameter
119 Int_t fRetries; // Number of DCS server connection retries
5164a766 120
2bb7b766 121 TMap fPreprocessorMap; // list of detector Preprocessors ("DET", "Preprocessor")
57f50b3c 122
2bb7b766 123 AliShuttleLogbookEntry* fLogbookEntry; //! current Shuttle logbook entry
124 TString fCurrentDetector; // current detector
57f50b3c 125
2c15234c 126 TSQLServer *fServer[4]; // pointer to the three FXS + Run & Shuttle logbook servers
127 Bool_t fFXSCalled[3]; // FXS call status
128 TList fFXSlist[3]; // List of files retrieved from each FXS
85a80aa9 129
2bb7b766 130 AliCDBEntry* fStatusEntry; // last CDB entry containing a AliShuttleStatus retrieved
131 Bool_t fGridError; // Grid storage error flag
be48e3ea 132
cb343cfd 133 TMutex* fMonitoringMutex; // mutex to lock the monitoring class members
134 UInt_t fLastActionTime; // time of last action for monitoring
135 TString fLastAction; // string description for last action
4f0ab988 136
be48e3ea 137 Bool_t fFirstUnprocessed[AliShuttleInterface::kNDetectors]; // array of flags for first unprocessed dets
138
e7f62f16 139 TMonaLisaWriter* fMonaLisa; // ML instance that sends the processing information
140
4f0ab988 141 //TODO Test only, remove later !
142 static Bool_t fgkProcessDCS; // flag to enable DCS archive data processing
b948db8d 143
73abe331 144 ClassDef(AliShuttle, 0);
145};
146
147#endif