aboutsummaryrefslogtreecommitdiff
path: root/node/node.cpp
diff options
context:
space:
mode:
authorDennis Brentjes <d.brentjes@gmail.com>2016-12-01 21:42:51 +0100
committerDennis Brentjes <d.brentjes@gmail.com>2016-12-01 21:43:48 +0100
commit16c28db384adbe61034eb8a2267cd6a886ffd72f (patch)
tree426be5a41f5186ba17e909dda90afca5b7921c30 /node/node.cpp
parent463b8ec708db0d2d7405d434e28d0140c94b1d98 (diff)
downloadcmix-16c28db384adbe61034eb8a2267cd6a886ffd72f.tar.gz
cmix-16c28db384adbe61034eb8a2267cd6a886ffd72f.tar.bz2
cmix-16c28db384adbe61034eb8a2267cd6a886ffd72f.zip
Added the client side code for the statsd in the nodes.
Diffstat (limited to 'node/node.cpp')
-rw-r--r--node/node.cpp29
1 files changed, 27 insertions, 2 deletions
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 <boost/utility/in_place_factory.hpp>
+
#include <numeric>
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>(boost::asio::ssl::context::sslv23))
, server(io_service, listen_settings, ssl_ctx, [this](std::unique_ptr<boost::asio::ssl::stream<boost::asio::ip::tcp::socket>>&& socket, std::shared_ptr<boost::asio::ssl::context> 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<cmix_proto::RealPre> 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()