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
evf::SMProxy Class Reference

#include <SMProxy.h>

Public Member Functions

UInt_t sendDataEvent (UInt_t fuResourceId, UInt_t runNumber, UInt_t evtNumber, UInt_t outModId, UInt_t fuProcessId, UInt_t fuGuid, UChar_t *data, UInt_t dataSize) throw (evf::Exception)
 
UInt_t sendDqmEvent (UInt_t fuDqmId, UInt_t runNumber, UInt_t evtAtUpdate, UInt_t folderId, UInt_t fuProcessId, UInt_t fuGuid, UChar_t *data, UInt_t dataSize) throw (evf::Exception)
 
UInt_t sendErrorEvent (UInt_t fuResourceId, UInt_t runNumber, UInt_t evtNumber, UInt_t fuProcessId, UInt_t fuGuid, UChar_t *data, UInt_t dataSize) throw (evf::Exception)
 
UInt_t sendInitMessage (UInt_t fuResourceId, UInt_t outModId, UInt_t fuProcessId, UInt_t fuGuid, UChar_t *data, UInt_t dataSize, UInt_t nExpectedEPs) throw (evf::Exception)
 
 SMProxy (xdaq::ApplicationDescriptor *fuAppDesc, xdaq::ApplicationDescriptor *smAppDesc, xdaq::ApplicationContext *fuAppContext, toolbox::mem::Pool *i2oPool)
 
virtual ~SMProxy ()
 

Private Member Functions

MemRef_tcreateFragmentChain (UShort_t i2oFunctionCode, UInt_t headerSize, UChar_t *data, UInt_t dataSize, UInt_t &totalSize) throw (evf::Exception)
 

Private Attributes

UInt_t dataHeaderSize_
 
UInt_t dqmHeaderSize_
 
xdaq::ApplicationContext * fuAppContext_
 
xdaq::ApplicationDescriptor * fuAppDesc_
 
std::string fuClassName_
 
std::string fuUrl_
 
toolbox::mem::Pool * i2oPool_
 
UInt_t initHeaderSize_
 
Logger log_
 
xdaq::ApplicationDescriptor * smAppDesc_
 

Detailed Description

Proxy for StorageManager

Definition at line 24 of file SMProxy.h.

Constructor & Destructor Documentation

SMProxy::SMProxy ( xdaq::ApplicationDescriptor *  fuAppDesc,
xdaq::ApplicationDescriptor *  smAppDesc,
xdaq::ApplicationContext *  fuAppContext,
toolbox::mem::Pool *  i2oPool 
)

Definition at line 34 of file SMProxy.cc.

References fuAppDesc_, fuClassName_, fuUrl_, and MAX_I2O_SM_URLCHARS.

36  :
37  log_(fuAppContext->getLogger()), fuAppDesc_(fuAppDesc),
38  smAppDesc_(smAppDesc), fuAppContext_(fuAppContext),
39  i2oPool_(i2oPool),
43  fuUrl_ = fuAppDesc_->getContextDescriptor()->getURL();
44  if (fuUrl_.size() >= MAX_I2O_SM_URLCHARS)
45  fuUrl_ = fuUrl_.substr(0, MAX_I2O_SM_URLCHARS - 1);
46 
47  fuClassName_ = fuAppDesc_->getClassName();
48  if (fuClassName_.size() >= MAX_I2O_SM_URLCHARS)
50 }
xdaq::ApplicationDescriptor * fuAppDesc_
Definition: SMProxy.h:81
std::string fuUrl_
Definition: SMProxy.h:90
toolbox::mem::Pool * i2oPool_
Definition: SMProxy.h:84
xdaq::ApplicationDescriptor * smAppDesc_
Definition: SMProxy.h:82
UInt_t dqmHeaderSize_
Definition: SMProxy.h:88
std::string fuClassName_
Definition: SMProxy.h:91
UInt_t dataHeaderSize_
Definition: SMProxy.h:87
xdaq::ApplicationContext * fuAppContext_
Definition: SMProxy.h:83
Logger log_
Definition: SMProxy.h:80
UInt_t initHeaderSize_
Definition: SMProxy.h:86
#define MAX_I2O_SM_URLCHARS
Definition: i2oEvfMsgs.h:53
SMProxy::~SMProxy ( )
virtual

Definition at line 53 of file SMProxy.cc.

53  {
54 
55 }

Member Function Documentation

MemRef_t * SMProxy::createFragmentChain ( UShort_t  i2oFunctionCode,
UInt_t  headerSize,
UChar_t data,
UInt_t  dataSize,
UInt_t totalSize 
)
throw (evf::Exception
)
private

Definition at line 188 of file SMProxy.cc.

References filterCSVwithJSON::copy, data, _I2O_SM_MULTIPART_MESSAGE_FRAME::dataSize, alignCSCRings::e, edm::hlt::Exception, _I2O_SM_MULTIPART_MESSAGE_FRAME::frameCount, _I2O_SM_MULTIPART_MESSAGE_FRAME::hltClassName, _I2O_SM_MULTIPART_MESSAGE_FRAME::hltInstance, _I2O_SM_MULTIPART_MESSAGE_FRAME::hltLocalId, _I2O_SM_MULTIPART_MESSAGE_FRAME::hltTid, _I2O_SM_MULTIPART_MESSAGE_FRAME::hltURL, i, I2O_MAX_SIZE, lumiQueryAPI::msg, _I2O_SM_MULTIPART_MESSAGE_FRAME::numFrames, and _I2O_SM_MULTIPART_MESSAGE_FRAME::originalSize.

190  {
191  totalSize = 0;
192 
193  UInt_t fragmentDataSizeMax = I2O_MAX_SIZE - headerSize;
194  UInt_t fragmentCount = (dataSize / fragmentDataSizeMax);
195  if (dataSize % fragmentDataSizeMax)
196  ++fragmentCount;
197 
198  UInt_t currentPosition = 0;
199  UInt_t remainingDataSize = dataSize;
200 
201  MemRef_t *head(0);
202  MemRef_t *tail(0);
203 
204  try {
205 
206  for (UInt_t iFragment = 0; iFragment < fragmentCount; iFragment++) {
207 
208  UInt_t fragmentDataSize = fragmentDataSizeMax;
209  UInt_t fragmentSize = fragmentDataSize + headerSize;
210 
211  if (remainingDataSize < fragmentDataSizeMax) {
212  fragmentDataSize = remainingDataSize;
213  fragmentSize = fragmentDataSize + headerSize;
214  if (fragmentSize & 0x7)
215  fragmentSize = ((fragmentSize >> 3) + 1) << 3;
216  }
217 
218  // allocate the fragment buffer from the pool
219  toolbox::mem::Reference *bufRef =
220  toolbox::mem::getMemoryPoolFactory()->getFrame(i2oPool_,
221  fragmentSize);
222 
223  // set up pointers to the allocated message buffer
224  I2O_MESSAGE_FRAME *stdMsg;
225  I2O_PRIVATE_MESSAGE_FRAME *pvtMsg;
227 
228  stdMsg = (I2O_MESSAGE_FRAME*) bufRef->getDataLocation();
229  pvtMsg = (I2O_PRIVATE_MESSAGE_FRAME*) stdMsg;
230  msg = (I2O_SM_MULTIPART_MESSAGE_FRAME*) stdMsg;
231 
232  stdMsg->VersionOffset = 0;
233  stdMsg->MsgFlags = 0; // normal message (not multicast)
234  stdMsg->MessageSize = fragmentSize >> 2;
235  stdMsg->Function = I2O_PRIVATE_MESSAGE;
236  stdMsg->InitiatorAddress = i2o::utils::getAddressMap()->getTid(
237  fuAppDesc_);
238  stdMsg->TargetAddress = i2o::utils::getAddressMap()->getTid(
239  smAppDesc_);
240 
241  pvtMsg->XFunctionCode = i2oFunctionCode;
242  pvtMsg->OrganizationID = XDAQ_ORGANIZATION_ID;
243 
244  msg->dataSize = fragmentDataSize;
245  msg->hltLocalId = fuAppDesc_->getLocalId();
246  msg->hltInstance = fuAppDesc_->getInstance();
247  msg->hltTid = i2o::utils::getAddressMap()->getTid(fuAppDesc_);
248  msg->numFrames = fragmentCount;
249  msg->frameCount = iFragment;
250  msg->originalSize = dataSize;
251 
252  for (UInt_t i = 0; i < fuUrl_.size(); i++)
253  msg->hltURL[i] = fuUrl_[i];
254  msg->hltURL[fuUrl_.size()] = '\0';
255 
256  for (UInt_t i = 0; i < fuClassName_.size(); i++)
257  msg->hltClassName[i] = fuClassName_[i];
258  msg->hltClassName[fuClassName_.size()] = '\0';
259 
260  if (iFragment == 0) {
261  head = bufRef;
262  tail = bufRef;
263  } else {
264  tail->setNextReference(bufRef);
265  tail = bufRef;
266  }
267 
268  if (fragmentDataSize != 0) {
269  UChar_t* targetAddr = (UChar_t*) msg + headerSize;
270  std::copy(data + currentPosition,
271  data + currentPosition + fragmentDataSize, targetAddr);
272  }
273 
274  bufRef->setDataSize(fragmentSize);
275  remainingDataSize -= fragmentDataSize;
276  currentPosition += fragmentDataSize;
277  totalSize += fragmentSize;
278 
279  } // for (iFragment ...)
281  if (0 != head)
282  head->release();
283  totalSize = 0;
284  string errmsg = "Failed to allocate buffer reference.";
285  LOG4CPLUS_FATAL(log_, errmsg);
286  XCEPT_RETHROW(evf::Exception, errmsg, e);
287  } catch (xdaq::exception::ApplicationDescriptorNotFound& e) {
288  if (0 != head)
289  head->release();
290  totalSize = 0;
291  string errmsg = "Failed to get tid.";
292  LOG4CPLUS_FATAL(log_, errmsg);
293  XCEPT_RETHROW(evf::Exception, errmsg, e);
294  }
295 
296  return head;
297 }
int i
Definition: DBlmapReader.cc:9
xdaq::ApplicationDescriptor * fuAppDesc_
Definition: SMProxy.h:81
std::string fuUrl_
Definition: SMProxy.h:90
toolbox::mem::Reference MemRef_t
Definition: FUTypes.h:10
toolbox::mem::Pool * i2oPool_
Definition: SMProxy.h:84
xdaq::ApplicationDescriptor * smAppDesc_
Definition: SMProxy.h:82
std::string fuClassName_
Definition: SMProxy.h:91
unsigned char UChar_t
Definition: FUTypes.h:14
Logger log_
Definition: SMProxy.h:80
unsigned int UInt_t
Definition: FUTypes.h:12
#define I2O_MAX_SIZE
Definition: i2oEvfMsgs.h:46
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
UInt_t SMProxy::sendDataEvent ( UInt_t  fuResourceId,
UInt_t  runNumber,
UInt_t  evtNumber,
UInt_t  outModId,
UInt_t  fuProcessId,
UInt_t  fuGuid,
UChar_t data,
UInt_t  dataSize 
)
throw (evf::Exception
)

Send Data Event message to SM

Definition at line 91 of file SMProxy.cc.

References data, alignCSCRings::e, _I2O_SM_DATA_MESSAGE_FRAME::eventID, edm::hlt::Exception, _I2O_SM_DATA_MESSAGE_FRAME::fuGUID, _I2O_SM_DATA_MESSAGE_FRAME::fuProcID, I2O_SM_DATA, lumiQueryAPI::msg, GetRecoTauVFromDQM_MC_cff::next, _I2O_SM_DATA_MESSAGE_FRAME::outModID, _I2O_SM_DATA_MESSAGE_FRAME::rbBufferID, _I2O_SM_DATA_MESSAGE_FRAME::runID, and convertSQLiteXML::runNumber.

Referenced by evf::IPCMethod::sendDataEvent().

93  {
94  UInt_t totalSize = 0;
96  dataSize, totalSize);
97 
99  MemRef_t* next = bufRef;
100  do {
101  msg = (I2O_SM_DATA_MESSAGE_FRAME*) next->getDataLocation();
102  msg->rbBufferID = fuResourceId;
103  msg->runID = runNumber;
104  msg->eventID = evtNumber;
105  msg->outModID = outModId;
106  msg->fuProcID = fuProcessId;
107  msg->fuGUID = fuGuid;
108  } while ((next = next->getNextReference()));
109 
110  try {
111  fuAppContext_->postFrame(bufRef, fuAppDesc_, smAppDesc_);
112  } catch (xdaq::exception::Exception &e) {
113  string errmsg = "Failed to post DATA Message.";
114  LOG4CPLUS_FATAL(log_, errmsg);
115  XCEPT_RETHROW(evf::Exception, errmsg, e);
116  }
117 
118  return totalSize;
119 }
xdaq::ApplicationDescriptor * fuAppDesc_
Definition: SMProxy.h:81
toolbox::mem::Reference MemRef_t
Definition: FUTypes.h:10
xdaq::ApplicationDescriptor * smAppDesc_
Definition: SMProxy.h:82
UInt_t dataHeaderSize_
Definition: SMProxy.h:87
xdaq::ApplicationContext * fuAppContext_
Definition: SMProxy.h:83
MemRef_t * createFragmentChain(UShort_t i2oFunctionCode, UInt_t headerSize, UChar_t *data, UInt_t dataSize, UInt_t &totalSize)
Definition: SMProxy.cc:188
Logger log_
Definition: SMProxy.h:80
unsigned int UInt_t
Definition: FUTypes.h:12
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
#define I2O_SM_DATA
Definition: i2oEvfMsgs.h:22
UInt_t SMProxy::sendDqmEvent ( UInt_t  fuDqmId,
UInt_t  runNumber,
UInt_t  evtAtUpdate,
UInt_t  folderId,
UInt_t  fuProcessId,
UInt_t  fuGuid,
UChar_t data,
UInt_t  dataSize 
)
throw (evf::Exception
)

Send DQM Event message to SM

Definition at line 153 of file SMProxy.cc.

References data, alignCSCRings::e, _I2O_SM_DQM_MESSAGE_FRAME::eventAtUpdateID, edm::hlt::Exception, _I2O_SM_DQM_MESSAGE_FRAME::folderID, _I2O_SM_DQM_MESSAGE_FRAME::fuGUID, _I2O_SM_DQM_MESSAGE_FRAME::fuProcID, I2O_SM_DQM, lumiQueryAPI::msg, GetRecoTauVFromDQM_MC_cff::next, _I2O_SM_DQM_MESSAGE_FRAME::rbBufferID, _I2O_SM_DQM_MESSAGE_FRAME::runID, and convertSQLiteXML::runNumber.

Referenced by evf::IPCMethod::sendDqmEvent().

155  {
156  UInt_t totalSize = 0;
158  dataSize, totalSize);
159 
161  MemRef_t* next = bufRef;
162  do {
163  msg = (I2O_SM_DQM_MESSAGE_FRAME*) next->getDataLocation();
164  msg->rbBufferID = fuDqmId;
165  msg->runID = runNumber;
166  msg->eventAtUpdateID = evtAtUpdate;
167  msg->folderID = folderId;
168  msg->fuProcID = fuProcessId;
169  msg->fuGUID = fuGuid;
170  } while ((next = next->getNextReference()));
171 
172  try {
173  fuAppContext_->postFrame(bufRef, fuAppDesc_, smAppDesc_);
174  } catch (xdaq::exception::Exception &e) {
175  string errmsg = "Failed to post DQM Message.";
176  LOG4CPLUS_FATAL(log_, errmsg);
177  XCEPT_RETHROW(evf::Exception, errmsg, e);
178  }
179 
180  return totalSize;
181 }
xdaq::ApplicationDescriptor * fuAppDesc_
Definition: SMProxy.h:81
#define I2O_SM_DQM
Definition: i2oEvfMsgs.h:25
toolbox::mem::Reference MemRef_t
Definition: FUTypes.h:10
xdaq::ApplicationDescriptor * smAppDesc_
Definition: SMProxy.h:82
UInt_t dqmHeaderSize_
Definition: SMProxy.h:88
xdaq::ApplicationContext * fuAppContext_
Definition: SMProxy.h:83
MemRef_t * createFragmentChain(UShort_t i2oFunctionCode, UInt_t headerSize, UChar_t *data, UInt_t dataSize, UInt_t &totalSize)
Definition: SMProxy.cc:188
Logger log_
Definition: SMProxy.h:80
unsigned int UInt_t
Definition: FUTypes.h:12
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
UInt_t SMProxy::sendErrorEvent ( UInt_t  fuResourceId,
UInt_t  runNumber,
UInt_t  evtNumber,
UInt_t  fuProcessId,
UInt_t  fuGuid,
UChar_t data,
UInt_t  dataSize 
)
throw (evf::Exception
)

Send Error Event message to SM

Definition at line 122 of file SMProxy.cc.

References data, alignCSCRings::e, _I2O_SM_DATA_MESSAGE_FRAME::eventID, edm::hlt::Exception, _I2O_SM_DATA_MESSAGE_FRAME::fuGUID, _I2O_SM_DATA_MESSAGE_FRAME::fuProcID, I2O_SM_ERROR, lumiQueryAPI::msg, GetRecoTauVFromDQM_MC_cff::next, _I2O_SM_DATA_MESSAGE_FRAME::outModID, _I2O_SM_DATA_MESSAGE_FRAME::rbBufferID, _I2O_SM_DATA_MESSAGE_FRAME::runID, and convertSQLiteXML::runNumber.

Referenced by evf::IPCMethod::sendErrorEvent().

124  {
125  UInt_t totalSize = 0;
127  dataSize, totalSize);
128 
130  MemRef_t* next = bufRef;
131  do {
132  msg = (I2O_SM_DATA_MESSAGE_FRAME*) next->getDataLocation();
133  msg->rbBufferID = fuResourceId;
134  msg->runID = runNumber;
135  msg->eventID = evtNumber;
136  msg->outModID = 0xffffffff;
137  msg->fuProcID = fuProcessId;
138  msg->fuGUID = fuGuid;
139  } while ((next = next->getNextReference()));
140 
141  try {
142  fuAppContext_->postFrame(bufRef, fuAppDesc_, smAppDesc_);
143  } catch (xdaq::exception::Exception &e) {
144  string errmsg = "Failed to post ERROR Message.";
145  LOG4CPLUS_FATAL(log_, errmsg);
146  XCEPT_RETHROW(evf::Exception, errmsg, e);
147  }
148 
149  return totalSize;
150 }
#define I2O_SM_ERROR
Definition: i2oEvfMsgs.h:23
xdaq::ApplicationDescriptor * fuAppDesc_
Definition: SMProxy.h:81
toolbox::mem::Reference MemRef_t
Definition: FUTypes.h:10
xdaq::ApplicationDescriptor * smAppDesc_
Definition: SMProxy.h:82
UInt_t dataHeaderSize_
Definition: SMProxy.h:87
xdaq::ApplicationContext * fuAppContext_
Definition: SMProxy.h:83
MemRef_t * createFragmentChain(UShort_t i2oFunctionCode, UInt_t headerSize, UChar_t *data, UInt_t dataSize, UInt_t &totalSize)
Definition: SMProxy.cc:188
Logger log_
Definition: SMProxy.h:80
unsigned int UInt_t
Definition: FUTypes.h:12
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
UInt_t SMProxy::sendInitMessage ( UInt_t  fuResourceId,
UInt_t  outModId,
UInt_t  fuProcessId,
UInt_t  fuGuid,
UChar_t data,
UInt_t  dataSize,
UInt_t  nExpectedEPs 
)
throw (evf::Exception
)

Send Init message to SM

Definition at line 62 of file SMProxy.cc.

References data, alignCSCRings::e, edm::hlt::Exception, _I2O_SM_PREAMBLE_MESSAGE_FRAME::fuGUID, _I2O_SM_PREAMBLE_MESSAGE_FRAME::fuProcID, I2O_SM_PREAMBLE, lumiQueryAPI::msg, _I2O_SM_PREAMBLE_MESSAGE_FRAME::nExpectedEPs, GetRecoTauVFromDQM_MC_cff::next, _I2O_SM_PREAMBLE_MESSAGE_FRAME::outModID, and _I2O_SM_PREAMBLE_MESSAGE_FRAME::rbBufferID.

Referenced by evf::IPCMethod::sendInitMessage().

64  {
65  UInt_t totalSize = 0;
67  data, dataSize, totalSize);
68 
70  MemRef_t* next = bufRef;
71  do {
72  msg = (I2O_SM_PREAMBLE_MESSAGE_FRAME*) next->getDataLocation();
73  msg->rbBufferID = fuResourceId;
74  msg->outModID = outModId;
75  msg->fuProcID = fuProcessId;
76  msg->fuGUID = fuGuid;
77  msg->nExpectedEPs = nExpectedEPs;
78  } while ((next = next->getNextReference()));
79 
80  try {
81  fuAppContext_->postFrame(bufRef, fuAppDesc_, smAppDesc_);
82  } catch (xdaq::exception::Exception &e) {
83  string msg = "Failed to post INIT Message.";
84  XCEPT_RETHROW(evf::Exception, msg, e);
85  }
86 
87  return totalSize;
88 }
xdaq::ApplicationDescriptor * fuAppDesc_
Definition: SMProxy.h:81
#define I2O_SM_PREAMBLE
Definition: i2oEvfMsgs.h:21
toolbox::mem::Reference MemRef_t
Definition: FUTypes.h:10
xdaq::ApplicationDescriptor * smAppDesc_
Definition: SMProxy.h:82
xdaq::ApplicationContext * fuAppContext_
Definition: SMProxy.h:83
MemRef_t * createFragmentChain(UShort_t i2oFunctionCode, UInt_t headerSize, UChar_t *data, UInt_t dataSize, UInt_t &totalSize)
Definition: SMProxy.cc:188
UInt_t initHeaderSize_
Definition: SMProxy.h:86
unsigned int UInt_t
Definition: FUTypes.h:12
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82

Member Data Documentation

UInt_t evf::SMProxy::dataHeaderSize_
private

Definition at line 87 of file SMProxy.h.

UInt_t evf::SMProxy::dqmHeaderSize_
private

Definition at line 88 of file SMProxy.h.

xdaq::ApplicationContext* evf::SMProxy::fuAppContext_
private

Definition at line 83 of file SMProxy.h.

xdaq::ApplicationDescriptor* evf::SMProxy::fuAppDesc_
private

Definition at line 81 of file SMProxy.h.

Referenced by SMProxy().

std::string evf::SMProxy::fuClassName_
private

Definition at line 91 of file SMProxy.h.

Referenced by SMProxy().

std::string evf::SMProxy::fuUrl_
private

Definition at line 90 of file SMProxy.h.

Referenced by SMProxy().

toolbox::mem::Pool* evf::SMProxy::i2oPool_
private

Definition at line 84 of file SMProxy.h.

UInt_t evf::SMProxy::initHeaderSize_
private

Definition at line 86 of file SMProxy.h.

Logger evf::SMProxy::log_
private

Definition at line 80 of file SMProxy.h.

xdaq::ApplicationDescriptor* evf::SMProxy::smAppDesc_
private

Definition at line 82 of file SMProxy.h.