00001
00002
00003 #include <iostream>
00004 #include <iomanip>
00005 #include <sstream>
00006 #include <vector>
00007 #include <sys/stat.h>
00008
00009 #include "EventFilter/SMProxyServer/interface/SMProxyServer.h"
00010 #include "EventFilter/StorageManager/interface/ConsumerPipe.h"
00011 #include "EventFilter/StorageManager/interface/ProgressMarker.h"
00012
00013
00014
00015 #include "EventFilter/Utilities/interface/ParameterSetRetriever.h"
00016
00017 #include "FWCore/Utilities/interface/DebugMacros.h"
00018 #include "FWCore/ServiceRegistry/interface/ServiceToken.h"
00019 #include "FWCore/ServiceRegistry/interface/Service.h"
00020 #include "FWCore/RootAutoLibraryLoader/interface/RootAutoLibraryLoader.h"
00021
00022 #include "IOPool/Streamer/interface/MsgHeader.h"
00023 #include "IOPool/Streamer/interface/InitMessage.h"
00024 #include "IOPool/Streamer/interface/OtherMessage.h"
00025 #include "IOPool/Streamer/interface/ConsRegMessage.h"
00026 #include "IOPool/Streamer/interface/HLTInfo.h"
00027 #include "IOPool/Streamer/interface/Utilities.h"
00028 #include "IOPool/Streamer/interface/TestFileReader.h"
00029
00030 #include "xcept/tools.h"
00031
00032 #include "xgi/Method.h"
00033
00034 #include "xoap/SOAPEnvelope.h"
00035 #include "xoap/SOAPBody.h"
00036 #include "xoap/domutils.h"
00037
00038 #include "xdata/InfoSpaceFactory.h"
00039
00040 #include "boost/algorithm/string/case_conv.hpp"
00041 #include "cgicc/Cgicc.h"
00042 #include "zlib.h"
00043
00044 using namespace edm;
00045 using namespace std;
00046 using namespace stor;
00047
00048 SMProxyServer::SMProxyServer(xdaq::ApplicationStub * s)
00049 throw (xdaq::exception::Exception) :
00050 xdaq::Application(s),
00051 fsm_(this),
00052 reasonForFailedState_(),
00053 ah_(0),
00054 collateDQM_(false),
00055 archiveDQM_(false),
00056 archiveIntervalDQM_(0),
00057 filePrefixDQM_("/tmp/DQM"),
00058 purgeTimeDQM_(DEFAULT_PURGE_TIME),
00059 readyTimeDQM_(DEFAULT_READY_TIME),
00060 useCompressionDQM_(true),
00061 compressionLevelDQM_(1),
00062 receivedEvents_(0),
00063 receivedDQMEvents_(0),
00064 mybuffer_(7000000),
00065 fairShareES_(false),
00066 connectedSMs_(0),
00067 storedDQMEvents_(0),
00068 sentEvents_(0),
00069 sentDQMEvents_(0),
00070 storedVolume_(0.),
00071 progressMarker_(ProgressMarker::instance()->idle())
00072 {
00073 LOG4CPLUS_INFO(this->getApplicationLogger(),"Making SMProxyServer");
00074
00075 ah_ = new edm::AssertHandler();
00076 fsm_.initialize<SMProxyServer>(this);
00077
00078
00079 setupFlashList();
00080
00081 xdata::InfoSpace *ispace = getApplicationInfoSpace();
00082
00083 ispace->fireItemAvailable("stateName", fsm_.stateName());
00084 ispace->fireItemAvailable("connectedSMs", &connectedSMs_);
00085 ispace->fireItemAvailable("storedDQMEvents", &storedDQMEvents_);
00086 ispace->fireItemAvailable("sentEvents", &sentEvents_);
00087 ispace->fireItemAvailable("sentDQMEvents", &sentDQMEvents_);
00088 ispace->fireItemAvailable("SMRegistrationList",&smRegList_);
00089
00090
00091
00092
00093
00094
00095 xgi::bind(this,&SMProxyServer::defaultWebPage, "Default");
00096 xgi::bind(this,&SMProxyServer::css, "styles.css");
00097 xgi::bind(this,&SMProxyServer::smsenderWebPage, "smsenderlist");
00098 xgi::bind(this,&SMProxyServer::DQMOutputWebPage, "DQMoutputStatus");
00099 xgi::bind(this,&SMProxyServer::eventdataWebPage, "geteventdata");
00100 xgi::bind(this,&SMProxyServer::headerdataWebPage, "getregdata");
00101 xgi::bind(this,&SMProxyServer::consumerWebPage, "registerConsumer");
00102 xgi::bind(this,&SMProxyServer::consumerListWebPage, "consumerList");
00103 xgi::bind(this,&SMProxyServer::DQMeventdataWebPage, "getDQMeventdata");
00104 xgi::bind(this,&SMProxyServer::DQMconsumerWebPage, "registerDQMConsumer");
00105 xgi::bind(this,&SMProxyServer::eventServerWebPage, "EventServerStats");
00106
00107 xgi::bind(this,&SMProxyServer::receiveEventWebPage, "pushEventData");
00108 xgi::bind(this,&SMProxyServer::receiveDQMEventWebPage, "pushDQMEventData");
00109
00110 ispace->fireItemAvailable("collateDQM", &collateDQM_);
00111 ispace->fireItemAvailable("archiveDQM", &archiveDQM_);
00112 ispace->fireItemAvailable("archiveIntervalDQM", &archiveIntervalDQM_);
00113 ispace->fireItemAvailable("purgeTimeDQM", &purgeTimeDQM_);
00114 ispace->fireItemAvailable("readyTimeDQM", &readyTimeDQM_);
00115 ispace->fireItemAvailable("filePrefixDQM", &filePrefixDQM_);
00116 ispace->fireItemAvailable("useCompressionDQM", &useCompressionDQM_);
00117 ispace->fireItemAvailable("compressionLevelDQM", &compressionLevelDQM_);
00118
00119
00120 ispace->fireItemAvailable("rcmsStateListener", fsm_.rcmsStateListener());
00121 ispace->fireItemAvailable("foundRcmsStateListener", fsm_.foundRcmsStateListener());
00122
00123
00124 fsm_.findRcmsStateListener();
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 maxESEventRate_ = 100.0;
00141 ispace->fireItemAvailable("maxESEventRate",&maxESEventRate_);
00142 maxESDataRate_ = 1024.0;
00143 ispace->fireItemAvailable("maxESDataRate",&maxESDataRate_);
00144 maxEventRequestRate_ = 25.0;
00145 ispace->fireItemAvailable("maxEventRequestRate",&maxEventRequestRate_);
00146 activeConsumerTimeout_ = 60;
00147 ispace->fireItemAvailable("activeConsumerTimeout",&activeConsumerTimeout_);
00148 idleConsumerTimeout_ = 60;
00149 ispace->fireItemAvailable("idleConsumerTimeout",&idleConsumerTimeout_);
00150 consumerQueueSize_ = 10;
00151 ispace->fireItemAvailable("consumerQueueSize",&consumerQueueSize_);
00152
00153 DQMmaxESEventRate_ = 1.0;
00154 ispace->fireItemAvailable("DQMmaxESEventRate",&DQMmaxESEventRate_);
00155 maxDQMEventRequestRate_ = 1.0;
00156 ispace->fireItemAvailable("maxDQMEventRequestRate",&maxDQMEventRequestRate_);
00157 DQMactiveConsumerTimeout_ = 60;
00158 ispace->fireItemAvailable("DQMactiveConsumerTimeout",&DQMactiveConsumerTimeout_);
00159 DQMidleConsumerTimeout_ = 120;
00160 ispace->fireItemAvailable("DQMidleConsumerTimeout",&DQMidleConsumerTimeout_);
00161 DQMconsumerQueueSize_ = 10;
00162 ispace->fireItemAvailable("DQMconsumerQueueSize",&DQMconsumerQueueSize_);
00163 esSelectedHLTOutputModule_ = "out4DQM";
00164 ispace->fireItemAvailable("esSelectedHLTOutputModule",&esSelectedHLTOutputModule_);
00165
00166
00167 ispace->fireItemAvailable("receivedSamples4Stats",&samples_);
00168 ispace->fireItemAvailable("receivedPeriod4Stats",&period4samples_);
00169 samples_ = 100;
00170 period4samples_ = 5;
00171 instantBandwidth_ = 0.;
00172 instantRate_ = 0.;
00173 instantLatency_ = 0.;
00174 totalSamples_ = 0;
00175 duration_ = 0.;
00176 meanBandwidth_ = 0.;
00177 meanRate_ = 0.;
00178 meanLatency_ = 0.;
00179 maxBandwidth_ = 0.;
00180 minBandwidth_ = 999999.;
00181 receivedVolume_ = 0.;
00182 outreceivedVolume_ = 0.;
00183 outinstantBandwidth_ = 0.;
00184 outinstantRate_ = 0.;
00185 outinstantLatency_ = 0.;
00186 outtotalSamples_ = 0;
00187 outduration_ = 0.;
00188 outmeanBandwidth_ = 0.;
00189 outmeanRate_ = 0.;
00190 outmeanLatency_ = 0.;
00191 outmaxBandwidth_ = 0.;
00192 outminBandwidth_ = 999999.;
00193 instantBandwidth2_ = 0.;
00194 instantRate2_ = 0.;
00195 instantLatency2_ = 0.;
00196 totalSamples2_ = 0;
00197 duration2_ = 0.;
00198 meanBandwidth2_ = 0.;
00199 meanRate2_ = 0.;
00200 meanLatency2_ = 0.;
00201 maxBandwidth2_ = 0.;
00202 minBandwidth2_ = 999999.;
00203 outinstantBandwidth2_ = 0.;
00204 outinstantRate2_ = 0.;
00205 outinstantLatency2_ = 0.;
00206 outtotalSamples2_ = 0;
00207 outduration2_ = 0.;
00208 outmeanBandwidth2_ = 0.;
00209 outmeanRate2_ = 0.;
00210 outmeanLatency2_ = 0.;
00211 outmaxBandwidth2_ = 0.;
00212 outminBandwidth2_ = 999999.;
00213
00214 outpmeter_ = new stor::SMPerformanceMeter();
00215 outpmeter_->init(samples_, period4samples_);
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226 edm::RootAutoLibraryLoader::enable();
00227 }
00228
00229 SMProxyServer::~SMProxyServer()
00230 {
00231 delete ah_;
00232 delete outpmeter_;
00233 }
00234
00235 xoap::MessageReference
00236 SMProxyServer::ParameterGet(xoap::MessageReference message)
00237 throw (xoap::exception::Exception)
00238 {
00239 connectedSMs_.value_ = smsenders_.size();
00240 return Application::ParameterGet(message);
00241 }
00242
00243
00244
00245
00247 void SMProxyServer::addMeasurement(unsigned long size)
00248 {
00249
00250 if (dpm_.get() != NULL)
00251 {
00252 dpm_->addMeasurement(size);
00253 }
00254 }
00255
00256 void SMProxyServer::addOutMeasurement(unsigned long size)
00257 {
00258
00259 if ( outpmeter_->addSample(size) )
00260 {
00261
00262 stor::SMPerfStats stats = outpmeter_->getStats();
00263 outinstantBandwidth_= stats.shortTermCounter_->getValueRate();
00264 outinstantRate_ = stats.shortTermCounter_->getSampleRate();
00265 outinstantLatency_ = 1000000.0 / outinstantRate_;
00266 double now = ForeverCounter::getCurrentTime();
00267 outtotalSamples_ = stats.longTermCounter_->getSampleCount();
00268 outduration_ = stats.longTermCounter_->getDuration(now);
00269 outmeanBandwidth_ = stats.longTermCounter_->getValueRate(now);
00270 outmeanRate_ = stats.longTermCounter_->getSampleRate(now);
00271 outmeanLatency_ = 1000000.0 / outmeanRate_;
00272 outmaxBandwidth_ = stats.maxBandwidth_;
00273 outminBandwidth_ = stats.minBandwidth_;
00274 }
00275
00276
00277 if ( outpmeter_->getStats().shortPeriodCounter_->hasValidResult() )
00278 {
00279
00280 stor::SMPerfStats stats = outpmeter_->getStats();
00281 outinstantBandwidth2_= stats.shortPeriodCounter_->getValueRate();
00282 outinstantRate2_ = stats.shortPeriodCounter_->getSampleRate();
00283 outinstantLatency2_ = 1000000.0 / outinstantRate2_;
00284 double now = ForeverCounter::getCurrentTime();
00285 outtotalSamples2_ = stats.longTermCounter_->getSampleCount();
00286 outduration2_ = stats.longTermCounter_->getDuration(now);
00287 outmeanBandwidth2_ = stats.longTermCounter_->getValueRate(now);
00288 outmeanRate2_ = stats.longTermCounter_->getSampleRate(now);
00289 outmeanLatency2_ = 1000000.0 / outmeanRate2_;
00290 outmaxBandwidth2_ = stats.maxBandwidth2_;
00291 outminBandwidth2_ = stats.minBandwidth2_;
00292 }
00293 outreceivedVolume_ = outpmeter_->totalvolumemb();
00294
00295 }
00296
00298 void SMProxyServer::defaultWebPage(xgi::Input *in, xgi::Output *out)
00299 throw (xgi::exception::Exception)
00300 {
00301 *out << "<html>" << endl;
00302 *out << "<head>" << endl;
00303 *out << "<link type=\"text/css\" rel=\"stylesheet\"";
00304 *out << " href=\"/" << getApplicationDescriptor()->getURN()
00305 << "/styles.css\"/>" << endl;
00306 *out << "<title>" << getApplicationDescriptor()->getClassName() << " instance "
00307 << getApplicationDescriptor()->getInstance()
00308 << "</title>" << endl;
00309 *out << "<table border=\"0\" width=\"100%\">" << endl;
00310 *out << "<tr>" << endl;
00311 *out << " <td align=\"left\">" << endl;
00312 *out << " <img" << endl;
00313 *out << " align=\"middle\"" << endl;
00314 *out << " src=\"/rubuilder/fu/images/fu64x64.gif\"" << endl;
00315 *out << " alt=\"main\"" << endl;
00316 *out << " width=\"64\"" << endl;
00317 *out << " height=\"64\"" << endl;
00318 *out << " border=\"\"/>" << endl;
00319 *out << " <b>" << endl;
00320 *out << getApplicationDescriptor()->getClassName() << " instance "
00321 << getApplicationDescriptor()->getInstance() << endl;
00322 *out << " " << fsm_.stateName()->toString() << endl;
00323 *out << " </b>" << endl;
00324 *out << " </td>" << endl;
00325 *out << " <td width=\"32\">" << endl;
00326 *out << " <a href=\"/urn:xdaq-application:lid=3\">" << endl;
00327 *out << " <img" << endl;
00328 *out << " align=\"middle\"" << endl;
00329 *out << " src=\"/hyperdaq/images/HyperDAQ.jpg\"" << endl;
00330 *out << " alt=\"HyperDAQ\"" << endl;
00331 *out << " width=\"32\"" << endl;
00332 *out << " height=\"32\"" << endl;
00333 *out << " border=\"\"/>" << endl;
00334 *out << " </a>" << endl;
00335 *out << " </td>" << endl;
00336 *out << " <td width=\"32\">" << endl;
00337 *out << " </td>" << endl;
00338 *out << " <td width=\"32\">" << endl;
00339 *out << " <a href=\"/" << getApplicationDescriptor()->getURN()
00340 << "/debug\">" << endl;
00341 *out << " <img" << endl;
00342 *out << " align=\"middle\"" << endl;
00343 *out << " src=\"/rubuilder/fu/images/debug32x32.gif\"" << endl;
00344 *out << " alt=\"debug\"" << endl;
00345 *out << " width=\"32\"" << endl;
00346 *out << " height=\"32\"" << endl;
00347 *out << " border=\"\"/>" << endl;
00348 *out << " </a>" << endl;
00349 *out << " </td>" << endl;
00350 *out << "</tr>" << endl;
00351 if(fsm_.stateName()->value_ == "Failed")
00352 {
00353 *out << "<tr>" << endl;
00354 *out << " <td>" << endl;
00355 *out << "<textarea rows=" << 5 << " cols=60 scroll=yes";
00356 *out << " readonly title=\"Reason For Failed\">" << endl;
00357 *out << reasonForFailedState_ << endl;
00358 *out << "</textarea>" << endl;
00359 *out << " </td>" << endl;
00360 *out << "</tr>" << endl;
00361 }
00362 *out << "</table>" << endl;
00363
00364 *out << "<hr/>" << endl;
00365 *out << "<table>" << endl;
00366 *out << "<tr valign=\"top\">" << endl;
00367 *out << " <td>" << endl;
00368
00369 *out << "<table frame=\"void\" rules=\"groups\" class=\"states\">" << endl;
00370 *out << "<colgroup> <colgroup align=\"right\">" << endl;
00371 *out << " <tr>" << endl;
00372 *out << " <th colspan=2>" << endl;
00373 *out << " " << "Input and Output Statistics" << endl;
00374 *out << " </th>" << endl;
00375 *out << " </tr>" << endl;
00376
00377 if (dpm_.get() != NULL)
00378 {
00379 receivedEvents_ = dpm_->receivedevents();
00380 receivedDQMEvents_ = dpm_->receivedDQMevents();
00381 stor::SMPerfStats stats = dpm_->getStats();
00382
00383 instantBandwidth_= stats.shortTermCounter_->getValueRate();
00384 instantRate_ = stats.shortTermCounter_->getSampleRate();
00385 instantLatency_ = 1000000.0 / instantRate_;
00386 double now = ForeverCounter::getCurrentTime();
00387 totalSamples_ = stats.longTermCounter_->getSampleCount();
00388 duration_ = stats.longTermCounter_->getDuration(now);
00389 meanBandwidth_ = stats.longTermCounter_->getValueRate(now);
00390 meanRate_ = stats.longTermCounter_->getSampleRate(now);
00391 meanLatency_ = 1000000.0 / meanRate_;
00392 maxBandwidth_ = stats.maxBandwidth_;
00393 minBandwidth_ = stats.minBandwidth_;
00394
00395 if ( stats.shortPeriodCounter_->hasValidResult() )
00396 {
00397 instantBandwidth2_= stats.shortPeriodCounter_->getValueRate();
00398 instantRate2_ = stats.shortPeriodCounter_->getSampleRate();
00399 instantLatency2_ = 1000000.0 / instantRate2_;
00400 double now = ForeverCounter::getCurrentTime();
00401 totalSamples2_ = stats.longTermCounter_->getSampleCount();
00402 duration2_ = stats.longTermCounter_->getDuration(now);
00403 meanBandwidth2_ = stats.longTermCounter_->getValueRate(now);
00404 meanRate2_ = stats.longTermCounter_->getSampleRate(now);
00405 meanLatency2_ = 1000000.0 / meanRate2_;
00406 maxBandwidth2_ = stats.maxBandwidth2_;
00407 minBandwidth2_ = stats.minBandwidth2_;
00408 }
00409 receivedVolume_ = dpm_->totalvolumemb();
00410 }
00411
00412 *out << "<tr>" << endl;
00413 *out << "<th >" << endl;
00414 *out << "Parameter" << endl;
00415 *out << "</th>" << endl;
00416 *out << "<th>" << endl;
00417 *out << "Value" << endl;
00418 *out << "</th>" << endl;
00419 *out << "</tr>" << endl;
00420 *out << "<tr>" << endl;
00421 *out << "<td >" << endl;
00422 *out << "Events Received" << endl;
00423 *out << "</td>" << endl;
00424 *out << "<td align=right>" << endl;
00425 *out << receivedEvents_ << endl;
00426 *out << "</td>" << endl;
00427 *out << " </tr>" << endl;
00428 *out << "<tr>" << endl;
00429 *out << "<td >" << endl;
00430 *out << "DQMEvents Received" << endl;
00431 *out << "</td>" << endl;
00432 *out << "<td align=right>" << endl;
00433 *out << receivedDQMEvents_ << endl;
00434 *out << "</td>" << endl;
00435 *out << " </tr>" << endl;
00436 *out << "<tr>" << endl;
00437 *out << "<td >" << endl;
00438 *out << "DQMEvents Stored" << endl;
00439 *out << "</td>" << endl;
00440 *out << "<td align=right>" << endl;
00441 *out << storedDQMEvents_ << endl;
00442 *out << "</td>" << endl;
00443 *out << " </tr>" << endl;
00444 *out << "<tr>" << endl;
00445 *out << "<td >" << endl;
00446 *out << "Events sent to consumers" << endl;
00447 *out << "</td>" << endl;
00448 *out << "<td align=right>" << endl;
00449 *out << sentEvents_ << endl;
00450 *out << "</td>" << endl;
00451 *out << " </tr>" << endl;
00452 *out << "<tr>" << endl;
00453 *out << "<td >" << endl;
00454 *out << "DQMEvents sent to consumers" << endl;
00455 *out << "</td>" << endl;
00456 *out << "<td align=right>" << endl;
00457 *out << sentDQMEvents_ << endl;
00458 *out << "</td>" << endl;
00459 *out << " </tr>" << endl;
00460
00461 *out << " <tr>" << endl;
00462 *out << " <th colspan=2>" << endl;
00463 *out << " " << "Input Performance for last " << samples_ << " HTTP posts" << " (and last " << period4samples_ << " sec)" << endl;
00464 *out << " </th>" << endl;
00465 *out << " </tr>" << endl;
00466 *out << "<tr>" << endl;
00467 *out << "<td >" << endl;
00468 *out << "Bandwidth (MB/s)" << endl;
00469 *out << "</td>" << endl;
00470 *out << "<td align=right>" << endl;
00471 *out << instantBandwidth_ << " (" << instantBandwidth2_ << ")" << endl;
00472 *out << "</td>" << endl;
00473 *out << " </tr>" << endl;
00474 *out << "<tr>" << endl;
00475 *out << "<td >" << endl;
00476 *out << "Rate (Posts/s)" << endl;
00477 *out << "</td>" << endl;
00478 *out << "<td align=right>" << endl;
00479 *out << instantRate_ << " (" << instantRate2_ << ")" << endl;
00480 *out << "</td>" << endl;
00481 *out << " </tr>" << endl;
00482 *out << "<tr>" << endl;
00483 *out << "<td >" << endl;
00484 *out << "Latency (us/post)" << endl;
00485 *out << "</td>" << endl;
00486 *out << "<td align=right>" << endl;
00487 *out << instantLatency_ << " (" << instantLatency2_ << ")" << endl;
00488 *out << "</td>" << endl;
00489 *out << " </tr>" << endl;
00490 *out << "<tr>" << endl;
00491 *out << "<td >" << endl;
00492 *out << "Maximum Bandwidth (MB/s)" << endl;
00493 *out << "</td>" << endl;
00494 *out << "<td align=right>" << endl;
00495 *out << maxBandwidth_ << " (" << maxBandwidth2_ << ")" << endl;
00496 *out << "</td>" << endl;
00497 *out << " </tr>" << endl;
00498 *out << "<tr>" << endl;
00499 *out << "<td >" << endl;
00500 *out << "Minimum Bandwidth (MB/s)" << endl;
00501 *out << "</td>" << endl;
00502 *out << "<td align=right>" << endl;
00503 *out << minBandwidth_ << " (" << minBandwidth2_ << ")" << endl;
00504 *out << "</td>" << endl;
00505 *out << " </tr>" << endl;
00506
00507 *out << " <tr>" << endl;
00508 *out << " <th colspan=2>" << endl;
00509 *out << " " << "Mean Performance for " << totalSamples_ << " (" << totalSamples2_ << ")" << " posts, duration "
00510 << duration_ << " (" << duration2_ << ")" << " seconds" << endl;
00511 *out << " </th>" << endl;
00512 *out << " </tr>" << endl;
00513 *out << "<tr>" << endl;
00514 *out << "<td >" << endl;
00515 *out << "Bandwidth (MB/s)" << endl;
00516 *out << "</td>" << endl;
00517 *out << "<td align=right>" << endl;
00518 *out << meanBandwidth_ << " (" << meanBandwidth2_ << ")" << endl;
00519 *out << "</td>" << endl;
00520 *out << " </tr>" << endl;
00521 *out << "<tr>" << endl;
00522 *out << "<td >" << endl;
00523 *out << "Rate (Posts/s)" << endl;
00524 *out << "</td>" << endl;
00525 *out << "<td align=right>" << endl;
00526 *out << meanRate_ << " (" << meanRate2_ << ")" << endl;
00527 *out << "</td>" << endl;
00528 *out << " </tr>" << endl;
00529 *out << "<tr>" << endl;
00530 *out << "<td >" << endl;
00531 *out << "Latency (us/post)" << endl;
00532 *out << "</td>" << endl;
00533 *out << "<td align=right>" << endl;
00534 *out << meanLatency_ << " (" << meanLatency2_ << ")" << endl;
00535 *out << "</td>" << endl;
00536 *out << " </tr>" << endl;
00537 *out << "<tr>" << endl;
00538 *out << "<td >" << endl;
00539 *out << "Data Volume (MB)" << endl;
00540 *out << "</td>" << endl;
00541 *out << "<td align=right>" << endl;
00542 *out << receivedVolume_ << endl;
00543 *out << "</td>" << endl;
00544 *out << " </tr>" << endl;
00545
00546 *out << " <tr>" << endl;
00547 *out << " <th colspan=2>" << endl;
00548 *out << " " << "Output Performance for last " << samples_ << " HTTP posts"<< " (and last " << period4samples_ << " sec)" << endl;
00549 *out << " </th>" << endl;
00550 *out << " </tr>" << endl;
00551 *out << "<tr>" << endl;
00552 *out << "<td >" << endl;
00553 *out << "Bandwidth (MB/s)" << endl;
00554 *out << "</td>" << endl;
00555 *out << "<td align=right>" << endl;
00556 *out << outinstantBandwidth_ << " (" << outinstantBandwidth2_ << ")" << endl;
00557 *out << "</td>" << endl;
00558 *out << " </tr>" << endl;
00559 *out << "<tr>" << endl;
00560 *out << "<td >" << endl;
00561 *out << "Rate (Posts/s)" << endl;
00562 *out << "</td>" << endl;
00563 *out << "<td align=right>" << endl;
00564 *out << outinstantRate_ << " (" << outinstantRate2_ << ")" << endl;
00565 *out << "</td>" << endl;
00566 *out << " </tr>" << endl;
00567 *out << "<tr>" << endl;
00568 *out << "<td >" << endl;
00569 *out << "Latency (us/post)" << endl;
00570 *out << "</td>" << endl;
00571 *out << "<td align=right>" << endl;
00572 *out << outinstantLatency_ << " (" << outinstantLatency2_ << ")" << endl;
00573 *out << "</td>" << endl;
00574 *out << " </tr>" << endl;
00575 *out << "<tr>" << endl;
00576 *out << "<td >" << endl;
00577 *out << "Maximum Bandwidth (MB/s)" << endl;
00578 *out << "</td>" << endl;
00579 *out << "<td align=right>" << endl;
00580 *out << outmaxBandwidth_ << " (" << outmaxBandwidth2_ << ")" << endl;
00581 *out << "</td>" << endl;
00582 *out << " </tr>" << endl;
00583 *out << "<tr>" << endl;
00584 *out << "<td >" << endl;
00585 *out << "Minimum Bandwidth (MB/s)" << endl;
00586 *out << "</td>" << endl;
00587 *out << "<td align=right>" << endl;
00588 *out << outminBandwidth_ << " (" << outminBandwidth2_ << ")" << endl;
00589 *out << "</td>" << endl;
00590 *out << " </tr>" << endl;
00591
00592 *out << " <tr>" << endl;
00593 *out << " <th colspan=2>" << endl;
00594 *out << " " << "Mean Performance for " << outtotalSamples_ << " (" << outtotalSamples2_ << ")" << " posts, duration "
00595 << outduration_ << " seconds" << endl;
00596 *out << " </th>" << endl;
00597 *out << " </tr>" << endl;
00598 *out << "<tr>" << endl;
00599 *out << "<td >" << endl;
00600 *out << "Bandwidth (MB/s)" << endl;
00601 *out << "</td>" << endl;
00602 *out << "<td align=right>" << endl;
00603 *out << outmeanBandwidth_ << " (" << outmeanBandwidth2_ << ")" << endl;
00604 *out << "</td>" << endl;
00605 *out << " </tr>" << endl;
00606 *out << "<tr>" << endl;
00607 *out << "<td >" << endl;
00608 *out << "Rate (Posts/s)" << endl;
00609 *out << "</td>" << endl;
00610 *out << "<td align=right>" << endl;
00611 *out << outmeanRate_ << " (" << outmeanRate2_ << ")" << endl;
00612 *out << "</td>" << endl;
00613 *out << " </tr>" << endl;
00614 *out << "<tr>" << endl;
00615 *out << "<td >" << endl;
00616 *out << "Latency (us/post)" << endl;
00617 *out << "</td>" << endl;
00618 *out << "<td align=right>" << endl;
00619 *out << outmeanLatency_ << " (" << outmeanLatency2_ << ")" << endl;
00620 *out << "</td>" << endl;
00621 *out << " </tr>" << endl;
00622 *out << "<tr>" << endl;
00623 *out << "<td >" << endl;
00624 *out << "Data Volume (MB)" << endl;
00625 *out << "</td>" << endl;
00626 *out << "<td align=right>" << endl;
00627 *out << outreceivedVolume_ << endl;
00628 *out << "</td>" << endl;
00629 *out << " </tr>" << endl;
00630
00631
00632 *out << "</table>" << endl;
00633
00634 *out << " </td>" << endl;
00635 *out << "</table>" << endl;
00636
00637 *out << "<hr/>" << endl;
00638 *out << "<table>" << endl;
00639 *out << "<tr valign=\"top\">" << endl;
00640 *out << " <td>" << endl;
00641
00642 *out << "<table frame=\"void\" rules=\"groups\" class=\"states\">" << endl;
00643 *out << "<colgroup> <colgroup align=\"rigth\">" << endl;
00644 *out << " <tr>" << endl;
00645 *out << " <th colspan=2>" << endl;
00646 *out << " " << "SM Sender Information" << endl;
00647 *out << " </th>" << endl;
00648 *out << " </tr>" << endl;
00649
00650 *out << "<tr>" << endl;
00651 *out << "<th >" << endl;
00652 *out << "Parameter" << endl;
00653 *out << "</th>" << endl;
00654 *out << "<th>" << endl;
00655 *out << "Value" << endl;
00656 *out << "</th>" << endl;
00657 *out << "</tr>" << endl;
00658 *out << "<tr>" << endl;
00659 *out << "<td >" << endl;
00660 *out << "Number of SM Senders" << endl;
00661 *out << "</td>" << endl;
00662 *out << "<td>" << endl;
00663 *out << smsenders_.size() << endl;
00664 *out << "</td>" << endl;
00665 *out << " </tr>" << endl;
00666
00667 *out << "</table>" << endl;
00668
00669 *out << " </td>" << endl;
00670 *out << "</table>" << endl;
00671
00672 *out << "<hr/>" << endl;
00673 std::string url = getApplicationDescriptor()->getContextDescriptor()->getURL();
00674 std::string urn = getApplicationDescriptor()->getURN();
00675 *out << "<a href=\"" << url << "/" << urn << "/smsenderlist" << "\">"
00676 << "SM Sender list web page" << "</a>" << endl;
00677 *out << "<hr/>" << endl;
00678 *out << "<a href=\"" << url << "/" << urn << "/DQMoutputStatus" << "\">"
00679 << "DQM Output Status web page" << "</a>" << endl;
00680 *out << "<hr/>" << endl;
00681 *out << "<a href=\"" << url << "/" << urn << "/EventServerStats?update=off"
00682 << "\">Event Server Statistics" << "</a>" << endl;
00683
00684 *out << "</body>" << endl;
00685 *out << "</html>" << endl;
00686 }
00687
00688
00690 void SMProxyServer::smsenderWebPage(xgi::Input *in, xgi::Output *out)
00691 throw (xgi::exception::Exception)
00692 {
00693 *out << "<html>" << endl;
00694 *out << "<head>" << endl;
00695 *out << "<link type=\"text/css\" rel=\"stylesheet\"";
00696 *out << " href=\"/" << getApplicationDescriptor()->getURN()
00697 << "/styles.css\"/>" << endl;
00698 *out << "<title>" << getApplicationDescriptor()->getClassName() << " instance "
00699 << getApplicationDescriptor()->getInstance()
00700 << "</title>" << endl;
00701 *out << "<table border=\"0\" width=\"100%\">" << endl;
00702 *out << "<tr>" << endl;
00703 *out << " <td align=\"left\">" << endl;
00704 *out << " <img" << endl;
00705 *out << " align=\"middle\"" << endl;
00706 *out << " src=\"/rubuilder/fu/images/fu64x64.gif\"" << endl;
00707 *out << " alt=\"main\"" << endl;
00708 *out << " width=\"64\"" << endl;
00709 *out << " height=\"64\"" << endl;
00710 *out << " border=\"\"/>" << endl;
00711 *out << " <b>" << endl;
00712 *out << getApplicationDescriptor()->getClassName() << " instance "
00713 << getApplicationDescriptor()->getInstance() << endl;
00714 *out << " " << fsm_.stateName()->toString() << endl;
00715 *out << " </b>" << endl;
00716 *out << " </td>" << endl;
00717 *out << " <td width=\"32\">" << endl;
00718 *out << " <a href=\"/urn:xdaq-application:lid=3\">" << endl;
00719 *out << " <img" << endl;
00720 *out << " align=\"middle\"" << endl;
00721 *out << " src=\"/hyperdaq/images/HyperDAQ.jpg\"" << endl;
00722 *out << " alt=\"HyperDAQ\"" << endl;
00723 *out << " width=\"32\"" << endl;
00724 *out << " height=\"32\"" << endl;
00725 *out << " border=\"\"/>" << endl;
00726 *out << " </a>" << endl;
00727 *out << " </td>" << endl;
00728 *out << " <td width=\"32\">" << endl;
00729 *out << " </td>" << endl;
00730 *out << " <td width=\"32\">" << endl;
00731 *out << " <a href=\"/" << getApplicationDescriptor()->getURN()
00732 << "/debug\">" << endl;
00733 *out << " <img" << endl;
00734 *out << " align=\"middle\"" << endl;
00735 *out << " src=\"/rubuilder/fu/images/debug32x32.gif\"" << endl;
00736 *out << " alt=\"debug\"" << endl;
00737 *out << " width=\"32\"" << endl;
00738 *out << " height=\"32\"" << endl;
00739 *out << " border=\"\"/>" << endl;
00740 *out << " </a>" << endl;
00741 *out << " </td>" << endl;
00742 *out << "</tr>" << endl;
00743 if(fsm_.stateName()->value_ == "Failed")
00744 {
00745 *out << "<tr>" << endl;
00746 *out << " <td>" << endl;
00747 *out << "<textarea rows=" << 5 << " cols=60 scroll=yes";
00748 *out << " readonly title=\"Reason For Failed\">" << endl;
00749 *out << reasonForFailedState_ << endl;
00750 *out << "</textarea>" << endl;
00751 *out << " </td>" << endl;
00752 *out << "</tr>" << endl;
00753 }
00754 *out << "</table>" << endl;
00755
00756 *out << "<hr/>" << endl;
00757
00758
00759 *out << "<table>" << endl;
00760 *out << "<tr valign=\"top\">" << endl;
00761 *out << " <td>" << endl;
00762
00763 *out << "<table frame=\"void\" rules=\"groups\" class=\"states\">" << endl;
00764 *out << "<colgroup> <colgroup align=\"rigth\">" << endl;
00765 *out << " <tr>" << endl;
00766 *out << " <th colspan=2>" << endl;
00767 *out << " " << "FU Sender List" << endl;
00768 *out << " </th>" << endl;
00769 *out << " </tr>" << endl;
00770
00771 *out << "<tr>" << endl;
00772 *out << "<th >" << endl;
00773 *out << "Parameter" << endl;
00774 *out << "</th>" << endl;
00775 *out << "<th>" << endl;
00776 *out << "Value" << endl;
00777 *out << "</th>" << endl;
00778 *out << "</tr>" << endl;
00779 *out << "<tr>" << endl;
00780 *out << "<td >" << endl;
00781 *out << "Number of SM Senders" << endl;
00782 *out << "</td>" << endl;
00783 *out << "<td>" << endl;
00784 *out << smsenders_.size() << endl;
00785 *out << "</td>" << endl;
00786 *out << " </tr>" << endl;
00787 if(smsenders_.size() > 0) {
00788 *out << "<tr>" << endl;
00789 *out << "<td >" << endl;
00790 *out << "SM Sender URL" << endl;
00791 *out << "</td>" << endl;
00792 *out << "<td>" << endl;
00793 *out << "Registered?" << endl;
00794 *out << "</td>" << endl;
00795 *out << " </tr>" << endl;
00796 }
00797 std::map< std::string, bool >::iterator si(smsenders_.begin()), se(smsenders_.end());
00798 for( ; si != se; ++si) {
00799 *out << "<tr>" << endl;
00800 *out << "<td>" << endl;
00801 *out << si->first << endl;
00802 *out << "</td>" << endl;
00803 *out << "<td>" << endl;
00804 if(si->second)
00805 *out << "Yes" << endl;
00806 else
00807 *out << "No" << endl;
00808 *out << "</td>" << endl;
00809 *out << " </tr>" << endl;
00810 }
00811
00812 *out << "</table>" << endl;
00813
00814 *out << " </td>" << endl;
00815 *out << "</table>" << endl;
00816
00817 *out << "</body>" << endl;
00818 *out << "</html>" << endl;
00819 }
00820
00821
00823 void SMProxyServer::DQMOutputWebPage(xgi::Input *in, xgi::Output *out)
00824 throw (xgi::exception::Exception)
00825 {
00826 *out << "<html>" << endl;
00827 *out << "<head>" << endl;
00828 *out << "<link type=\"text/css\" rel=\"stylesheet\"";
00829 *out << " href=\"/" << getApplicationDescriptor()->getURN()
00830 << "/styles.css\"/>" << endl;
00831 *out << "<title>" << getApplicationDescriptor()->getClassName() << " instance "
00832 << getApplicationDescriptor()->getInstance()
00833 << "</title>" << endl;
00834 *out << "<table border=\"0\" width=\"100%\">" << endl;
00835 *out << "<tr>" << endl;
00836 *out << " <td align=\"left\">" << endl;
00837 *out << " <img" << endl;
00838 *out << " align=\"middle\"" << endl;
00839 *out << " src=\"/rubuilder/fu/images/fu64x64.gif\"" << endl;
00840 *out << " alt=\"main\"" << endl;
00841 *out << " width=\"64\"" << endl;
00842 *out << " height=\"64\"" << endl;
00843 *out << " border=\"\"/>" << endl;
00844 *out << " <b>" << endl;
00845 *out << getApplicationDescriptor()->getClassName() << " instance "
00846 << getApplicationDescriptor()->getInstance() << endl;
00847 *out << " " << fsm_.stateName()->toString() << endl;
00848 *out << " </b>" << endl;
00849 *out << " </td>" << endl;
00850 *out << " <td width=\"32\">" << endl;
00851 *out << " <a href=\"/urn:xdaq-application:lid=3\">" << endl;
00852 *out << " <img" << endl;
00853 *out << " align=\"middle\"" << endl;
00854 *out << " src=\"/hyperdaq/images/HyperDAQ.jpg\"" << endl;
00855 *out << " alt=\"HyperDAQ\"" << endl;
00856 *out << " width=\"32\"" << endl;
00857 *out << " height=\"32\"" << endl;
00858 *out << " border=\"\"/>" << endl;
00859 *out << " </a>" << endl;
00860 *out << " </td>" << endl;
00861 *out << " <td width=\"32\">" << endl;
00862 *out << " </td>" << endl;
00863 *out << " <td width=\"32\">" << endl;
00864 *out << " <a href=\"/" << getApplicationDescriptor()->getURN()
00865 << "/debug\">" << endl;
00866 *out << " <img" << endl;
00867 *out << " align=\"middle\"" << endl;
00868 *out << " src=\"/rubuilder/fu/images/debug32x32.gif\"" << endl;
00869 *out << " alt=\"debug\"" << endl;
00870 *out << " width=\"32\"" << endl;
00871 *out << " height=\"32\"" << endl;
00872 *out << " border=\"\"/>" << endl;
00873 *out << " </a>" << endl;
00874 *out << " </td>" << endl;
00875 *out << "</tr>" << endl;
00876 if(fsm_.stateName()->value_ == "Failed")
00877 {
00878 *out << "<tr>" << endl;
00879 *out << " <td>" << endl;
00880 *out << "<textarea rows=" << 5 << " cols=60 scroll=yes";
00881 *out << " readonly title=\"Reason For Failed\">" << endl;
00882 *out << reasonForFailedState_ << endl;
00883 *out << "</textarea>" << endl;
00884 *out << " </td>" << endl;
00885 *out << "</tr>" << endl;
00886 }
00887 *out << "</table>" << endl;
00888
00889 *out << "<hr/>" << endl;
00890
00891 *out << "</body>" << endl;
00892 *out << "</html>" << endl;
00893 }
00894
00895
00897 void SMProxyServer::eventdataWebPage(xgi::Input *in, xgi::Output *out)
00898 throw (xgi::exception::Exception)
00899 {
00900
00901 int len=0;
00902
00903
00904
00905 unsigned int consumerId = 0;
00906 std::string lengthString = in->getenv("CONTENT_LENGTH");
00907 unsigned long contentLength = std::atol(lengthString.c_str());
00908 if (contentLength > 0)
00909 {
00910 auto_ptr< vector<char> > bufPtr(new vector<char>(contentLength));
00911 in->read(&(*bufPtr)[0], contentLength);
00912 OtherMessageView requestMessage(&(*bufPtr)[0]);
00913 if (requestMessage.code() == Header::EVENT_REQUEST)
00914 {
00915 uint8 *bodyPtr = requestMessage.msgBody();
00916 consumerId = convert32(bodyPtr);
00917 }
00918 }
00919
00920
00921
00922 bool haveHeaderAlready = false;
00923 if(dpm_.get() != NULL) haveHeaderAlready = dpm_->haveHeader();
00924 if(fsm_.stateName()->toString() == "Enabled" && haveHeaderAlready)
00925 {
00926 boost::shared_ptr<EventServer> eventServer;
00927 if (dpm_.get() != NULL)
00928 {
00929 eventServer = dpm_->getEventServer();
00930 }
00931 if (eventServer.get() != NULL)
00932 {
00933
00934
00935
00936 boost::shared_ptr<ConsumerPipe> consPtr =
00937 eventServer->getConsumer(consumerId);
00938 if (consPtr.get() != NULL && consPtr->hasRegistryWarning())
00939 {
00940 std::vector<char> registryWarning = consPtr->getRegistryWarning();
00941 const char* from = ®istryWarning[0];
00942 unsigned int msize = registryWarning.size();
00943 if(mybuffer_.capacity() < msize) mybuffer_.resize(msize);
00944 unsigned char* pos = (unsigned char*) &mybuffer_[0];
00945
00946 copy(from,from+msize,pos);
00947 len = msize;
00948 consPtr->clearRegistryWarning();
00949 }
00950 else
00951 {
00952 boost::shared_ptr< std::vector<char> > bufPtr =
00953 eventServer->getEvent(consumerId);
00954 if (bufPtr.get() != NULL)
00955 {
00956 EventMsgView msgView(&(*bufPtr)[0]);
00957
00958 unsigned char* from = msgView.startAddress();
00959 unsigned int dsize = msgView.size();
00960 if(dsize > mybuffer_.capacity() ) mybuffer_.resize(dsize);
00961 unsigned char* pos = (unsigned char*) &mybuffer_[0];
00962
00963 copy(from,from+dsize,pos);
00964 len = dsize;
00965 FDEBUG(10) << "sending event " << msgView.event() << std::endl;
00966 ++sentEvents_;
00967 addOutMeasurement(len);
00968 }
00969 }
00970 }
00971
00972 out->getHTTPResponseHeader().addHeader("Content-Type", "application/octet-stream");
00973 out->getHTTPResponseHeader().addHeader("Content-Transfer-Encoding", "binary");
00974 out->write((char*) &mybuffer_[0],len);
00975 }
00976 else
00977 {
00978 OtherMessageBuilder othermsg(&mybuffer_[0],Header::DONE);
00979 len = othermsg.size();
00980
00981 out->getHTTPResponseHeader().addHeader("Content-Type", "application/octet-stream");
00982 out->getHTTPResponseHeader().addHeader("Content-Transfer-Encoding", "binary");
00983 out->write((char*) &mybuffer_[0],len);
00984 }
00985
00986 }
00987
00988
00990 void SMProxyServer::headerdataWebPage(xgi::Input *in, xgi::Output *out)
00991 throw (xgi::exception::Exception)
00992 {
00993 unsigned int len = 0;
00994
00995
00996
00997 auto_ptr< vector<char> > httpsPostData;
00998 unsigned int consumerId = 0;
00999 std::string lengthString = in->getenv("CONTENT_LENGTH");
01000 unsigned long contentLength = std::atol(lengthString.c_str());
01001 if (contentLength > 0) {
01002 auto_ptr< vector<char> > bufPtr(new vector<char>(contentLength));
01003 in->read(&(*bufPtr)[0], contentLength);
01004 OtherMessageView requestMessage(&(*bufPtr)[0]);
01005 if (requestMessage.code() == Header::HEADER_REQUEST)
01006 {
01007 uint8 *bodyPtr = requestMessage.msgBody();
01008 consumerId = convert32(bodyPtr);
01009 }
01010
01011
01012
01013 httpsPostData = bufPtr;
01014 }
01015
01016
01017
01018
01019 if(fsm_.stateName()->toString() == "Enabled" && dpm_.get() != NULL &&
01020 dpm_->getInitMsgCollection().get() != NULL &&
01021 dpm_->getInitMsgCollection()->size() > 0)
01022 {
01023 std::string errorString;
01024 InitMsgSharedPtr serializedProds;
01025 boost::shared_ptr<EventServer> eventServer = dpm_->getEventServer();
01026 if (eventServer.get() != NULL)
01027 {
01028 boost::shared_ptr<ConsumerPipe> consPtr =
01029 eventServer->getConsumer(consumerId);
01030 if (consPtr.get() != NULL)
01031 {
01032 boost::shared_ptr<InitMsgCollection> initMsgCollection =
01033 dpm_->getInitMsgCollection();
01034 try
01035 {
01036 std::string hltOMLabel = consPtr->getHLTOutputSelection();
01037 serializedProds =
01038 initMsgCollection->getElementForOutputModule(hltOMLabel);
01039 if (serializedProds.get() != NULL)
01040 {
01041 Strings triggerNameList;
01042 InitMsgView initView(&(*serializedProds)[0]);
01043 initView.hltTriggerNames(triggerNameList);
01044
01045 uint32 outputModuleId;
01046 if (initView.protocolVersion() >= 6) {
01047 outputModuleId = initView.outputModuleId();
01048 }
01049 else {
01050 std::string moduleLabel = initView.outputModuleLabel();
01051 uLong crc = crc32(0L, Z_NULL, 0);
01052 Bytef* crcbuf = (Bytef*) moduleLabel.data();
01053 crc = crc32(crc, crcbuf, moduleLabel.length());
01054 outputModuleId = static_cast<uint32>(crc);
01055 }
01056 consPtr->initializeSelection(triggerNameList,
01057 outputModuleId);
01058 }
01059 }
01060 catch (const edm::Exception& excpt)
01061 {
01062 errorString = excpt.what();
01063 }
01064 catch (const cms::Exception& excpt)
01065 {
01066
01067 errorString.append("ERROR: The configuration for this ");
01068 errorString.append("consumer does not specify an HLT output ");
01069 errorString.append("module.\nPlease specify one of the HLT ");
01070 errorString.append("output modules listed below as the ");
01071 errorString.append("SelectHLTOutput parameter ");
01072 errorString.append("in the InputSource configuration.\n");
01073 errorString.append(initMsgCollection->getSelectionHelpString());
01074 errorString.append("\n");
01075 }
01076 }
01077 }
01078 if (errorString.length() > 0) {
01079 len = errorString.length();
01080 }
01081 else if (serializedProds.get() != NULL) {
01082 len = serializedProds->size();
01083 }
01084 else {
01085 len = 0;
01086 }
01087 if (mybuffer_.capacity() < len) mybuffer_.resize(len);
01088 if (errorString.length() > 0) {
01089 const char *errorBytes = errorString.c_str();
01090 for (unsigned int i=0; i<len; ++i) mybuffer_[i]=errorBytes[i];
01091 }
01092 else if (serializedProds.get() != NULL) {
01093 for (unsigned int i=0; i<len; ++i) mybuffer_[i]=(*serializedProds)[i];
01094 }
01095 }
01096
01097 out->getHTTPResponseHeader().addHeader("Content-Type", "application/octet-stream");
01098 out->getHTTPResponseHeader().addHeader("Content-Transfer-Encoding", "binary");
01099 out->write((char*) &mybuffer_[0],len);
01100 }
01101
01102
01104 void SMProxyServer::consumerWebPage(xgi::Input *in, xgi::Output *out)
01105 throw (xgi::exception::Exception)
01106 {
01107
01108
01109
01110
01111
01112
01113
01114 if(dpm_.get() != NULL && dpm_->haveRegWithEventServer() &&
01115 fsm_.stateName()->toString() == "Enabled")
01116 {
01117
01118 std::string consumerName = "None provided";
01119 std::string consumerPriority = "normal";
01120 std::string consumerRequest = "<>";
01121 std::string consumerHost = in->getenv("REMOTE_HOST");
01122
01123
01124 std::string lengthString = in->getenv("CONTENT_LENGTH");
01125 unsigned long contentLength = std::atol(lengthString.c_str());
01126 if (contentLength > 0)
01127 {
01128 auto_ptr< vector<char> > bufPtr(new vector<char>(contentLength));
01129 in->read(&(*bufPtr)[0], contentLength);
01130 ConsRegRequestView requestMessage(&(*bufPtr)[0]);
01131 consumerName = requestMessage.getConsumerName();
01132 consumerPriority = requestMessage.getConsumerPriority();
01133 std::string reqString = requestMessage.getRequestParameterSet();
01134 if (reqString.size() >= 2) consumerRequest = reqString;
01135 }
01136
01137
01138 const int BUFFER_SIZE = 100;
01139 char msgBuff[BUFFER_SIZE];
01140
01141
01142
01143 boost::shared_ptr<EventServer> eventServer;
01144 if (dpm_.get() != NULL)
01145 {
01146 eventServer = dpm_->getEventServer();
01147 }
01148
01149
01150 if (eventServer.get() == NULL)
01151 {
01152
01153 ConsRegResponseBuilder respMsg(msgBuff, BUFFER_SIZE,
01154 ConsRegResponseBuilder::ES_NOT_READY, 0);
01155
01156 FDEBUG(20) << "Registration response size = " <<
01157 respMsg.size() << std::endl;
01158 }
01159 else
01160 {
01161
01162 edm::ParameterSet requestParamSet(consumerRequest);
01163 Strings selectionRequest =
01164 EventSelector::getEventSelectionVString(requestParamSet);
01165 Strings modifiedRequest =
01166 eventServer->updateTriggerSelectionForStreams(selectionRequest);
01167
01168
01169 double maxEventRequestRate =
01170 requestParamSet.getUntrackedParameter<double>("maxEventRequestRate", 1.0);
01171
01172
01173
01174 std::string hltOMLabel =
01175 requestParamSet.getUntrackedParameter<std::string>("SelectHLTOutput",
01176 std::string());
01177
01178
01179 boost::shared_ptr<ConsumerPipe>
01180 consPtr(new ConsumerPipe(consumerName, consumerPriority,
01181 activeConsumerTimeout_.value_,
01182 idleConsumerTimeout_.value_,
01183 modifiedRequest, maxEventRequestRate,
01184 hltOMLabel,
01185 consumerHost, consumerQueueSize_));
01186 eventServer->addConsumer(consPtr);
01187
01188
01189 ConsRegResponseBuilder respMsg(msgBuff, BUFFER_SIZE,
01190 0, consPtr->getConsumerId());
01191
01192 FDEBUG(20) << "Registration response size = " <<
01193 respMsg.size() << std::endl;
01194 }
01195
01196
01197 ConsRegResponseView responseMessage(msgBuff);
01198 unsigned int len = responseMessage.size();
01199 if(len > mybuffer_.capacity() ) mybuffer_.resize(len);
01200 for (int i=0; i<(int)len; i++) mybuffer_[i]=msgBuff[i];
01201
01202 out->getHTTPResponseHeader().addHeader("Content-Type", "application/octet-stream");
01203 out->getHTTPResponseHeader().addHeader("Content-Transfer-Encoding", "binary");
01204 out->write((char*) &mybuffer_[0],len);
01205
01206 } else {
01207
01208 int len = 0;
01209 out->getHTTPResponseHeader().addHeader("Content-Type", "application/octet-stream");
01210 out->getHTTPResponseHeader().addHeader("Content-Transfer-Encoding", "binary");
01211 out->write((char*) &mybuffer_[0],len);
01212 }
01213
01214 }
01215
01216 void SMProxyServer::consumerListWebPage(xgi::Input *in, xgi::Output *out)
01217 throw (xgi::exception::Exception)
01218 {
01219 char buffer[65536];
01220
01221 out->getHTTPResponseHeader().addHeader("Content-Type", "application/xml");
01222 sprintf(buffer,
01223 "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<Monitor>\n");
01224 out->write(buffer,strlen(buffer));
01225
01226 if(fsm_.stateName()->toString() == "Enabled")
01227 {
01228 sprintf(buffer, "<ConsumerList>\n");
01229 out->write(buffer,strlen(buffer));
01230
01231 boost::shared_ptr<EventServer> eventServer;
01232 if (dpm_.get() != NULL)
01233 {
01234 eventServer = dpm_->getEventServer();
01235 }
01236 if (eventServer.get() != NULL)
01237 {
01238 std::map< uint32, boost::shared_ptr<ConsumerPipe> > consumerTable =
01239 eventServer->getConsumerTable();
01240 std::map< uint32, boost::shared_ptr<ConsumerPipe> >::const_iterator
01241 consumerIter;
01242 for (consumerIter = consumerTable.begin();
01243 consumerIter != consumerTable.end();
01244 consumerIter++)
01245 {
01246 boost::shared_ptr<ConsumerPipe> consumerPipe = consumerIter->second;
01247 sprintf(buffer, "<Consumer>\n");
01248 out->write(buffer,strlen(buffer));
01249
01250 sprintf(buffer, "<Name>%s</Name>\n",
01251 consumerPipe->getConsumerName().c_str());
01252 out->write(buffer,strlen(buffer));
01253
01254 sprintf(buffer, "<ID>%d</ID>\n", consumerPipe->getConsumerId());
01255 out->write(buffer,strlen(buffer));
01256
01257 sprintf(buffer, "<Time>%d</Time>\n",
01258 (int)consumerPipe->getLastEventRequestTime());
01259 out->write(buffer,strlen(buffer));
01260
01261 sprintf(buffer, "<Host>%s</Host>\n",
01262 consumerPipe->getHostName().c_str());
01263 out->write(buffer,strlen(buffer));
01264
01265 sprintf(buffer, "<Events>%d</Events>\n", consumerPipe->getEvents());
01266 out->write(buffer,strlen(buffer));
01267
01268 sprintf(buffer, "<Failed>%d</Failed>\n",
01269 consumerPipe->getPushEventFailures());
01270 out->write(buffer,strlen(buffer));
01271
01272 sprintf(buffer, "<Idle>%d</Idle>\n", consumerPipe->isIdle());
01273 out->write(buffer,strlen(buffer));
01274
01275 sprintf(buffer, "<Disconnected>%d</Disconnected>\n",
01276 consumerPipe->isDisconnected());
01277 out->write(buffer,strlen(buffer));
01278
01279 sprintf(buffer, "<Ready>%d</Ready>\n", consumerPipe->isReadyForEvent());
01280 out->write(buffer,strlen(buffer));
01281
01282 sprintf(buffer, "</Consumer>\n");
01283 out->write(buffer,strlen(buffer));
01284 }
01285 }
01286 boost::shared_ptr<DQMEventServer> dqmServer;
01287 if (dpm_.get() != NULL)
01288 {
01289 dqmServer = dpm_->getDQMEventServer();
01290 }
01291 if (dqmServer.get() != NULL)
01292 {
01293 std::map< uint32, boost::shared_ptr<DQMConsumerPipe> > dqmTable =
01294 dqmServer->getConsumerTable();
01295 std::map< uint32, boost::shared_ptr<DQMConsumerPipe> >::const_iterator
01296 dqmIter;
01297 for (dqmIter = dqmTable.begin();
01298 dqmIter != dqmTable.end();
01299 dqmIter++)
01300 {
01301 boost::shared_ptr<DQMConsumerPipe> dqmPipe = dqmIter->second;
01302 sprintf(buffer, "<DQMConsumer>\n");
01303 out->write(buffer,strlen(buffer));
01304
01305 sprintf(buffer, "<Name>%s</Name>\n",
01306 dqmPipe->getConsumerName().c_str());
01307 out->write(buffer,strlen(buffer));
01308
01309 sprintf(buffer, "<ID>%d</ID>\n", dqmPipe->getConsumerId());
01310 out->write(buffer,strlen(buffer));
01311
01312 sprintf(buffer, "<Time>%d</Time>\n",
01313 (int)dqmPipe->getLastEventRequestTime());
01314 out->write(buffer,strlen(buffer));
01315
01316 sprintf(buffer, "<Host>%s</Host>\n",
01317 dqmPipe->getHostName().c_str());
01318 out->write(buffer,strlen(buffer));
01319
01320 sprintf(buffer, "<Events>%d</Events>\n", dqmPipe->getEvents());
01321 out->write(buffer,strlen(buffer));
01322
01323 sprintf(buffer, "<Failed>%d</Failed>\n",
01324 dqmPipe->getPushEventFailures());
01325 out->write(buffer,strlen(buffer));
01326
01327 sprintf(buffer, "<Idle>%d</Idle>\n", dqmPipe->isIdle());
01328 out->write(buffer,strlen(buffer));
01329
01330 sprintf(buffer, "<Disconnected>%d</Disconnected>\n",
01331 dqmPipe->isDisconnected());
01332 out->write(buffer,strlen(buffer));
01333
01334 sprintf(buffer, "<Ready>%d</Ready>\n", dqmPipe->isReadyForEvent());
01335 out->write(buffer,strlen(buffer));
01336
01337 sprintf(buffer, "</DQMConsumer>\n");
01338 out->write(buffer,strlen(buffer));
01339 }
01340 }
01341 sprintf(buffer, "</ConsumerList>\n");
01342 out->write(buffer,strlen(buffer));
01343 }
01344 sprintf(buffer, "</Monitor>");
01345 out->write(buffer,strlen(buffer));
01346 }
01347
01349 void SMProxyServer::eventServerWebPage(xgi::Input *in, xgi::Output *out)
01350 throw (xgi::exception::Exception)
01351 {
01352
01353 std::string url =
01354 getApplicationDescriptor()->getContextDescriptor()->getURL();
01355 std::string urn = getApplicationDescriptor()->getURN();
01356
01357
01358
01359
01360
01361
01362
01363 bool autoUpdate = false;
01364 if(fsm_.stateName()->toString() == "Enabled") {
01365 cgicc::Cgicc cgiWrapper(in);
01366 cgicc::const_form_iterator updateRef = cgiWrapper.getElement("update");
01367 if (updateRef != cgiWrapper.getElements().end()) {
01368 std::string updateString =
01369 boost::algorithm::to_lower_copy(updateRef->getValue());
01370 if (updateString == "off") {
01371 autoUpdate = false;
01372 }
01373 else {
01374 autoUpdate = true;
01375 }
01376 }
01377 }
01378
01379 *out << "<html>" << std::endl;
01380 *out << "<head>" << std::endl;
01381 if (autoUpdate) {
01382 *out << "<meta https-equiv=\"refresh\" content=\"10\">" << std::endl;
01383 }
01384 *out << "<link type=\"text/css\" rel=\"stylesheet\"";
01385 *out << " href=\"/" << urn << "/styles.css\"/>" << std::endl;
01386 *out << "<title>" << getApplicationDescriptor()->getClassName()
01387 << " Instance " << getApplicationDescriptor()->getInstance()
01388 << "</title>" << std::endl;
01389 *out << "<style type=\"text/css\">" << std::endl;
01390 *out << " .noBotMarg {margin-bottom:0px;}" << std::endl;
01391 *out << "</style>" << std::endl;
01392 *out << "</head><body>" << std::endl;
01393
01394 *out << "<table border=\"1\" width=\"100%\">" << endl;
01395 *out << "<tr>" << endl;
01396 *out << " <td align=\"left\">" << endl;
01397 *out << " <img" << endl;
01398 *out << " align=\"middle\"" << endl;
01399 *out << " src=\"/evf/images/smicon.jpg\"" << endl;
01400 *out << " alt=\"main\"" << endl;
01401 *out << " width=\"64\"" << endl;
01402 *out << " height=\"64\"" << endl;
01403 *out << " border=\"\"/>" << endl;
01404 *out << " <b>" << endl;
01405 *out << getApplicationDescriptor()->getClassName() << " Instance "
01406 << getApplicationDescriptor()->getInstance();
01407 *out << ", State is " << fsm_.stateName()->toString() << endl;
01408 *out << " </b>" << endl;
01409 *out << " </td>" << endl;
01410 *out << " <td width=\"32\">" << endl;
01411 *out << " <a href=\"/urn:xdaq-application:lid=3\">" << endl;
01412 *out << " <img" << endl;
01413 *out << " align=\"middle\"" << endl;
01414 *out << " src=\"/hyperdaq/images/HyperDAQ.jpg\"" << endl;
01415 *out << " alt=\"HyperDAQ\"" << endl;
01416 *out << " width=\"32\"" << endl;
01417 *out << " height=\"32\"" << endl;
01418 *out << " border=\"\"/>" << endl;
01419 *out << " </a>" << endl;
01420 *out << " </td>" << endl;
01421 *out << "</tr>" << endl;
01422 if(fsm_.stateName()->value_ == "Failed")
01423 {
01424 *out << "<tr>" << endl;
01425 *out << " <td>" << endl;
01426 *out << "<textarea rows=" << 5 << " cols=60 scroll=yes";
01427 *out << " readonly title=\"Reason For Failed\">" << endl;
01428 *out << reasonForFailedState_ << endl;
01429 *out << "</textarea>" << endl;
01430 *out << " </td>" << endl;
01431 *out << "</tr>" << endl;
01432 }
01433 *out << "</table>" << endl;
01434
01435 if(fsm_.stateName()->toString() == "Enabled")
01436 {
01437 boost::shared_ptr<EventServer> eventServer;
01438 boost::shared_ptr<InitMsgCollection> initMsgCollection;
01439 if (dpm_.get() != NULL)
01440 {
01441 eventServer = dpm_->getEventServer();
01442 initMsgCollection = dpm_->getInitMsgCollection();
01443 }
01444 if (eventServer.get() != NULL && initMsgCollection.get() != NULL)
01445 {
01446 if (initMsgCollection->size() > 0)
01447 {
01448 int displayedConsumerCount = 0;
01449 double eventSum = 0.0;
01450 double eventRateSum = 0.0;
01451 double dataRateSum = 0.0;
01452
01453 double now = ForeverCounter::getCurrentTime();
01454 *out << "<table border=\"0\" width=\"100%\">" << std::endl;
01455 *out << "<tr>" << std::endl;
01456 *out << " <td width=\"25%\" align=\"center\">" << std::endl;
01457 *out << " </td>" << std::endl;
01458 *out << " " << std::endl;
01459 *out << " <td width=\"50%\" align=\"center\">" << std::endl;
01460 *out << " <font size=\"+2\"><b>Event Server Statistics</b></font>"
01461 << std::endl;
01462 *out << " <br/>" << std::endl;
01463 *out << " Data rates are reported in MB/sec." << std::endl;
01464 *out << " <br/>" << std::endl;
01465 *out << " Maximum input event rate is "
01466 << eventServer->getMaxEventRate() << " Hz." << std::endl;
01467 *out << " <br/>" << std::endl;
01468 *out << " Maximum input data rate is "
01469 << eventServer->getMaxDataRate() << " MB/sec." << std::endl;
01470 *out << " <br/>" << std::endl;
01471 *out << " Consumer queue size is " << consumerQueueSize_
01472 << "." << std::endl;
01473 *out << " <br/>" << std::endl;
01474 *out << " Event request rate from SMs is "
01475 << maxEventRequestRate_ << " Hz." << std::endl;
01476
01477
01478
01479
01480
01481
01482
01483
01484 *out << " <br/>" << std::endl;
01485 *out << " Selected HLT output module is "
01486 << eventServer->getHLTOutputSelection()
01487 << "." << std::endl;
01488 *out << " </td>" << std::endl;
01489 *out << " <td width=\"25%\" align=\"center\">" << std::endl;
01490 if (autoUpdate) {
01491 *out << " <a href=\"" << url << "/" << urn
01492 << "/EventServerStats?update=off\">Turn updating OFF</a>"
01493 << std::endl;
01494 }
01495 else {
01496 *out << " <a href=\"" << url << "/" << urn
01497 << "/EventServerStats?update=on\">Turn updating ON</a>"
01498 << std::endl;
01499 }
01500 *out << " <br/><br/>" << std::endl;
01501 *out << " <a href=\"" << url << "/" << urn
01502 << "\">Back to Proxy Status</a>"
01503 << std::endl;
01504 *out << " </td>" << std::endl;
01505 *out << "</tr>" << std::endl;
01506 *out << "</table>" << std::endl;
01507
01508 *out << "<h3>Event Server:</h3>" << std::endl;
01509 *out << "<h4 class=\"noBotMarg\">Input Events, Recent Results:</h4>" << std::endl;
01510 *out << "<font size=\"-1\">(Events can be double-counted if they are sent by multiple output modules.)</font><br/><br/>" << std::endl;
01511 *out << "<table border=\"1\" width=\"100%\">" << std::endl;
01512 *out << "<tr>" << std::endl;
01513 *out << " <th>HLT Output Module</th>" << std::endl;
01514 *out << " <th>Event Count</th>" << std::endl;
01515 *out << " <th>Event Rate</th>" << std::endl;
01516 *out << " <th>Data Rate</th>" << std::endl;
01517 *out << " <th>Duration (sec)</th>" << std::endl;
01518 *out << "</tr>" << std::endl;
01519
01520 eventSum = 0.0;
01521 eventRateSum = 0.0;
01522 dataRateSum = 0.0;
01523 for (int idx = 0; idx < initMsgCollection->size(); ++idx) {
01524 InitMsgSharedPtr serializedProds = initMsgCollection->getElementAt(idx);
01525 InitMsgView initView(&(*serializedProds)[0]);
01526 uint32 outputModuleId = initView.outputModuleId();
01527
01528 eventSum += eventServer->getEventCount(EventServer::SHORT_TERM_STATS,
01529 EventServer::INPUT_STATS,
01530 outputModuleId, now);
01531 eventRateSum += eventServer->getEventRate(EventServer::SHORT_TERM_STATS,
01532 EventServer::INPUT_STATS,
01533 outputModuleId, now);
01534 dataRateSum += eventServer->getDataRate(EventServer::SHORT_TERM_STATS,
01535 EventServer::INPUT_STATS,
01536 outputModuleId, now);
01537
01538 *out << "<tr>" << std::endl;
01539 *out << " <td align=\"center\">" << initView.outputModuleLabel()
01540 << "</td>" << std::endl;
01541 *out << " <td align=\"center\">"
01542 << eventServer->getEventCount(EventServer::SHORT_TERM_STATS,
01543 EventServer::INPUT_STATS,
01544 outputModuleId, now)
01545 << "</td>" << std::endl;
01546 *out << " <td align=\"center\">"
01547 << eventServer->getEventRate(EventServer::SHORT_TERM_STATS,
01548 EventServer::INPUT_STATS,
01549 outputModuleId, now)
01550 << "</td>" << std::endl;
01551 *out << " <td align=\"center\">"
01552 << eventServer->getDataRate(EventServer::SHORT_TERM_STATS,
01553 EventServer::INPUT_STATS,
01554 outputModuleId, now)
01555 << "</td>" << std::endl;
01556 *out << " <td align=\"center\">"
01557 << eventServer->getDuration(EventServer::SHORT_TERM_STATS,
01558 EventServer::INPUT_STATS,
01559 outputModuleId, now)
01560 << "</td>" << std::endl;
01561 *out << "</tr>" << std::endl;
01562 }
01563
01564
01565 if (initMsgCollection->size() > 1) {
01566 *out << "<tr>" << std::endl;
01567 *out << " <td align=\"center\">Totals</td>" << std::endl;
01568 *out << " <td align=\"center\">" << eventSum << "</td>" << std::endl;
01569 *out << " <td align=\"center\">" << eventRateSum << "</td>" << std::endl;
01570 *out << " <td align=\"center\">" << dataRateSum << "</td>" << std::endl;
01571 *out << " <td align=\"center\"> </td>" << std::endl;
01572 *out << "</tr>" << std::endl;
01573 }
01574 *out << "</table>" << std::endl;
01575
01576 *out << "<h4 class=\"noBotMarg\">Accepted Unique Events, Recent Results:</h4>" << std::endl;
01577 *out << "<font size=\"-1\">(Events can be double-counted if they are sent by multiple output modules.)</font><br/><br/>" << std::endl;
01578 *out << "<table border=\"1\" width=\"100%\">" << std::endl;
01579 *out << "<tr>" << std::endl;
01580 *out << " <th>HLT Output Module</th>" << std::endl;
01581 *out << " <th>Event Count</th>" << std::endl;
01582 *out << " <th>Event Rate</th>" << std::endl;
01583 *out << " <th>Data Rate</th>" << std::endl;
01584 *out << " <th>Duration (sec)</th>" << std::endl;
01585 *out << "</tr>" << std::endl;
01586
01587 eventSum = 0.0;
01588 eventRateSum = 0.0;
01589 dataRateSum = 0.0;
01590 for (int idx = 0; idx < initMsgCollection->size(); ++idx) {
01591 InitMsgSharedPtr serializedProds = initMsgCollection->getElementAt(idx);
01592 InitMsgView initView(&(*serializedProds)[0]);
01593 uint32 outputModuleId = initView.outputModuleId();
01594
01595 eventSum += eventServer->getEventCount(EventServer::SHORT_TERM_STATS,
01596 EventServer::UNIQUE_ACCEPT_STATS,
01597 outputModuleId, now);
01598 eventRateSum += eventServer->getEventRate(EventServer::SHORT_TERM_STATS,
01599 EventServer::UNIQUE_ACCEPT_STATS,
01600 outputModuleId, now);
01601 dataRateSum += eventServer->getDataRate(EventServer::SHORT_TERM_STATS,
01602 EventServer::UNIQUE_ACCEPT_STATS,
01603 outputModuleId, now);
01604
01605 *out << "<tr>" << std::endl;
01606 *out << " <td align=\"center\">" << initView.outputModuleLabel()
01607 << "</td>" << std::endl;
01608 *out << " <td align=\"center\">"
01609 << eventServer->getEventCount(EventServer::SHORT_TERM_STATS,
01610 EventServer::UNIQUE_ACCEPT_STATS,
01611 outputModuleId, now)
01612 << "</td>" << std::endl;
01613 *out << " <td align=\"center\">"
01614 << eventServer->getEventRate(EventServer::SHORT_TERM_STATS,
01615 EventServer::UNIQUE_ACCEPT_STATS,
01616 outputModuleId, now)
01617 << "</td>" << std::endl;
01618 *out << " <td align=\"center\">"
01619 << eventServer->getDataRate(EventServer::SHORT_TERM_STATS,
01620 EventServer::UNIQUE_ACCEPT_STATS,
01621 outputModuleId, now)
01622 << "</td>" << std::endl;
01623 *out << " <td align=\"center\">"
01624 << eventServer->getDuration(EventServer::SHORT_TERM_STATS,
01625 EventServer::UNIQUE_ACCEPT_STATS,
01626 outputModuleId, now)
01627 << "</td>" << std::endl;
01628 *out << "</tr>" << std::endl;
01629 }
01630
01631
01632 if (initMsgCollection->size() > 1) {
01633 *out << "<tr>" << std::endl;
01634 *out << " <td align=\"center\">Totals</td>" << std::endl;
01635 *out << " <td align=\"center\">" << eventSum << "</td>" << std::endl;
01636 *out << " <td align=\"center\">" << eventRateSum << "</td>" << std::endl;
01637 *out << " <td align=\"center\">" << dataRateSum << "</td>" << std::endl;
01638 *out << " <td align=\"center\"> </td>" << std::endl;
01639 *out << "</tr>" << std::endl;
01640 }
01641 *out << "</table>" << std::endl;
01642
01643 *out << "<h4 class=\"noBotMarg\">Accepted Events To All Consumers, Recent Results:</h4>" << std::endl;
01644 *out << "<font size=\"-1\">(Events can be double-counted if they are sent by multiple output modules or if they are sent to multiple consumers.)</font><br/><br/>" << std::endl;
01645 *out << "<table border=\"1\" width=\"100%\">" << std::endl;
01646 *out << "<tr>" << std::endl;
01647 *out << " <th>HLT Output Module</th>" << std::endl;
01648 *out << " <th>Event Count</th>" << std::endl;
01649 *out << " <th>Event Rate</th>" << std::endl;
01650 *out << " <th>Data Rate</th>" << std::endl;
01651 *out << " <th>Duration (sec)</th>" << std::endl;
01652 *out << "</tr>" << std::endl;
01653
01654 eventSum = 0.0;
01655 eventRateSum = 0.0;
01656 dataRateSum = 0.0;
01657 for (int idx = 0; idx < initMsgCollection->size(); ++idx) {
01658 InitMsgSharedPtr serializedProds = initMsgCollection->getElementAt(idx);
01659 InitMsgView initView(&(*serializedProds)[0]);
01660 uint32 outputModuleId = initView.outputModuleId();
01661
01662 eventSum += eventServer->getEventCount(EventServer::SHORT_TERM_STATS,
01663 EventServer::OUTPUT_STATS,
01664 outputModuleId, now);
01665 eventRateSum += eventServer->getEventRate(EventServer::SHORT_TERM_STATS,
01666 EventServer::OUTPUT_STATS,
01667 outputModuleId, now);
01668 dataRateSum += eventServer->getDataRate(EventServer::SHORT_TERM_STATS,
01669 EventServer::OUTPUT_STATS,
01670 outputModuleId, now);
01671
01672 *out << "<tr>" << std::endl;
01673 *out << " <td align=\"center\">" << initView.outputModuleLabel()
01674 << "</td>" << std::endl;
01675 *out << " <td align=\"center\">"
01676 << eventServer->getEventCount(EventServer::SHORT_TERM_STATS,
01677 EventServer::OUTPUT_STATS,
01678 outputModuleId, now)
01679 << "</td>" << std::endl;
01680 *out << " <td align=\"center\">"
01681 << eventServer->getEventRate(EventServer::SHORT_TERM_STATS,
01682 EventServer::OUTPUT_STATS,
01683 outputModuleId, now)
01684 << "</td>" << std::endl;
01685 *out << " <td align=\"center\">"
01686 << eventServer->getDataRate(EventServer::SHORT_TERM_STATS,
01687 EventServer::OUTPUT_STATS,
01688 outputModuleId, now)
01689 << "</td>" << std::endl;
01690 *out << " <td align=\"center\">"
01691 << eventServer->getDuration(EventServer::SHORT_TERM_STATS,
01692 EventServer::OUTPUT_STATS,
01693 outputModuleId, now)
01694 << "</td>" << std::endl;
01695 *out << "</tr>" << std::endl;
01696 }
01697
01698
01699 if (initMsgCollection->size() > 1) {
01700 *out << "<tr>" << std::endl;
01701 *out << " <td align=\"center\">Totals</td>" << std::endl;
01702 *out << " <td align=\"center\">" << eventSum << "</td>" << std::endl;
01703 *out << " <td align=\"center\">" << eventRateSum << "</td>" << std::endl;
01704 *out << " <td align=\"center\">" << dataRateSum << "</td>" << std::endl;
01705 *out << " <td align=\"center\"> </td>" << std::endl;
01706 *out << "</tr>" << std::endl;
01707 }
01708 *out << "</table>" << std::endl;
01709
01710 *out << "<h4 class=\"noBotMarg\">Input Events, Full Results:</h4>" << std::endl;
01711 *out << "<font size=\"-1\">(Events can be double-counted if they are sent by multiple output modules.)</font><br/><br/>" << std::endl;
01712 *out << "<table border=\"1\" width=\"100%\">" << std::endl;
01713 *out << "<tr>" << std::endl;
01714 *out << " <th>HLT Output Module</th>" << std::endl;
01715 *out << " <th>Event Count</th>" << std::endl;
01716 *out << " <th>Event Rate</th>" << std::endl;
01717 *out << " <th>Data Rate</th>" << std::endl;
01718 *out << " <th>Duration (sec)</th>" << std::endl;
01719 *out << "</tr>" << std::endl;
01720
01721 eventSum = 0.0;
01722 eventRateSum = 0.0;
01723 dataRateSum = 0.0;
01724 for (int idx = 0; idx < initMsgCollection->size(); ++idx) {
01725 InitMsgSharedPtr serializedProds = initMsgCollection->getElementAt(idx);
01726 InitMsgView initView(&(*serializedProds)[0]);
01727 uint32 outputModuleId = initView.outputModuleId();
01728
01729 eventSum += eventServer->getEventCount(EventServer::LONG_TERM_STATS,
01730 EventServer::INPUT_STATS,
01731 outputModuleId, now);
01732 eventRateSum += eventServer->getEventRate(EventServer::LONG_TERM_STATS,
01733 EventServer::INPUT_STATS,
01734 outputModuleId, now);
01735 dataRateSum += eventServer->getDataRate(EventServer::LONG_TERM_STATS,
01736 EventServer::INPUT_STATS,
01737 outputModuleId, now);
01738
01739 *out << "<tr>" << std::endl;
01740 *out << " <td align=\"center\">" << initView.outputModuleLabel()
01741 << "</td>" << std::endl;
01742 *out << " <td align=\"center\">"
01743 << eventServer->getEventCount(EventServer::LONG_TERM_STATS,
01744 EventServer::INPUT_STATS,
01745 outputModuleId, now)
01746 << "</td>" << std::endl;
01747 *out << " <td align=\"center\">"
01748 << eventServer->getEventRate(EventServer::LONG_TERM_STATS,
01749 EventServer::INPUT_STATS,
01750 outputModuleId, now)
01751 << "</td>" << std::endl;
01752 *out << " <td align=\"center\">"
01753 << eventServer->getDataRate(EventServer::LONG_TERM_STATS,
01754 EventServer::INPUT_STATS,
01755 outputModuleId, now)
01756 << "</td>" << std::endl;
01757 *out << " <td align=\"center\">"
01758 << eventServer->getDuration(EventServer::LONG_TERM_STATS,
01759 EventServer::INPUT_STATS,
01760 outputModuleId, now)
01761 << "</td>" << std::endl;
01762 *out << "</tr>" << std::endl;
01763 }
01764
01765
01766 if (initMsgCollection->size() > 1) {
01767 *out << "<tr>" << std::endl;
01768 *out << " <td align=\"center\">Totals</td>" << std::endl;
01769 *out << " <td align=\"center\">" << eventSum << "</td>" << std::endl;
01770 *out << " <td align=\"center\">" << eventRateSum << "</td>" << std::endl;
01771 *out << " <td align=\"center\">" << dataRateSum << "</td>" << std::endl;
01772 *out << " <td align=\"center\"> </td>" << std::endl;
01773 *out << "</tr>" << std::endl;
01774 }
01775 *out << "</table>" << std::endl;
01776
01777 *out << "<h4 class=\"noBotMarg\">Accepted Unique Events, Full Results:</h4>" << std::endl;
01778 *out << "<font size=\"-1\">(Events can be double-counted if they are sent by multiple output modules.)</font><br/><br/>" << std::endl;
01779 *out << "<table border=\"1\" width=\"100%\">" << std::endl;
01780 *out << "<tr>" << std::endl;
01781 *out << " <th>HLT Output Module</th>" << std::endl;
01782 *out << " <th>Event Count</th>" << std::endl;
01783 *out << " <th>Event Rate</th>" << std::endl;
01784 *out << " <th>Data Rate</th>" << std::endl;
01785 *out << " <th>Duration (sec)</th>" << std::endl;
01786 *out << "</tr>" << std::endl;
01787
01788 eventSum = 0.0;
01789 eventRateSum = 0.0;
01790 dataRateSum = 0.0;
01791 for (int idx = 0; idx < initMsgCollection->size(); ++idx) {
01792 InitMsgSharedPtr serializedProds = initMsgCollection->getElementAt(idx);
01793 InitMsgView initView(&(*serializedProds)[0]);
01794 uint32 outputModuleId = initView.outputModuleId();
01795
01796 eventSum += eventServer->getEventCount(EventServer::LONG_TERM_STATS,
01797 EventServer::UNIQUE_ACCEPT_STATS,
01798 outputModuleId, now);
01799 eventRateSum += eventServer->getEventRate(EventServer::LONG_TERM_STATS,
01800 EventServer::UNIQUE_ACCEPT_STATS,
01801 outputModuleId, now);
01802 dataRateSum += eventServer->getDataRate(EventServer::LONG_TERM_STATS,
01803 EventServer::UNIQUE_ACCEPT_STATS,
01804 outputModuleId, now);
01805
01806 *out << "<tr>" << std::endl;
01807 *out << " <td align=\"center\">" << initView.outputModuleLabel()
01808 << "</td>" << std::endl;
01809 *out << " <td align=\"center\">"
01810 << eventServer->getEventCount(EventServer::LONG_TERM_STATS,
01811 EventServer::UNIQUE_ACCEPT_STATS,
01812 outputModuleId, now)
01813 << "</td>" << std::endl;
01814 *out << " <td align=\"center\">"
01815 << eventServer->getEventRate(EventServer::LONG_TERM_STATS,
01816 EventServer::UNIQUE_ACCEPT_STATS,
01817 outputModuleId, now)
01818 << "</td>" << std::endl;
01819 *out << " <td align=\"center\">"
01820 << eventServer->getDataRate(EventServer::LONG_TERM_STATS,
01821 EventServer::UNIQUE_ACCEPT_STATS,
01822 outputModuleId, now)
01823 << "</td>" << std::endl;
01824 *out << " <td align=\"center\">"
01825 << eventServer->getDuration(EventServer::LONG_TERM_STATS,
01826 EventServer::UNIQUE_ACCEPT_STATS,
01827 outputModuleId, now)
01828 << "</td>" << std::endl;
01829 *out << "</tr>" << std::endl;
01830 }
01831
01832
01833 if (initMsgCollection->size() > 1) {
01834 *out << "<tr>" << std::endl;
01835 *out << " <td align=\"center\">Totals</td>" << std::endl;
01836 *out << " <td align=\"center\">" << eventSum << "</td>" << std::endl;
01837 *out << " <td align=\"center\">" << eventRateSum << "</td>" << std::endl;
01838 *out << " <td align=\"center\">" << dataRateSum << "</td>" << std::endl;
01839 *out << " <td align=\"center\"> </td>" << std::endl;
01840 *out << "</tr>" << std::endl;
01841 }
01842 *out << "</table>" << std::endl;
01843
01844 *out << "<h4 class=\"noBotMarg\">Accepted Events To All Consumers, Full Results:</h4>" << std::endl;
01845 *out << "<font size=\"-1\">(Events can be double-counted if they are sent by multiple output modules or if they are sent to multiple consumers.)</font><br/><br/>" << std::endl;
01846 *out << "<table border=\"1\" width=\"100%\">" << std::endl;
01847 *out << "<tr>" << std::endl;
01848 *out << " <th>HLT Output Module</th>" << std::endl;
01849 *out << " <th>Event Count</th>" << std::endl;
01850 *out << " <th>Event Rate</th>" << std::endl;
01851 *out << " <th>Data Rate</th>" << std::endl;
01852 *out << " <th>Duration (sec)</th>" << std::endl;
01853 *out << "</tr>" << std::endl;
01854
01855 eventSum = 0.0;
01856 eventRateSum = 0.0;
01857 dataRateSum = 0.0;
01858 for (int idx = 0; idx < initMsgCollection->size(); ++idx) {
01859 InitMsgSharedPtr serializedProds = initMsgCollection->getElementAt(idx);
01860 InitMsgView initView(&(*serializedProds)[0]);
01861 uint32 outputModuleId = initView.outputModuleId();
01862
01863 eventSum += eventServer->getEventCount(EventServer::LONG_TERM_STATS,
01864 EventServer::OUTPUT_STATS,
01865 outputModuleId, now);
01866 eventRateSum += eventServer->getEventRate(EventServer::LONG_TERM_STATS,
01867 EventServer::OUTPUT_STATS,
01868 outputModuleId, now);
01869 dataRateSum += eventServer->getDataRate(EventServer::LONG_TERM_STATS,
01870 EventServer::OUTPUT_STATS,
01871 outputModuleId, now);
01872
01873 *out << "<tr>" << std::endl;
01874 *out << " <td align=\"center\">" << initView.outputModuleLabel()
01875 << "</td>" << std::endl;
01876 *out << " <td align=\"center\">"
01877 << eventServer->getEventCount(EventServer::LONG_TERM_STATS,
01878 EventServer::OUTPUT_STATS,
01879 outputModuleId, now)
01880 << "</td>" << std::endl;
01881 *out << " <td align=\"center\">"
01882 << eventServer->getEventRate(EventServer::LONG_TERM_STATS,
01883 EventServer::OUTPUT_STATS,
01884 outputModuleId, now)
01885 << "</td>" << std::endl;
01886 *out << " <td align=\"center\">"
01887 << eventServer->getDataRate(EventServer::LONG_TERM_STATS,
01888 EventServer::OUTPUT_STATS,
01889 outputModuleId, now)
01890 << "</td>" << std::endl;
01891 *out << " <td align=\"center\">"
01892 << eventServer->getDuration(EventServer::LONG_TERM_STATS,
01893 EventServer::OUTPUT_STATS,
01894 outputModuleId, now)
01895 << "</td>" << std::endl;
01896 *out << "</tr>" << std::endl;
01897 }
01898
01899
01900 if (initMsgCollection->size() > 1) {
01901 *out << "<tr>" << std::endl;
01902 *out << " <td align=\"center\">Totals</td>" << std::endl;
01903 *out << " <td align=\"center\">" << eventSum << "</td>" << std::endl;
01904 *out << " <td align=\"center\">" << eventRateSum << "</td>" << std::endl;
01905 *out << " <td align=\"center\">" << dataRateSum << "</td>" << std::endl;
01906 *out << " <td align=\"center\"> </td>" << std::endl;
01907 *out << "</tr>" << std::endl;
01908 }
01909 *out << "</table>" << std::endl;
01910
01911 *out << "<h4>Timing:</h4>" << std::endl;
01912 *out << "<table border=\"1\" width=\"100%\">" << std::endl;
01913 *out << "<tr>" << std::endl;
01914 *out << " <th> </th>" << std::endl;
01915 *out << " <th>CPU Time<br/>(sec)</th>" << std::endl;
01916 *out << " <th>CPU Time<br/>Percent</th>" << std::endl;
01917 *out << " <th>Real Time<br/>(sec)</th>" << std::endl;
01918 *out << " <th>Real Time<br/>Percent</th>" << std::endl;
01919 *out << " <th>Duration (sec)</th>" << std::endl;
01920 *out << "</tr>" << std::endl;
01921 *out << "<tr>" << std::endl;
01922 *out << " <td align=\"center\">Recent Results</td>" << std::endl;
01923 *out << " <td align=\"center\">"
01924 << eventServer->getInternalTime(EventServer::SHORT_TERM_STATS,
01925 EventServer::CPUTIME,
01926 now)
01927 << "</td>" << std::endl;
01928 *out << " <td align=\"center\">"
01929 << 100 * eventServer->getTimeFraction(EventServer::SHORT_TERM_STATS,
01930 EventServer::CPUTIME,
01931 now)
01932 << "</td>" << std::endl;
01933 *out << " <td align=\"center\">"
01934 << eventServer->getInternalTime(EventServer::SHORT_TERM_STATS,
01935 EventServer::REALTIME,
01936 now)
01937 << "</td>" << std::endl;
01938 *out << " <td align=\"center\">"
01939 << 100 * eventServer->getTimeFraction(EventServer::SHORT_TERM_STATS,
01940 EventServer::REALTIME,
01941 now)
01942 << "</td>" << std::endl;
01943 *out << " <td align=\"center\">"
01944 << eventServer->getTotalTime(EventServer::SHORT_TERM_STATS,
01945 EventServer::REALTIME,
01946 now)
01947 << "</td>" << std::endl;
01948 *out << "</tr>" << std::endl;
01949 *out << "<tr>" << std::endl;
01950 *out << " <td align=\"center\">Full Results</td>" << std::endl;
01951 *out << " <td align=\"center\">"
01952 << eventServer->getInternalTime(EventServer::LONG_TERM_STATS,
01953 EventServer::CPUTIME,
01954 now)
01955 << "</td>" << std::endl;
01956 *out << " <td align=\"center\">"
01957 << 100 * eventServer->getTimeFraction(EventServer::LONG_TERM_STATS,
01958 EventServer::CPUTIME,
01959 now)
01960 << "</td>" << std::endl;
01961 *out << " <td align=\"center\">"
01962 << eventServer->getInternalTime(EventServer::LONG_TERM_STATS,
01963 EventServer::REALTIME,
01964 now)
01965 << "</td>" << std::endl;
01966 *out << " <td align=\"center\">"
01967 << 100 * eventServer->getTimeFraction(EventServer::LONG_TERM_STATS,
01968 EventServer::REALTIME,
01969 now)
01970 << "</td>" << std::endl;
01971 *out << " <td align=\"center\">"
01972 << eventServer->getTotalTime(EventServer::LONG_TERM_STATS,
01973 EventServer::REALTIME,
01974 now)
01975 << "</td>" << std::endl;
01976 *out << "</tr>" << std::endl;
01977 *out << "</table>" << std::endl;
01978
01979 *out << "<h3>Consumers:</h3>" << std::endl;
01980 std::map< uint32, boost::shared_ptr<ConsumerPipe> > consumerTable =
01981 eventServer->getConsumerTable();
01982 if (consumerTable.size() == 0)
01983 {
01984 *out << "No consumers are currently registered with "
01985 << "this SMProxyServer instance.<br/>" << std::endl;
01986 }
01987 else
01988 {
01989 std::map< uint32, boost::shared_ptr<ConsumerPipe> >::const_iterator
01990 consumerIter;
01991
01992
01993
01994
01995 *out << "<h4>Summary:</h4>" << std::endl;
01996 *out << "<table border=\"1\" width=\"100%\">" << std::endl;
01997 *out << "<tr>" << std::endl;
01998 *out << " <th>ID</th>" << std::endl;
01999 *out << " <th>Name</th>" << std::endl;
02000 *out << " <th>State</th>" << std::endl;
02001 *out << " <th>Requested<br/>Rate</th>" << std::endl;
02002 *out << " <th>Requested HLT<br/>Output Module</th>" << std::endl;
02003 *out << " <th>Trigger<br/>Request</th>" << std::endl;
02004 *out << "</tr>" << std::endl;
02005
02006 for (consumerIter = consumerTable.begin();
02007 consumerIter != consumerTable.end();
02008 consumerIter++)
02009 {
02010 boost::shared_ptr<ConsumerPipe> consPtr = consumerIter->second;
02011 *out << "<tr>" << std::endl;
02012 *out << " <td align=\"center\">" << consPtr->getConsumerId()
02013 << "</td>" << std::endl;
02014
02015 *out << " <td align=\"center\">";
02016 if (consPtr->isProxyServer()) {
02017 *out << "Proxy Server";
02018 }
02019 else {
02020 *out << consPtr->getConsumerName();
02021 }
02022 *out << "</td>" << std::endl;
02023
02024 *out << " <td align=\"center\">";
02025 if (consPtr->isDisconnected()) {
02026 *out << "Disconnected";
02027 }
02028 else if (consPtr->isIdle()) {
02029 *out << "Idle";
02030 }
02031 else {
02032 *out << "Active";
02033 }
02034 *out << "</td>" << std::endl;
02035
02036 *out << " <td align=\"center\">" << consPtr->getRateRequest()
02037 << " Hz</td>" << std::endl;
02038
02039 {
02040 std::string hltOut = consPtr->getHLTOutputSelection();
02041 if (hltOut.empty()) {
02042 *out << " <td align=\"center\"><none></td>" << std::endl;
02043 }
02044 else {
02045 *out << " <td align=\"center\">" << hltOut
02046 << "</td>" << std::endl;
02047 }
02048 }
02049
02050 *out << " <td align=\"center\">"
02051 << InitMsgCollection::stringsToText(consPtr->getTriggerSelection(), 5)
02052 << "</td>" << std::endl;
02053
02054 *out << "</tr>" << std::endl;
02055 }
02056 *out << "</table>" << std::endl;
02057
02058
02059
02060
02061 *out << "<h4>Queued Events, Recent Results:</h4>" << std::endl;
02062 *out << "<table border=\"1\" width=\"100%\">" << std::endl;
02063 *out << "<tr>" << std::endl;
02064 *out << " <th>ID</th>" << std::endl;
02065 *out << " <th>Name</th>" << std::endl;
02066 *out << " <th>Event Count</th>" << std::endl;
02067 *out << " <th>Event Rate</th>" << std::endl;
02068 *out << " <th>Data Rate</th>" << std::endl;
02069 *out << " <th>Duration<br/>(sec)</th>" << std::endl;
02070 *out << " <th>Average<br/>Queue Size</th>" << std::endl;
02071 *out << "</tr>" << std::endl;
02072
02073 displayedConsumerCount = 0;
02074 eventSum = 0.0;
02075 eventRateSum = 0.0;
02076 dataRateSum = 0.0;
02077 for (consumerIter = consumerTable.begin();
02078 consumerIter != consumerTable.end();
02079 consumerIter++)
02080 {
02081 boost::shared_ptr<ConsumerPipe> consPtr = consumerIter->second;
02082 if (consPtr->isDisconnected()) {continue;}
02083
02084 ++displayedConsumerCount;
02085 eventSum += consPtr->getEventCount(ConsumerPipe::SHORT_TERM,
02086 ConsumerPipe::QUEUED_EVENTS,
02087 now);
02088 eventRateSum += consPtr->getEventRate(ConsumerPipe::SHORT_TERM,
02089 ConsumerPipe::QUEUED_EVENTS,
02090 now);
02091 dataRateSum += consPtr->getDataRate(ConsumerPipe::SHORT_TERM,
02092 ConsumerPipe::QUEUED_EVENTS,
02093 now);
02094
02095 *out << "<tr>" << std::endl;
02096 *out << " <td align=\"center\">" << consPtr->getConsumerId()
02097 << "</td>" << std::endl;
02098 *out << " <td align=\"center\">";
02099 if (consPtr->isProxyServer()) {
02100 *out << "Proxy Server";
02101 }
02102 else {
02103 *out << consPtr->getConsumerName();
02104 }
02105 *out << "</td>" << std::endl;
02106
02107 *out << " <td align=\"center\">"
02108 << consPtr->getEventCount(ConsumerPipe::SHORT_TERM,
02109 ConsumerPipe::QUEUED_EVENTS,
02110 now)
02111 << "</td>" << std::endl;
02112 *out << " <td align=\"center\">"
02113 << consPtr->getEventRate(ConsumerPipe::SHORT_TERM,
02114 ConsumerPipe::QUEUED_EVENTS,
02115 now)
02116 << "</td>" << std::endl;
02117 *out << " <td align=\"center\">"
02118 << consPtr->getDataRate(ConsumerPipe::SHORT_TERM,
02119 ConsumerPipe::QUEUED_EVENTS,
02120 now)
02121 << "</td>" << std::endl;
02122 *out << " <td align=\"center\">"
02123 << consPtr->getDuration(ConsumerPipe::SHORT_TERM,
02124 ConsumerPipe::QUEUED_EVENTS,
02125 now)
02126 << "</td>" << std::endl;
02127 *out << " <td align=\"center\">"
02128 << consPtr->getAverageQueueSize(ConsumerPipe::SHORT_TERM,
02129 ConsumerPipe::QUEUED_EVENTS,
02130 now)
02131 << "</td>" << std::endl;
02132 *out << "</tr>" << std::endl;
02133 }
02134
02135
02136 if (displayedConsumerCount > 1) {
02137 *out << "<tr>" << std::endl;
02138 *out << " <td align=\"center\"> </td>" << std::endl;
02139 *out << " <td align=\"center\">Totals</td>" << std::endl;
02140 *out << " <td align=\"center\">" << eventSum << "</td>" << std::endl;
02141 *out << " <td align=\"center\">" << eventRateSum << "</td>" << std::endl;
02142 *out << " <td align=\"center\">" << dataRateSum << "</td>" << std::endl;
02143 *out << " <td align=\"center\"> </td>" << std::endl;
02144 *out << " <td align=\"center\"> </td>" << std::endl;
02145 *out << "</tr>" << std::endl;
02146 }
02147 *out << "</table>" << std::endl;
02148
02149
02150
02151
02152 *out << "<h4>Served Events, Recent Results:</h4>" << std::endl;
02153 *out << "<table border=\"1\" width=\"100%\">" << std::endl;
02154 *out << "<tr>" << std::endl;
02155 *out << " <th>ID</th>" << std::endl;
02156 *out << " <th>Name</th>" << std::endl;
02157 *out << " <th>Event Count</th>" << std::endl;
02158 *out << " <th>Event Rate</th>" << std::endl;
02159 *out << " <th>Data Rate</th>" << std::endl;
02160 *out << " <th>Duration (sec)</th>" << std::endl;
02161 *out << "</tr>" << std::endl;
02162
02163 displayedConsumerCount = 0;
02164 eventSum = 0.0;
02165 eventRateSum = 0.0;
02166 dataRateSum = 0.0;
02167 for (consumerIter = consumerTable.begin();
02168 consumerIter != consumerTable.end();
02169 consumerIter++)
02170 {
02171 boost::shared_ptr<ConsumerPipe> consPtr = consumerIter->second;
02172 if (consPtr->isDisconnected()) {continue;}
02173
02174 ++displayedConsumerCount;
02175 eventSum += consPtr->getEventCount(ConsumerPipe::SHORT_TERM,
02176 ConsumerPipe::SERVED_EVENTS,
02177 now);
02178 eventRateSum += consPtr->getEventRate(ConsumerPipe::SHORT_TERM,
02179 ConsumerPipe::SERVED_EVENTS,
02180 now);
02181 dataRateSum += consPtr->getDataRate(ConsumerPipe::SHORT_TERM,
02182 ConsumerPipe::SERVED_EVENTS,
02183 now);
02184
02185 *out << "<tr>" << std::endl;
02186 *out << " <td align=\"center\">" << consPtr->getConsumerId()
02187 << "</td>" << std::endl;
02188 *out << " <td align=\"center\">";
02189 if (consPtr->isProxyServer()) {
02190 *out << "Proxy Server";
02191 }
02192 else {
02193 *out << consPtr->getConsumerName();
02194 }
02195 *out << "</td>" << std::endl;
02196
02197 *out << " <td align=\"center\">"
02198 << consPtr->getEventCount(ConsumerPipe::SHORT_TERM,
02199 ConsumerPipe::SERVED_EVENTS,
02200 now)
02201 << "</td>" << std::endl;
02202 *out << " <td align=\"center\">"
02203 << consPtr->getEventRate(ConsumerPipe::SHORT_TERM,
02204 ConsumerPipe::SERVED_EVENTS,
02205 now)
02206 << "</td>" << std::endl;
02207 *out << " <td align=\"center\">"
02208 << consPtr->getDataRate(ConsumerPipe::SHORT_TERM,
02209 ConsumerPipe::SERVED_EVENTS,
02210 now)
02211 << "</td>" << std::endl;
02212 *out << " <td align=\"center\">"
02213 << consPtr->getDuration(ConsumerPipe::SHORT_TERM,
02214 ConsumerPipe::SERVED_EVENTS,
02215 now)
02216 << "</td>" << std::endl;
02217 *out << "</tr>" << std::endl;
02218 }
02219
02220
02221 if (displayedConsumerCount > 1) {
02222 *out << "<tr>" << std::endl;
02223 *out << " <td align=\"center\"> </td>" << std::endl;
02224 *out << " <td align=\"center\">Totals</td>" << std::endl;
02225 *out << " <td align=\"center\">" << eventSum << "</td>" << std::endl;
02226 *out << " <td align=\"center\">" << eventRateSum << "</td>" << std::endl;
02227 *out << " <td align=\"center\">" << dataRateSum << "</td>" << std::endl;
02228 *out << " <td align=\"center\"> </td>" << std::endl;
02229 *out << "</tr>" << std::endl;
02230 }
02231 *out << "</table>" << std::endl;
02232
02233
02234
02235
02236 *out << "<h4>Queued Events, Full Results:</h4>" << std::endl;
02237 *out << "<table border=\"1\" width=\"100%\">" << std::endl;
02238 *out << "<tr>" << std::endl;
02239 *out << " <th>ID</th>" << std::endl;
02240 *out << " <th>Name</th>" << std::endl;
02241 *out << " <th>Event Count</th>" << std::endl;
02242 *out << " <th>Event Rate</th>" << std::endl;
02243 *out << " <th>Data Rate</th>" << std::endl;
02244 *out << " <th>Duration<br/>(sec)</th>" << std::endl;
02245 *out << " <th>Average<br/>Queue Size</th>" << std::endl;
02246 *out << "</tr>" << std::endl;
02247
02248 displayedConsumerCount = 0;
02249 eventSum = 0.0;
02250 eventRateSum = 0.0;
02251 dataRateSum = 0.0;
02252 for (consumerIter = consumerTable.begin();
02253 consumerIter != consumerTable.end();
02254 consumerIter++)
02255 {
02256 boost::shared_ptr<ConsumerPipe> consPtr = consumerIter->second;
02257 if (consPtr->isDisconnected()) {continue;}
02258
02259 ++displayedConsumerCount;
02260 eventSum += consPtr->getEventCount(ConsumerPipe::LONG_TERM,
02261 ConsumerPipe::QUEUED_EVENTS,
02262 now);
02263 eventRateSum += consPtr->getEventRate(ConsumerPipe::LONG_TERM,
02264 ConsumerPipe::QUEUED_EVENTS,
02265 now);
02266 dataRateSum += consPtr->getDataRate(ConsumerPipe::LONG_TERM,
02267 ConsumerPipe::QUEUED_EVENTS,
02268 now);
02269
02270 *out << "<tr>" << std::endl;
02271 *out << " <td align=\"center\">" << consPtr->getConsumerId()
02272 << "</td>" << std::endl;
02273 *out << " <td align=\"center\">";
02274 if (consPtr->isProxyServer()) {
02275 *out << "Proxy Server";
02276 }
02277 else {
02278 *out << consPtr->getConsumerName();
02279 }
02280 *out << "</td>" << std::endl;
02281
02282 *out << " <td align=\"center\">"
02283 << consPtr->getEventCount(ConsumerPipe::LONG_TERM,
02284 ConsumerPipe::QUEUED_EVENTS,
02285 now)
02286 << "</td>" << std::endl;
02287 *out << " <td align=\"center\">"
02288 << consPtr->getEventRate(ConsumerPipe::LONG_TERM,
02289 ConsumerPipe::QUEUED_EVENTS,
02290 now)
02291 << "</td>" << std::endl;
02292 *out << " <td align=\"center\">"
02293 << consPtr->getDataRate(ConsumerPipe::LONG_TERM,
02294 ConsumerPipe::QUEUED_EVENTS,
02295 now)
02296 << "</td>" << std::endl;
02297 *out << " <td align=\"center\">"
02298 << consPtr->getDuration(ConsumerPipe::LONG_TERM,
02299 ConsumerPipe::QUEUED_EVENTS,
02300 now)
02301 << "</td>" << std::endl;
02302 *out << " <td align=\"center\">"
02303 << consPtr->getAverageQueueSize(ConsumerPipe::LONG_TERM,
02304 ConsumerPipe::QUEUED_EVENTS,
02305 now)
02306 << "</td>" << std::endl;
02307 *out << "</tr>" << std::endl;
02308 }
02309
02310
02311 if (displayedConsumerCount > 1) {
02312 *out << "<tr>" << std::endl;
02313 *out << " <td align=\"center\"> </td>" << std::endl;
02314 *out << " <td align=\"center\">Totals</td>" << std::endl;
02315 *out << " <td align=\"center\">" << eventSum << "</td>" << std::endl;
02316 *out << " <td align=\"center\">" << eventRateSum << "</td>" << std::endl;
02317 *out << " <td align=\"center\">" << dataRateSum << "</td>" << std::endl;
02318 *out << " <td align=\"center\"> </td>" << std::endl;
02319 *out << " <td align=\"center\"> </td>" << std::endl;
02320 *out << "</tr>" << std::endl;
02321 }
02322 *out << "</table>" << std::endl;
02323
02324
02325
02326
02327 *out << "<h4>Served Events, Full Results:</h4>" << std::endl;
02328 *out << "<table border=\"1\" width=\"100%\">" << std::endl;
02329 *out << "<tr>" << std::endl;
02330 *out << " <th>ID</th>" << std::endl;
02331 *out << " <th>Name</th>" << std::endl;
02332 *out << " <th>Event Count</th>" << std::endl;
02333 *out << " <th>Event Rate</th>" << std::endl;
02334 *out << " <th>Data Rate</th>" << std::endl;
02335 *out << " <th>Duration (sec)</th>" << std::endl;
02336 *out << "</tr>" << std::endl;
02337
02338 displayedConsumerCount = 0;
02339 eventSum = 0.0;
02340 eventRateSum = 0.0;
02341 dataRateSum = 0.0;
02342 for (consumerIter = consumerTable.begin();
02343 consumerIter != consumerTable.end();
02344 consumerIter++)
02345 {
02346 boost::shared_ptr<ConsumerPipe> consPtr = consumerIter->second;
02347 if (consPtr->isDisconnected ()) {continue;}
02348
02349 ++displayedConsumerCount;
02350 eventSum += consPtr->getEventCount(ConsumerPipe::LONG_TERM,
02351 ConsumerPipe::SERVED_EVENTS,
02352 now);
02353 eventRateSum += consPtr->getEventRate(ConsumerPipe::LONG_TERM,
02354 ConsumerPipe::SERVED_EVENTS,
02355 now);
02356 dataRateSum += consPtr->getDataRate(ConsumerPipe::LONG_TERM,
02357 ConsumerPipe::SERVED_EVENTS,
02358 now);
02359
02360 *out << "<tr>" << std::endl;
02361 *out << " <td align=\"center\">" << consPtr->getConsumerId()
02362 << "</td>" << std::endl;
02363 *out << " <td align=\"center\">";
02364 if (consPtr->isProxyServer()) {
02365 *out << "Proxy Server";
02366 }
02367 else {
02368 *out << consPtr->getConsumerName();
02369 }
02370 *out << "</td>" << std::endl;
02371
02372 *out << " <td align=\"center\">"
02373 << consPtr->getEventCount(ConsumerPipe::LONG_TERM,
02374 ConsumerPipe::SERVED_EVENTS,
02375 now)
02376 << "</td>" << std::endl;
02377 *out << " <td align=\"center\">"
02378 << consPtr->getEventRate(ConsumerPipe::LONG_TERM,
02379 ConsumerPipe::SERVED_EVENTS,
02380 now)
02381 << "</td>" << std::endl;
02382 *out << " <td align=\"center\">"
02383 << consPtr->getDataRate(ConsumerPipe::LONG_TERM,
02384 ConsumerPipe::SERVED_EVENTS,
02385 now)
02386 << "</td>" << std::endl;
02387 *out << " <td align=\"center\">"
02388 << consPtr->getDuration(ConsumerPipe::LONG_TERM,
02389 ConsumerPipe::SERVED_EVENTS,
02390 now)
02391 << "</td>" << std::endl;
02392 *out << "</tr>" << std::endl;
02393 }
02394
02395
02396 if (displayedConsumerCount > 1) {
02397 *out << "<tr>" << std::endl;
02398 *out << " <td align=\"center\"> </td>" << std::endl;
02399 *out << " <td align=\"center\">Totals</td>" << std::endl;
02400 *out << " <td align=\"center\">" << eventSum << "</td>" << std::endl;
02401 *out << " <td align=\"center\">" << eventRateSum << "</td>" << std::endl;
02402 *out << " <td align=\"center\">" << dataRateSum << "</td>" << std::endl;
02403 *out << " <td align=\"center\"> </td>" << std::endl;
02404 *out << "</tr>" << std::endl;
02405 }
02406 *out << "</table>" << std::endl;
02407 }
02408
02409
02410
02411
02412 *out << "<h3>HTTP Timing:</h3>" << std::endl;
02413 *out << "<h4>Event Retrieval from Storage Manager(s):</h4>"
02414 << std::endl;
02415 *out << "<table border=\"1\" width=\"100%\">" << std::endl;
02416 *out << "<tr>" << std::endl;
02417 *out << " <th> </th>" << std::endl;
02418 *out << " <th>Average Time per<br/>Request (sec)</th>" << std::endl;
02419 *out << " <th>Number of<br/>Requests</th>" << std::endl;
02420 *out << " <th>Measurement<br/>Duration (sec)</th>" << std::endl;
02421 *out << "</tr>" << std::endl;
02422 *out << "<tr>" << std::endl;
02423 *out << " <td align=\"center\">Recent Results</td>" << std::endl;
02424 *out << " <td align=\"center\">"
02425 << dpm_->getAverageValue(DataProcessManager::SHORT_TERM,
02426 DataProcessManager::EVENT_FETCH,
02427 now)
02428 << "</td>" << std::endl;
02429 *out << " <td align=\"center\">"
02430 << dpm_->getSampleCount(DataProcessManager::SHORT_TERM,
02431 DataProcessManager::EVENT_FETCH,
02432 now)
02433 << "</td>" << std::endl;
02434 *out << " <td align=\"center\">"
02435 << dpm_->getDuration(DataProcessManager::SHORT_TERM,
02436 DataProcessManager::EVENT_FETCH,
02437 now)
02438 << "</td>" << std::endl;
02439 *out << "</tr>" << std::endl;
02440 *out << "<tr>" << std::endl;
02441 *out << " <td align=\"center\">Full Results</td>" << std::endl;
02442 *out << " <td align=\"center\">"
02443 << dpm_->getAverageValue(DataProcessManager::LONG_TERM,
02444 DataProcessManager::EVENT_FETCH,
02445 now)
02446 << "</td>" << std::endl;
02447 *out << " <td align=\"center\">"
02448 << dpm_->getSampleCount(DataProcessManager::LONG_TERM,
02449 DataProcessManager::EVENT_FETCH,
02450 now)
02451 << "</td>" << std::endl;
02452 *out << " <td align=\"center\">"
02453 << dpm_->getDuration(DataProcessManager::LONG_TERM,
02454 DataProcessManager::EVENT_FETCH,
02455 now)
02456 << "</td>" << std::endl;
02457 *out << "</tr>" << std::endl;
02458 *out << "</table>" << std::endl;
02459
02460 *out << "<h4>DQM Event Retrieval from Storage Manager(s):</h4>"
02461 << std::endl;
02462 *out << "<table border=\"1\" width=\"100%\">" << std::endl;
02463 *out << "<tr>" << std::endl;
02464 *out << " <th> </th>" << std::endl;
02465 *out << " <th>Average Time per<br/>Request (sec)</th>" << std::endl;
02466 *out << " <th>Number of<br/>Requests</th>" << std::endl;
02467 *out << " <th>Measurement<br/>Duration (sec)</th>" << std::endl;
02468 *out << "</tr>" << std::endl;
02469 *out << "<tr>" << std::endl;
02470 *out << " <td align=\"center\">Recent Results</td>" << std::endl;
02471 *out << " <td align=\"center\">"
02472 << dpm_->getAverageValue(DataProcessManager::SHORT_TERM,
02473 DataProcessManager::DQMEVENT_FETCH,
02474 now)
02475 << "</td>" << std::endl;
02476 *out << " <td align=\"center\">"
02477 << dpm_->getSampleCount(DataProcessManager::SHORT_TERM,
02478 DataProcessManager::DQMEVENT_FETCH,
02479 now)
02480 << "</td>" << std::endl;
02481 *out << " <td align=\"center\">"
02482 << dpm_->getDuration(DataProcessManager::SHORT_TERM,
02483 DataProcessManager::DQMEVENT_FETCH,
02484 now)
02485 << "</td>" << std::endl;
02486 *out << "</tr>" << std::endl;
02487 *out << "<tr>" << std::endl;
02488 *out << " <td align=\"center\">Full Results</td>" << std::endl;
02489 *out << " <td align=\"center\">"
02490 << dpm_->getAverageValue(DataProcessManager::LONG_TERM,
02491 DataProcessManager::DQMEVENT_FETCH,
02492 now)
02493 << "</td>" << std::endl;
02494 *out << " <td align=\"center\">"
02495 << dpm_->getSampleCount(DataProcessManager::LONG_TERM,
02496 DataProcessManager::DQMEVENT_FETCH,
02497 now)
02498 << "</td>" << std::endl;
02499 *out << " <td align=\"center\">"
02500 << dpm_->getDuration(DataProcessManager::LONG_TERM,
02501 DataProcessManager::DQMEVENT_FETCH,
02502 now)
02503 << "</td>" << std::endl;
02504 *out << "</tr>" << std::endl;
02505 *out << "</table>" << std::endl;
02506 }
02507 else
02508 {
02509 *out << "<br/>Waiting for INIT messages from the Storage Managers...<br/>"
02510 << std::endl;
02511 }
02512 }
02513 else
02514 {
02515 *out << "<br/>The system is unable to fetch the Event Server "
02516 << "instance or the Init Message Collection instance. "
02517 << "This is a (very) unexpected error and could "
02518 << "be caused by an uninitialized DataProcessManager.<br/>"
02519 << std::endl;
02520 }
02521
02522 if(dpm_->getInitMsgCollection().get() != NULL &&
02523 dpm_->getInitMsgCollection()->size() > 0)
02524 {
02525 boost::shared_ptr<InitMsgCollection> initMsgCollection =
02526 dpm_->getInitMsgCollection();
02527 *out << "<h3>HLT Trigger Paths:</h3>" << std::endl;
02528 *out << "<table border=\"1\" width=\"100%\">" << std::endl;
02529
02530 {
02531 InitMsgSharedPtr serializedProds = initMsgCollection->getLastElement();
02532 InitMsgView initView(&(*serializedProds)[0]);
02533 Strings triggerNameList;
02534 initView.hltTriggerNames(triggerNameList);
02535
02536 *out << "<tr>" << std::endl;
02537 *out << " <td align=\"left\" valign=\"top\">"
02538 << "Full Trigger List</td>" << std::endl;
02539 *out << " <td align=\"left\" valign=\"top\">"
02540 << InitMsgCollection::stringsToText(triggerNameList, 0)
02541 << "</td>" << std::endl;
02542 *out << "</tr>" << std::endl;
02543 }
02544
02545 for (int idx = 0; idx < initMsgCollection->size(); ++idx) {
02546 InitMsgSharedPtr serializedProds = initMsgCollection->getElementAt(idx);
02547 InitMsgView initView(&(*serializedProds)[0]);
02548 Strings triggerSelectionList;
02549 initView.hltTriggerSelections(triggerSelectionList);
02550
02551 *out << "<tr>" << std::endl;
02552 *out << " <td align=\"left\" valign=\"top\">"
02553 << initView.outputModuleLabel()
02554 << " Output Module</td>" << std::endl;
02555 *out << " <td align=\"left\" valign=\"top\">"
02556 << InitMsgCollection::stringsToText(triggerSelectionList, 0)
02557 << "</td>" << std::endl;
02558 *out << "</tr>" << std::endl;
02559 }
02560
02561 *out << "</table>" << std::endl;
02562 }
02563 }
02564 else
02565 {
02566 *out << "<br/>Event server statistics are only available when the "
02567 << "SMProxyServer is in the Enabled state.<br/>" << std::endl;
02568 }
02569
02570 *out << "<br/><hr/>" << std::endl;
02571 char timeString[64];
02572 time_t now = time(0);
02573 strftime(timeString, 60, "%d-%b-%Y %H:%M:%S %Z", localtime(&now));
02574 *out << "Last updated: " << timeString << std::endl;;
02575 *out << "</body>" << std::endl;
02576 *out << "</html>" << std::endl;
02577 }
02578
02580 void SMProxyServer::DQMeventdataWebPage(xgi::Input *in, xgi::Output *out)
02581 throw (xgi::exception::Exception)
02582 {
02583
02584 int len=0;
02585
02586
02587
02588 unsigned int consumerId = 0;
02589 std::string lengthString = in->getenv("CONTENT_LENGTH");
02590 unsigned int contentLength = std::atol(lengthString.c_str());
02591 if (contentLength > 0)
02592 {
02593 auto_ptr< vector<char> > bufPtr(new vector<char>(contentLength));
02594 in->read(&(*bufPtr)[0], contentLength);
02595 OtherMessageView requestMessage(&(*bufPtr)[0]);
02596
02597 if (requestMessage.code() == Header::DQMEVENT_REQUEST)
02598 {
02599 uint8 *bodyPtr = requestMessage.msgBody();
02600 consumerId = convert32(bodyPtr);
02601 }
02602 }
02603
02604
02605
02606 if(fsm_.stateName()->toString() == "Enabled" && consumerId != 0)
02607 {
02608 boost::shared_ptr<DQMEventServer> eventServer;
02609 if (dpm_.get() != NULL)
02610 {
02611 eventServer = dpm_->getDQMEventServer();
02612 }
02613 if (eventServer.get() != NULL)
02614 {
02615 boost::shared_ptr< std::vector<char> > bufPtr =
02616 eventServer->getDQMEvent(consumerId);
02617 if (bufPtr.get() != NULL)
02618 {
02619 DQMEventMsgView msgView(&(*bufPtr)[0]);
02620
02621
02622 unsigned char* from = msgView.startAddress();
02623 unsigned int dsize = msgView.size();
02624 if(dsize > mybuffer_.capacity() ) mybuffer_.resize(dsize);
02625 unsigned char* pos = (unsigned char*) &mybuffer_[0];
02626
02627 copy(from,from+dsize,pos);
02628 len = dsize;
02629 FDEBUG(10) << "sending update at event " << msgView.eventNumberAtUpdate() << std::endl;
02630 ++sentDQMEvents_;
02631 addOutMeasurement(len);
02632 }
02633 }
02634
02635
02636
02637 out->getHTTPResponseHeader().addHeader("Content-Type", "application/octet-stream");
02638 out->getHTTPResponseHeader().addHeader("Content-Transfer-Encoding", "binary");
02639 out->write((char*) &mybuffer_[0],len);
02640 }
02641 else
02642 {
02643
02644 OtherMessageBuilder othermsg(&mybuffer_[0],Header::DONE);
02645 len = othermsg.size();
02646
02647 out->getHTTPResponseHeader().addHeader("Content-Type", "application/octet-stream");
02648 out->getHTTPResponseHeader().addHeader("Content-Transfer-Encoding", "binary");
02649 out->write((char*) &mybuffer_[0],len);
02650 }
02651
02652 }
02653
02655 void SMProxyServer::DQMconsumerWebPage(xgi::Input *in, xgi::Output *out)
02656 throw (xgi::exception::Exception)
02657 {
02658 if(fsm_.stateName()->toString() == "Enabled")
02659 {
02660
02661 std::string consumerName = "None provided";
02662 std::string consumerPriority = "normal";
02663 std::string consumerRequest = "*";
02664 std::string consumerHost = in->getenv("REMOTE_HOST");
02665
02666
02667 std::string lengthString = in->getenv("CONTENT_LENGTH");
02668 unsigned int contentLength = std::atol(lengthString.c_str());
02669 if (contentLength > 0)
02670 {
02671 auto_ptr< vector<char> > bufPtr(new vector<char>(contentLength));
02672 in->read(&(*bufPtr)[0], contentLength);
02673 ConsRegRequestView requestMessage(&(*bufPtr)[0]);
02674 consumerName = requestMessage.getConsumerName();
02675 consumerPriority = requestMessage.getConsumerPriority();
02676
02677 std::string reqFolder = requestMessage.getRequestParameterSet();
02678 if (reqFolder.size() >= 1) consumerRequest = reqFolder;
02679 }
02680
02681
02682 const int BUFFER_SIZE = 100;
02683 char msgBuff[BUFFER_SIZE];
02684
02685
02686
02687
02688 boost::shared_ptr<DQMEventServer> eventServer;
02689 if (dpm_.get() != NULL)
02690 {
02691 eventServer = dpm_->getDQMEventServer();
02692 }
02693
02694
02695 if (eventServer.get() == NULL)
02696 {
02697
02698 ConsRegResponseBuilder respMsg(msgBuff, BUFFER_SIZE,
02699 ConsRegResponseBuilder::ES_NOT_READY, 0);
02700
02701 FDEBUG(20) << "Registration response size = " <<
02702 respMsg.size() << std::endl;
02703 }
02704 else
02705 {
02706
02707 boost::shared_ptr<DQMConsumerPipe>
02708 consPtr(new DQMConsumerPipe(consumerName, consumerPriority,
02709 DQMactiveConsumerTimeout_.value_,
02710 DQMidleConsumerTimeout_.value_,
02711 consumerRequest, consumerHost,
02712 DQMconsumerQueueSize_));
02713 eventServer->addConsumer(consPtr);
02714
02715
02716
02717 consPtr->initializeSelection();
02718
02719
02720 ConsRegResponseBuilder respMsg(msgBuff, BUFFER_SIZE,
02721 0, consPtr->getConsumerId());
02722
02723 FDEBUG(20) << "Registration response size = " <<
02724 respMsg.size() << std::endl;
02725 }
02726
02727
02728 ConsRegResponseView responseMessage(msgBuff);
02729 unsigned int len = responseMessage.size();
02730 if(len > mybuffer_.capacity() ) mybuffer_.resize(len);
02731 for (int i=0; i<(int)len; i++) mybuffer_[i]=msgBuff[i];
02732
02733 out->getHTTPResponseHeader().addHeader("Content-Type", "application/octet-stream");
02734 out->getHTTPResponseHeader().addHeader("Content-Transfer-Encoding", "binary");
02735 out->write((char*) &mybuffer_[0],len);
02736
02737 } else {
02738
02739 int len = 0;
02740 out->getHTTPResponseHeader().addHeader("Content-Type", "application/octet-stream");
02741 out->getHTTPResponseHeader().addHeader("Content-Transfer-Encoding", "binary");
02742 out->write((char*) &mybuffer_[0],len);
02743 }
02744
02745 }
02746
02748 void SMProxyServer::receiveEventWebPage(xgi::Input *in, xgi::Output *out)
02749 throw (xgi::exception::Exception)
02750 {
02751 bool haveHeaderAlready = false;
02752 if(dpm_.get() != NULL) haveHeaderAlready = dpm_->haveHeader();
02753 if(fsm_.stateName()->toString() == "Enabled" && haveHeaderAlready)
02754 {
02755
02756
02757 std::string lengthString = in->getenv("CONTENT_LENGTH");
02758 unsigned long contentLength = std::atol(lengthString.c_str());
02759 if (contentLength > 0)
02760 {
02761
02762
02763 auto_ptr< vector<char> > bufPtr(new vector<char>(contentLength));
02764 in->read(&(*bufPtr)[0], contentLength);
02765 EventMsgView eventView(&(*bufPtr)[0]);
02766 boost::shared_ptr<EventServer> eventServer;
02767 if (dpm_.get() != NULL)
02768 {
02769 eventServer = dpm_->getEventServer();
02770 if(eventServer.get() != NULL) {
02771 eventServer->processEvent(eventView);
02772 }
02773 }
02774 ++receivedEvents_;
02775 addMeasurement(contentLength);
02776 }
02777
02778
02779
02780 int len = 0;
02781 out->getHTTPResponseHeader().addHeader("Content-Type", "application/octet-stream");
02782 out->getHTTPResponseHeader().addHeader("Content-Transfer-Encoding", "binary");
02783 out->write((char*) &mybuffer_[0],len);
02784 } else {
02785
02786 int len = 0;
02787 out->getHTTPResponseHeader().addHeader("Content-Type", "application/octet-stream");
02788 out->getHTTPResponseHeader().addHeader("Content-Transfer-Encoding", "binary");
02789 out->write((char*) &mybuffer_[0],len);
02790 }
02791
02792 }
02793
02795 void SMProxyServer::receiveDQMEventWebPage(xgi::Input *in, xgi::Output *out)
02796 throw (xgi::exception::Exception)
02797 {
02798 bool haveHeaderAlready = false;
02799 if(dpm_.get() != NULL) haveHeaderAlready = dpm_->haveHeader();
02800 if(fsm_.stateName()->toString() == "Enabled" && haveHeaderAlready)
02801 {
02802
02803
02804 std::string lengthString = in->getenv("CONTENT_LENGTH");
02805 unsigned long contentLength = std::atol(lengthString.c_str());
02806 if (contentLength > 0)
02807 {
02808
02809
02810 auto_ptr< vector<char> > bufPtr(new vector<char>(contentLength));
02811 in->read(&(*bufPtr)[0], contentLength);
02812 DQMEventMsgView dqmEventView(&(*bufPtr)[0]);
02813
02814
02815
02816
02817
02818
02819
02820
02821 boost::shared_ptr<stor::DQMServiceManager> dqmManager;
02822 if (dpm_.get() != NULL)
02823 {
02824 dqmManager = dpm_->getDQMServiceManager();
02825 if(dqmManager.get() != NULL) {
02826 dqmManager->manageDQMEventMsg(dqmEventView);
02827 }
02828 }
02829 ++receivedDQMEvents_;
02830 addMeasurement(contentLength);
02831 }
02832
02833
02834
02835 int len = 0;
02836 out->getHTTPResponseHeader().addHeader("Content-Type", "application/octet-stream");
02837 out->getHTTPResponseHeader().addHeader("Content-Transfer-Encoding", "binary");
02838 out->write((char*) &mybuffer_[0],len);
02839 } else {
02840
02841 int len = 0;
02842 out->getHTTPResponseHeader().addHeader("Content-Type", "application/octet-stream");
02843 out->getHTTPResponseHeader().addHeader("Content-Transfer-Encoding", "binary");
02844 out->write((char*) &mybuffer_[0],len);
02845 }
02846
02847
02848 }
02849
02850
02851
02852
02853
02854
02855
02856 void SMProxyServer::setupFlashList()
02857 {
02858
02859
02860
02861 class_ = getApplicationDescriptor()->getClassName();
02862 instance_ = getApplicationDescriptor()->getInstance();
02863 std::string url;
02864 url = getApplicationDescriptor()->getContextDescriptor()->getURL();
02865 url += "/";
02866 url += getApplicationDescriptor()->getURN();
02867 url_ = url;
02868
02869
02870
02871
02872 std::ostringstream oss;
02873 oss << "urn:xdaq-monitorable:" << class_.value_ << ":" << instance_.value_;
02874 toolbox::net::URN urn = this->createQualifiedInfoSpace(oss.str());
02875 xdata::InfoSpace *is = xdata::getInfoSpaceFactory()->get(urn.toString());
02876
02877
02878
02879
02880 is->fireItemAvailable("class", &class_);
02881 is->fireItemAvailable("instance", &instance_);
02882 is->fireItemAvailable("runNumber", &runNumber_);
02883 is->fireItemAvailable("url", &url_);
02884
02885 is->fireItemAvailable("storedDQMEvents", &storedDQMEvents_);
02886 is->fireItemAvailable("sentEvents", &sentEvents_);
02887 is->fireItemAvailable("sentDQMEvents", &sentDQMEvents_);
02888 is->fireItemAvailable("storedVolume", &storedVolume_);
02889 is->fireItemAvailable("instantBandwidth", &instantBandwidth_);
02890 is->fireItemAvailable("instantRate", &instantRate_);
02891 is->fireItemAvailable("instantLatency", &instantLatency_);
02892 is->fireItemAvailable("maxBandwidth", &maxBandwidth_);
02893 is->fireItemAvailable("minBandwidth", &minBandwidth_);
02894 is->fireItemAvailable("duration", &duration_);
02895 is->fireItemAvailable("totalSamples", &totalSamples_);
02896 is->fireItemAvailable("meanBandwidth", &meanBandwidth_);
02897 is->fireItemAvailable("meanRate", &meanRate_);
02898 is->fireItemAvailable("meanLatency", &meanLatency_);
02899 is->fireItemAvailable("stateName", fsm_.stateName());
02900 is->fireItemAvailable("progressMarker", &progressMarker_);
02901 is->fireItemAvailable("connectedSMs", &connectedSMs_);
02902 is->fireItemAvailable("collateDQM", &collateDQM_);
02903 is->fireItemAvailable("archiveDQM", &archiveDQM_);
02904 is->fireItemAvailable("archiveIntervalDQM", &archiveIntervalDQM_);
02905 is->fireItemAvailable("purgeTimeDQM", &purgeTimeDQM_);
02906 is->fireItemAvailable("readyTimeDQM", &readyTimeDQM_);
02907 is->fireItemAvailable("filePrefixDQM", &filePrefixDQM_);
02908 is->fireItemAvailable("useCompressionDQM", &useCompressionDQM_);
02909 is->fireItemAvailable("compressionLevelDQM", &compressionLevelDQM_);
02910
02911
02912 is->fireItemAvailable("maxESEventRate", &maxESEventRate_);
02913 is->fireItemAvailable("maxESDataRate", &maxESDataRate_);
02914 is->fireItemAvailable("DQMmaxESEventRate", &DQMmaxESEventRate_);
02915 is->fireItemAvailable("maxEventRequestRate",&maxEventRequestRate_);
02916 is->fireItemAvailable("maxDQMEventRequestRate",&maxDQMEventRequestRate_);
02917 is->fireItemAvailable("activeConsumerTimeout",&activeConsumerTimeout_);
02918 is->fireItemAvailable("idleConsumerTimeout", &idleConsumerTimeout_);
02919 is->fireItemAvailable("consumerQueueSize", &consumerQueueSize_);
02920 is->fireItemAvailable("esSelectedHLTOutputModule",&esSelectedHLTOutputModule_);
02921
02922
02923
02924
02925
02926 is->addItemRetrieveListener("class", this);
02927 is->addItemRetrieveListener("instance", this);
02928 is->addItemRetrieveListener("runNumber", this);
02929 is->addItemRetrieveListener("url", this);
02930
02931 is->addItemRetrieveListener("storedDQMEvents", this);
02932 is->addItemRetrieveListener("sentEvents", this);
02933 is->addItemRetrieveListener("sentDQMEvents", this);
02934 is->addItemRetrieveListener("storedVolume", this);
02935 is->addItemRetrieveListener("instantBandwidth", this);
02936 is->addItemRetrieveListener("instantRate", this);
02937 is->addItemRetrieveListener("instantLatency", this);
02938 is->addItemRetrieveListener("maxBandwidth", this);
02939 is->addItemRetrieveListener("minBandwidth", this);
02940 is->addItemRetrieveListener("duration", this);
02941 is->addItemRetrieveListener("totalSamples", this);
02942 is->addItemRetrieveListener("meanBandwidth", this);
02943 is->addItemRetrieveListener("meanRate", this);
02944 is->addItemRetrieveListener("meanLatency", this);
02945 is->addItemRetrieveListener("stateName", this);
02946 is->addItemRetrieveListener("progressMarker", this);
02947 is->addItemRetrieveListener("connectedSMs", this);
02948 is->addItemRetrieveListener("collateDQM", this);
02949 is->addItemRetrieveListener("archiveDQM", this);
02950 is->addItemRetrieveListener("archiveIntervalDQM", this);
02951 is->addItemRetrieveListener("purgeTimeDQM", this);
02952 is->addItemRetrieveListener("readyTimeDQM", this);
02953 is->addItemRetrieveListener("filePrefixDQM", this);
02954 is->addItemRetrieveListener("useCompressionDQM", this);
02955 is->addItemRetrieveListener("compressionLevelDQM", this);
02956
02957
02958 is->addItemRetrieveListener("maxESEventRate", this);
02959 is->addItemRetrieveListener("maxESDataRate", this);
02960 is->addItemRetrieveListener("DQMmaxESEventRate", this);
02961 is->addItemRetrieveListener("maxEventRequestRate", this);
02962 is->addItemRetrieveListener("maxDQMEventRequestRate",this);
02963 is->addItemRetrieveListener("activeConsumerTimeout",this);
02964 is->addItemRetrieveListener("idleConsumerTimeout", this);
02965 is->addItemRetrieveListener("consumerQueueSize", this);
02966 is->addItemRetrieveListener("esSelectedHLTOutputModule",this);
02967
02968
02969 }
02970
02971
02972 void SMProxyServer::actionPerformed(xdata::Event& e)
02973 {
02974 if (e.type() == "ItemRetrieveEvent") {
02975 std::ostringstream oss;
02976 oss << "urn:xdaq-monitorable:" << class_.value_ << ":" << instance_.value_;
02977 xdata::InfoSpace *is = xdata::InfoSpace::get(oss.str());
02978
02979 is->lock();
02980 std::string item = dynamic_cast<xdata::ItemRetrieveEvent&>(e).itemName();
02981
02982 if (item == "connectedSMs")
02983 connectedSMs_ = smsenders_.size();
02984 else if (item == "storedVolume")
02985 if (dpm_.get() != NULL)
02986 storedVolume_ = dpm_->totalvolumemb();
02987 else
02988 storedVolume_ = 0;
02989 else if (item == "progressMarker")
02990 progressMarker_ = ProgressMarker::instance()->status();
02991 is->unlock();
02992 }
02993 }
02994
02995
02996
02997 bool SMProxyServer::configuring(toolbox::task::WorkLoop* wl)
02998 {
02999 try {
03000 LOG4CPLUS_INFO(getApplicationLogger(),"Start configuring ...");
03001
03002
03003 if((bool)archiveDQM_) {
03004 try {
03005 checkDirectoryOK(filePrefixDQM_.toString());
03006 }
03007 catch(cms::Exception& e)
03008 {
03009 reasonForFailedState_ = e.explainSelf();
03010 fsm_.fireFailed(reasonForFailedState_,this);
03011 return false;
03012 }
03013 }
03014
03015
03016
03017
03018 if (maxESEventRate_ < 0.0)
03019 maxESEventRate_ = 0.0;
03020 if (maxESDataRate_ < 0.0)
03021 maxESDataRate_ = 0.0;
03022 if (DQMmaxESEventRate_ < 0.0)
03023 DQMmaxESEventRate_ = 0.0;
03024
03025 outpmeter_->init(samples_, period4samples_);
03026
03027
03028 xdata::Integer cutoff(20);
03029 xdata::Integer mincutoff(10);
03030 if (consumerQueueSize_ > cutoff)
03031 consumerQueueSize_ = cutoff;
03032 if (DQMconsumerQueueSize_ > cutoff)
03033 DQMconsumerQueueSize_ = cutoff;
03034 if (consumerQueueSize_ < mincutoff)
03035 consumerQueueSize_ = mincutoff;
03036 if (DQMconsumerQueueSize_ < mincutoff)
03037 DQMconsumerQueueSize_ = mincutoff;
03038
03039
03040 std::string url = getApplicationDescriptor()->getContextDescriptor()->getURL();
03041 std::string urn = getApplicationDescriptor()->getURN();
03042 consumerName_ = url + "/" + urn + "/pushEventData";
03043 DQMconsumerName_ = url + "/" + urn + "/pushDQMEventData";
03044
03045
03046
03047 try {
03048 dpm_.reset(new stor::DataProcessManager());
03049
03050 boost::shared_ptr<EventServer>
03051 eventServer(new EventServer(maxESEventRate_, maxESDataRate_,
03052 esSelectedHLTOutputModule_,
03053 fairShareES_));
03054 dpm_->setEventServer(eventServer);
03055 boost::shared_ptr<DQMEventServer>
03056 DQMeventServer(new DQMEventServer(DQMmaxESEventRate_));
03057 dpm_->setDQMEventServer(DQMeventServer);
03058 boost::shared_ptr<InitMsgCollection>
03059 initMsgCollection(new InitMsgCollection());
03060 dpm_->setInitMsgCollection(initMsgCollection);
03061 dpm_->setMaxEventRequestRate(maxEventRequestRate_);
03062 dpm_->setMaxDQMEventRequestRate(maxDQMEventRequestRate_);
03063
03064 dpm_->setCollateDQM(collateDQM_);
03065 dpm_->setArchiveDQM(archiveDQM_);
03066 dpm_->setArchiveIntervalDQM(archiveIntervalDQM_);
03067 dpm_->setPurgeTimeDQM(purgeTimeDQM_);
03068 dpm_->setReadyTimeDQM(readyTimeDQM_);
03069 dpm_->setFilePrefixDQM(filePrefixDQM_);
03070 dpm_->setUseCompressionDQM(useCompressionDQM_);
03071 dpm_->setCompressionLevelDQM(compressionLevelDQM_);
03072 dpm_->setSamples(samples_);
03073 dpm_->setPeriod4Samples(period4samples_);
03074
03075
03076
03077
03078 dpm_->setConsumerName(consumerName_.toString());
03079 dpm_->setDQMConsumerName(DQMconsumerName_.toString());
03080 unsigned int rsize = (unsigned int)smRegList_.size();
03081 for(unsigned int i = 0; i < rsize; ++i)
03082 {
03083 std::cout << "add to register list num = " << i << " url = "
03084 << smRegList_.elementAt(i)->toString() << std::endl;
03085 dpm_->addSM2Register(smRegList_.elementAt(i)->toString());
03086 dpm_->addDQMSM2Register(smRegList_.elementAt(i)->toString());
03087 smsenders_.insert(std::make_pair(smRegList_.elementAt(i)->toString(), false));
03088 }
03089
03090 }
03091 catch(cms::Exception& e)
03092 {
03093
03094 reasonForFailedState_ = e.explainSelf();
03095 fsm_.fireFailed(reasonForFailedState_,this);
03096 return false;
03097 }
03098 catch(std::exception& e)
03099 {
03100
03101 reasonForFailedState_ = e.what();
03102 fsm_.fireFailed(reasonForFailedState_,this);
03103 return false;
03104 }
03105 catch(...)
03106 {
03107
03108 reasonForFailedState_ = "Unknown Exception while configuring";
03109 fsm_.fireFailed(reasonForFailedState_,this);
03110 return false;
03111 }
03112
03113
03114 LOG4CPLUS_INFO(getApplicationLogger(),"Finished configuring!");
03115
03116 fsm_.fireEvent("ConfigureDone",this);
03117 }
03118 catch (xcept::Exception &e) {
03119 reasonForFailedState_ = "configuring FAILED: " + (string)e.what();
03120 fsm_.fireFailed(reasonForFailedState_,this);
03121 return false;
03122 }
03123
03124 return false;
03125 }
03126
03127
03128 bool SMProxyServer::enabling(toolbox::task::WorkLoop* wl)
03129 {
03130 try {
03131 LOG4CPLUS_INFO(getApplicationLogger(),"Start enabling ...");
03132
03133
03134
03135
03136 storedDQMEvents_ = 0;
03137 sentEvents_ = 0;
03138 sentDQMEvents_ = 0;
03139 receivedEvents_ = 0;
03140 receivedDQMEvents_ = 0;
03141
03142 dpm_->start();
03143
03144 LOG4CPLUS_INFO(getApplicationLogger(),"Finished enabling!");
03145
03146 fsm_.fireEvent("EnableDone",this);
03147 }
03148 catch (xcept::Exception &e) {
03149 reasonForFailedState_ = "enabling FAILED: " + (string)e.what();
03150 fsm_.fireFailed(reasonForFailedState_,this);
03151 return false;
03152 }
03153
03154 return false;
03155 }
03156
03157
03158 bool SMProxyServer::stopping(toolbox::task::WorkLoop* wl)
03159 {
03160 try {
03161 LOG4CPLUS_INFO(getApplicationLogger(),"Start stopping :) ...");
03162
03163
03164 boost::shared_ptr<stor::DQMServiceManager> dqmManager;
03165 if (dpm_.get() != NULL)
03166 {
03167 dqmManager = dpm_->getDQMServiceManager();
03168 if(dqmManager.get() != NULL) {
03169 dqmManager->stop();
03170 }
03171 }
03172
03173 boost::shared_ptr<EventServer> eventServer;
03174 boost::shared_ptr<DQMEventServer> dqmeventServer;
03175 if (dpm_.get() != NULL)
03176 {
03177 eventServer = dpm_->getEventServer();
03178 dqmeventServer = dpm_->getDQMEventServer();
03179 }
03180 if (eventServer.get() != NULL) eventServer->clearQueue();
03181 if (dqmeventServer.get() != NULL) dqmeventServer->clearQueue();
03182
03183
03184
03185 dpm_->stop();
03186 dpm_->join();
03187
03188
03189
03190
03191 LOG4CPLUS_INFO(getApplicationLogger(),"Finished stopping!");
03192
03193 fsm_.fireEvent("StopDone",this);
03194 }
03195 catch (xcept::Exception &e) {
03196 reasonForFailedState_ = "stopping FAILED: " + (string)e.what();
03197 fsm_.fireFailed(reasonForFailedState_,this);
03198 return false;
03199 }
03200
03201 return false;
03202 }
03203
03204
03205 bool SMProxyServer::halting(toolbox::task::WorkLoop* wl)
03206 {
03207 try {
03208 LOG4CPLUS_INFO(getApplicationLogger(),"Start halting ...");
03209
03210 dpm_->stop();
03211 dpm_->join();
03212
03213 smsenders_.clear();
03214 connectedSMs_ = 0;
03215
03216
03217
03218
03219
03220
03221
03222
03223 {
03224 boost::mutex::scoped_lock sl(halt_lock_);
03225 dpm_.reset();
03226 }
03227
03228 LOG4CPLUS_INFO(getApplicationLogger(),"Finished halting!");
03229
03230 fsm_.fireEvent("HaltDone",this);
03231 }
03232 catch (xcept::Exception &e) {
03233 reasonForFailedState_ = "halting FAILED: " + (string)e.what();
03234 fsm_.fireFailed(reasonForFailedState_,this);
03235 return false;
03236 }
03237
03238 return false;
03239 }
03240
03241 void SMProxyServer::checkDirectoryOK(std::string path)
03242 {
03243 struct stat buf;
03244
03245 int retVal = stat(path.c_str(), &buf);
03246 if(retVal !=0 )
03247 {
03248 edm::LogError("SMProxyServer") << "Directory or file " << path
03249 << " does not exist. Error=" << errno ;
03250 throw cms::Exception("SMProxyServer","checkDirectoryOK")
03251 << "Directory or file " << path << " does not exist. Error=" << errno << std::endl;
03252 }
03253 }
03254
03256 xoap::MessageReference SMProxyServer::fsmCallback(xoap::MessageReference msg)
03257 throw (xoap::exception::Exception)
03258 {
03259 return fsm_.commandCallback(msg);
03260 }
03261
03262
03264
03265
03266 extern "C" xdaq::Application
03267 *instantiate_SMProxyServer(xdaq::ApplicationStub * stub)
03268 {
03269 std::cout << "Going to construct a SMProxyServer instance "
03270 << std::endl;
03271 return new stor::SMProxyServer(stub);
03272 }
03273