diff --git a/build/includes/summa_actor/batch_manager.hpp b/build/includes/summa_actor/batch_manager.hpp index 182dbba74b1c3d75ed0209fac8744eef37b279e0..f1416a9fa209c6ea152cf7e8f6113192ddbde39c 100644 --- a/build/includes/summa_actor/batch_manager.hpp +++ b/build/includes/summa_actor/batch_manager.hpp @@ -5,14 +5,7 @@ class Batch; -enum batch_status { - unassigned, - assigned, - solved, - failed -}; - -class Batch{ +class Batch { private: int batch_id; int start_hru; @@ -27,6 +20,8 @@ class Batch{ bool getBatchStatus(); + void printBatchInfo(); + template <class Inspector> friend bool inspect(Inspector& inspector, Batch& batch) { @@ -38,61 +33,6 @@ class Batch{ } }; - - - -// class Batch { -// private: -// int batch_id; -// int start_hru; -// int num_hru; - - // double run_time = -1; - // double read_time = -1; - // double write_time = -1; - -// std::string assigned_host; -// caf::actor assigned_actor; -// // batch_status status; - - -// public: -// Batch(int batch_id = -1, int start_hru = -1, int num_hru = -1); - -// // void printBatchInfo(); - -// // batch_status getBatchStatus(); - -// // int getBatchID(); - -// // int getStartHRU(); - -// // int getNumHRU(); - -// // void solvedBatch(double run_time, double read_time, double write_time); - -// // void assignedBatch(std::string hostname, caf::actor actor_ref); - -// // void updateRunTime(double run_time); - -// // void writeBatchToFile(std::string file_name); - -// template <class Inspector> -// friend bool inspect(Inspector& inspector, Batch& batch) { -// return inspector.object(batch).fields( -// inspector.field("batch_id", batch.batch_id), -// inspector.field("start_hru", batch.start_hru), -// inspector.field("num_hru", batch.num_hru), -// inspector.field("run_time", batch.run_time), -// inspector.field("read_time", batch.read_time), -// inspector.field("write_time", batch.write_time), -// inspector.field("assigned_host", batch.assigned_host), -// inspector.field("assigned_actor", batch.assigned_actor), -// inspector.field("status", batch.status)); -// } -// }; - - class Batch_Container { private: int total_hru_count; @@ -145,6 +85,15 @@ class Batch_Container { * Create the csv file for the completed batches. */ void inititalizeCSVOutput(std::string csv_output_name); + + + /** + * @brief Print the batches from the batch list + * + */ + void printBatches(); + + private: /** @@ -156,4 +105,6 @@ class Batch_Container { + + }; \ No newline at end of file diff --git a/build/includes/summa_actor/summa_server.hpp b/build/includes/summa_actor/summa_server.hpp index 5844358f0b12247a3845c66c36e0e4f9bb8cd4ff..7bbfd2080b9b45eb9bebe29c914bdee2c1aba9ce 100644 --- a/build/includes/summa_actor/summa_server.hpp +++ b/build/includes/summa_actor/summa_server.hpp @@ -22,8 +22,8 @@ struct summa_server_state { std::vector<Client> client_list; std::string csv_output_name; - Client_Container client_container; - // Batch_Container batch_container; + Client_Container *client_container; + Batch_Container *batch_container; Distributed_Settings distributed_settings; Summa_Actor_Settings summa_actor_settings; diff --git a/build/source/actors/summa_actor/batch_manager.cpp b/build/source/actors/summa_actor/batch_manager.cpp index e4d466ffcda3366f27bfc0d8953cae3fdbe1ae6c..43fabca8cac0b76f965f969273e00a263c8b6fb9 100644 --- a/build/source/actors/summa_actor/batch_manager.cpp +++ b/build/source/actors/summa_actor/batch_manager.cpp @@ -12,22 +12,27 @@ Batch_Container::Batch_Container(int total_hru_count, int num_hru_per_batch) { void Batch_Container::assembleBatches(int total_hru_count, int num_hru_per_batch) { int remaining_hru_to_batch = total_hru_count; - int count_index = 0; + int batch_id = 0; int start_hru = 1; - // while(remaining_hru_to_batch > 0) { - // if (num_hru_per_batch > remaining_hru_to_batch) { - // batch_list.push_back(Batch(count_index, start_hru, remaining_hru_to_batch)); - // remaining_hru_to_batch = 0; - // } else { - // batch_list.push_back(Batch(count_index, start_hru, num_hru_per_batch)); + while(remaining_hru_to_batch > 0) { + if (num_hru_per_batch > remaining_hru_to_batch) { + this->batch_list.push_back(Batch(batch_id, start_hru, remaining_hru_to_batch)); + remaining_hru_to_batch = 0; + } else { + this->batch_list.push_back(Batch(batch_id, start_hru, num_hru_per_batch)); - // remaining_hru_to_batch -= self->state.distributed_settings.num_hru_per_batch; - // start_hru += self->state.distributed_settings.num_hru_per_batch; - // count_index += 1; - // } - // } - // return 0; + remaining_hru_to_batch -= num_hru_per_batch; + start_hru += num_hru_per_batch; + batch_id += 1; + } + } +} + +void Batch_Container::printBatches(){ + for (std::vector<int>::size_type i = 0; i < this->batch_list.size(); i++) { + this->batch_list[i].printBatchInfo(); + } } @@ -50,11 +55,11 @@ bool Batch::getBatchStatus() { } -// void Batch::printBatchInfo() { -// std::cout << "batch_id: " << this->batch_id << "\n"; -// std::cout << "start_hru: " << this->start_hru << "\n"; -// std::cout << "num_hru: " << this->num_hru << "\n"; -// } +void Batch::printBatchInfo() { + std::cout << "batch_id: " << this->batch_id << "\n"; + std::cout << "start_hru: " << this->start_hru << "\n"; + std::cout << "num_hru: " << this->num_hru << "\n"; +} // batch_status Batch::getBatchStatus() { // return this->status; diff --git a/build/source/actors/summa_actor/client.cpp b/build/source/actors/summa_actor/client.cpp index cea1b9b10a2f8c839ce52b83b0daba273a09d542..47dd301f0c6ac4d474e2bfd19e11f569638c6ebe 100644 --- a/build/source/actors/summa_actor/client.cpp +++ b/build/source/actors/summa_actor/client.cpp @@ -2,8 +2,6 @@ #include "client.hpp" - - Client::Client(int id, caf::actor client_actor, std::string hostname) { this->id = id; this->client_actor = client_actor; diff --git a/build/source/actors/summa_actor/summa_server.cpp b/build/source/actors/summa_actor/summa_server.cpp index 499f28640a760ad29280514a43ab0c1313806f9a..3b9de903d0e0d141556becea172c626963f11d01 100644 --- a/build/source/actors/summa_actor/summa_server.cpp +++ b/build/source/actors/summa_actor/summa_server.cpp @@ -21,8 +21,12 @@ behavior summa_server(stateful_actor<summa_server_state>* self, Distributed_Sett self->state.job_actor_settings = job_actor_settings; self->state.hru_actor_settings = hru_actor_settings; - self->state.client_container = Client_Container(); - // self->state.batch_manager = Batch_Manager(); + self->state.client_container = new Client_Container(); + self->state.batch_container = new Batch_Container( + self->state.distributed_settings.total_hru_count, + self->state.distributed_settings.num_hru_per_batch); + + self->state.batch_container->printBatches(); // self->state.csv_output_name = "Batch_Results.csv"; // initializeCSVOutput(self->state.csv_output_name); @@ -49,13 +53,13 @@ behavior summa_server(stateful_actor<summa_server_state>* self, Distributed_Sett [=](connect_to_server, actor client_actor, std::string hostname) { // self->send(client, Batch{3,4,5}); aout(self) << "Actor trying to connect with hostname " << hostname << "\n"; - self->state.client_container.addClient(client_actor, hostname); + self->state.client_container->addClient(client_actor, hostname); // Tell client they are connected self->send(client_actor, connect_to_server_v, 1, self->state.summa_actor_settings, self->state.file_access_actor_settings, self->state.job_actor_settings, self->state.hru_actor_settings); - + // std::optional<int> batch_id = getUnsolvedBatchID(self); // if (batch_id.has_value()) { @@ -137,28 +141,6 @@ behavior summa_server(stateful_actor<summa_server_state>* self, Distributed_Sett } -int assembleBatches(stateful_actor<summa_server_state>* self) { - int remaining_hru_to_batch = self->state.distributed_settings.total_hru_count; - int count_index = 0; - int start_hru = 1; - - while(remaining_hru_to_batch > 0) { - if (self->state.distributed_settings.num_hru_per_batch > remaining_hru_to_batch) { - self->state.batch_list.push_back(Batch(count_index, start_hru, - remaining_hru_to_batch)); - remaining_hru_to_batch = 0; - } else { - self->state.batch_list.push_back(Batch(count_index, start_hru, - self->state.distributed_settings.num_hru_per_batch)); - - remaining_hru_to_batch -= self->state.distributed_settings.num_hru_per_batch; - start_hru += self->state.distributed_settings.num_hru_per_batch; - count_index += 1; - } - } - return 0; -} - std::optional<int> getUnsolvedBatchID(stateful_actor<summa_server_state>* self) { // Find the first unassigned batch // for (std::vector<int>::size_type i = 0; i < self->state.batch_list.size(); i++) {