CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/EventFilter/StorageManager/src/Stopping.cc

Go to the documentation of this file.
00001 // $Id: Stopping.cc,v 1.10 2011/03/07 15:31:32 mommsen Exp $
00003 
00004 #include "EventFilter/StorageManager/interface/CommandQueue.h"
00005 #include "EventFilter/StorageManager/interface/DiskWriterResources.h"
00006 #include "EventFilter/StorageManager/interface/DQMEventProcessorResources.h"
00007 #include "EventFilter/StorageManager/interface/SharedResources.h"
00008 #include "EventFilter/StorageManager/interface/StateMachine.h"
00009 #include "EventFilter/StorageManager/interface/TransitionRecord.h"
00010 
00011 #include <iostream>
00012 #include <unistd.h>
00013 
00014 using namespace std;
00015 using namespace stor;
00016 
00017 Stopping::Stopping( my_context c ): my_base(c)
00018 {
00019   safeEntryAction();
00020 }
00021 
00022 void Stopping::do_entryActionWork()
00023 {
00024 
00025   TransitionRecord tr( stateName(), true );
00026   outermost_context().updateHistory( tr );
00027 
00028   SharedResourcesPtr sharedResources =
00029     outermost_context().getSharedResources();
00030 
00031   // request that the streams that are currently configured in the disk
00032   // writer be destroyed (this has the side effect of closing files)
00033   sharedResources->diskWriterResources_->requestStreamDestruction();
00034 
00035   // request that the DQM event store is cleared
00036   // if FinishingDQM has succeeded, the store is already empty
00037   sharedResources->dqmEventProcessorResources_->requestStoreDestruction();
00038 }
00039 
00040 Stopping::~Stopping()
00041 {
00042   safeExitAction();
00043 }
00044 
00045 void Stopping::do_exitActionWork()
00046 {
00047   TransitionRecord tr( stateName(), false );
00048   outermost_context().updateHistory( tr );
00049 }
00050 
00051 string Stopping::do_stateName() const
00052 {
00053   return std::string( "Stopping" );
00054 }
00055 
00056 void Stopping::do_moveToFailedState( xcept::Exception& exception ) const
00057 {
00058   outermost_context().getSharedResources()->moveToFailedState( exception );
00059 }
00060 
00061 void Stopping::logHaltDoneRequest( const HaltDone& request )
00062 {
00063   outermost_context().unconsumed_event( request );
00064 }
00065 
00066 void
00067 Stopping::do_noFragmentToProcess() const
00068 {
00069   if ( destructionIsDone() )
00070   {
00071     SharedResourcesPtr sharedResources =
00072       outermost_context().getSharedResources();
00073     EventPtr_t stMachEvent( new StopDone() );
00074     sharedResources->commandQueue_->enqWait( stMachEvent );
00075   }
00076 }
00077 
00078 bool
00079 Stopping::destructionIsDone() const
00080 {
00081   SharedResourcesPtr sharedResources =
00082     outermost_context().getSharedResources();
00083 
00084   // check if the requests are still being processed
00085   if ( sharedResources->diskWriterResources_->streamChangeOngoing() ) return false;
00086 
00087   if ( sharedResources->dqmEventProcessorResources_->requestsOngoing() ) return false;
00088 
00089   return true;
00090 }
00091 
00092