CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
stor::EventServerProxy< RegInfo > Class Template Reference

#include <EventServerProxy.h>

Public Member Functions

 EventServerProxy (edm::ParameterSet const &)
 
bool getEventMaybe (CurlInterface::Content &data)
 
void getInitMsg (CurlInterface::Content &data)
 
template<>
void getInitMsg (CurlInterface::Content &data)
 
void getOneEvent (CurlInterface::Content &data)
 
void reconnect ()
 
virtual ~EventServerProxy ()
 

Private Member Functions

void checkEvent (CurlInterface::Content &)
 
void checkInitMsg (CurlInterface::Content &)
 
template<>
void checkInitMsg (CurlInterface::Content &data)
 
void connectToEventServer (CurlInterface::Content &)
 
bool extractConsumerId (CurlInterface::Content &)
 
void getInitMsgFromEventServer (CurlInterface::Content &)
 
template<>
void getInitMsgFromEventServer (CurlInterface::Content &data)
 
void getOneEventFromEventServer (CurlInterface::Content &)
 
void registerWithEventServer ()
 

Private Attributes

bool alreadySaidHalted_
 
bool alreadySaidWaiting_
 
unsigned int consumerId_
 
unsigned int failedAttemptsToGetData_
 
const stor::utils::Duration_t minEventRequestInterval_
 
stor::utils::TimePoint_t nextRequestTime_
 
const RegInfo regInfo_
 

Detailed Description

template<typename RegInfo>
class stor::EventServerProxy< RegInfo >

Retrieve events from the Storage Manager event server.

This does uses a HTTP get using the CURL library. The Storage Manager event server responses with a binary octet-stream. The init message is also obtained through a HTTP get.

Author:
mommsen
Revision:
1.8
Date:
2012/04/23 08:41:27

Definition at line 36 of file EventServerProxy.h.

Constructor & Destructor Documentation

template<typename RegInfo>
stor::EventServerProxy< RegInfo >::EventServerProxy ( edm::ParameterSet const &  )
template<typename RegInfo>
virtual stor::EventServerProxy< RegInfo >::~EventServerProxy ( )
inlinevirtual

Definition at line 42 of file EventServerProxy.h.

42 {};

Member Function Documentation

template<typename RegInfo>
void stor::EventServerProxy< RegInfo >::checkEvent ( CurlInterface::Content )
private
template<typename RegInfo>
void stor::EventServerProxy< RegInfo >::checkInitMsg ( CurlInterface::Content )
private
template<>
void stor::EventServerProxy< EventConsumerRegistrationInfo >::checkInitMsg ( CurlInterface::Content data)
inlineprivate

Definition at line 144 of file EventServerProxy.h.

References HeaderView::code(), hcal_timing_source_file_cfg::dump, edm::hlt::Exception, Header::INIT, and AlCaHLTBitMon_QueryRunRegistry::string.

145  {
146  try {
147  HeaderView hdrView(&data[0]);
148  if (hdrView.code() != Header::INIT) {
149  throw cms::Exception("EventServerProxy", "readHeader");
150  }
151  }
152  catch (cms::Exception excpt) {
153  const unsigned int MAX_DUMP_LENGTH = 1000;
154  std::ostringstream dump;
155  dump << "========================================" << std::endl;
156  dump << "* Exception decoding the getregdata response from the event server!" << std::endl;
157  if (data.size() <= MAX_DUMP_LENGTH)
158  {
159  dump << "* Here is the raw text that was returned:" << std::endl;
160  dump << std::string(&data[0]) << std::endl;
161  }
162  else
163  {
164  dump << "* Here are the first " << MAX_DUMP_LENGTH <<
165  " characters of the raw text that was returned:" << std::endl;
166  dump << std::string(&data[0], MAX_DUMP_LENGTH) << std::endl;
167  }
168  dump << "========================================" << std::endl;
169  edm::LogError("EventServerProxy") << dump.str();
170  throw excpt;
171  }
172  }
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
template<typename RegInfo>
void stor::EventServerProxy< RegInfo >::connectToEventServer ( CurlInterface::Content )
private
template<typename RegInfo>
bool stor::EventServerProxy< RegInfo >::extractConsumerId ( CurlInterface::Content )
private
template<typename RegInfo>
bool stor::EventServerProxy< RegInfo >::getEventMaybe ( CurlInterface::Content data)

Try to get one event from the event server. If succesful, returns true.

template<typename RegInfo>
void stor::EventServerProxy< RegInfo >::getInitMsg ( CurlInterface::Content data)

Get the init message from the the event server.

Referenced by edm::EventStreamHttpReader::readHeader().

template<>
void stor::EventServerProxy< EventConsumerRegistrationInfo >::getInitMsg ( CurlInterface::Content data)
inline

Definition at line 177 of file EventServerProxy.h.

References edm::hlt::Exception, and edm::shutdown_flag.

178  {
179  do
180  {
181  data.clear();
183  }
184  while ( !edm::shutdown_flag && data.empty() );
185 
186  if (edm::shutdown_flag) {
187  throw cms::Exception("readHeader","EventServerProxy")
188  << "The header read was aborted by a shutdown request.\n";
189  }
190 
192  }
void getInitMsgFromEventServer(CurlInterface::Content &)
void checkInitMsg(CurlInterface::Content &)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
volatile bool shutdown_flag
template<typename RegInfo>
void stor::EventServerProxy< RegInfo >::getInitMsgFromEventServer ( CurlInterface::Content )
private
template<>
void stor::EventServerProxy< EventConsumerRegistrationInfo >::getInitMsgFromEventServer ( CurlInterface::Content data)
inlineprivate

Definition at line 95 of file EventServerProxy.h.

References convert(), data, stor::CurlInterface::getInterface(), Header::HEADER_REQUEST, OtherMessageBuilder::msgBody(), query::result, OtherMessageBuilder::size(), stor::utils::sleep(), OtherMessageBuilder::startAddress(), and AlCaHLTBitMon_QueryRunRegistry::string.

96  {
97  // build the header request message to send to the event server
98  char msgBuff[100];
99  OtherMessageBuilder requestMessage(
100  &msgBuff[0],
102  sizeof(char_uint32)
103  );
104  uint8 *bodyPtr = requestMessage.msgBody();
105  convert(consumerId_, bodyPtr);
106 
107  // send the header request
109  CURLcode result = curl->postBinaryMessage(
110  regInfo_.sourceURL() + "/getregdata",
111  requestMessage.startAddress(),
112  requestMessage.size(),
113  data
114  );
115 
116  if ( result != CURLE_OK )
117  {
118  // connection failed: try to reconnect
119  edm::LogError("EventServerProxy") << "curl perform failed for header:"
120  << std::string(&data[0]) << std::endl
121  << ". Trying to reconnect.";
122  data.clear();
124  }
125 
126  if( data.empty() )
127  {
128  if(!alreadySaidWaiting_) {
129  edm::LogInfo("EventServerProxy") << "...waiting for header from event server...";
130  alreadySaidWaiting_ = true;
131  }
132  // sleep for desired amount of time
133  ::sleep(regInfo_.headerRetryInterval());
134  }
135  else
136  {
137  alreadySaidWaiting_ = false;
138  }
139  }
void sleep(Duration_t)
Definition: Utils.h:163
void convert(uint32 i, char_uint32 v)
Definition: MsgTools.h:46
static boost::shared_ptr< CurlInterface > getInterface()
tuple result
Definition: query.py:137
unsigned char char_uint32[sizeof(uint32)]
Definition: MsgTools.h:16
boost::shared_ptr< CurlInterface > CurlInterfacePtr
Definition: CurlInterface.h:71
unsigned char uint8
Definition: MsgTools.h:11
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
template<typename RegInfo>
void stor::EventServerProxy< RegInfo >::getOneEvent ( CurlInterface::Content data)

Get one event from the event server.

Referenced by edm::EventStreamHttpReader::checkNextEvent(), and edm::DQMHttpSource::checkNextEvent().

template<typename RegInfo>
void stor::EventServerProxy< RegInfo >::getOneEventFromEventServer ( CurlInterface::Content )
private
template<typename RegInfo>
void stor::EventServerProxy< RegInfo >::reconnect ( )

Reconnect to the event server

template<typename RegInfo>
void stor::EventServerProxy< RegInfo >::registerWithEventServer ( )
private

Member Data Documentation

template<typename RegInfo>
bool stor::EventServerProxy< RegInfo >::alreadySaidHalted_
private

Definition at line 81 of file EventServerProxy.h.

template<typename RegInfo>
bool stor::EventServerProxy< RegInfo >::alreadySaidWaiting_
private

Definition at line 82 of file EventServerProxy.h.

template<typename RegInfo>
unsigned int stor::EventServerProxy< RegInfo >::consumerId_
private

Definition at line 77 of file EventServerProxy.h.

template<typename RegInfo>
unsigned int stor::EventServerProxy< RegInfo >::failedAttemptsToGetData_
private

Definition at line 83 of file EventServerProxy.h.

template<typename RegInfo>
const stor::utils::Duration_t stor::EventServerProxy< RegInfo >::minEventRequestInterval_
private

Definition at line 79 of file EventServerProxy.h.

template<typename RegInfo>
stor::utils::TimePoint_t stor::EventServerProxy< RegInfo >::nextRequestTime_
private

Definition at line 78 of file EventServerProxy.h.

template<typename RegInfo>
const RegInfo stor::EventServerProxy< RegInfo >::regInfo_
private

Definition at line 76 of file EventServerProxy.h.