overview of c++20 coroutine interfaces for metadata sync
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <vector> | |
#include <string> | |
#include <boost/asio/awaitable.hpp> | |
#include <boost/asio/io_context.hpp> | |
#include "common/ceph_time.h" | |
#include "rgw_meta_sync_status.h" | |
struct meta_list_result; // TODO: move out of RGWFetchAllMetaCR | |
namespace rgw::sync::meta { | |
template <typename T, typename Executor = boost::asio::executor> | |
using boost::asio::awaitable; | |
// interfaces that tests can mock | |
class RemoteMetadata { | |
public: | |
virtual ~RemoteMetadata() {} | |
virtual awaitable<int> list_sections(std::vector<std::string>& sections) = 0; | |
virtual awaitable<int> list(std::string_view section, | |
meta_list_result& result) = 0; | |
virtual awaitable<int> read(std::string_view section, | |
std::string_view key, bufferlist& bl) = 0; | |
}; | |
class LocalMetadata { | |
public: | |
virtual ~LocalMetadata() {} | |
virtual awaitable<int> write(std::string_view section, | |
RGWObjVersionTracker& objv, | |
std::string_view key, const bufferlist& bl) = 0; | |
virtual awaitable<int> remove(std::string_view section, | |
RGWObjVersionTracker& objv, | |
std::string_view key) = 0; | |
}; | |
class RemoteLog { | |
public: | |
virtual ~RemoteLog() {} | |
virtual awaitable<int> list(std::string_view period, int shard, | |
std::string_view marker, | |
mdlog_shard_data& result) = 0; | |
}; | |
class LocalLog { | |
public: | |
virtual ~LocalLog() {} | |
virtual awaitable<int> list(std::string_view period, int shard, | |
std::string_view marker, | |
mdlog_shard_data& result) = 0; | |
virtual awaitable<int> write(std::string_view period, int shard, | |
const std::vector<rgw_mdlog_entry>& entries) = 0; | |
}; | |
class Status { | |
public: | |
virtual ~Status() {} | |
virtual awaitable<int> read(RGWObjVersionTracker& objv, | |
rgw_meta_sync_info& status) = 0; | |
virtual awaitable<int> write(RGWObjVersionTracker& objv, | |
const rgw_meta_sync_info& status) = 0; | |
}; | |
class LogStatus { | |
public: | |
virtual ~LogStatus() {} | |
virtual awaitable<int> read(int shard, RGWObjVersionTracker& objv, | |
rgw_meta_sync_marker& status) = 0; | |
virtual awaitable<int> write(int shard, RGWObjVersionTracker& objv, | |
const rgw_meta_sync_marker& status) = 0; | |
virtual awaitable<int> lock(int shard, std::string_view cookie, | |
ceph::timespan duration) = 0; | |
virtual awaitable<int> unlock(int shard, std::string_view cookie) = 0; | |
}; | |
// continuous lease renewal coroutine. TODO: cancellation | |
awaitable<int> renew_lease(boost::asio::io_context& ctx, | |
std::string_view cookie, | |
ceph::timespan duration, | |
LogStatus* log_status); | |
// start global sync | |
awaitable<int> sync(boost::asio::io_context& ctx, int num_shards, | |
RemoteLog* peer_log, LocalLog* local_log, | |
RemoteMetadata* peer_meta, LocalMetadata* local_meta, | |
Status* status, LogStatus* log_status); | |
// run incremental sync on the given period | |
awaitable<int> sync_period(boost::asio::io_context& ctx, | |
std::string_view period, int num_shards, | |
RemoteLog* peer_log, LocalLog* local_log, | |
RemoteMetadata* peer_meta, LocalMetadata* local_meta, | |
LogStatus* log_status); | |
// run incremental sync on the given mdlog shard | |
awaitable<int> sync_shard(boost::asio::io_context& ctx, int shard, | |
RemoteLog* peer_log, LocalLog* local_log, | |
RemoteMetadata* peer_meta, LocalMetadata* local_meta, | |
LogStatus* log_status); | |
// copy remote log entries to the local log | |
awaitable<int> clone_log(int shard, RemoteLog* peer_log, LocalLog* local_log); | |
} // namespace rgw::sync::meta |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment