1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.14 2007/12/07 19:14:36 acolla
21 Added automatic collection of new runs on a regular time basis (settable from the configuration)
23 in AliShuttleConfig: new members
25 - triggerWait: time to wait for DIM trigger (s) before starting automatic collection of new runs
26 - mode: run mode (test, prod) -> used to build log folder (logs or logs_PROD)
30 - logs now stored in logs/#RUN/DET_#RUN.log
32 Revision 1.13 2006/11/16 16:16:48 jgrosseo
33 introducing strict run ordering flag
34 removed giving preprocessor name to preprocessor, they have to know their name themselves ;-)
36 Revision 1.12 2006/10/20 15:22:59 jgrosseo
37 o) Adding time out to the execution of the preprocessors: The Shuttle forks and the parent process monitors the child
38 o) Merging Collect, CollectAll, CollectNew function
39 o) Removing implementation of empty copy constructors (declaration still there!)
41 Revision 1.11 2006/10/02 16:38:39 jgrosseo
44 storing of objects that failed to be stored to the grid before
45 interfacing of shuttle status table in daq system
47 Revision 1.10 2006/08/15 10:50:00 jgrosseo
48 effc++ corrections (alberto)
50 Revision 1.9 2006/08/08 14:19:29 jgrosseo
51 Update to shuttle classes (Alberto)
53 - Possibility to set the full object's path in the Preprocessor's and
54 Shuttle's Store functions
55 - Possibility to extend the object's run validity in the same classes
56 ("startValidity" and "validityInfinite" parameters)
57 - Implementation of the StoreReferenceData function to store reference
58 data in a dedicated CDB storage.
60 Revision 1.8 2006/07/21 07:37:20 jgrosseo
61 last run is stored after each run
63 Revision 1.7 2006/07/20 09:54:40 jgrosseo
64 introducing status management: The processing per subdetector is divided into several steps,
65 after each step the status is stored on disk. If the system crashes in any of the steps the Shuttle
66 can keep track of the number of failures and skips further processing after a certain threshold is
67 exceeded. These thresholds can be configured in LDAP.
69 Revision 1.6 2006/07/19 10:09:55 jgrosseo
70 new configuration, accesst to DAQ FES (Alberto)
72 Revision 1.5 2006/07/10 13:01:41 jgrosseo
73 enhanced storing of last sucessfully processed run (alberto)
75 Revision 1.4 2006/07/04 14:59:57 jgrosseo
76 revision of AliDCSValue: Removed wrapper classes, reduced storage size per value by factor 2
78 Revision 1.3 2006/06/12 09:11:16 jgrosseo
79 coding conventions (Alberto)
81 Revision 1.2 2006/06/06 14:26:40 jgrosseo
82 o) removed files that were moved to STEER
83 o) shuttle updated to follow the new interface (Alberto)
85 Revision 1.1 2006/03/07 07:52:34 hristov
86 New version (B.Yordanov)
88 Revision 1.5 2005/11/21 09:03:48 byordano
91 Revision 1.4 2005/11/20 10:12:37 byordano
92 comments added to AliShuttleTrigger
98 // This class is to deal with DAQ LogBook and DAQ "end of run" notification.
99 // It has severeal two modes:
100 // 1) synchronized - Collect()
101 // 2) asynchronized - Run() - starts listening for DAQ "end of run"
102 // notification by DIM service.
105 #include "AliShuttleTrigger.h"
110 #include "AliShuttleConfig.h"
111 #include "AliShuttle.h"
112 #include "DATENotifier.h"
114 ClassImp(TerminateSignalHandler)
115 ClassImp(AliShuttleTrigger)
117 //______________________________________________________________________________________________
118 Bool_t TerminateSignalHandler::Notify()
120 // Sentd terminate command to the Shuttle trigger
122 AliInfo("Terminate signal received ...");
123 fTrigger->Terminate();
128 //______________________________________________________________________________________________
129 AliShuttleTrigger::AliShuttleTrigger(const AliShuttleConfig* config,
130 UInt_t timeout, Int_t retries):
131 fConfig(config), fShuttle(NULL),
132 fNotified(kFALSE), fTerminate(kFALSE),
133 fMutex(), fCondition(&fMutex),
134 fQuitSignalHandler(0),
135 fInterruptSignalHandler(0)
138 // config - pointer to the AliShuttleConfig object which represents
140 // mainStorage - pointer to AliCDBStorage for the undelying CDBStorage
141 // localStorage (local) CDB storage to be used if mainStorage is unavailable
144 if (!fConfig->IsValid()) AliFatal("********** !!!!! Invalid configuration !!!!! **********");
145 fShuttle = new AliShuttle(config, timeout, retries);
147 TerminateSignalHandler* fQuitSignalHandler = new TerminateSignalHandler(this, kSigQuit);
148 TerminateSignalHandler* fInterruptSignalHandler = new TerminateSignalHandler(this, kSigInterrupt);
150 gSystem->AddSignalHandler(fQuitSignalHandler);
151 gSystem->AddSignalHandler(fInterruptSignalHandler);
155 //______________________________________________________________________________________________
156 AliShuttleTrigger::~AliShuttleTrigger()
160 gSystem->RemoveSignalHandler(fQuitSignalHandler);
161 gSystem->RemoveSignalHandler(fInterruptSignalHandler);
165 delete fQuitSignalHandler;
166 fQuitSignalHandler = 0;
168 delete fInterruptSignalHandler;
169 fInterruptSignalHandler = 0;
172 //______________________________________________________________________________________________
173 Bool_t AliShuttleTrigger::Notify() {
175 // Trigger Collect() methods in asynchronized (listen) mode.
176 // Usually called automaticly by DATENotifier on "end of run"
177 // notification event.
190 //______________________________________________________________________________________________
191 void AliShuttleTrigger::Terminate() {
193 // Stop triggers listen mode and exist from Run()
194 // Usually called automaticly by TerminateSignalHandler.
201 //______________________________________________________________________________________________
202 void AliShuttleTrigger::Run() {
204 // AliShuttleTrigger main loop for asynchronized (listen) mode.
205 // It spawns DIM service listener and waits for DAQ "end of run"
206 // notification. Calls Collect() on notification.
211 DATENotifier* notifier = new DATENotifier(this, "/DATE/LOGBOOK/UPDATE");
214 Int_t nMaxTry = fConfig->GetMaxRetries()+1;
217 AliInfo("Listening for ECS trigger");
223 while (!(fNotified || fTerminate)) {
224 received=fCondition.TimedWaitRelative(1000*fConfig->GetTriggerWait());
225 if (received==1) break; // 1 = timeout
233 AliInfo("Terminated.");
239 AliInfo("Trigger from ECS received!");
240 } else if (received == 1) {
241 AliInfo(Form("Timeout (%d s) waiting for trigger. "
242 "Starting collection of new runs!",
243 fConfig->GetTriggerWait()));
245 AliInfo("Error receiving trigger from ECS!");
249 if (fConfig->GetRunMode() == AliShuttleConfig::kTest)
252 AliInfo(Form("Received %d triggers so far", nTry));
255 AliInfo(Form("Collect() ran more than %d times -> Exiting!",
267 //______________________________________________________________________________________________
268 Bool_t AliShuttleTrigger::Collect(Int_t run)
271 // this function creates a thread that runs the shuttle
272 // then it checks if the shuttle is still running by checking the monitoring functions of the shuttle
275 return fShuttle->Collect(run);