Go to the documentation of this file.00001 #ifndef FUEVENTPROCESSOR_H
00002 #define FUEVENTPROCESSOR_H 1
00003
00004 #include "EventFilter/Utilities/interface/StateMachine.h"
00005 #include "EventFilter/Utilities/interface/RunBase.h"
00006 #include "EventFilter/Utilities/interface/Css.h"
00007 #include "EventFilter/Utilities/interface/Exception.h"
00008 #include "EventFilter/Utilities/interface/SquidNet.h"
00009 #include "EventFilter/Utilities/interface/Vulture.h"
00010
00011 #include "EventFilter/Utilities/interface/MasterQueue.h"
00012 #include "EventFilter/Utilities/interface/SlaveQueue.h"
00013 #include "EventFilter/Utilities/interface/ModuleWeb.h"
00014 #include "EventFilter/Utilities/interface/ModuleWebRegistry.h"
00015 #include "EventFilter/Modules/interface/ShmOutputModuleRegistry.h"
00016 #include "SubProcess.h"
00017 #include "FWEPWrapper.h"
00018
00019 #include "DataFormats/Provenance/interface/ModuleDescription.h"
00020
00021 #include "xdaq/Application.h"
00022 #include "xdaq/NamespaceURI.h"
00023
00024 #include "xdata/String.h"
00025 #include "xdata/Integer.h"
00026 #include "xdata/Boolean.h"
00027 #include "xdata/Vector.h"
00028 #include "xdata/UnsignedInteger32.h"
00029 #include "xdata/ActionListener.h"
00030 #include "xdata/InfoSpaceFactory.h"
00031
00032 #include "xgi/Input.h"
00033 #include "xgi/Output.h"
00034 #include "xgi/exception/Exception.h"
00035
00036 #include <sys/time.h>
00037 #include <pthread.h>
00038 #include <sys/resource.h>
00039 #include <signal.h>
00040
00041 #include <list>
00042 #include <vector>
00043 #include <map>
00044
00045 namespace evf
00046 {
00047
00048
00049 struct filter {
00050
00051 };
00052 class CPUStat;
00053 class RateStat;
00054 namespace internal{
00055
00056 class MyCgi : public xgi::Input{
00057 public:
00058 MyCgi() : xgi::Input("",0){}
00059
00060 std::map<std::string, std::string, std::less<std::string> > &getEnvironment(){return environment_;}
00061 };
00062 }
00063 class FUEventProcessor : public xdaq::Application,
00064 public xdata::ActionListener
00065 {
00066 public:
00067
00068
00069
00070 XDAQ_INSTANTIATOR();
00071 FUEventProcessor(xdaq::ApplicationStub *s);
00072 virtual ~FUEventProcessor();
00073
00074
00075
00076
00077
00078
00079
00080 bool configuring(toolbox::task::WorkLoop* wl);
00081 bool enabling(toolbox::task::WorkLoop* wl);
00082 bool stopping(toolbox::task::WorkLoop* wl);
00083 bool halting(toolbox::task::WorkLoop* wl);
00084
00085
00086 xoap::MessageReference fsmCallback(xoap::MessageReference msg)
00087 throw (xoap::exception::Exception);
00088
00089
00090 void actionPerformed(xdata::Event& e);
00091
00092
00093
00094
00095
00096
00097
00098 void defaultWebPage(xgi::Input *in,xgi::Output *out)
00099 throw(xgi::exception::Exception);
00100 void spotlightWebPage(xgi::Input *,xgi::Output *)
00101 throw(xgi::exception::Exception);
00102 void scalersWeb(xgi::Input *,xgi::Output *)
00103 throw(xgi::exception::Exception);
00104 void pathNames(xgi::Input *,xgi::Output *)
00105 throw(xgi::exception::Exception);
00106 void css(xgi::Input *in,xgi::Output *out) throw (xgi::exception::Exception)
00107 {
00108 css_.css(in,out);
00109 }
00110
00111 void getSlavePids(xgi::Input *in, xgi::Output *out);
00112 void subWeb(xgi::Input *in,xgi::Output *out);
00113 void moduleWeb(xgi::Input *in,xgi::Output *out){evtProcessor_.moduleWeb(in,out);}
00114 void serviceWeb(xgi::Input *in,xgi::Output *out){evtProcessor_.serviceWeb(in,out);}
00115 void microState(xgi::Input *in,xgi::Output *out);
00116 void updater(xgi::Input *in,xgi::Output *out);
00117 void procStat(xgi::Input *in,xgi::Output *out);
00118 void sendMessageOverMonitorQueue(MsgBuf &);
00119
00120 static void forkProcessFromEDM_helper(void * addr);
00121 void handleSignalSlave(int sig, siginfo_t* info, void* c);
00122
00123 private:
00124
00125
00126 void forkProcessesFromEDM();
00127
00128 bool enableForkInEDM();
00129 bool restartForkInEDM(unsigned int slotId);
00130 bool doEndRunInEDM();
00131
00132 void setAttachDqmToShm() throw (evf::Exception);
00133 void attachDqmToShm() throw (evf::Exception);
00134 void detachDqmFromShm() throw (evf::Exception);
00135
00136 std::string logsAsString();
00137 void localLog(std::string);
00138
00139
00140 void startSupervisorLoop();
00141 void startReceivingLoop();
00142 void startReceivingMonitorLoop();
00143
00144 void startScalersWorkLoop() throw (evf::Exception);
00145 bool scalers(toolbox::task::WorkLoop* wl);
00146 void startSummarizeWorkLoop() throw (evf::Exception);
00147 bool summarize(toolbox::task::WorkLoop* wl);
00148
00149 bool receiving(toolbox::task::WorkLoop* wl);
00150 bool receivingAndMonitor(toolbox::task::WorkLoop* wl);
00151 bool supervisor(toolbox::task::WorkLoop* wl);
00152 void startSignalMonitorWorkLoop() throw (evf::Exception);
00153 bool sigmon(toolbox::task::WorkLoop* wl);
00154
00155 bool enableCommon();
00156 bool enableClassic();
00157
00158 bool enableMPEPSlave();
00159 bool stopClassic();
00160 void stopSlavesAndAcknowledge();
00161 void makeStaticInfo();
00162
00163
00164
00165
00166
00167
00168 evf::StateMachine fsm_;
00169
00170
00171 Logger log_;
00172
00173
00174 FWEPWrapper evtProcessor_;
00175
00176
00177 xdata::String url_;
00178 xdata::String class_;
00179 xdata::UnsignedInteger32 instance_;
00180 xdata::UnsignedInteger32 runNumber_;
00181 xdata::Boolean epInitialized_;
00182 xdata::String configString_;
00183 std::string configuration_;
00184
00185 xdata::Boolean outPut_;
00186
00187 xdata::Boolean autoRestartSlaves_;
00188 xdata::UnsignedInteger32 slaveRestartDelaySecs_;
00189
00190 xdata::Boolean hasShMem_;
00191 xdata::Boolean hasPrescaleService_;
00192 xdata::Boolean hasModuleWebRegistry_;
00193 xdata::Boolean hasServiceWebRegistry_;
00194 xdata::Boolean isRunNumberSetter_;
00195 xdata::Boolean iDieStatisticsGathering_;
00196 bool outprev_;
00197
00198
00199 std::string sourceId_;
00200
00201
00202 xdata::Boolean squidPresent_;
00203
00204
00205
00206 xdata::Boolean exitOnError_;
00207
00208
00209 Css css_;
00210
00211
00212 std::string reasonForFailedState_;
00213
00214 SquidNet squidnet_;
00215 std::vector<std::string> logRing_;
00216 unsigned int logRingIndex_;
00217 static const unsigned int logRingSize_ = 50;
00218 bool logWrap_;
00219
00220 xdata::UnsignedInteger32 nbSubProcesses_;
00221 xdata::UnsignedInteger32 nbSubProcessesReporting_;
00222 xdata::UnsignedInteger32 forkInEDM_;
00223 std::vector<SubProcess> subs_;
00224 unsigned int nblive_;
00225 unsigned int nbdead_;
00226
00227 unsigned int nbTotalDQM_;
00228
00229
00230 toolbox::task::WorkLoop *wlReceiving_;
00231 toolbox::task::ActionSignature *asReceiveMsgAndExecute_;
00232 bool receiving_;
00233 toolbox::task::WorkLoop *wlReceivingMonitor_;
00234 toolbox::task::ActionSignature *asReceiveMsgAndRead_;
00235 bool receivingM_;
00236 SubProcess* myProcess_;
00237 toolbox::task::WorkLoop *wlSupervising_;
00238 toolbox::task::ActionSignature *asSupervisor_;
00239 bool supervising_;
00240 toolbox::task::WorkLoop *wlSignalMonitor_;
00241 toolbox::task::ActionSignature *asSignalMonitor_;
00242 bool signalMonitorActive_;
00243
00244
00245 xdata::InfoSpace* monitorInfoSpace_;
00246 xdata::InfoSpace* monitorLegendaInfoSpace_;
00247 xdata::InfoSpace* applicationInfoSpace_;
00248 pthread_mutex_t stop_lock_;
00249 pthread_mutex_t start_lock_;
00250 pthread_mutex_t pickup_lock_;
00251 std::string updaterStatic_;
00252 xdata::Serializable *nbProcessed;
00253 xdata::Serializable *nbAccepted;
00254
00255
00256 xdata::InfoSpace *scalersInfoSpace_;
00257 xdata::InfoSpace *scalersLegendaInfoSpace_;
00258
00259
00260 toolbox::task::WorkLoop *wlScalers_;
00261 toolbox::task::ActionSignature *asScalers_;
00262 bool wlScalersActive_;
00263 unsigned int scalersUpdates_;
00264
00265
00266 toolbox::task::WorkLoop *wlSummarize_;
00267 toolbox::task::ActionSignature *asSummarize_;
00268 bool wlSummarizeActive_;
00269 int anonymousPipe_[2];
00270 xdata::Vector<xdata::Integer> spMStates_;
00271 xdata::Vector<xdata::Integer> spmStates_;
00272 xdata::UnsignedInteger32 superSleepSec_;
00273 std::list<std::string> names_;
00274 xdata::String iDieUrl_;
00275 Vulture *vulture_;
00276 pid_t vp_;
00277 CPUStat *cpustat_;
00278 RateStat *ratestat_;
00279
00280 ModuleWebRegistry *mwrRef_;
00281 ShmOutputModuleRegistry *sorRef_;
00282 MsgBuf master_message_prg_;
00283 MsgBuf master_message_prr_;
00284 MsgBuf slave_message_prr_;
00285 MsgBuf slave_message_monitoring_;
00286 MsgBuf master_message_trr_;
00287
00288 moduleweb::ForkInfoObj *forkInfoObj_;
00289 pthread_mutex_t forkObjLock_;
00290 bool edm_init_done_;
00291
00292 unsigned int crashesThisRun_;
00293 bool rlimit_coresize_changed_;
00294 rlimit rlimit_coresize_default_;
00295 xdata::UnsignedInteger32 crashesToDump_;
00296 sem_t *sigmon_sem_;
00297 timeval lastCrashTime_;
00298
00299 unsigned long long idleProcStats_;
00300 unsigned long long allProcStats_;
00301 };
00302
00303
00304 }
00305
00306
00307 #endif