Skip to content
Open
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
10 changes: 10 additions & 0 deletions doc/en/mooncake-store.md
Original file line number Diff line number Diff line change
Expand Up @@ -732,3 +732,13 @@ We provide a reference example `distributed_object_store_provider.py`, located i

#### C++ Usage Example
The C++ API of Mooncake Store provides more low-level control capabilities. We provide a reference example `client_integration_test`, located in the `mooncake-store/tests` directory. To check if the related components are properly installed, you can run etcd and Master Service (`mooncake_master`) on the same server, and then execute this C++ program (located in the `build/mooncake-store/tests` directory). It should output a successful test result.

## Version Management Policy

The current version of Mooncake Store is defined in [`CMakeLists.txt`](../../mooncake-store/CMakeLists.txt) as `project(MooncakeStore VERSION 2.0.0)`.

When to bump the version:

* **Major version (X.0.0)**: For breaking API changes, major architectural changes, or significant new features that affect backward compatibility
* **Minor version (0.X.0)**: For new features, API additions, or notable improvements that maintain backward compatibility
* **Patch version (0.0.X)**: For bug fixes, performance optimizations, or minor improvements that don't affect the API
10 changes: 10 additions & 0 deletions doc/zh/mooncake-store.md
Original file line number Diff line number Diff line change
Expand Up @@ -738,3 +738,13 @@ python -m mooncake.mooncake_store_service --config=[config_path] --port=8081
#### C++ 使用示例

Mooncake Store 的 C++ API 提供了更底层的控制能力。我们提供一个参考样例 `client_integration_test`,其位于 `mooncake-store/tests` 目录下。为了检测相关组件是否正常安装,可在相同的服务器上运行 etcd、Master Service(`mooncake_master`),并执行该 C++ 程序(位于 `build/mooncake-store/tests` 目录下),应输出测试成功的结果。

## 版本管理策略

Mooncake Store 的当前版本定义在 [`CMakeLists.txt`](../../mooncake-store/CMakeLists.txt) 中,为 `project(MooncakeStore VERSION 2.0.0)`

何时需要升级版本:

* **主版本号 (X.0.0)**:当存在破坏性的 API 变更、主要架构更改,或影响向后兼容性的重要新功能时
* **次版本号 (0.X.0)**:当添加新功能、API 扩展,或保持向后兼容性的显著改进时
* **修订版本号 (0.0.X)**:当进行错误修复、性能优化,或不改变 API 的细微改进时
8 changes: 7 additions & 1 deletion mooncake-store/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
project(MooncakeStore)
project(MooncakeStore VERSION 2.0.0)

# Extract version components for C++ usage
set(MOONCAKE_STORE_VERSION ${PROJECT_VERSION})

configure_file(include/version.h.in include/version.h @ONLY)

if (STORE_USE_ETCD)
set(ETCD_WRAPPER_INCLUDE ${CMAKE_CURRENT_BINARY_DIR}/../mooncake-common/etcd/)
Expand All @@ -14,6 +19,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include/cachelib_memory_allocator/
${CMAKE_CURRENT_SOURCE_DIR}/include/mooncake-store/proto/
${CMAKE_CURRENT_SOURCE_DIR}/include/
${CMAKE_CURRENT_BINARY_DIR}/include/
${CMAKE_CURRENT_SOURCE_DIR}/../mooncake-transfer-engine/include
${ETCD_WRAPPER_INCLUDE}
)
Expand Down
4 changes: 2 additions & 2 deletions mooncake-store/include/rpc_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class WrappedMasterService {

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

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

private:
MasterService master_service_;
Expand All @@ -97,4 +97,4 @@ class WrappedMasterService {
void RegisterRpcService(coro_rpc::coro_rpc_server& server,
mooncake::WrappedMasterService& wrapped_master_service);

} // namespace mooncake
} // namespace mooncake
16 changes: 16 additions & 0 deletions mooncake-store/include/version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include <string>

namespace mooncake {

// Version information for the Mooncake system
constexpr const char* MOONCAKE_STORE_VERSION = "@MOONCAKE_STORE_VERSION@";

// Function to get the version string
inline const std::string& GetMooncakeStoreVersion() {
static const std::string version(MOONCAKE_STORE_VERSION);
return version;
}

} // namespace mooncake
13 changes: 12 additions & 1 deletion mooncake-store/src/master_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "types.h"
#include "utils/scoped_vlog_timer.h"
#include "master_metric_manager.h"
#include "version.h"

namespace mooncake {

Expand Down Expand Up @@ -229,11 +230,21 @@ ErrorCode MasterClient::Connect(const std::string& master_addr) {
auto pool = client_accessor_.GetClientPool();
// The client pool does not have native connection check method, so we need
// to use custom ServiceReady API.
auto result = invoke_rpc<&WrappedMasterService::ServiceReady, void>();
auto result =
invoke_rpc<&WrappedMasterService::ServiceReady, std::string>();
if (!result.has_value()) {
timer.LogResponse("error_code=", result.error());
return result.error();
}
// Check if server version matches client version
std::string server_version = result.value();
std::string client_version = GetMooncakeStoreVersion();
if (server_version != client_version) {
LOG(ERROR) << "Version mismatch: server=" << server_version
<< " client=" << client_version;
timer.LogResponse("error_code=", ErrorCode::INVALID_VERSION);
return ErrorCode::INVALID_VERSION;
}
timer.LogResponse("error_code=", ErrorCode::OK);
return ErrorCode::OK;
}
Expand Down
5 changes: 3 additions & 2 deletions mooncake-store/src/rpc_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "rpc_helper.h"
#include "types.h"
#include "utils/scoped_vlog_timer.h"
#include "version.h"

namespace mooncake {

Expand Down Expand Up @@ -585,8 +586,8 @@ tl::expected<PingResponse, ErrorCode> WrappedMasterService::Ping(
return result;
}

tl::expected<void, ErrorCode> WrappedMasterService::ServiceReady() {
return {};
tl::expected<std::string, ErrorCode> WrappedMasterService::ServiceReady() {
return GetMooncakeStoreVersion();
}

void RegisterRpcService(
Expand Down
Loading