From 16c28db384adbe61034eb8a2267cd6a886ffd72f Mon Sep 17 00:00:00 2001 From: Dennis Brentjes Date: Thu, 1 Dec 2016 21:42:51 +0100 Subject: Added the client side code for the statsd in the nodes. --- node/node.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'node/node.cpp') diff --git a/node/node.cpp b/node/node.cpp index aadc123..dc0d1c0 100644 --- a/node/node.cpp +++ b/node/node.cpp @@ -4,15 +4,19 @@ #include "logging.hpp" +#include + #include using namespace boost::asio::ip; -Node::Node(ListenSettings const& listen_settings, NodeNetworkSettings network_settings) +Node::Node(ListenSettings const& listen_settings, NodeNetworkSettings network_settings, PerformanceSettings performance_settings) : io_service() , timer(io_service) , ssl_ctx(std::make_shared(boost::asio::ssl::context::sslv23)) , server(io_service, listen_settings, ssl_ctx, [this](std::unique_ptr>&& socket, std::shared_ptr ctx){accept_handler(std::move(socket), ctx);}) +, purgatory() +, performance(boost::none) , clients() , data() , messages() @@ -22,6 +26,10 @@ Node::Node(ListenSettings const& listen_settings, NodeNetworkSettings network_se , cmix_ctx(initialize_cmix_context(get_implementation())) , shutting_down(false) { + if(performance_settings.run) { + performance = boost::in_place(performance_settings.name, boost::ref(io_service), performance_settings.host, performance_settings.port); + } + initialize_keypair(&cmix_ctx); GOOGLE_PROTOBUF_VERIFY_VERSION; @@ -135,6 +143,10 @@ void Node::handle_message(Purgatory::iterator handle, cmix_proto::CMixMessage me } void Node::start_precomputation() { + if(performance) { + performance->send("pre_pre_start"); + } + BOOST_LOG_TRIVIAL(trace) << "Starting precomputation for " << messages.size() << " clients."; index_map.clear(); @@ -188,6 +200,10 @@ void Node::start_precomputation() { exit(-1); } + if(performance) { + performance->send("pre_pre_end"); + } + BOOST_LOG_TRIVIAL(trace) << "Sending prepre message: " << prepre.ShortDebugString(); next_node.async_send(prepre); @@ -203,6 +219,10 @@ void Node::start_precomputation() { void Node::start_realtime_phase() { + if(performance) { + performance->send("real_pre_start"); + } + ArenaMessage arena; cmix_proto::RealPre& realpre = arena.get(); @@ -244,11 +264,16 @@ void Node::start_realtime_phase() { keys.data() ); + if(performance) { + performance->send("real_pre_end"); + } + + next_node.async_send(realpre); + for(auto&& pair : index_map) { messages.at(pair.first).pop(); } - next_node.async_send(realpre); } void Node::shutdown() -- cgit v1.2.3-70-g09d2