Check-in basic shard scheduler skeleton

This commit is contained in:
Tyler Neely 2022-10-27 13:36:53 +00:00
parent eafccaea84
commit 9448e23dc9
2 changed files with 46 additions and 1 deletions

View File

@ -28,6 +28,7 @@
#include <storage/v3/shard_rsm.hpp>
#include "coordinator/shard_map.hpp"
#include "storage/v3/config.hpp"
#include "storage/v3/shard_scheduler.hpp"
namespace memgraph::storage::v3 {
@ -78,7 +79,7 @@ template <typename IoImpl>
class ShardManager {
public:
ShardManager(io::Io<IoImpl> io, Address coordinator_leader, coordinator::ShardMap shard_map)
: io_(io), coordinator_leader_(coordinator_leader), shard_map_{std::move(shard_map)} {}
: io_(io), coordinator_leader_(coordinator_leader), shard_map_{std::move(shard_map)}, shard_scheduler_(io) {}
/// Periodic protocol maintenance. Returns the time that Cron should be called again
/// in the future.
@ -133,6 +134,7 @@ class ShardManager {
private:
io::Io<IoImpl> io_;
ShardScheduler<IoImpl> shard_scheduler_;
std::map<uuid, ShardRaft<IoImpl>> rsm_map_;
std::priority_queue<std::pair<Time, uuid>, std::vector<std::pair<Time, uuid>>, std::greater<>> cron_schedule_;
Time next_cron_ = Time::min();

View File

@ -0,0 +1,43 @@
// Copyright 2022 Memgraph Ltd.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
// License, and you may not use this file except in compliance with the Business Source License.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.
#pragma once
#include <boost/asio/thread_pool.hpp>
#include <boost/uuid/uuid.hpp>
#include "io/rsm/raft.hpp"
#include "query/v2/requests.hpp"
#include "storage/v3/shard_manager.hpp"
namespace memgraph::storage::v3 {
using memgraph::io::rsm::Raft;
using memgraph::io::rsm::WriteRequest;
using memgraph::io::rsm::WriteResponse;
using memgraph::msgs::ReadRequests;
using memgraph::msgs::ReadResponses;
using memgraph::msgs::WriteRequests;
using memgraph::msgs::WriteResponses;
template <typename IoImpl>
using ShardRaft = Raft<IoImpl, ShardRsm, WriteRequests, WriteResponses, ReadRequests, ReadResponses>;
template <class IoImpl>
class ShardScheduler {
std::map<boost::uuids::uuid, ShardRaft<IoImpl>> rsm_map_;
io::Io<IoImpl> io_;
public:
ShardScheduler(io::Io<IoImpl> io) : io_(io) {}
};
} // namespace memgraph::storage::v3