diff --git a/build/includes/summa_actor/batch_manager.hpp b/build/includes/summa_actor/batch_manager.hpp index 062cd06b0681653aa722b003cc0c82f30298c20c..cca0837a11c2cd815b3ebb9e679300932b68cefc 100644 --- a/build/includes/summa_actor/batch_manager.hpp +++ b/build/includes/summa_actor/batch_manager.hpp @@ -11,14 +11,43 @@ enum batch_status { failed }; +struct Batch_Struct { + int batch_id; + int start_hru; + int num_hru; + + double run_time; + double read_time; + double write_time; + + std::string assigned_host; + caf::actor assigned_actor; + bool assigned; +}; + +template<class Inspector> +bool inspect(Inspector& inspector, Batch_Struct& 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("write_time",batch.write_time), + inspector.field("assigned_host", batch.assigned_host), + inspector.field("assigned_actor", batch.assigned_actor), + inspector.field("assigned", batch.assigned)); +} + class Batch { private: int batch_id; int start_hru; int num_hru; + double run_time; double read_time; double write_time; + std::string assigned_host; caf::actor assigned_actor; batch_status status; @@ -52,6 +81,49 @@ class Batch_Manager { std::vector<Batch> batch_list; std::vector<Batch> solved_batches; std::vector<Batch> failed_batches; + + public: + /** + * Assemble the total number of HRUs given by the user into batches. + * The total number of hrus and the sizes of the batches are parameters + * provided by the user. + */ + void assembleBatches(int total_hru_count, int num_hru_per_batch); + + + /** + * Assign a batch to be solved by a client. + * The hostname and the actor_ref of the client solving this batch + * are added to the client for the servers awareness + * The batch is then returned by this method and sent to the respective client + */ + Batch assignBatch(std::string hostname, caf::actor actor_ref); + + + /** + * On a successful batch we take the batch given to us by the client + * and add it to our solved_batches list. + * + * We can then remove the batch from the global batch list. + */ + void batchSuccess(Batch successful_batch, std::string output_csv); + + + /** + * A batch failure is returned to us by the client + * This is for when a client failed to solve the batch. + */ + void batchFailure(Batch failed_batch); + + + /** + * A client has found to be disconnected. Unassign all batches + * that were assigned to the disconnected client. The client id + * is passed in as a parameter + */ + void disconnected_client(int client_id); + + }; \ No newline at end of file diff --git a/build/includes/summa_actor/summa_client.hpp b/build/includes/summa_actor/summa_client.hpp index 37f171dc19ede45e3300bfda1097f259a060097d..496429d236075e9a54049c129c95c428741f40d8 100644 --- a/build/includes/summa_actor/summa_client.hpp +++ b/build/includes/summa_actor/summa_client.hpp @@ -3,6 +3,7 @@ #include "caf/all.hpp" #include "caf/io/all.hpp" #include "settings_functions.hpp" +#include "batch_manager.hpp" #include <string> #include <optional> diff --git a/build/source/actors/summa_actor/client.cpp b/build/source/actors/summa_actor/client.cpp index bc5faa16663312972ee84117a4fedab95f7b6dea..b2e868a47a0d1ae6f2c36f3df02a3cfb75886b74 100644 --- a/build/source/actors/summa_actor/client.cpp +++ b/build/source/actors/summa_actor/client.cpp @@ -2,6 +2,8 @@ #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_actor.cpp b/build/source/actors/summa_actor/summa_actor.cpp index 679339251fcb8948242bb1794d59040028acb3ac..88d8ade1c55ebd760712ac23d698781d8853c2e1 100644 --- a/build/source/actors/summa_actor/summa_actor.cpp +++ b/build/source/actors/summa_actor/summa_actor.cpp @@ -109,4 +109,5 @@ void spawnJob(stateful_actor<summa_actor_state>* self) { self->state.numGRU = 0; } } + } // end namespace diff --git a/build/source/actors/summa_actor/summa_client.cpp b/build/source/actors/summa_actor/summa_client.cpp index 89606b354c05196a9dc790b7b2d35ca8f82ddffd..e8dfa8311133994445cce1b827c856efe756fe20 100644 --- a/build/source/actors/summa_actor/summa_client.cpp +++ b/build/source/actors/summa_actor/summa_client.cpp @@ -87,6 +87,8 @@ behavior running(stateful_actor<summa_client_state>* self, const actor& server_a }, + // [=](compute_batch) {} + [=](batch, int client_id, int batch_id, int start_hru, int num_hru, std::string config_path) { aout(self) << "\nReceived batch to compute" << "\n"; diff --git a/build/source/actors/summa_actor/summa_server.cpp b/build/source/actors/summa_actor/summa_server.cpp index abd617682072a2cddcf8800f9398230f5c83365b..68389ead371c4a0979e23153c6e65a24eb02c982 100644 --- a/build/source/actors/summa_actor/summa_server.cpp +++ b/build/source/actors/summa_actor/summa_server.cpp @@ -176,4 +176,6 @@ void initializeCSVOutput(std::string csv_output_name) { csv_output.close(); } + + } // end namespace