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 | Private Attributes
stor::StateMachineMonitorCollection Class Reference

#include <StateMachineMonitorCollection.h>

Inheritance diagram for stor::StateMachineMonitorCollection:
stor::MonitorCollection

Public Types

typedef std::vector
< TransitionRecord
History
 
- Public Types inherited from stor::MonitorCollection
typedef std::vector< std::pair
< std::string,
xdata::Serializable * > > 
InfoSpaceItems
 

Public Member Functions

void clearStatusMessage ()
 
void dumpHistory (std::ostream &) const
 
const std::string & externallyVisibleState () const
 
void getHistory (History &) const
 
std::string innerStateName () const
 
void setExternallyVisibleState (const std::string &)
 
void setStatusMessage (const std::string &)
 
 StateMachineMonitorCollection (const utils::Duration_t &updateInterval)
 
bool statusMessage (std::string &msg) const
 
void updateHistory (const TransitionRecord &)
 
- Public Member Functions inherited from stor::MonitorCollection
void appendInfoSpaceItems (InfoSpaceItems &)
 
void calculateStatistics (const utils::TimePoint_t &now)
 
 MonitorCollection (const utils::Duration_t &updateInterval)
 
void reset (const utils::TimePoint_t &now)
 
void updateInfoSpaceItems ()
 
virtual ~MonitorCollection ()
 

Private Member Functions

virtual void do_appendInfoSpaceItems (InfoSpaceItems &)
 
virtual void do_calculateStatistics ()
 
virtual void do_reset ()
 
virtual void do_updateInfoSpaceItems ()
 
StateMachineMonitorCollectionoperator= (StateMachineMonitorCollection const &)
 
 StateMachineMonitorCollection (StateMachineMonitorCollection const &)
 

Private Attributes

std::string externallyVisibleState_
 
History history_
 
boost::mutex stateMutex_
 
xdata::String stateName_
 
std::string statusMessage_
 

Additional Inherited Members

Detailed Description

A collection of monitored quantities related to the state machine

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

Definition at line 26 of file StateMachineMonitorCollection.h.

Member Typedef Documentation

Copy the state machine history in the given History vector

Definition at line 41 of file StateMachineMonitorCollection.h.

Constructor & Destructor Documentation

stor::StateMachineMonitorCollection::StateMachineMonitorCollection ( const utils::Duration_t updateInterval)
explicit

Definition at line 10 of file StateMachineMonitorCollection.cc.

10  :
11  MonitorCollection(updateInterval),
12  externallyVisibleState_( "unknown" ),
13  stateName_( "unknown" )
14  {}
MonitorCollection(const utils::Duration_t &updateInterval)
stor::StateMachineMonitorCollection::StateMachineMonitorCollection ( StateMachineMonitorCollection const &  )
private

Member Function Documentation

void stor::StateMachineMonitorCollection::clearStatusMessage ( )

Clear status message

Definition at line 70 of file StateMachineMonitorCollection.cc.

References stateMutex_, and statusMessage_.

71  {
72  boost::mutex::scoped_lock sl( stateMutex_ );
73  statusMessage_.clear();
74  }
void stor::StateMachineMonitorCollection::do_appendInfoSpaceItems ( InfoSpaceItems infoSpaceItems)
privatevirtual

Reimplemented from stor::MonitorCollection.

Definition at line 108 of file StateMachineMonitorCollection.cc.

111  {
112  infoSpaceItems.push_back(std::make_pair("stateName", &stateName_));
113  }
void stor::StateMachineMonitorCollection::do_calculateStatistics ( )
privatevirtual

Implements stor::MonitorCollection.

Definition at line 93 of file StateMachineMonitorCollection.cc.

94  {
95  // nothing to do
96  }
void stor::StateMachineMonitorCollection::do_reset ( )
privatevirtual

Implements stor::MonitorCollection.

Definition at line 99 of file StateMachineMonitorCollection.cc.

References history_, and stateMutex_.

100  {
101  // we shall not reset the state name
102  boost::mutex::scoped_lock sl( stateMutex_ );
103  history_.clear();
104  }
void stor::StateMachineMonitorCollection::do_updateInfoSpaceItems ( )
privatevirtual

Reimplemented from stor::MonitorCollection.

Definition at line 116 of file StateMachineMonitorCollection.cc.

References externallyVisibleState_, stateMutex_, and stateName_.

117  {
118  boost::mutex::scoped_lock sl( stateMutex_ );
119 
120  stateName_ = static_cast<xdata::String>( externallyVisibleState_ );
121  }
void stor::StateMachineMonitorCollection::dumpHistory ( std::ostream &  os) const

Dump the state machine history into the stream

Definition at line 31 of file StateMachineMonitorCollection.cc.

References history_, j, and stateMutex_.

32  {
33  boost::mutex::scoped_lock sl( stateMutex_ );
34 
35  os << "**** Begin transition history ****" << std::endl;
36 
37  for( History::const_iterator j = history_.begin();
38  j != history_.end(); ++j )
39  {
40  os << " " << *j << std::endl;
41  }
42 
43  os << "**** End transition history ****" << std::endl;
44 
45  }
int j
Definition: DBlmapReader.cc:9
const std::string & stor::StateMachineMonitorCollection::externallyVisibleState ( ) const

Retrieve the externally visible state name

Definition at line 55 of file StateMachineMonitorCollection.cc.

References externallyVisibleState_, and stateMutex_.

Referenced by stor::SMWebPageHelper::consumerStatistics(), and stor::SMWebPageHelper::createWebPageBody().

56  {
57  boost::mutex::scoped_lock sl( stateMutex_ );
59  }
void stor::StateMachineMonitorCollection::getHistory ( History history) const

Definition at line 24 of file StateMachineMonitorCollection.cc.

References history_, and stateMutex_.

25  {
26  boost::mutex::scoped_lock sl( stateMutex_ );
27  history = history_;
28  }
std::string stor::StateMachineMonitorCollection::innerStateName ( ) const

Retrieve the current internal state name

Definition at line 85 of file StateMachineMonitorCollection.cc.

References history_, stateMutex_, and stor::TransitionRecord::stateName().

Referenced by stor::SMWebPageHelper::consumerStatistics(), and stor::SMWebPageHelper::createWebPageBody().

86  {
87  boost::mutex::scoped_lock sl( stateMutex_ );
88  TransitionRecord tr = history_.back();
89  return tr.stateName();;
90  }
StateMachineMonitorCollection& stor::StateMachineMonitorCollection::operator= ( StateMachineMonitorCollection const &  )
private
void stor::StateMachineMonitorCollection::setExternallyVisibleState ( const std::string &  n)

Set the externally visible state name

Definition at line 48 of file StateMachineMonitorCollection.cc.

References externallyVisibleState_, n, and stateMutex_.

49  {
50  boost::mutex::scoped_lock sl( stateMutex_ );
52  }
void stor::StateMachineMonitorCollection::setStatusMessage ( const std::string &  m)

Set status message

Definition at line 62 of file StateMachineMonitorCollection.cc.

References stateMutex_, and statusMessage_.

63  {
64  boost::mutex::scoped_lock sl( stateMutex_ );
65  if ( statusMessage_.empty() )
66  statusMessage_ = m;
67  }
bool stor::StateMachineMonitorCollection::statusMessage ( std::string &  msg) const

Get status message

Definition at line 77 of file StateMachineMonitorCollection.cc.

References stateMutex_, and statusMessage_.

Referenced by stor::SMWebPageHelper::consumerStatistics(), and stor::SMWebPageHelper::createWebPageBody().

78  {
79  boost::mutex::scoped_lock sl( stateMutex_ );
80  m = statusMessage_;
81  return ( ! statusMessage_.empty() );
82  }
void stor::StateMachineMonitorCollection::updateHistory ( const TransitionRecord tr)

Add the TransitionRecord to the state machine history

Definition at line 17 of file StateMachineMonitorCollection.cc.

References history_, and stateMutex_.

18  {
19  boost::mutex::scoped_lock sl( stateMutex_ );
20  history_.push_back( tr );
21  }

Member Data Documentation

std::string stor::StateMachineMonitorCollection::externallyVisibleState_
private
History stor::StateMachineMonitorCollection::history_
private
boost::mutex stor::StateMachineMonitorCollection::stateMutex_
mutableprivate
xdata::String stor::StateMachineMonitorCollection::stateName_
private

Definition at line 96 of file StateMachineMonitorCollection.h.

Referenced by do_updateInfoSpaceItems().

std::string stor::StateMachineMonitorCollection::statusMessage_
private