Commit d4eb8fa0 authored by Dainius Simelevicius's avatar Dainius Simelevicius
Browse files

references #139: support for eventing url by pattern in store2g

parent 9c08da04
......@@ -123,6 +123,10 @@ namespace xmas
// Application parameters
//
xdata::Vector<xdata::String> eventings_;
xdata::UnsignedInteger eventingReplicas_;
xdata::String eventingPattern_;
std::vector<std::string> eventingList_;
xdata::Vector<xdata::String> tstores_;
xdata::String subscribeGroup_; // one or more comma separated groups hosting a ws-eventing service for monitoring
xdata::String storeGroup_; // one or more comma separated groups hosting a tstore service for storage
......
......@@ -17,7 +17,7 @@
// !!! Edit this line to reflect the latest package version !!!
#define WORKSUITE_XMASSTORE2G_VERSION_MAJOR 3
#define WORKSUITE_XMASSTORE2G_VERSION_MINOR 0
#define WORKSUITE_XMASSTORE2G_VERSION_MINOR 1
#define WORKSUITE_XMASSTORE2G_VERSION_PATCH 0
// If any previous versions available E.g. #define WORKSUITE_XMASSTORE2G_PREVIOUS_VERSIONS "3.8.0,3.8.1"
#undef WORKSUITE_XMASSTORE2G_PREVIOUS_VERSIONS
......@@ -38,11 +38,11 @@ namespace xmasstore2g
const std::string package = "xmasstore2g";
const std::string versions = WORKSUITE_XMASSTORE2G_FULL_VERSION_LIST;
const std::string description = "This package provide facilities to automatically make monitoring data persistent";
const std::string authors = "Johannes Gutleber, Luciano Orsini";
const std::string authors = "Johannes Gutleber, Luciano Orsini, Dainius Simelevicius";
const std::string summary = "An service used to store2g monitor data injected into the XMAS system";
const std::string link = "http://xdaqwiki.cern.ch/index.php/Power_Pack";
config::PackageInfo getPackageInfo();
void checkPackageDependencies() ;
void checkPackageDependencies();
std::set<std::string, std::less<std::string> > getPackageDependencies();
}
......
......@@ -9,15 +9,18 @@
* For the licensing terms see LICENSE. *
* For the list of contributors see CREDITS. *
*************************************************************************/
#include <string>
#include <regex>
#include "cgicc/CgiDefs.h"
#include "cgicc/Cgicc.h"
#include "cgicc/HTTPHTMLHeader.h"
#include "cgicc/HTMLClasses.h"
#include "cgicc/HTTPResponseHeader.h"
#include "cgicc/HTTPResponseHeader.h"
#include "xdaq/ApplicationGroup.h"
#include "xdaq/ApplicationRegistry.h"
#include "xdaq/ApplicationRegistry.h"
#include "xoap/MessageReference.h"
#include "xoap/MessageFactory.h"
......@@ -77,7 +80,14 @@ xmas::store2g::Application::Application (xdaq::ApplicationStub* s)
period_ = "PT15S";
subscribeExpiration_ = "PT30S";
this->getApplicationInfoSpace()->fireItemAvailable("eventings", &eventings_); //direct eventing addresses
// Direct eventing addresses
this->getApplicationInfoSpace()->fireItemAvailable("eventings", &eventings_);
// Eventing addresses by pattern
this->getApplicationInfoSpace()->fireItemAvailable("eventingReplicas", &eventingReplicas_);
this->getApplicationInfoSpace()->fireItemAvailable("eventingPattern", &eventingPattern_);
this->getApplicationInfoSpace()->fireItemAvailable("tstores", &tstores_); //direct tstore addresses
this->getApplicationInfoSpace()->fireItemAvailable("oclFileName", &oclFileName_);
this->getApplicationInfoSpace()->fireItemAvailable("db", &db_);
......@@ -205,22 +215,45 @@ void xmas::store2g::Application::actionPerformed (toolbox::Event& event)
{
LOG4CPLUS_DEBUG(this->getApplicationLogger(), "Setting proxy to b2in-eventing services");
if (eventings_.elements() != 0)
for (xdata::Vector<xdata::String>::iterator i = eventings_.begin(); i != eventings_.end(); i++)
{
eventingList_.push_back(i->toString());
}
std::string eventingPattern = eventingPattern_.toString();
for (unsigned int i = 0; i < eventingReplicas_; ++i)
{
for (xdata::Vector<xdata::String>::iterator i = eventings_.begin(); i != eventings_.end(); i++)
std::string s = std::to_string(i);
std::string eventing;
try
{
try
{
LOG4CPLUS_DEBUG(this->getApplicationLogger(), "Adding eventing on " << (*i).toString());
b2inEventingProxy_->addURL(*i);
}
catch(b2in::utils::exception::Exception & e)
{
std::stringstream msg;
msg << "Failed to add b2in-eventing address";
XCEPT_DECLARE_NESTED(xmas::store2g::exception::Exception, ex, msg.str(), e);
LOG4CPLUS_ERROR (this->getApplicationLogger(), xcept::stdformat_exception_history(ex));
}
eventing = std::regex_replace(eventingPattern, std::regex("#"), s);
}
catch (std::regex_error & e)
{
std::stringstream msg;
msg << "Failed to process eventing pattern: '" << eventingPattern << "'. " << e.what();
XCEPT_DECLARE(xmas::store2g::exception::Exception, ex, msg.str());
LOG4CPLUS_ERROR(this->getApplicationLogger(), xcept::stdformat_exception_history(ex));
break;
}
eventingList_.push_back(eventing);
}
for(std::string eventing : eventingList_)
{
try
{
LOG4CPLUS_DEBUG(this->getApplicationLogger(), "Adding eventing on " << eventing);
xdata::String url(eventing);
b2inEventingProxy_->addURL(url);
}
catch(b2in::utils::exception::Exception & e)
{
std::stringstream msg;
msg << "Failed to add b2in-eventing address";
XCEPT_DECLARE_NESTED(xmas::store2g::exception::Exception, ex, msg.str(), e);
LOG4CPLUS_ERROR (this->getApplicationLogger(), xcept::stdformat_exception_history(ex));
}
}
......@@ -320,7 +353,7 @@ void xmas::store2g::Application::actionPerformed (xdata::Event& event)
}
if (eventings_.elements() == 0)
if (eventingList_.size() == 0)
{
// initialize discovery services
try
......@@ -334,7 +367,7 @@ void xmas::store2g::Application::actionPerformed (xdata::Event& event)
}
}
if ( oclFileName_.toString() != "" ) // for backward compatibility if paramater not specified
if (oclFileName_.toString() != "") // for backward compatibility if paramater not specified
{
// makes use of the credential as specified in the OCL file for the current default zone (-z zonename or XDAQ_ZONE or default)
this->loadOCL(oclFileName_.toString());
......@@ -711,7 +744,7 @@ void xmas::store2g::Application::timeExpired (toolbox::task::TimerEvent& e)
if (name == "discovery-staging")
{
if (eventings_.elements() == 0)
if (eventingList_.size() == 0)
{
try
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment