]> git.uio.no Git - u/mrichter/AliRoot.git/blame - SHUTTLE/AliShuttleTrigger.cxx
Dealing with two different loaders for simulation and reconstruction if necessary...
[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$
be48e3ea 18 Revision 1.12 2006/10/20 15:22:59 jgrosseo
19 o) Adding time out to the execution of the preprocessors: The Shuttle forks and the parent process monitors the child
20 o) Merging Collect, CollectAll, CollectNew function
21 o) Removing implementation of empty copy constructors (declaration still there!)
22
cb343cfd 23 Revision 1.11 2006/10/02 16:38:39 jgrosseo
24 update (alberto):
25 fixed memory leaks
26 storing of objects that failed to be stored to the grid before
27 interfacing of shuttle status table in daq system
28
2bb7b766 29 Revision 1.10 2006/08/15 10:50:00 jgrosseo
30 effc++ corrections (alberto)
31
4f0ab988 32 Revision 1.9 2006/08/08 14:19:29 jgrosseo
33 Update to shuttle classes (Alberto)
34
35 - Possibility to set the full object's path in the Preprocessor's and
36 Shuttle's Store functions
37 - Possibility to extend the object's run validity in the same classes
38 ("startValidity" and "validityInfinite" parameters)
39 - Implementation of the StoreReferenceData function to store reference
40 data in a dedicated CDB storage.
41
84090f85 42 Revision 1.8 2006/07/21 07:37:20 jgrosseo
43 last run is stored after each run
44
7bfb2090 45 Revision 1.7 2006/07/20 09:54:40 jgrosseo
46 introducing status management: The processing per subdetector is divided into several steps,
47 after each step the status is stored on disk. If the system crashes in any of the steps the Shuttle
48 can keep track of the number of failures and skips further processing after a certain threshold is
49 exceeded. These thresholds can be configured in LDAP.
50
5164a766 51 Revision 1.6 2006/07/19 10:09:55 jgrosseo
52 new configuration, accesst to DAQ FES (Alberto)
53
57f50b3c 54 Revision 1.5 2006/07/10 13:01:41 jgrosseo
55 enhanced storing of last sucessfully processed run (alberto)
56
a7160fe9 57 Revision 1.4 2006/07/04 14:59:57 jgrosseo
58 revision of AliDCSValue: Removed wrapper classes, reduced storage size per value by factor 2
59
45a493ce 60 Revision 1.3 2006/06/12 09:11:16 jgrosseo
61 coding conventions (Alberto)
62
58bc3020 63 Revision 1.2 2006/06/06 14:26:40 jgrosseo
64 o) removed files that were moved to STEER
65 o) shuttle updated to follow the new interface (Alberto)
66
b948db8d 67 Revision 1.1 2006/03/07 07:52:34 hristov
68 New version (B.Yordanov)
69
d477ad88 70 Revision 1.5 2005/11/21 09:03:48 byordano
71 one more print added
72
73 Revision 1.4 2005/11/20 10:12:37 byordano
74 comments added to AliShuttleTrigger
75
76 */
77
78
79//
80// This class is to deal with DAQ LogBook and DAQ "end of run" notification.
81// It has severeal two modes:
cb343cfd 82// 1) synchronized - Collect()
b948db8d 83// 2) asynchronized - Run() - starts listening for DAQ "end of run"
d477ad88 84// notification by DIM service.
85//
86
87#include "AliShuttleTrigger.h"
88
d477ad88 89#include <TSystem.h>
cb343cfd 90
d477ad88 91#include "AliLog.h"
d477ad88 92#include "AliShuttleConfig.h"
93#include "AliShuttle.h"
94#include "DATENotifier.h"
95
96ClassImp(TerminateSignalHandler)
cb343cfd 97ClassImp(AliShuttleTrigger)
58bc3020 98
b948db8d 99//______________________________________________________________________________________________
cb343cfd 100Bool_t TerminateSignalHandler::Notify()
58bc3020 101{
102// Sentd terminate command to the Shuttle trigger
d477ad88 103
104 AliInfo("Terminate signal received ...");
105 fTrigger->Terminate();
106
107 return kTRUE;
108}
109
b948db8d 110//______________________________________________________________________________________________
d477ad88 111AliShuttleTrigger::AliShuttleTrigger(const AliShuttleConfig* config,
b948db8d 112 UInt_t timeout, Int_t retries):
113 fConfig(config), fShuttle(NULL),
2bb7b766 114 fNotified(kFALSE), fTerminate(kFALSE),
4f0ab988 115 fMutex(), fCondition(&fMutex),
cb343cfd 116 fQuitSignalHandler(0),
117 fInterruptSignalHandler(0)
d477ad88 118{
119 //
120 // config - pointer to the AliShuttleConfig object which represents
121 // the configuration
b948db8d 122 // mainStorage - pointer to AliCDBStorage for the undelying CDBStorage
123 // localStorage (local) CDB storage to be used if mainStorage is unavailable
d477ad88 124 //
125
b948db8d 126 fShuttle = new AliShuttle(config, timeout, retries);
d477ad88 127
be48e3ea 128 TerminateSignalHandler* fQuitSignalHandler = new TerminateSignalHandler(this, kSigQuit);
129 TerminateSignalHandler* fInterruptSignalHandler = new TerminateSignalHandler(this, kSigInterrupt);
58bc3020 130
cb343cfd 131 gSystem->AddSignalHandler(fQuitSignalHandler);
132 gSystem->AddSignalHandler(fInterruptSignalHandler);
58bc3020 133
134}
135
b948db8d 136//______________________________________________________________________________________________
58bc3020 137AliShuttleTrigger::~AliShuttleTrigger()
138{
cb343cfd 139 // destructor
d477ad88 140
cb343cfd 141 gSystem->RemoveSignalHandler(fQuitSignalHandler);
142 gSystem->RemoveSignalHandler(fInterruptSignalHandler);
d477ad88 143
144 delete fShuttle;
cb343cfd 145
146 delete fQuitSignalHandler;
147 fQuitSignalHandler = 0;
148
149 delete fInterruptSignalHandler;
150 fInterruptSignalHandler = 0;
d477ad88 151}
152
b948db8d 153//______________________________________________________________________________________________
d477ad88 154Bool_t AliShuttleTrigger::Notify() {
155 //
cb343cfd 156 // Trigger Collect() methods in asynchronized (listen) mode.
d477ad88 157 // Usually called automaticly by DATENotifier on "end of run"
158 // notification event.
159 //
160
161 fMutex.Lock();
162
163 fNotified = kTRUE;
164 fCondition.Signal();
165
166 fMutex.UnLock();
167
168 return kTRUE;
169}
170
b948db8d 171//______________________________________________________________________________________________
d477ad88 172void AliShuttleTrigger::Terminate() {
173 //
174 // Stop triggers listen mode and exist from Run()
175 // Usually called automaticly by TerminateSignalHandler.
176 //
177
178 fTerminate = kTRUE;
179 fCondition.Signal();
180}
181
b948db8d 182//______________________________________________________________________________________________
d477ad88 183void AliShuttleTrigger::Run() {
184 //
185 // AliShuttleTrigger main loop for asynchronized (listen) mode.
186 // It spawns DIM service listener and waits for DAQ "end of run"
cb343cfd 187 // notification. Calls Collect() on notification.
d477ad88 188 //
189
190 fTerminate = kFALSE;
191
192 DATENotifier* notifier = new DATENotifier(this, "/DATE/LOGBOOK/UPDATE");
193
194 while (1) {
195
196 fMutex.Lock();
197
198 while (!(fNotified || fTerminate)) {
199 fCondition.Wait();
200 }
201
202 fNotified = kFALSE;
203
204 fMutex.UnLock();
205
206 if (fTerminate) {
207 AliInfo("Terminated.");
208 break;
209 }
210
cb343cfd 211 Collect();
d477ad88 212 }
213
214 delete notifier;
215}
216
b948db8d 217//______________________________________________________________________________________________
a7160fe9 218Bool_t AliShuttleTrigger::Collect(Int_t run)
58bc3020 219{
d477ad88 220 //
cb343cfd 221 // this function creates a thread that runs the shuttle
222 // then it checks if the shuttle is still running by checking the monitoring functions of the shuttle
d477ad88 223 //
224
cb343cfd 225 return fShuttle->Collect(run);
d477ad88 226}