From cdc6eb4266abacfd687563b832fea1fe7a44c617 Mon Sep 17 00:00:00 2001 From: Andrej Babic Date: Tue, 7 Apr 2020 11:13:59 +0200 Subject: [PATCH] Refactor ProcessManager --- core-writer/include/ProcessManager.hpp | 27 +++++---------- core-writer/src/ProcessManager.cpp | 46 +++++++------------------- 2 files changed, 21 insertions(+), 52 deletions(-) diff --git a/core-writer/include/ProcessManager.hpp b/core-writer/include/ProcessManager.hpp index c248c0b..65b4613 100644 --- a/core-writer/include/ProcessManager.hpp +++ b/core-writer/include/ProcessManager.hpp @@ -1,35 +1,26 @@ #ifndef PROCESSMANAGER_H #define PROCESSMANAGER_H -#include "WriterManager.hpp" +#include "WriterUtils.hpp" #include "H5Format.hpp" #include "RingBuffer.hpp" #include "ZmqReceiver.hpp" #include #include "date.h" +#include "H5WriteModule.hpp" +#include "ZmqRecvModule.hpp" class ProcessManager { - WriterManager& writer_manager; - ZmqReceiver& receiver; - RingBuffer& ring_buffer; - const H5Format& format; - - uint16_t rest_port; - const std::string& bsread_rest_address; - hsize_t frames_per_file; + H5WriteModule& write_module_; + ZmqRecvModule& recv_module_; public: - ProcessManager(WriterManager& writer_manager, - ZmqReceiver& receiver, - RingBuffer& ring_buffer, - const H5Format& format, - uint16_t rest_port, - const std::string& bsread_rest_address, - hsize_t frames_per_file=0); + ProcessManager(H5WriteModule& write_module, + ZmqRecvModule& recv_module); - void receive_zmq(); - void run_receivers(uint8_t n_receiving_threads); + + void start(uint16_t rest_port); }; diff --git a/core-writer/src/ProcessManager.cpp b/core-writer/src/ProcessManager.cpp index 13bd23c..3b59634 100644 --- a/core-writer/src/ProcessManager.cpp +++ b/core-writer/src/ProcessManager.cpp @@ -1,54 +1,32 @@ -#include -#include -#include -#include #include -#include -#include -#include -#include - #include "RestApi.hpp" #include "ProcessManager.hpp" -#include "config.hpp" -#include "BufferedWriter.hpp" -#include "compression.hpp" + using namespace std; ProcessManager::ProcessManager( - WriterManager& writer_manager, - ZmqReceiver& receiver, - RingBuffer& ring_buffer, - const H5Format& format, - uint16_t rest_port, - const string& bsread_rest_address, - hsize_t frames_per_file) : - writer_manager(writer_manager), - receiver(receiver), - ring_buffer(ring_buffer), - format(format), - rest_port(rest_port), - bsread_rest_address(bsread_rest_address), - frames_per_file(frames_per_file) + H5WriteModule& write_module, + ZmqRecvModule& recv_module) : + write_module_(write_module), + recv_module_(recv_module) { } -void ProcessManager::run_receivers(uint8_t n_receiving_threads) +void ProcessManager::start(uint16_t rest_port) { - - - RestApi::start_rest_api(writer_manager, rest_port); - + RestApi::start_rest_api(*this, rest_port); // In case SIGINT stopped the rest_api. - writer_manager.stop(); + // writer_manager.stop(); #ifdef DEBUG_OUTPUT using namespace date; - cout << "[" << std::chrono::system_clock::now() << "]"; - cout << "[ProcessManager::run_writer] Writer properly stopped." << endl; + using namespace chrono; + cout << "[" << system_clock::now() << "]"; + cout << "[ProcessManager::start]"; + cout << " Server stopped." << endl; #endif }