CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/EventFilter/StorageManager/src/Starting.cc

Go to the documentation of this file.
00001 // $Id: Starting.cc,v 1.12 2011/11/08 10:48:41 mommsen Exp $
00003 
00004 #include "EventFilter/StorageManager/interface/AlarmHandler.h"
00005 #include "EventFilter/StorageManager/interface/CommandQueue.h"
00006 #include "EventFilter/StorageManager/interface/Configuration.h"
00007 #include "EventFilter/StorageManager/interface/DiskWriterResources.h"
00008 #include "EventFilter/StorageManager/interface/DQMEventProcessorResources.h"
00009 #include "EventFilter/StorageManager/interface/ErrorStreamConfigurationInfo.h"
00010 #include "EventFilter/StorageManager/interface/EventStreamConfigurationInfo.h"
00011 #include "EventFilter/StorageManager/interface/SharedResources.h"
00012 #include "EventFilter/StorageManager/interface/StateMachine.h"
00013 #include "EventFilter/StorageManager/interface/TransitionRecord.h"
00014 
00015 #include <iostream>
00016 #include <unistd.h>
00017 
00018 using namespace std;
00019 using namespace stor;
00020 
00021 Starting::Starting( my_context c ): my_base(c)
00022 {
00023   safeEntryAction();
00024 }
00025 
00026 void Starting::do_entryActionWork()
00027 {
00028   TransitionRecord tr( stateName(), true );
00029   outermost_context().updateHistory( tr );
00030 
00031   SharedResourcesPtr sharedResources =
00032     outermost_context().getSharedResources();
00033 
00034   // Request DiskWriter to configure streams
00035   EvtStrConfigListPtr evtCfgList = sharedResources->configuration_->
00036     getCurrentEventStreamConfig();
00037   ErrStrConfigListPtr errCfgList = sharedResources->configuration_->
00038     getCurrentErrorStreamConfig();
00039 
00040   WorkerThreadParams workerParams =
00041     sharedResources->configuration_->getWorkerThreadParams();
00042   sharedResources->diskWriterResources_->
00043     requestStreamConfiguration(evtCfgList, errCfgList,
00044       sharedResources->configuration_->getDiskWritingParams(),
00045       sharedResources->configuration_->getRunNumber(),
00046       workerParams.DWdeqWaitTime_);
00047 
00048   // Request configuration of DQMEventProcessor
00049   sharedResources->dqmEventProcessorResources_->
00050     requestConfiguration(
00051       sharedResources->configuration_->getDQMProcessingParams(),
00052       workerParams.DQMEPdeqWaitTime_);
00053 }
00054 
00055 Starting::~Starting()
00056 {
00057   safeExitAction();
00058 }
00059 
00060 void Starting::do_exitActionWork()
00061 {
00062   TransitionRecord tr( stateName(), false );
00063   outermost_context().updateHistory( tr );
00064 }
00065 
00066 string Starting::do_stateName() const
00067 {
00068   return std::string( "Starting" );
00069 }
00070 
00071 void Starting::do_moveToFailedState( xcept::Exception& exception ) const
00072 {
00073   outermost_context().getSharedResources()->alarmHandler_->moveToFailedState( exception );
00074 }
00075 
00076 void Starting::logStopDoneRequest( const StopDone& request )
00077 {
00078   outermost_context().unconsumed_event( request );
00079 }
00080 
00081 void Starting::logHaltDoneRequest( const HaltDone& request )
00082 {
00083   outermost_context().unconsumed_event( request );
00084 }
00085 
00086 void
00087 Starting::do_noFragmentToProcess() const
00088 {
00089   if ( workerThreadsConfigured() )
00090   {
00091     SharedResourcesPtr sharedResources =
00092       outermost_context().getSharedResources();
00093     EventPtr_t stMachEvent( new StartRun() );
00094     sharedResources->commandQueue_->enqWait( stMachEvent );
00095   }
00096 }
00097 
00098 bool
00099 Starting::workerThreadsConfigured() const
00100 {
00101   SharedResourcesPtr sharedResources =
00102     outermost_context().getSharedResources();
00103 
00104   // check if the requests are still being processed
00105   if ( sharedResources->diskWriterResources_->streamChangeOngoing() ) return false;
00106 
00107   if ( sharedResources->dqmEventProcessorResources_->requestsOngoing() ) return false;
00108 
00109   return true; 
00110 }
00111 
00112