From e1953d11e9913e83c96d73518792cc75882369d7 Mon Sep 17 00:00:00 2001
From: KyleKlenk <kyle.c.klenk@gmail.com>
Date: Fri, 7 Oct 2022 15:09:41 +0000
Subject: [PATCH] client can use batch object to get info to start computing
 batch

client now needs to send the server the message that it is done
---
 build/includes/summa_actor/batch_manager.hpp  |  4 ++++
 .../actors/summa_actor/batch_manager.cpp      | 16 +++++++++----
 .../actors/summa_actor/summa_client.cpp       | 23 ++++++-------------
 .../actors/summa_actor/summa_server.cpp       |  2 +-
 4 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/build/includes/summa_actor/batch_manager.hpp b/build/includes/summa_actor/batch_manager.hpp
index a104cb9..d0a003f 100644
--- a/build/includes/summa_actor/batch_manager.hpp
+++ b/build/includes/summa_actor/batch_manager.hpp
@@ -21,6 +21,10 @@ class Batch {
 
         int getBatchID();
 
+        int getStartHRU();
+
+        int getNumHRU();
+
         bool getBatchStatus();
 
         void printBatchInfo();
diff --git a/build/source/actors/summa_actor/batch_manager.cpp b/build/source/actors/summa_actor/batch_manager.cpp
index 75b5769..d1e674b 100644
--- a/build/source/actors/summa_actor/batch_manager.cpp
+++ b/build/source/actors/summa_actor/batch_manager.cpp
@@ -48,9 +48,9 @@ std::optional<Batch> Batch_Container::assignBatch(std::string hostname, caf::act
 }
 
 
-
-
-
+// **************************
+// Batch Class
+// **************************
 
 Batch::Batch(int batch_id, int start_hru, int num_hru){
     this->batch_id = batch_id;
@@ -59,11 +59,19 @@ Batch::Batch(int batch_id, int start_hru, int num_hru){
     this->assigned_to_actor = false;
 }
 
-// Setters
+// Getters
 int Batch::getBatchID() {
     return this->batch_id;
 }
 
+int Batch::getStartHRU() {
+    return this->start_hru;
+}
+
+int Batch::getNumHRU() {
+    return this->num_hru;
+}
+
 bool Batch::getBatchStatus() {
     return this->assigned_to_actor;
 }
diff --git a/build/source/actors/summa_actor/summa_client.cpp b/build/source/actors/summa_actor/summa_client.cpp
index 4fde772..f0faa70 100644
--- a/build/source/actors/summa_actor/summa_client.cpp
+++ b/build/source/actors/summa_actor/summa_client.cpp
@@ -87,25 +87,16 @@ behavior running(stateful_actor<summa_client_state>* self, const actor& server_a
             
         },
 
+        // Received batch from server to compute
         [=](Batch& batch) {
-            aout(self) << "Recieved Batch" << std::endl;
-            aout(self) << batch.getBatchID() << std::endl;
-        },
-
+            aout(self) << "\nReceived batch to compute\n";
+            aout(self) << "BatchID = " << batch.getBatchID() << "\n";
+            aout(self) << "StartHRU = " << batch.getStartHRU() << "\n";
+            aout(self) << "NumHRU = " << batch.getNumHRU() << "\n";
 
-        [=](compute_batch, int client_id, int batch_id, int start_hru, int num_hru, std::string config_path) {
-            aout(self) << "\nReceived batch to compute" << "\n";
-            aout(self) << "BatchID = " << batch_id << "\n";
-            aout(self) << "Start HRU = " << start_hru << "\n";
-            aout(self) << "Num HRU = " << num_hru << "\n";
-            aout(self) << "Config Path = " << config_path << "\n";
-            self->state.client_id = client_id;
-            self->state.batch_id = batch_id;
-
-            
             self->state.summa_actor_ref = self->spawn(summa_actor, 
-                start_hru, 
-                num_hru, 
+                batch.getStartHRU(), 
+                batch.getNumHRU(), 
                 self->state.summa_actor_settings,
                 self->state.file_access_actor_settings,
                 self->state.job_actor_settings,
diff --git a/build/source/actors/summa_actor/summa_server.cpp b/build/source/actors/summa_actor/summa_server.cpp
index cf0fe86..f9e8994 100644
--- a/build/source/actors/summa_actor/summa_server.cpp
+++ b/build/source/actors/summa_actor/summa_server.cpp
@@ -37,7 +37,7 @@ behavior summa_server(stateful_actor<summa_server_state>* self, Distributed_Sett
          * @param hostname human readable hostname of the machine that the actor is running on
          */
         [=](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);
 
-- 
GitLab