aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-03-07 17:19:31 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-03-07 17:27:12 +0100
commit3f4214227e993305bb320b299245f466b9b22233 (patch)
tree0863975f29692d0939e3acc53b76a00e97f2aadc /src
parent0414d5788090bb6df728d370079e44e95b4ffd20 (diff)
downloaddabmux-3f4214227e993305bb320b299245f466b9b22233.tar.gz
dabmux-3f4214227e993305bb320b299245f466b9b22233.tar.bz2
dabmux-3f4214227e993305bb320b299245f466b9b22233.zip
Merge Stats and Config server, config is also JSON
Diffstat (limited to 'src')
-rw-r--r--src/ConfigParser.cpp7
-rw-r--r--src/ConfigParser.h2
-rw-r--r--src/ConfigServer.cpp177
-rw-r--r--src/ConfigServer.h120
-rw-r--r--src/DabMux.cpp41
-rw-r--r--src/Makefile.am5
-rw-r--r--src/ManagementServer.cpp (renamed from src/StatsServer.cpp)67
-rw-r--r--src/ManagementServer.h (renamed from src/StatsServer.h)71
-rw-r--r--src/dabInputZmq.cpp3
-rw-r--r--src/dabInputZmq.h2
10 files changed, 119 insertions, 376 deletions
diff --git a/src/ConfigParser.cpp b/src/ConfigParser.cpp
index 2c4ab63..8c5cbaa 100644
--- a/src/ConfigParser.cpp
+++ b/src/ConfigParser.cpp
@@ -67,7 +67,7 @@
#include "dabInputDmbUdp.h"
#include "dabInputZmq.h"
#include "DabMux.h"
-#include "StatsServer.h"
+#include "ManagementServer.h"
#ifdef _WIN32
@@ -132,7 +132,7 @@ void parse_ptree(boost::property_tree::ptree& pt,
bool* factumAnalyzer,
unsigned long* limit,
BaseRemoteController** rc,
- int* statsServerPort,
+ int* mgmtserverport,
edi_configuration_t* edi
)
{
@@ -169,7 +169,8 @@ void parse_ptree(boost::property_tree::ptree& pt,
*enableTist = pt_general.get("tist", false);
- *statsServerPort = pt_general.get<int>("statsserverport", 0);
+ *mgmtserverport = pt_general.get<int>("managementport",
+ pt_general.get<int>("statsserverport", 0) );
/************** READ REMOTE CONTROL PARAMETERS *************/
ptree pt_rc = pt.get_child("remotecontrol");
diff --git a/src/ConfigParser.h b/src/ConfigParser.h
index 16d2146..4af010a 100644
--- a/src/ConfigParser.h
+++ b/src/ConfigParser.h
@@ -45,7 +45,7 @@ void parse_ptree(boost::property_tree::ptree& pt,
bool* factumAnalyzer,
unsigned long* limit,
BaseRemoteController** rc,
- int* statsServerPort,
+ int* mgmtserverport,
edi_configuration_t* edi);
void setup_subchannel_from_ptree(dabSubchannel* subchan,
diff --git a/src/ConfigServer.cpp b/src/ConfigServer.cpp
deleted file mode 100644
index e2eefd4..0000000
--- a/src/ConfigServer.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
- 2011, 2012 Her Majesty the Queen in Right of Canada (Communications
- Research Center Canada)
-
- Copyright (C) 2014
- Matthias P. Braendli, matthias.braendli@mpb.li
- */
-/*
- This file is part of ODR-DabMux.
-
- ODR-DabMux is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- ODR-DabMux is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with ODR-DabMux. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "ConfigServer.h"
-
-#include <errno.h>
-#include <string.h>
-#include <math.h>
-#include <stdint.h>
-#include <limits>
-#include <sstream>
-#include <ctime>
-#include <boost/thread.hpp>
-#include "Log.h"
-
-void ConfigServer::serverThread()
-{
- m_fault = false;
-
- try {
- int accepted_sock;
- char buffer[256];
- char welcome_msg[256];
- struct sockaddr_in serv_addr, cli_addr;
- int n;
-
- int welcome_msg_len = snprintf(welcome_msg, 256,
- "%s %s Config Server\n",
- PACKAGE_NAME,
-#if defined(GITVERSION)
- GITVERSION
-#else
- PACKAGE_VERSION
-#endif
- );
-
-
- m_sock = socket(AF_INET, SOCK_STREAM, 0);
- if (m_sock < 0) {
- etiLog.level(error) << "Error opening Config Server socket: " <<
- strerror(errno);
- m_fault = true;
- return;
- }
-
- memset(&serv_addr, 0, sizeof(serv_addr));
- serv_addr.sin_family = AF_INET;
- serv_addr.sin_addr.s_addr = INADDR_ANY; // TODO listen only on 127.0.0.1
- serv_addr.sin_port = htons(m_listenport);
-
- if (bind(m_sock, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
- etiLog.level(error) << "Error binding Config Server socket: " <<
- strerror(errno);
- goto end_serverthread;
- }
-
- if (listen(m_sock, 5) < 0) {
- etiLog.level(error) << "Error listening on Config Server socket: " <<
- strerror(errno);
- goto end_serverthread;
- }
-
- m_running = true;
-
- while (m_running) {
- socklen_t cli_addr_len = sizeof(cli_addr);
-
- /* Accept actual connection from the client */
- accepted_sock = accept(m_sock,
- (struct sockaddr *)&cli_addr,
- &cli_addr_len);
-
- if (accepted_sock < 0) {
- etiLog.level(warn) << "Config Server cound not accept connection: " <<
- strerror(errno);
- continue;
- }
- /* Send welcome message with version */
- n = write(accepted_sock, welcome_msg, welcome_msg_len);
- if (n < 0) {
- etiLog.level(warn) << "Error writing to Config Server socket " <<
- strerror(errno);
- close(accepted_sock);
- continue;
- }
-
- /* receive command */
- memset(buffer, 0, 256);
- int n = read(accepted_sock, buffer, 255);
- if (n < 0) {
- etiLog.level(warn) << "Error reading from Config Server socket " <<
- strerror(errno);
- close(accepted_sock);
- continue;
- }
-
- if (strcmp(buffer, "getconfig\n") == 0) {
- boost::unique_lock<boost::mutex> lock(m_mutex);
- m_pending_request = "getconfig";
- m_pending = true;
-
- while (m_pending) {
- m_condition.wait(lock);
- }
- std::stringstream ss;
- boost::property_tree::info_parser::write_info(ss, m_pt);
-
- std::string response = ss.str();
-
- n = write(accepted_sock, response.c_str(), response.size());
- }
- else {
- int len = snprintf(buffer, 256, "Invalid command\n");
- n = write(accepted_sock, buffer, len);
- }
-
- if (n < 0) {
- etiLog.level(warn) << "Error writing to Config Server socket " <<
- strerror(errno);
- }
- close(accepted_sock);
- }
-
-end_serverthread:
- m_fault = true;
- close(m_sock);
-
- }
- catch (std::exception& e) {
- etiLog.level(error) << "Config server caught exception: " << e.what();
- m_fault = true;
- }
-}
-
-void ConfigServer::restart()
-{
- m_restarter_thread = boost::thread(&ConfigServer::restart_thread,
- this, 0);
-}
-
-// This runs in a separate thread, because
-// it would take too long to be done in the main loop
-// thread.
-void ConfigServer::restart_thread(long)
-{
- m_running = false;
-
- if (m_listenport) {
- m_thread.interrupt();
- m_thread.join();
- }
-
- m_thread = boost::thread(&ConfigServer::serverThread, this);
-}
-
diff --git a/src/ConfigServer.h b/src/ConfigServer.h
deleted file mode 100644
index b51ef32..0000000
--- a/src/ConfigServer.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
- 2011, 2012 Her Majesty the Queen in Right of Canada (Communications
- Research Center Canada)
-
- Copyright (C) 2014
- Matthias P. Braendli, matthias.braendli@mpb.li
- */
-/*
- This file is part of ODR-DabMux.
-
- ODR-DabMux is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- ODR-DabMux is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with ODR-DabMux. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef __CONFIG_SERVER_H_
-#define __CONFIG_SERVER_H_
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <boost/property_tree/ptree.hpp>
-#include <boost/property_tree/info_parser.hpp>
-#include <boost/thread.hpp>
-#include <cstdio>
-#include <stdlib.h>
-#include <iostream>
-#include <fstream>
-#include <iomanip>
-#include <cstring>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <unistd.h>
-#include <netdb.h>
-#include <arpa/inet.h>
-
-class ConfigServer
-{
- public:
- ConfigServer() :
- m_listenport(0),
- m_running(false),
- m_fault(false)
- { }
-
- ConfigServer(int listen_port) :
- m_listenport(listen_port),
- m_running(false),
- m_fault(false),
- m_thread(&ConfigServer::serverThread, this)
- {
- m_sock = 0;
- }
-
- ~ConfigServer()
- {
- m_running = false;
- m_fault = false;
- if (m_sock) {
- close(m_sock);
- }
- m_thread.join();
- }
-
- bool request_pending() {
- return m_pending;
- }
-
- void update_ptree(const boost::property_tree::ptree& pt) {
- boost::unique_lock<boost::mutex> lock(m_mutex);
- m_pt = pt;
- m_pending = false;
-
- m_condition.notify_one();
- }
-
- bool fault_detected() { return m_fault; }
- void restart(void);
-
- private:
- void restart_thread(long);
-
- /******* TCP Socket Server ******/
- // no copying (because of the thread)
- ConfigServer(const ConfigServer& other);
-
- void serverThread(void);
-
- int m_listenport;
-
- // serverThread runs in a separate thread
- bool m_running;
- bool m_fault;
- boost::thread m_thread;
- boost::thread m_restarter_thread;
-
- int m_sock;
-
- bool m_pending;
- std::string m_pending_request;
- boost::condition_variable m_condition;
- boost::mutex m_mutex;
-
- boost::property_tree::ptree m_pt;
-};
-
-
-#endif
-
diff --git a/src/DabMux.cpp b/src/DabMux.cpp
index 950eefe..cbbd612 100644
--- a/src/DabMux.cpp
+++ b/src/DabMux.cpp
@@ -3,8 +3,10 @@
2011, 2012 Her Majesty the Queen in Right of Canada (Communications
Research Center Canada)
- Copyright (C) 2014
+ Copyright (C) 2014, 2015
Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://www.opendigitalradio.org
*/
/*
This file is part of ODR-DabMux.
@@ -127,8 +129,7 @@ typedef DWORD32 uint32_t;
#include "utils.h"
#include "ParserCmdline.h"
#include "ConfigParser.h"
-#include "StatsServer.h"
-#include "ConfigServer.h"
+#include "ManagementServer.h"
#include "Log.h"
#include "RemoteControl.h"
@@ -137,10 +138,8 @@ using boost::property_tree::ptree;
using boost::property_tree::ptree_error;
-/* Global stats server */
-StatsServer* global_stats;
-
-ConfigServer config_server(8001);
+/* Global stats and config server */
+ManagementServer* mgmt_server;
class MuxInitException : public exception
{
@@ -333,7 +332,7 @@ int main(int argc, char *argv[])
bool enableTist = false;
unsigned timestamp = 0;
- int statsserverport = 0;
+ int mgmtserverport = 0;
edi_configuration_t edi_conf;
@@ -373,7 +372,7 @@ int main(int argc, char *argv[])
read_info(conf_file, pt);
parse_ptree(pt, outputs, ensemble, &enableTist, &FICL,
- &factumAnalyzer, &limit, &rc, &statsserverport, &edi_conf);
+ &factumAnalyzer, &limit, &rc, &mgmtserverport, &edi_conf);
}
catch (runtime_error &e) {
etiLog.log(error, "Configuration file parsing error: %s\n",
@@ -393,7 +392,7 @@ int main(int argc, char *argv[])
string conf_file = argv[2];
parse_configfile(conf_file, outputs, ensemble, &enableTist, &FICL,
- &factumAnalyzer, &limit, &rc, &statsserverport, &edi_conf);
+ &factumAnalyzer, &limit, &rc, &mgmtserverport, &edi_conf);
}
catch (runtime_error &e) {
@@ -415,11 +414,11 @@ int main(int argc, char *argv[])
}
#endif
- if (statsserverport != 0) {
- global_stats = new StatsServer(statsserverport);
+ if (mgmtserverport != 0) {
+ mgmt_server = new ManagementServer(mgmtserverport);
}
else {
- global_stats = new StatsServer();
+ mgmt_server = new ManagementServer();
}
if (rc) {
@@ -2174,21 +2173,15 @@ int main(int argc, char *argv[])
}
/* Same for statistics server */
- if (global_stats && fc->FCT == 249 && global_stats->fault_detected()) {
+ if (mgmt_server && fc->FCT % 10 == 0) {
+ if (mgmt_server->fault_detected()) {
etiLog.level(warn) <<
"Detected Statistics Server fault, restarting it";
- global_stats->restart();
- }
-
- if (fc->FCT % 10 == 0) {
- if (config_server.fault_detected()) {
- config_server.restart();
+ mgmt_server->restart();
}
-
- if (config_server.request_pending()) {
- config_server.update_ptree(pt);
+ else if (mgmt_server->request_pending()) {
+ mgmt_server->update_ptree(pt);
}
-
}
}
diff --git a/src/Makefile.am b/src/Makefile.am
index aa1f86a..f3bce5e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -79,7 +79,7 @@ odr_dabmux_SOURCES =DabMux.cpp DabMux.h \
MuxElements.cpp MuxElements.h \
RemoteControl.cpp RemoteControl.h \
ParserCmdline.cpp ParserCmdline.h \
- ParserConfig.cpp ParserConfig.h \
+ ConfigParser.cpp ConfigParser.h \
Eti.h Eti.cpp \
Log.h Log.cpp \
UdpSocket.h UdpSocket.cpp \
@@ -92,8 +92,7 @@ odr_dabmux_SOURCES =DabMux.cpp DabMux.h \
Interleaver.h Interleaver.cpp \
ReedSolomon.h ReedSolomon.cpp \
mpeg.h mpeg.c \
- StatsServer.h StatsServer.cpp \
- ConfigServer.h ConfigServer.cpp \
+ ManagementServer.h ManagementServer.cpp \
TcpServer.h TcpServer.cpp \
TcpSocket.h TcpSocket.cpp \
zmq.hpp
diff --git a/src/StatsServer.cpp b/src/ManagementServer.cpp
index 558a479..9ebdfeb 100644
--- a/src/StatsServer.cpp
+++ b/src/ManagementServer.cpp
@@ -2,13 +2,14 @@
Copyright (C) 2009 Her Majesty the Queen in Right of Canada (Communications
Research Center Canada)
- Copyright (C) 2014 Matthias P. Braendli
- http://mpb.li
+ Copyright (C) 2014, 2015
+ Matthias P. Braendli, matthias.braendli@mpb.li
- A TCP Socket server that serves state information and statistics for
- monitoring purposes.
+ http://www.opendigitalradio.org
- This server is very easy to integrate with munin http://munin-monitoring.org/
+ A TCP Socket server that serves state information and statistics for
+ monitoring purposes, and also serves the internal configuration
+ property tree.
*/
/*
This file is part of ODR-DabMux.
@@ -35,12 +36,12 @@
#include <sstream>
#include <ctime>
#include <boost/thread.hpp>
-#include "StatsServer.h"
+#include "ManagementServer.h"
#include "Log.h"
-void StatsServer::registerInput(InputStat* is)
+void ManagementServer::registerInput(InputStat* is)
{
- boost::mutex::scoped_lock lock(m_mutex);
+ boost::mutex::scoped_lock lock(m_statsmutex);
std::string id(is->get_name());
@@ -54,9 +55,9 @@ void StatsServer::registerInput(InputStat* is)
m_inputStats[id] = is;
}
-void StatsServer::unregisterInput(std::string id)
+void ManagementServer::unregisterInput(std::string id)
{
- boost::mutex::scoped_lock lock(m_mutex);
+ boost::mutex::scoped_lock lock(m_statsmutex);
if (m_inputStats.count(id) == 1) {
m_inputStats.erase(id);
@@ -64,9 +65,9 @@ void StatsServer::unregisterInput(std::string id)
}
-bool StatsServer::isInputRegistered(std::string& id)
+bool ManagementServer::isInputRegistered(std::string& id)
{
- boost::mutex::scoped_lock lock(m_mutex);
+ boost::mutex::scoped_lock lock(m_statsmutex);
if (m_inputStats.count(id) == 0) {
etiLog.level(error) <<
@@ -77,9 +78,9 @@ bool StatsServer::isInputRegistered(std::string& id)
return true;
}
-std::string StatsServer::getConfigJSON()
+std::string ManagementServer::getStatConfigJSON()
{
- boost::mutex::scoped_lock lock(m_mutex);
+ boost::mutex::scoped_lock lock(m_statsmutex);
std::ostringstream ss;
ss << "{ \"config\" : [\n";
@@ -103,9 +104,9 @@ std::string StatsServer::getConfigJSON()
return ss.str();
}
-std::string StatsServer::getValuesJSON()
+std::string ManagementServer::getValuesJSON()
{
- boost::mutex::scoped_lock lock(m_mutex);
+ boost::mutex::scoped_lock lock(m_statsmutex);
std::ostringstream ss;
ss << "{ \"values\" : {\n";
@@ -132,9 +133,9 @@ std::string StatsServer::getValuesJSON()
return ss.str();
}
-std::string StatsServer::getStateJSON()
+std::string ManagementServer::getStateJSON()
{
- boost::mutex::scoped_lock lock(m_mutex);
+ boost::mutex::scoped_lock lock(m_statsmutex);
std::ostringstream ss;
ss << "{\n";
@@ -161,16 +162,16 @@ std::string StatsServer::getStateJSON()
return ss.str();
}
-void StatsServer::restart()
+void ManagementServer::restart()
{
- m_restarter_thread = boost::thread(&StatsServer::restart_thread,
+ m_restarter_thread = boost::thread(&ManagementServer::restart_thread,
this, 0);
}
// This runs in a separate thread, because
// it would take too long to be done in the main loop
// thread.
-void StatsServer::restart_thread(long)
+void ManagementServer::restart_thread(long)
{
m_running = false;
@@ -179,10 +180,10 @@ void StatsServer::restart_thread(long)
m_thread.join();
}
- m_thread = boost::thread(&StatsServer::serverThread, this);
+ m_thread = boost::thread(&ManagementServer::serverThread, this);
}
-void StatsServer::serverThread()
+void ManagementServer::serverThread()
{
m_fault = false;
@@ -265,7 +266,7 @@ void StatsServer::serverThread()
}
if (strcmp(buffer, "config\n") == 0) {
- std::string json = getConfigJSON();
+ std::string json = getStatConfigJSON();
n = write(accepted_sock, json.c_str(), json.size());
}
else if (strcmp(buffer, "values\n") == 0) {
@@ -276,6 +277,20 @@ void StatsServer::serverThread()
std::string json = getStateJSON();
n = write(accepted_sock, json.c_str(), json.size());
}
+ if (strcmp(buffer, "getptree\n") == 0) {
+ boost::unique_lock<boost::mutex> lock(m_configmutex);
+ m_pending = true;
+
+ while (m_pending) {
+ m_condition.wait(lock);
+ }
+ std::stringstream ss;
+ boost::property_tree::json_parser::write_json(ss, m_pt);
+
+ std::string response = ss.str();
+
+ n = write(accepted_sock, response.c_str(), response.size());
+ }
else {
int len = snprintf(buffer, 256, "Invalid command\n");
n = write(accepted_sock, buffer, len);
@@ -303,12 +318,12 @@ end_serverthread:
void InputStat::registerAtServer()
{
- global_stats->registerInput(this);
+ mgmt_server->registerInput(this);
}
InputStat::~InputStat()
{
- global_stats->unregisterInput(m_name);
+ mgmt_server->unregisterInput(m_name);
}
std::string InputStat::encodeValuesJSON()
diff --git a/src/StatsServer.h b/src/ManagementServer.h
index 26f90d4..fa3f170 100644
--- a/src/StatsServer.h
+++ b/src/ManagementServer.h
@@ -2,17 +2,20 @@
Copyright (C) 2009 Her Majesty the Queen in Right of Canada (Communications
Research Center Canada)
- Copyright (C) 2014 Matthias P. Braendli
- http://mpb.li
+ Copyright (C) 2014, 2015
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://www.opendigitalradio.org
A TCP Socket server that serves state information and statistics for
- monitoring purposes.
+ monitoring purposes, and also serves the internal configuration
+ property tree.
- This server is very easy to integrate with munin
+ This statistics server is very easy to integrate with munin
http://munin-monitoring.org/
but is not specific to it.
- The TCP Server responds in JSON, and accepts two commands:
+ The TCP Server responds in JSON, and accepts the commands:
- config
- values
Inspired by the munin equivalent
@@ -20,6 +23,10 @@
- state
Returns the state of each input
+ - getptree
+ Returns the internal boost property_tree that contains the
+ multiplexer configuration DB.
+
*/
/*
This file is part of ODR-DabMux.
@@ -38,8 +45,8 @@
along with ODR-DabMux. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef __STATS_SERVER_H
-#define __STATS_SERVER_H
+#ifndef __MANAGEMENT_SERVER_H
+#define __MANAGEMENT_SERVER_H
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -54,6 +61,8 @@
#include <string>
#include <map>
#include <boost/thread.hpp>
+#include <boost/property_tree/ptree.hpp>
+#include <boost/property_tree/json_parser.hpp>
#include <ctime>
#include <math.h>
@@ -304,37 +313,57 @@ class InputStat
};
-class StatsServer
+class ManagementServer
{
public:
- StatsServer() :
+ ManagementServer() :
m_listenport(0),
m_running(false),
- m_fault(false)
+ m_fault(false),
+ m_pending(false)
{ }
- StatsServer(int listen_port) :
+ ManagementServer(int listen_port) :
m_listenport(listen_port),
m_running(false),
m_fault(false),
- m_thread(&StatsServer::serverThread, this)
+ m_thread(&ManagementServer::serverThread, this),
+ m_pending(false)
{
m_sock = 0;
}
- ~StatsServer()
+ ~ManagementServer()
{
m_running = false;
m_fault = false;
+ m_pending = false;
if (m_sock) {
close(m_sock);
}
m_thread.join();
}
+ /* Un-/Register a statistics data source */
void registerInput(InputStat* is);
void unregisterInput(std::string id);
+ /* Ask if there is a configuration request pending */
+ bool request_pending() { return m_pending; }
+
+ /* Update the copy of the configuration property tree and notify the
+ * update to the internal server thread.
+ */
+ void update_ptree(const boost::property_tree::ptree& pt) {
+ if (m_running) {
+ boost::unique_lock<boost::mutex> lock(m_configmutex);
+ m_pt = pt;
+ m_pending = false;
+
+ m_condition.notify_one();
+ }
+ }
+
bool fault_detected() { return m_fault; }
void restart(void);
@@ -343,7 +372,7 @@ class StatsServer
/******* TCP Socket Server ******/
// no copying (because of the thread)
- StatsServer(const StatsServer& other);
+ ManagementServer(const ManagementServer& other);
void serverThread(void);
@@ -367,7 +396,7 @@ class StatsServer
*
* returns: a JSON encoded configuration
*/
- std::string getConfigJSON();
+ std::string getStatConfigJSON();
/* Return the values for the statistics as defined in the configuration
*
@@ -382,11 +411,17 @@ class StatsServer
std::string getStateJSON();
// mutex for accessing the map
- mutable boost::mutex m_mutex;
-};
+ mutable boost::mutex m_statsmutex;
+
+ /******** Configuration Data *******/
+ bool m_pending;
+ boost::condition_variable m_condition;
+ mutable boost::mutex m_configmutex;
+ boost::property_tree::ptree m_pt;
+};
-extern StatsServer* global_stats;
+extern ManagementServer* mgmt_server;
#endif
diff --git a/src/dabInputZmq.cpp b/src/dabInputZmq.cpp
index 9dab6c9..9d39945 100644
--- a/src/dabInputZmq.cpp
+++ b/src/dabInputZmq.cpp
@@ -41,7 +41,6 @@
#include "dabInput.h"
#include "dabInputZmq.h"
-#include "StatsServer.h"
#include "PcDebug.h"
#ifdef HAVE_CONFIG_H
@@ -66,8 +65,6 @@
using namespace std;
-extern StatsServer* global_stats;
-
int readkey(string& keyfile, char* key)
{
int fd = open(keyfile.c_str(), O_RDONLY);
diff --git a/src/dabInputZmq.h b/src/dabInputZmq.h
index fd6c599..d13029d 100644
--- a/src/dabInputZmq.h
+++ b/src/dabInputZmq.h
@@ -55,7 +55,7 @@
#include <stdint.h>
#include "zmq.hpp"
#include "dabInput.h"
-#include "StatsServer.h"
+#include "ManagementServer.h"
/* The frame_buffer contains DAB logical frames as defined in
* TS 102 563, section 6.