CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions
stor::DrainingQueues Class Reference

#include <StateMachine.h>

Inheritance diagram for stor::DrainingQueues:
stor::Operations

Public Types

typedef bsc::in_state_reaction
< EndRun, DrainingQueues,&DrainingQueues::logEndRunRequest
EndRunIR
 
typedef bsc::transition
< QueuesEmpty, FinishingDQM
FT
 
typedef boost::mpl::list< FT,
EndRunIR
reactions
 

Public Member Functions

 DrainingQueues (my_context)
 
void logEndRunRequest (const EndRun &request)
 
virtual ~DrainingQueues ()
 
- Public Member Functions inherited from stor::Operations
void moveToFailedState (xcept::Exception &exception) const
 
void noFragmentToProcess () const
 
 Operations ()
 
void processI2OFragment (I2OChain &frag) const
 
std::string stateName () const
 
virtual ~Operations ()=0
 

Private Member Functions

bool allQueuesAndWorkersAreEmpty () const
 
virtual void do_entryActionWork ()
 
virtual void do_exitActionWork ()
 
virtual void do_moveToFailedState (xcept::Exception &exception) const
 
virtual void do_noFragmentToProcess () const
 
virtual std::string do_stateName () const
 
void processStaleFragments () const
 

Additional Inherited Members

- Protected Member Functions inherited from stor::Operations
virtual void do_processI2OFragment (I2OChain &frag) const
 
void safeEntryAction ()
 
void safeExitAction ()
 

Detailed Description

DrainingQueues state

Author:
mommsen
Revision:
1.11
Date:
2011/03/07 15:31:32

Definition at line 535 of file StateMachine.h.

Member Typedef Documentation

Definition at line 543 of file StateMachine.h.

Definition at line 542 of file StateMachine.h.

Definition at line 544 of file StateMachine.h.

Constructor & Destructor Documentation

DrainingQueues::DrainingQueues ( my_context  c)

Definition at line 23 of file DrainingQueues.cc.

References stor::Operations::safeEntryAction().

23  : my_base(c)
24 {
26 }
void safeEntryAction()
Definition: Operations.cc:77
DrainingQueues::~DrainingQueues ( )
virtual

Definition at line 34 of file DrainingQueues.cc.

References stor::Operations::safeExitAction().

35 {
37 }
void safeExitAction()
Definition: Operations.cc:108

Member Function Documentation

bool DrainingQueues::allQueuesAndWorkersAreEmpty ( ) const
private

Definition at line 73 of file DrainingQueues.cc.

References stor::FragmentStore::clear(), stor::FragmentStore::empty(), stor::EventDistributor::full(), and processStaleFragments().

Referenced by do_noFragmentToProcess().

74 {
75  SharedResourcesPtr sharedResources =
76  outermost_context().getSharedResources();
77 
78  // the order is important here - upstream entities first,
79  // followed by more downstream entities
80 
81  EventDistributor *ed = outermost_context().getEventDistributor();
82  if ( ed->full() ) return false;
83 
85  FragmentStore *fs = outermost_context().getFragmentStore();
86  if ( ! fs->empty() ) return false;
87 
88  if ( ! sharedResources->streamQueue_->empty() ) return false;
89 
90  if ( sharedResources->diskWriterResources_->isBusy() ) return false;
91 
92  //if ( ! sharedResources->dqmEventQueue_->empty() ) return false;
93  // Do not wait for dqmEventQueue to drain, just clear it
94  sharedResources->dqmEventQueue_->clear();
95 
96  return true;
97 }
void processStaleFragments() const
boost::shared_ptr< SharedResources > SharedResourcesPtr
const bool full() const
bool empty() const
Definition: FragmentStore.h:74
void DrainingQueues::do_entryActionWork ( )
privatevirtual

Implements stor::Operations.

Definition at line 28 of file DrainingQueues.cc.

References stor::Operations::stateName().

29 {
30  TransitionRecord tr( stateName(), true );
31  outermost_context().updateHistory( tr );
32 }
std::string stateName() const
Definition: Operations.cc:39
void DrainingQueues::do_exitActionWork ( )
privatevirtual

Implements stor::Operations.

Definition at line 39 of file DrainingQueues.cc.

References stor::Operations::stateName().

40 {
41  TransitionRecord tr( stateName(), false );
42  outermost_context().updateHistory( tr );
43 }
std::string stateName() const
Definition: Operations.cc:39
void DrainingQueues::do_moveToFailedState ( xcept::Exception &  exception) const
privatevirtual

Implements stor::Operations.

Definition at line 50 of file DrainingQueues.cc.

51 {
52  outermost_context().getSharedResources()->alarmHandler_->moveToFailedState( exception );
53 }
void DrainingQueues::do_noFragmentToProcess ( ) const
privatevirtual

Reimplemented from stor::Operations.

Definition at line 61 of file DrainingQueues.cc.

References allQueuesAndWorkersAreEmpty().

62 {
64  {
65  SharedResourcesPtr sharedResources =
66  outermost_context().getSharedResources();
67  EventPtr_t stMachEvent( new QueuesEmpty() );
68  sharedResources->commandQueue_->enqWait( stMachEvent );
69  }
70 }
bool allQueuesAndWorkersAreEmpty() const
boost::shared_ptr< SharedResources > SharedResourcesPtr
boost::shared_ptr< boost::statechart::event_base > EventPtr_t
Definition: CommandQueue.h:21
string DrainingQueues::do_stateName ( ) const
privatevirtual

Implements stor::Operations.

Definition at line 45 of file DrainingQueues.cc.

46 {
47  return std::string( "DrainingQueues" );
48 }
void DrainingQueues::logEndRunRequest ( const EndRun request)

Definition at line 55 of file DrainingQueues.cc.

56 {
57  outermost_context().unconsumed_event( request );
58 }
void DrainingQueues::processStaleFragments ( ) const
private

Definition at line 100 of file DrainingQueues.cc.

References stor::EventDistributor::addEventToRelevantQueues(), stor::EventDistributor::full(), and seconds().

Referenced by allQueuesAndWorkersAreEmpty().

101 {
102  I2OChain staleEvent;
103  bool gotStaleEvent = true;
104  int loopCounter = 0;
105 
106  EventDistributor *ed = outermost_context().getEventDistributor();
107 
108  while ( gotStaleEvent && !ed->full() && loopCounter++ < 10 )
109  {
110  gotStaleEvent =
111  outermost_context().getFragmentStore()->getStaleEvent(staleEvent, boost::posix_time::seconds(0));
112  if ( gotStaleEvent )
113  {
114  outermost_context().getSharedResources()->discardManager_->sendDiscardMessage(staleEvent);
115  ed->addEventToRelevantQueues(staleEvent);
116  }
117  }
118 }
double seconds()
const bool full() const
void addEventToRelevantQueues(I2OChain &)