Commit 868eeb70 authored by Dainius Simelevicius's avatar Dainius Simelevicius
Browse files

references #137: added support for direct eventing configuration in spotlight2g

parent 114d0677
......@@ -155,6 +155,7 @@ namespace sentinel
xdata::UnsignedInteger64T exceptionsLostCounter_;
xdata::String topic_;
xdata::Vector<xdata::String> eventings_;
xdata::String maintenanceInterval_; // interval at which the database switchover happens (> 1 minute)
xdata::String repositoryPath_; // folder in which to store the spotlight database files (/var/run/spotlight)
xdata::String subscribeGroup_; // one or more comma separated groups hosting a ws-eventing service for exceptions
......
......@@ -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 _sentinel_spotlight2g_version_h_
......@@ -17,11 +17,11 @@
// !!! Edit this line to reflect the latest package version !!!
#define WORKSUITE_SENTINELSPOTLIGHT2G_VERSION_MAJOR 2
#define WORKSUITE_SENTINELSPOTLIGHT2G_VERSION_MINOR 1
#define WORKSUITE_SENTINELSPOTLIGHT2G_VERSION_PATCH 2
#define WORKSUITE_SENTINELSPOTLIGHT2G_VERSION_MAJOR 3
#define WORKSUITE_SENTINELSPOTLIGHT2G_VERSION_MINOR 0
#define WORKSUITE_SENTINELSPOTLIGHT2G_VERSION_PATCH 0
// If any previous versions available E.g. #define WORKSUITE_SENTINELSPOTLIGHT2G_PREVIOUS_VERSIONS "3.8.0,3.8.1"
#define WORKSUITE_SENTINELSPOTLIGHT2G_PREVIOUS_VERSIONS "2.0.0,2.1.0,2.1.1"
#undef WORKSUITE_SENTINELSPOTLIGHT2G_PREVIOUS_VERSIONS
//
......@@ -41,7 +41,7 @@ namespace sentinelspotlight2g
const std::string versions = WORKSUITE_SENTINELSPOTLIGHT2G_FULL_VERSION_LIST;
const std::string summary = "Server for exceptions and alarms";
const std::string description = "";
const std::string authors = "Johannes Gutleber, Luciano Orsini";
const std::string authors = "Johannes Gutleber, Luciano Orsini, Dainius Simelevicius";
const std::string link = "http://xdaqwiki.cern.ch/index.php/Power_Pack";
config::PackageInfo getPackageInfo();
void checkPackageDependencies() ;
......
......@@ -72,6 +72,9 @@ sentinel::spotlight2g::Application::Application(xdaq::ApplicationStub* s)
s->getDescriptor()->setAttribute("icon", "/sentinel/spotlight2g/images/spotlight2g-icon.png");
s->getDescriptor()->setAttribute("icon16x16", "/sentinel/spotlight2g/images/spotlight2g-icon.png");
s->getDescriptor()->setAttribute("service", "sentinelspotlight2g");
//Direct eventing addresses
this->getApplicationInfoSpace()->fireItemAvailable("eventings", &eventings_);
subscribeGroup_ = "";
this->getApplicationInfoSpace()->fireItemAvailable("subscribeGroup", &subscribeGroup_);
......@@ -353,12 +356,11 @@ void sentinel::spotlight2g::Application::actionPerformed( xdata::Event& event)
LOG4CPLUS_INFO (this->getApplicationLogger(), "Schedule spotlight archivation timer for " << interval.toString());
timer->scheduleAtFixedRate( start, this, interval, 0, "archive-staging" );
// submit scan task
toolbox::TimeInterval interval2;
interval2.fromString(scanPeriod_);
// submit scan task
toolbox::TimeInterval interval2;
interval2.fromString(scanPeriod_);
LOG4CPLUS_INFO (this->getApplicationLogger(), "Schedule discovery timer for " << interval2.toString());
timer->scheduleAtFixedRate( start, this, interval2, 0, "discovery-staging" );
timer->scheduleAtFixedRate( start, this, interval2, 0, "discovery-staging" );
}
catch (toolbox::task::exception::InvalidListener& e)
{
......@@ -570,33 +572,34 @@ void sentinel::spotlight2g::Application::refreshSubscriptionsToEventing()
void sentinel::spotlight2g::Application::timeExpired(toolbox::task::TimerEvent& e)
{
std::string name = e.getTimerTask()->name;
std::string name = e.getTimerTask()->name;
if (name == "discovery-staging")
{
if (eventings_.elements() == 0)
{
try
{
b2inEventingProxy_->scan();
}
catch (b2in::utils::exception::Exception& e)
{
LOG4CPLUS_FATAL (this->getApplicationLogger(), xcept::stdformat_exception_history(e));
}
}
try
{
b2inEventingProxy_->scan();
}
catch (b2in::utils::exception::Exception& e)
{
LOG4CPLUS_FATAL (this->getApplicationLogger(), xcept::stdformat_exception_history(e));
}
try
{
this->refreshSubscriptionsToEventing();
}
catch (sentinel::exception::Exception& e)
{
LOG4CPLUS_FATAL (this->getApplicationLogger(), xcept::stdformat_exception_history(e));
}
{
this->refreshSubscriptionsToEventing();
}
catch (sentinel::exception::Exception& e)
{
LOG4CPLUS_FATAL (this->getApplicationLogger(), xcept::stdformat_exception_history(e));
}
}
else if ( (name == "archive-staging-now") || (name == "archive-staging") )
else if ( (name == "archive-staging-now") || (name == "archive-staging") )
{
// archive event
// archive event
// If we are in maintenance phase and the repository_ is NULL, just return
if (repository_)
{
......@@ -1121,12 +1124,31 @@ bool sentinel::spotlight2g::Application::match
return true;
}
void sentinel::spotlight2g::Application::actionPerformed( toolbox::Event& event)
void sentinel::spotlight2g::Application::actionPerformed(toolbox::Event& event)
{
/* xcept::Exception* newException = new xcept::Exception();
sentinel::utils::Serializer::importFrom (command, *newException);
toolbox::task::EventReference e(new sentinel::spotlight2g::ExceptionEvent(newException,""));
*/
if (event.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(sentinel::spotlight2g::exception::Exception, ex, msg.str(),e);
LOG4CPLUS_ERROR (this->getApplicationLogger(), xcept::stdformat_exception_history(ex));
}
}
}
}
if (event.type() == "urn:sentinel-spotlight:ExceptionEvent")
{
......@@ -1183,8 +1205,7 @@ void sentinel::spotlight2g::Application::actionPerformed( toolbox::Event& event)
LOG4CPLUS_FATAL (this->getApplicationLogger(), xcept::stdformat_exception_history(st));
}
}
}
}
......
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