diff --git a/src/coordinator/coordinator.hpp b/src/coordinator/coordinator.hpp index d37e93f53..69a2e5cd7 100644 --- a/src/coordinator/coordinator.hpp +++ b/src/coordinator/coordinator.hpp @@ -104,10 +104,9 @@ class Coordinator { uint64_t highest_reserved_timestamp_; /// Increment our - ReadResponses Read(HlcRequest &&hlc_request) { - HlcResponse res{}; - + ReadResponses Read(HlcRequest hlc_request) { std::cout << "HlcRequest->HlcResponse" << std::endl; + HlcResponse res{}; auto hlc_shard_map = shard_map_.GetHlc(); @@ -126,6 +125,8 @@ class Coordinator { } GetShardMapResponse Read(GetShardMapRequest &&get_shard_map_request) { + std::cout << "GetShardMapRequest" << std::endl; + GetShardMapResponse res; res.shard_map = shard_map_; return res; @@ -178,7 +179,23 @@ class Coordinator { explicit Coordinator(ShardMap sm) : shard_map_{(sm)} {} ReadResponses Read(ReadRequests requests) { - return std::visit([&](auto &&requests) { return Read(requests); }, std::move(requests)); + if (std::get_if<HlcRequest>(&requests)) { + std::cout << "HlcRequest" << std::endl; + } else if (std::get_if<GetShardMapRequest>(&requests)) { + std::cout << "GetShardMapRequest" << std::endl; + } else { + std::cout << "idk requests" << std::endl; + } + std::cout << "Coordinator Read()" << std::endl; + auto ret = std::visit([&](auto requests) { return Read(requests); }, (requests)); + if (std::get_if<HlcResponse>(&ret)) { + std::cout << "HlcResponse" << std::endl; + } else if (std::get_if<GetShardMapResponse>(&ret)) { + std::cout << "GetShardMapResponse" << std::endl; + } else { + std::cout << "idk response" << std::endl; + } + return ret; } WriteResponses Apply(WriteRequests requests) { diff --git a/src/coordinator/shard_map.hpp b/src/coordinator/shard_map.hpp index cf7cec541..bc891db5e 100644 --- a/src/coordinator/shard_map.hpp +++ b/src/coordinator/shard_map.hpp @@ -97,7 +97,15 @@ struct ShardMap { Shards GetShardsForRange(Label label, CompoundKey start, CompoundKey end); - Shard GetShardForKey(Label label, CompoundKey key) { return shards.at(label).at(key); } + Shard GetShardForKey(Label label, CompoundKey key) { + // return shards.at(label).at(key); + std::cout << "label" << std::endl; + auto asd1 = shards.at(label); + std::cout << "key" << std::endl; + auto asd2 = asd1[key]; + + return asd2; + } }; } // namespace memgraph::coordinator diff --git a/tests/simulation/sharded_map.cpp b/tests/simulation/sharded_map.cpp index 9b38ac123..ba24c4295 100644 --- a/tests/simulation/sharded_map.cpp +++ b/tests/simulation/sharded_map.cpp @@ -90,6 +90,7 @@ ShardMap CreateDummyShardmap(memgraph::coordinator::Address a_io_1, memgraph::co Shards shards2; shards2[cm2] = shard2; + shards[label1] = shards1; shards[label2] = shards2; return sm1; @@ -258,6 +259,11 @@ int main() { continue; } + if (!read_res_opt.value().success) { + std::cout << "Not successful." << std::endl; + continue; + } + std::cout << "Before" << std::endl; auto read_res = read_res_opt.value(); std::cout << "After" << std::endl; @@ -276,7 +282,12 @@ int main() { client_shard_map = res.fresher_shard_map.value(); std::cout << "After2" << std::endl; - auto target_shard = client_shard_map.GetShardForKey("label1", cm_k); + // TODO(gabor) check somewhere in the call chain if the entries are actually valid + for (auto &[key, val] : client_shard_map.GetShards()) { + std::cout << "key: " << key << std::endl; + } + + auto target_shard = client_shard_map.GetShardForKey(std::string("label1"), cm_k); // Determine which shard to send the requests to auto storage_client_opt = DetermineShardLocation(target_shard, a_addrs, shard_a_client, b_addrs, shard_b_client); diff --git a/tests/simulation/utils/rsm_client.hpp b/tests/simulation/utils/rsm_client.hpp index 0b4b47cae..e1614af8d 100644 --- a/tests/simulation/utils/rsm_client.hpp +++ b/tests/simulation/utils/rsm_client.hpp @@ -87,6 +87,7 @@ class RsmClient { read_req.operation = req; std::cout << "client sending GetRequest to Leader " << leader_.last_known_port << std::endl; + ResponseFuture<ReadResponse<ReadResponseT>> get_response_future = io_.template Request<ReadRequest<ReadRequestT>, ReadResponse<ReadResponseT>>(leader_, read_req);