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