Commit 90e2cf4d authored by Dainius Simelevicius's avatar Dainius Simelevicius
Browse files

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

parent f7b57584
......@@ -2,12 +2,12 @@
/*************************************************************************
* XDAQ Components for Distributed Data Acquisition *
* Copyright (C) 2000-2009, CERN. *
* Copyright (C) 2000-2020, CERN. *
* All rights reserved. *
* Authors: L. Orsini, A. Petrucci *
* Authors: L. Orsini, A. Petrucci and D. Simelevicius *
* *
* For the licensing terms see LICENSE. *
* For the list of contributors see CREDITS. *
* For the licensing terms see LICENSE. *
* For the list of contributors see CREDITS. *
*************************************************************************/
#ifndef _xmas_slash2g_Application_h_
......@@ -157,6 +157,9 @@ namespace xmas
std::map<std::string, xmas::slash2g::Settings*> flashSettings_; // indexed by flashlist name
xdata::Vector<xdata::String> eventings_;
xdata::UnsignedInteger eventingReplicas_;
xdata::String eventingPattern_;
std::vector<std::string> eventingList_;
xdata::Boolean httpVerbose_;
xdata::Boolean tcpNoDelay_;
......
......@@ -2,12 +2,12 @@
/*************************************************************************
* XDAQ Components for Distributed Data Acquisition *
* Copyright (C) 2000-2009, CERN. *
* Copyright (C) 2000-2020, CERN. *
* All rights reserved. *
* Authors: J. Gutleber and L. Orsini *
* Authors: J. Gutleber, L. Orsini and D. Simelevicius *
* *
* For the licensing terms see LICENSE. *
* For the list of contributors see CREDITS. *
* For the licensing terms see LICENSE. *
* For the list of contributors see CREDITS. *
*************************************************************************/
#ifndef _xmas_slash2g_version_h_
......@@ -17,10 +17,10 @@
// !!! Edit this line to reflect the latest package version !!!
#define WORKSUITE_XMASSLASH2G_VERSION_MAJOR 2
#define WORKSUITE_XMASSLASH2G_VERSION_MINOR 5
#define WORKSUITE_XMASSLASH2G_VERSION_PATCH 1
#define WORKSUITE_XMASSLASH2G_VERSION_MINOR 6
#define WORKSUITE_XMASSLASH2G_VERSION_PATCH 0
// If any previous versions available E.g. #define WORKSUITE_XMASSLASH2G_PREVIOUS_VERSIONS "3.8.0,3.8.1"
#define WORKSUITE_XMASSLASH2G_PREVIOUS_VERSIONS "2.1.0,2.1.1,2.2.0,2.3.0,2.4.0,2.4.1,2.4.2,2.4.3,2.4.4,2.4.5,2.5.0"
#undef WORKSUITE_XMASSLASH2G_PREVIOUS_VERSIONS
//
......
......@@ -71,6 +71,9 @@
#include "elastic/api/Stream.h"
#include "elastic/api/Namespaces.h"
#include <string>
#include <regex>
XDAQ_INSTANTIATOR_IMPL(xmas::slash2g::Application);
xmas::slash2g::Application::Application (xdaq::ApplicationStub* s)
......@@ -88,7 +91,10 @@ xmas::slash2g::Application::Application (xdaq::ApplicationStub* s)
// direct evetings addresses
this->getApplicationInfoSpace()->fireItemAvailable("eventings", &eventings_);
// Eventing addresses by pattern
this->getApplicationInfoSpace()->fireItemAvailable("eventingReplicas", &eventingReplicas_);
this->getApplicationInfoSpace()->fireItemAvailable("eventingPattern", &eventingPattern_);
// In which group to search for a ws-eventing
subscribeGroup_ = "";
this->getApplicationInfoSpace()->fireItemAvailable("subscribeGroup", &subscribeGroup_);
......@@ -174,7 +180,7 @@ void xmas::slash2g::Application::timeExpired(toolbox::task::TimerEvent& e)
}
if (eventings_.elements() == 0)
if (eventingList_.size() == 0)
{
// use of discovery
......@@ -354,29 +360,51 @@ void xmas::slash2g::Application::actionPerformed( xdata::Event& event)
void xmas::slash2g::Application::actionPerformed(toolbox::Event& e)
{
LOG4CPLUS_DEBUG(this->getApplicationLogger(), "Received event " << e.type());
if ( e.type() == "urn:xdaq-event:profile-loaded")
if (e.type() == "urn:xdaq-event:profile-loaded")
{
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++)
{
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::slash2g::exception::Exception, ex, msg.str(),e);
LOG4CPLUS_ERROR (this->getApplicationLogger(), xcept::stdformat_exception_history(ex));
}
}
}
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)
{
std::string s = std::to_string(i);
std::string eventing;
try
{
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::slash2g::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::slash2g::exception::Exception, ex, msg.str(), e);
LOG4CPLUS_ERROR(this->getApplicationLogger(), xcept::stdformat_exception_history(ex));
}
}
}
/*
if ( e.type() == "xdaq::EndpointAvailableEvent" )
......
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