Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions mooncake-store/include/master_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,10 @@ class MasterClient {
/**
* @brief Pings master to check its availability
* @param client_id The uuid of the client
* @return tl::expected<std::pair<ViewVersionId, ClientStatus>, ErrorCode>
* @return tl::expected<PingResponse, ErrorCode>
* containing view version and client status
*/
[[nodiscard]] tl::expected<std::pair<ViewVersionId, ClientStatus>,
ErrorCode>
[[nodiscard]] tl::expected<PingResponse, ErrorCode>
Ping(const UUID& client_id);

private:
Expand Down
5 changes: 2 additions & 3 deletions mooncake-store/include/master_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,12 @@ class MasterService {
/**
* @brief Heartbeat from client
* @param client_id The uuid of the client
* @param[out] view_version The view version of the master
* @param[out] client_status The status of the client from the master
* @return PingResponse containing view version and client status
* @return ErrorCode::OK on success, ErrorCode::INTERNAL_ERROR if the client
* ping queue is full
*/
auto Ping(const UUID& client_id)
-> tl::expected<std::pair<ViewVersionId, ClientStatus>, ErrorCode>;
-> tl::expected<PingResponse, ErrorCode>;

/**
* @brief Get the master service cluster ID to use as subdirectory name
Expand Down
2 changes: 1 addition & 1 deletion mooncake-store/include/rpc_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class WrappedMasterService {

tl::expected<std::string, ErrorCode> GetFsdir();

tl::expected<std::pair<ViewVersionId, ClientStatus>, ErrorCode> Ping(
tl::expected<PingResponse, ErrorCode> Ping(
const UUID& client_id);

private:
Expand Down
20 changes: 19 additions & 1 deletion mooncake-store/include/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ enum class ClientStatus {
NEED_REMOUNT, // Ping ttl expired, or the first time connect to master, so
// need to remount
};
YLT_REFL(ClientStatus);

/**
* @brief Stream operator for ClientStatus
Expand All @@ -483,6 +482,25 @@ inline std::ostream& operator<<(std::ostream& os,
return os;
}

/**
* @brief Response structure for Ping operation
*/
struct PingResponse {
ViewVersionId view_version_id;
ClientStatus client_status;

PingResponse() = default;
PingResponse(ViewVersionId view_version, ClientStatus status)
: view_version_id(view_version), client_status(status) {}

friend std::ostream& operator<<(std::ostream& os,
const PingResponse& response) noexcept {
return os << "PingResponse: { view_version_id: " << response.view_version_id
<< ", client_status: " << response.client_status << " }";
}
};
YLT_REFL(PingResponse, view_version_id, client_status);

enum class BufferAllocatorType {
CACHELIB = 0, // CachelibBufferAllocator
OFFSET = 1, // OffsetBufferAllocator
Expand Down
5 changes: 2 additions & 3 deletions mooncake-store/src/master_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ tl::expected<void, ErrorCode> MasterClient::UnmountSegment(
return result;
}

tl::expected<std::pair<ViewVersionId, ClientStatus>, ErrorCode>
tl::expected<PingResponse, ErrorCode>
MasterClient::Ping(const UUID& client_id) {
ScopedVLogTimer timer(1, "MasterClient::Ping");
timer.LogRequest("client_id=", client_id);
Expand All @@ -569,8 +569,7 @@ MasterClient::Ping(const UUID& client_id) {
auto request_result =
client->send_request<&WrappedMasterService::Ping>(client_id);
auto result = coro::syncAwait(
[&]() -> coro::Lazy<tl::expected<std::pair<ViewVersionId, ClientStatus>,
ErrorCode>> {
[&]() -> coro::Lazy<tl::expected<PingResponse, ErrorCode>> {
auto result = co_await co_await request_result;
if (!result) {
LOG(ERROR) << "Failed to ping master: " << result.error().msg;
Expand Down
4 changes: 2 additions & 2 deletions mooncake-store/src/master_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ size_t MasterService::GetKeyCount() const {
}

auto MasterService::Ping(const UUID& client_id)
-> tl::expected<std::pair<ViewVersionId, ClientStatus>, ErrorCode> {
-> tl::expected<PingResponse, ErrorCode> {
if (!enable_ha_) {
LOG(ERROR) << "Ping is only available in HA mode";
return tl::make_unexpected(ErrorCode::UNAVAILABLE_IN_CURRENT_MODE);
Expand All @@ -604,7 +604,7 @@ auto MasterService::Ping(const UUID& client_id)
<< ", error=client_ping_queue_full";
return tl::make_unexpected(ErrorCode::INTERNAL_ERROR);
}
return std::make_pair(view_version_, client_status);
return PingResponse(view_version_, client_status);
}

tl::expected<std::string, ErrorCode> MasterService::GetFsdir() const {
Expand Down
2 changes: 1 addition & 1 deletion mooncake-store/src/rpc_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ tl::expected<std::string, ErrorCode> WrappedMasterService::GetFsdir() {
return result;
}

tl::expected<std::pair<ViewVersionId, ClientStatus>, ErrorCode>
tl::expected<PingResponse, ErrorCode>
WrappedMasterService::Ping(const UUID& client_id) {
ScopedVLogTimer timer(1, "Ping");
timer.LogRequest("client_id=", client_id);
Expand Down
Loading