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