AliFatal added in SetAlignable
[u/mrichter/AliRoot.git] / SHUTTLE / AliShuttleTrigger.cxx
CommitLineData
d477ad88 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/*
17 $Log$
2bb7b766 18 Revision 1.10 2006/08/15 10:50:00 jgrosseo
19 effc++ corrections (alberto)
20
4f0ab988 21 Revision 1.9 2006/08/08 14:19:29 jgrosseo
22 Update to shuttle classes (Alberto)
23
24 - Possibility to set the full object's path in the Preprocessor's and
25 Shuttle's Store functions
26 - Possibility to extend the object's run validity in the same classes
27 ("startValidity" and "validityInfinite" parameters)
28 - Implementation of the StoreReferenceData function to store reference
29 data in a dedicated CDB storage.
30
84090f85 31 Revision 1.8 2006/07/21 07:37:20 jgrosseo
32 last run is stored after each run
33
7bfb2090 34 Revision 1.7 2006/07/20 09:54:40 jgrosseo
35 introducing status management: The processing per subdetector is divided into several steps,
36 after each step the status is stored on disk. If the system crashes in any of the steps the Shuttle
37 can keep track of the number of failures and skips further processing after a certain threshold is
38 exceeded. These thresholds can be configured in LDAP.
39
5164a766 40 Revision 1.6 2006/07/19 10:09:55 jgrosseo
41 new configuration, accesst to DAQ FES (Alberto)
42
57f50b3c 43 Revision 1.5 2006/07/10 13:01:41 jgrosseo
44 enhanced storing of last sucessfully processed run (alberto)
45
a7160fe9 46 Revision 1.4 2006/07/04 14:59:57 jgrosseo
47 revision of AliDCSValue: Removed wrapper classes, reduced storage size per value by factor 2
48
45a493ce 49 Revision 1.3 2006/06/12 09:11:16 jgrosseo
50 coding conventions (Alberto)
51
58bc3020 52 Revision 1.2 2006/06/06 14:26:40 jgrosseo
53 o) removed files that were moved to STEER
54 o) shuttle updated to follow the new interface (Alberto)
55
b948db8d 56 Revision 1.1 2006/03/07 07:52:34 hristov
57 New version (B.Yordanov)
58
d477ad88 59 Revision 1.5 2005/11/21 09:03:48 byordano
60 one more print added
61
62 Revision 1.4 2005/11/20 10:12:37 byordano
63 comments added to AliShuttleTrigger
64
65 */
66
67
68//
69// This class is to deal with DAQ LogBook and DAQ "end of run" notification.
70// It has severeal two modes:
71// 1) syncrhnized - Collect(), CollectNew() and CollectAll methods
b948db8d 72// 2) asynchronized - Run() - starts listening for DAQ "end of run"
d477ad88 73// notification by DIM service.
74//
75
76#include "AliShuttleTrigger.h"
77
d477ad88 78#include <TSystem.h>
d477ad88 79#include "AliLog.h"
d477ad88 80#include "AliShuttleConfig.h"
81#include "AliShuttle.h"
82#include "DATENotifier.h"
83
84ClassImp(TerminateSignalHandler)
b948db8d 85
58bc3020 86//______________________________________________________________________
87TerminateSignalHandler::TerminateSignalHandler(const TerminateSignalHandler& /*other*/):
4f0ab988 88TSignalHandler(), fTrigger()
58bc3020 89{
90// copy constructor (not implemented)
91
92}
93
94//______________________________________________________________________
95TerminateSignalHandler &TerminateSignalHandler::operator=(const TerminateSignalHandler& /*other*/)
96{
97// assignment operator (not implemented)
98
99return *this;
100}
101
b948db8d 102//______________________________________________________________________________________________
58bc3020 103Bool_t TerminateSignalHandler::Notify()
104{
105// Sentd terminate command to the Shuttle trigger
d477ad88 106
107 AliInfo("Terminate signal received ...");
108 fTrigger->Terminate();
109
110 return kTRUE;
111}
112
58bc3020 113//______________________________________________________________________________________________
114//______________________________________________________________________________________________
115
d477ad88 116ClassImp(AliShuttleTrigger)
b948db8d 117
118//______________________________________________________________________________________________
d477ad88 119AliShuttleTrigger::AliShuttleTrigger(const AliShuttleConfig* config,
b948db8d 120 UInt_t timeout, Int_t retries):
121 fConfig(config), fShuttle(NULL),
2bb7b766 122 fNotified(kFALSE), fTerminate(kFALSE),
4f0ab988 123 fMutex(), fCondition(&fMutex),
124 fQuitSignalHandler(this, kSigQuit),
d477ad88 125 fInterruptSignalHandler(this, kSigInterrupt)
126{
127 //
128 // config - pointer to the AliShuttleConfig object which represents
129 // the configuration
b948db8d 130 // mainStorage - pointer to AliCDBStorage for the undelying CDBStorage
131 // localStorage (local) CDB storage to be used if mainStorage is unavailable
d477ad88 132 //
133
b948db8d 134 fShuttle = new AliShuttle(config, timeout, retries);
d477ad88 135
136 gSystem->AddSignalHandler(&fQuitSignalHandler);
137 gSystem->AddSignalHandler(&fInterruptSignalHandler);
2bb7b766 138
d477ad88 139}
140
58bc3020 141
142
143//______________________________________________________________________
144AliShuttleTrigger::AliShuttleTrigger(const AliShuttleTrigger& /*other*/):
4f0ab988 145 TObject(), fConfig(), fShuttle(NULL),
2bb7b766 146 fNotified(kFALSE), fTerminate(kFALSE),
4f0ab988 147 fMutex(), fCondition(&fMutex),
148 fQuitSignalHandler(this, kSigQuit),
149 fInterruptSignalHandler(this, kSigInterrupt)
150
58bc3020 151{
152// copy constructor (not implemented)
153
154}
155
156//______________________________________________________________________
157AliShuttleTrigger &AliShuttleTrigger::operator=(const AliShuttleTrigger& /*other*/)
158{
159// assignment operator (not implemented)
160
161return *this;
162}
163
164
165
166
167
b948db8d 168//______________________________________________________________________________________________
58bc3020 169AliShuttleTrigger::~AliShuttleTrigger()
170{
171// destructor
d477ad88 172
173 gSystem->RemoveSignalHandler(&fQuitSignalHandler);
174 gSystem->RemoveSignalHandler(&fInterruptSignalHandler);
175
176 delete fShuttle;
177}
178
b948db8d 179//______________________________________________________________________________________________
d477ad88 180Bool_t AliShuttleTrigger::Notify() {
181 //
182 // Trigger CollectNew() methods in asynchronized (listen) mode.
183 // Usually called automaticly by DATENotifier on "end of run"
184 // notification event.
185 //
186
187 fMutex.Lock();
188
189 fNotified = kTRUE;
190 fCondition.Signal();
191
192 fMutex.UnLock();
193
194 return kTRUE;
195}
196
b948db8d 197//______________________________________________________________________________________________
d477ad88 198void AliShuttleTrigger::Terminate() {
199 //
200 // Stop triggers listen mode and exist from Run()
201 // Usually called automaticly by TerminateSignalHandler.
202 //
203
204 fTerminate = kTRUE;
205 fCondition.Signal();
206}
207
b948db8d 208//______________________________________________________________________________________________
d477ad88 209void AliShuttleTrigger::Run() {
210 //
211 // AliShuttleTrigger main loop for asynchronized (listen) mode.
212 // It spawns DIM service listener and waits for DAQ "end of run"
213 // notification. Calls CollectNew() on notification.
214 //
215
216 fTerminate = kFALSE;
217
218 DATENotifier* notifier = new DATENotifier(this, "/DATE/LOGBOOK/UPDATE");
219
220 while (1) {
221
222 fMutex.Lock();
223
224 while (!(fNotified || fTerminate)) {
225 fCondition.Wait();
226 }
227
228 fNotified = kFALSE;
229
230 fMutex.UnLock();
231
232 if (fTerminate) {
233 AliInfo("Terminated.");
234 break;
235 }
236
237 CollectNew();
238 }
239
240 delete notifier;
241}
242
b948db8d 243//______________________________________________________________________________________________
a7160fe9 244Bool_t AliShuttleTrigger::Collect(Int_t run)
58bc3020 245{
d477ad88 246 //
2bb7b766 247 // Collects conditions data for the given run.
d477ad88 248 //
249
2bb7b766 250 return fShuttle->Collect(run);
d477ad88 251}
252
b948db8d 253//______________________________________________________________________________________________
7bfb2090 254Bool_t AliShuttleTrigger::CollectNew()
58bc3020 255{
d477ad88 256 //
2bb7b766 257 // Collects conditions data for all UNPROCESSED run written to DAQ LogBook.
d477ad88 258 //
259
2bb7b766 260 return fShuttle->CollectNew();
d477ad88 261}
262
b948db8d 263//______________________________________________________________________________________________
7bfb2090 264Bool_t AliShuttleTrigger::CollectAll()
58bc3020 265{
d477ad88 266 //
2bb7b766 267 // Collects conditions data for all runs (even if they're already done!) written in Shuttle LogBook.
d477ad88 268 //
269
2bb7b766 270 return fShuttle->CollectAll();
d477ad88 271}
272