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::DiscardManager Class Reference

#include <DiscardManager.h>

Public Types

typedef std::map< HLTSenderKey,
boost::shared_ptr< FUProxy > > 
FUProxyMap
 
typedef boost::shared_ptr
< FUProxy
FUProxyPtr
 
typedef std::pair< std::string,
unsigned int > 
HLTSenderKey
 

Public Member Functions

void configure ()
 
 DiscardManager (xdaq::ApplicationContext *, xdaq::ApplicationDescriptor *, DataSenderMonitorCollection &)
 
bool sendDiscardMessage (I2OChain const &)
 

Private Member Functions

FUProxyPtr getProxyFromCache (std::string const &hltClassName, unsigned int const &hltInstance)
 
FUProxyPtr makeNewFUProxy (std::string const &hltClassName, unsigned int const &hltInstance)
 

Private Attributes

xdaq::ApplicationContext * appContext_
 
xdaq::ApplicationDescriptor * appDescriptor_
 
DataSenderMonitorCollectiondataSenderMonCollection_
 
toolbox::mem::Pool * msgPool_
 
FUProxyMap proxyCache_
 

Detailed Description

Handles the discard messages sent to the upstream Resource Brokers.

Author:
mommsen
Revision:
1.7
Date:
2011/04/07 08:02:03

Definition at line 33 of file DiscardManager.h.

Member Typedef Documentation

typedef std::map< HLTSenderKey, boost::shared_ptr<FUProxy> > stor::DiscardManager::FUProxyMap

Definition at line 39 of file DiscardManager.h.

typedef boost::shared_ptr<FUProxy> stor::DiscardManager::FUProxyPtr

Definition at line 38 of file DiscardManager.h.

typedef std::pair<std::string, unsigned int> stor::DiscardManager::HLTSenderKey

Definition at line 37 of file DiscardManager.h.

Constructor & Destructor Documentation

stor::DiscardManager::DiscardManager ( xdaq::ApplicationContext *  ctx,
xdaq::ApplicationDescriptor *  desc,
DataSenderMonitorCollection dsmc 
)

Creates a DiscardManager that will send discard messages to upstream Resource Brokers on behalf of the application specified in the application descriptor. The DiscardManager will use the specified application context to send the messages.

Definition at line 20 of file DiscardManager.cc.

References a.

24  :
25  appContext_(ctx),
26  appDescriptor_(desc),
28  {
29  std::ostringstream poolName;
30  poolName << desc->getClassName() << desc->getInstance();
31  toolbox::net::URN urn("toolbox-mem-pool", poolName.str());
32  toolbox::mem::HeapAllocator* a = new toolbox::mem::HeapAllocator();
33 
34  msgPool_ = toolbox::mem::getMemoryPoolFactory()->createPool(urn, a);
35  }
xdaq::ApplicationContext * appContext_
toolbox::mem::Pool * msgPool_
xdaq::ApplicationDescriptor * appDescriptor_
double a
Definition: hdecay.h:121
DataSenderMonitorCollection & dataSenderMonCollection_

Member Function Documentation

void stor::DiscardManager::configure ( )

Configures the discard manager.

Definition at line 37 of file DiscardManager.cc.

References proxyCache_.

38  {
39  proxyCache_.clear();
40  }
DiscardManager::FUProxyPtr stor::DiscardManager::getProxyFromCache ( std::string const &  hltClassName,
unsigned int const &  hltInstance 
)
private

Definition at line 85 of file DiscardManager.cc.

References pos.

Referenced by sendDiscardMessage().

89  {
90  HLTSenderKey mapKey = std::make_pair(hltClassName, hltInstance);
91  FUProxyMap::iterator pos = proxyCache_.lower_bound(mapKey);
92 
93  if (pos == proxyCache_.end() || (proxyCache_.key_comp()(mapKey, pos->first)))
94  {
95  // Use pos as a hint to insert a new record, so it can avoid another lookup
96  FUProxyPtr fuProxyPtr = makeNewFUProxy(hltClassName, hltInstance);
97  if (fuProxyPtr.get() != 0)
98  pos = proxyCache_.insert(pos, FUProxyMap::value_type(mapKey, fuProxyPtr));
99 
100  return fuProxyPtr;
101  }
102  else
103  {
104  return pos->second;
105  }
106  }
std::pair< std::string, unsigned int > HLTSenderKey
boost::shared_ptr< FUProxy > FUProxyPtr
FUProxyPtr makeNewFUProxy(std::string const &hltClassName, unsigned int const &hltInstance)
Container::value_type value_type
DiscardManager::FUProxyPtr stor::DiscardManager::makeNewFUProxy ( std::string const &  hltClassName,
unsigned int const &  hltInstance 
)
private

Definition at line 110 of file DiscardManager.cc.

114  {
115  FUProxyPtr proxyPtr;
116  std::set<xdaq::ApplicationDescriptor*> setOfRBs=
117  appContext_->getDefaultZone()->
118  getApplicationDescriptors(hltClassName.c_str());
119 
120  std::set<xdaq::ApplicationDescriptor*>::iterator iter;
121  std::set<xdaq::ApplicationDescriptor*>::iterator iterEnd = setOfRBs.end();
122 
123  for (iter = setOfRBs.begin(); iter != iterEnd; ++iter)
124  {
125  if ((*iter)->getInstance() == hltInstance)
126  {
127  proxyPtr.reset(new FUProxy(appDescriptor_, *iter,
129  break;
130  }
131  }
132 
133  return proxyPtr;
134  }
xdaq::ApplicationContext * appContext_
boost::shared_ptr< FUProxy > FUProxyPtr
toolbox::mem::Pool * msgPool_
xdaq::ApplicationDescriptor * appDescriptor_
bool stor::DiscardManager::sendDiscardMessage ( I2OChain const &  i2oMessage)

Sends a message to the appropriate resource broker telling it that the SM has received and processed the specified I2O message. At that point, we expect that the resource broker will free up the buffer that contained the original event (or INIT message or DQMEvent or whatever) and do whatever other cleanup it may need to do.

There are two failure modes to this method. In the first, the I2OChain could be so badly corrupt that the target resource broker can not be determined. In that case, this method simply returns false. (Since we expect that these messages will be sent to a special error stream, we will rely on their presence in that stream to indicate that something went very wrong.) In the second failure mode, the I2OChain was parsable, but the lookup of the RB in the XDAQ network failed. In that case, this method throws an exception. (This should never happen, so we will treat it as an exceptional condition.)

Exceptions
astor::exception::RBLookupFailed exception if the appropriate resource broker can not be determined.

Definition at line 42 of file DiscardManager.cc.

References dataSenderMonCollection_, Header::DQM_EVENT, getProxyFromCache(), stor::I2OChain::hltClassName(), stor::I2OChain::hltInstance(), stor::DataSenderMonitorCollection::incrementDataDiscardCount(), stor::DataSenderMonitorCollection::incrementDQMDiscardCount(), stor::DataSenderMonitorCollection::incrementSkippedDiscardCount(), Header::INVALID, stor::I2OChain::messageCode(), lumiQueryAPI::msg, stor::I2OChain::rbBufferId(), and AlCaHLTBitMon_QueryRunRegistry::string.

43  {
44  if (i2oMessage.messageCode() == Header::INVALID)
45  {
47  return false;
48  }
49 
50  unsigned int rbBufferId = i2oMessage.rbBufferId();
51  std::string hltClassName = i2oMessage.hltClassName();
52  unsigned int hltInstance = i2oMessage.hltInstance();
53  FUProxyPtr fuProxyPtr = getProxyFromCache(hltClassName, hltInstance);
54  if (fuProxyPtr.get() == 0)
55  {
57  std::stringstream msg;
58  msg << "Unable to find the resource broker corresponding to ";
59  msg << "classname = \"";
60  msg << hltClassName;
61  msg << "\" and instance = \"";
62  msg << hltInstance;
63  msg << "\".";
64  XCEPT_RAISE(exception::RBLookupFailed, msg.str());
65  }
66  else
67  {
68  if (i2oMessage.messageCode() == Header::DQM_EVENT)
69  {
70  fuProxyPtr->sendDQMDiscard(rbBufferId);
72  }
73  else
74  {
75  fuProxyPtr->sendDataDiscard(rbBufferId);
77  }
78  }
79 
80  return true;
81  }
FUProxyPtr getProxyFromCache(std::string const &hltClassName, unsigned int const &hltInstance)
boost::shared_ptr< FUProxy > FUProxyPtr
DataSenderMonitorCollection & dataSenderMonCollection_

Member Data Documentation

xdaq::ApplicationContext* stor::DiscardManager::appContext_
private

Definition at line 99 of file DiscardManager.h.

xdaq::ApplicationDescriptor* stor::DiscardManager::appDescriptor_
private

Definition at line 100 of file DiscardManager.h.

DataSenderMonitorCollection& stor::DiscardManager::dataSenderMonCollection_
private

Definition at line 105 of file DiscardManager.h.

Referenced by sendDiscardMessage().

toolbox::mem::Pool* stor::DiscardManager::msgPool_
private

Definition at line 101 of file DiscardManager.h.

FUProxyMap stor::DiscardManager::proxyCache_
private

Definition at line 103 of file DiscardManager.h.

Referenced by configure().