Check-in changes from hangout

This commit is contained in:
Tyler Neely 2022-07-26 15:23:55 +00:00
parent 3ec1ff9ee4
commit c100a86644
2 changed files with 35 additions and 3 deletions

View File

@ -12,15 +12,47 @@
#pragma once
#include "coordinator/shard_map.hpp"
#include "io/simulator/simulator.hpp"
#include "io/transport.hpp"
namespace memgraph::coordinator {
using Address = memgraph::io::Address;
using Io = memgraph::io::Io;
using SimT = memgraph::io::simulator::SimulatorTransport;
struct SplitShardRequest {};
struct SplitShardResponse {};
struct RegisterStorageEngineRequest {};
struct RegisterStorageEngineResponse {};
class Coordinator {
ShardMap shard_map_;
Io<SimT> io_;
void Handle(SplitShardRequest &split_shard_request, Address from_addr) {}
void Handle(RegisterStorageEngineRequest &register_storage_engine_request, Address from_addr) {}
public:
/// This splits the previous shard
bool SplitShard(uint64_t previous_shard_map_version, Label label, CompoundKey split_key);
void Run() {
while (!io_.ShouldShutDown()) {
std::cout << "[Coordinator] Is receiving..." << std::endl;
auto request_result = io_.ReceiveWithTimeout<SplitShardRequest, RegisterStorageEngineRequest>(100000);
if (request_result.HasError()) {
std::cout << "[Coordinator] Error, continue" << std::endl;
continue;
}
auto request_envelope = request_result.GetValue();
// TODO std::visit to determine whether to handle shard split, registration etc... (see raft.hpp Run / Handle
// methods in T0941)
}
}
};
} // namespace memgraph::coordinator

View File

@ -38,9 +38,9 @@ using Shards = std::map<CompoundKey, Shard>;
// use string for intermachine communication and NameIdMapper within the machine
using Label = std::string;
class ShardMap {
uint64_t shard_map_version_;
std::map<Label, Shards> shards_;
struct ShardMap {
uint64_t shard_map_version;
std::map<Label, Shards> shards;
public:
Shards GetShardsForRange(Label label, CompoundKey start, CompoundKey end);