CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions

stor::DrainingQueues Class Reference

#include <StateMachine.h>

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

List of all members.

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 ()

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

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

typedef bsc::in_state_reaction<EndRun,DrainingQueues,&DrainingQueues::logEndRunRequest> stor::DrainingQueues::EndRunIR

Definition at line 543 of file StateMachine.h.

Definition at line 542 of file StateMachine.h.

typedef boost::mpl::list<FT,EndRunIR> stor::DrainingQueues::reactions

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().

                                            : my_base(c)
{
  safeEntryAction();
}
DrainingQueues::~DrainingQueues ( ) [virtual]

Definition at line 33 of file DrainingQueues.cc.

References stor::Operations::safeExitAction().


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().

{
  SharedResourcesPtr sharedResources = 
    outermost_context().getSharedResources();

  // the order is important here - upstream entities first,
  // followed by more downstream entities

  EventDistributor *ed = outermost_context().getEventDistributor();
  if ( ed->full() ) return false;

  processStaleFragments();
  FragmentStore *fs = outermost_context().getFragmentStore();
  if ( ! fs->empty() ) return false;

  if ( ! sharedResources->streamQueue_->empty() ) return false;

  if ( sharedResources->diskWriterResources_->isBusy() ) return false;
  
  //if ( ! sharedResources->dqmEventQueue_->empty() ) return false;
  // Do not wait for dqmEventQueue to drain, just clear it
  sharedResources->dqmEventQueue_->clear();

  return true;
}
void DrainingQueues::do_entryActionWork ( ) [private, virtual]

Implements stor::Operations.

Definition at line 27 of file DrainingQueues.cc.

References stor::Operations::stateName().

{
  TransitionRecord tr( stateName(), true );
  outermost_context().updateHistory( tr );
}
void DrainingQueues::do_exitActionWork ( ) [private, virtual]

Implements stor::Operations.

Definition at line 38 of file DrainingQueues.cc.

References stor::Operations::stateName().

{
  TransitionRecord tr( stateName(), false );
  outermost_context().updateHistory( tr );
}
void DrainingQueues::do_moveToFailedState ( xcept::Exception exception) const [private, virtual]

Implements stor::Operations.

Definition at line 49 of file DrainingQueues.cc.

{
  outermost_context().getSharedResources()->moveToFailedState( exception );
}
void DrainingQueues::do_noFragmentToProcess ( ) const [private, virtual]

Reimplemented from stor::Operations.

Definition at line 60 of file DrainingQueues.cc.

References allQueuesAndWorkersAreEmpty().

{
  if ( allQueuesAndWorkersAreEmpty() )
  {
    SharedResourcesPtr sharedResources =
      outermost_context().getSharedResources();
    EventPtr_t stMachEvent( new QueuesEmpty() );
    sharedResources->commandQueue_->enqWait( stMachEvent );
  }
}
string DrainingQueues::do_stateName ( ) const [private, virtual]

Implements stor::Operations.

Definition at line 44 of file DrainingQueues.cc.

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

Definition at line 54 of file DrainingQueues.cc.

{
  outermost_context().unconsumed_event( request );
}
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().

{
  I2OChain staleEvent;
  bool gotStaleEvent = true;  
  int loopCounter = 0;

  EventDistributor *ed = outermost_context().getEventDistributor();

  while ( gotStaleEvent && !ed->full() && loopCounter++ < 10 )
  {
    gotStaleEvent = 
      outermost_context().getFragmentStore()->getStaleEvent(staleEvent, boost::posix_time::seconds(0));
    if ( gotStaleEvent )
    {
      outermost_context().getSharedResources()->discardManager_->sendDiscardMessage(staleEvent);
      ed->addEventToRelevantQueues(staleEvent);
    }
  }
}