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.10.12.1
Date:
2011/03/07 11:33:04

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 22 of file DrainingQueues.cc.

References stor::Operations::safeEntryAction().

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

Definition at line 33 of file DrainingQueues.cc.

References stor::Operations::safeExitAction().

34 {
36 }
void safeExitAction()
Definition: Operations.cc:108

Member Function Documentation

bool DrainingQueues::allQueuesAndWorkersAreEmpty ( ) const
private

Definition at line 72 of file DrainingQueues.cc.

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

Referenced by do_noFragmentToProcess().

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

Implements stor::Operations.

Definition at line 27 of file DrainingQueues.cc.

References stor::Operations::stateName().

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

Implements stor::Operations.

Definition at line 38 of file DrainingQueues.cc.

References stor::Operations::stateName().

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

Implements stor::Operations.

Definition at line 49 of file DrainingQueues.cc.

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

Reimplemented from stor::Operations.

Definition at line 60 of file DrainingQueues.cc.

References allQueuesAndWorkersAreEmpty().

61 {
63  {
64  SharedResourcesPtr sharedResources =
65  outermost_context().getSharedResources();
66  EventPtr_t stMachEvent( new QueuesEmpty() );
67  sharedResources->commandQueue_->enqWait( stMachEvent );
68  }
69 }
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 44 of file DrainingQueues.cc.

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

Definition at line 54 of file DrainingQueues.cc.

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

Definition at line 99 of file DrainingQueues.cc.

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

Referenced by allQueuesAndWorkersAreEmpty().

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