mirror of
https://github.com/wassname/ray.git
synced 2026-07-31 12:41:01 +08:00
[GCS] global state query node info table from GCS. (#8498)
This commit is contained in:
@@ -108,7 +108,8 @@ void GcsNodeManager::NodeFailureDetector::ScheduleTick() {
|
||||
GcsNodeManager::GcsNodeManager(boost::asio::io_service &io_service,
|
||||
gcs::NodeInfoAccessor &node_info_accessor,
|
||||
gcs::ErrorInfoAccessor &error_info_accessor,
|
||||
std::shared_ptr<gcs::GcsPubSub> gcs_pub_sub)
|
||||
std::shared_ptr<gcs::GcsPubSub> gcs_pub_sub,
|
||||
std::shared_ptr<gcs::GcsTableStorage> gcs_table_storage)
|
||||
: node_info_accessor_(node_info_accessor),
|
||||
error_info_accessor_(error_info_accessor),
|
||||
node_failure_detector_(new NodeFailureDetector(
|
||||
@@ -125,7 +126,8 @@ GcsNodeManager::GcsNodeManager(boost::asio::io_service &io_service,
|
||||
// TODO(Shanly): Remove node resources from resource table.
|
||||
}
|
||||
})),
|
||||
gcs_pub_sub_(gcs_pub_sub) {
|
||||
gcs_pub_sub_(gcs_pub_sub),
|
||||
gcs_table_storage_(gcs_table_storage) {
|
||||
// TODO(Shanly): Load node info list from storage synchronously.
|
||||
// TODO(Shanly): Load cluster resources from storage synchronously.
|
||||
}
|
||||
@@ -144,7 +146,8 @@ void GcsNodeManager::HandleRegisterNode(const rpc::RegisterNodeRequest &request,
|
||||
request.node_info().SerializeAsString(), nullptr));
|
||||
GCS_RPC_SEND_REPLY(send_reply_callback, reply, status);
|
||||
};
|
||||
RAY_CHECK_OK(node_info_accessor_.AsyncRegister(request.node_info(), on_done));
|
||||
RAY_CHECK_OK(
|
||||
gcs_table_storage_->NodeTable().Put(node_id, request.node_info(), on_done));
|
||||
}
|
||||
|
||||
void GcsNodeManager::HandleUnregisterNode(const rpc::UnregisterNodeRequest &request,
|
||||
@@ -163,7 +166,8 @@ void GcsNodeManager::HandleUnregisterNode(const rpc::UnregisterNodeRequest &requ
|
||||
node->SerializeAsString(), nullptr));
|
||||
GCS_RPC_SEND_REPLY(send_reply_callback, reply, status);
|
||||
};
|
||||
RAY_CHECK_OK(node_info_accessor_.AsyncUnregister(node_id, on_done));
|
||||
// Update node state to DEAD instead of deleting it.
|
||||
RAY_CHECK_OK(gcs_table_storage_->NodeTable().Put(node_id, *node, on_done));
|
||||
// TODO(Shanly): Remove node resources from resource table.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <ray/rpc/gcs_server/gcs_rpc_server.h>
|
||||
#include "absl/container/flat_hash_map.h"
|
||||
#include "absl/container/flat_hash_set.h"
|
||||
#include "gcs_table_storage.h"
|
||||
#include "ray/gcs/pubsub/gcs_pub_sub.h"
|
||||
|
||||
namespace ray {
|
||||
@@ -36,12 +37,15 @@ class GcsNodeManager : public rpc::NodeInfoHandler {
|
||||
///
|
||||
/// \param io_service The event loop to run the monitor on.
|
||||
/// \param node_info_accessor The node info accessor.
|
||||
/// \param error_info_accessor The error info accessor, which is used to report error
|
||||
/// \param error_info_accessor The error info accessor, which is used to report error.
|
||||
/// \param gcs_pub_sub GCS message pushlisher.
|
||||
/// \param gcs_table_storage GCS table external storage accessor.
|
||||
/// when detecting the death of nodes.
|
||||
explicit GcsNodeManager(boost::asio::io_service &io_service,
|
||||
gcs::NodeInfoAccessor &node_info_accessor,
|
||||
gcs::ErrorInfoAccessor &error_info_accessor,
|
||||
std::shared_ptr<gcs::GcsPubSub> gcs_pub_sub);
|
||||
std::shared_ptr<gcs::GcsPubSub> gcs_pub_sub,
|
||||
std::shared_ptr<gcs::GcsTableStorage> gcs_table_storage);
|
||||
|
||||
/// Handle register rpc request come from raylet.
|
||||
void HandleRegisterNode(const rpc::RegisterNodeRequest &request,
|
||||
@@ -203,6 +207,8 @@ class GcsNodeManager : public rpc::NodeInfoHandler {
|
||||
node_removed_listeners_;
|
||||
/// A publisher for publishing gcs messages.
|
||||
std::shared_ptr<gcs::GcsPubSub> gcs_pub_sub_;
|
||||
/// Storage for GCS tables.
|
||||
std::shared_ptr<gcs::GcsTableStorage> gcs_table_storage_;
|
||||
};
|
||||
|
||||
} // namespace gcs
|
||||
|
||||
@@ -133,9 +133,9 @@ void GcsServer::InitBackendClient() {
|
||||
|
||||
void GcsServer::InitGcsNodeManager() {
|
||||
RAY_CHECK(redis_gcs_client_ != nullptr);
|
||||
gcs_node_manager_ =
|
||||
std::make_shared<GcsNodeManager>(main_service_, redis_gcs_client_->Nodes(),
|
||||
redis_gcs_client_->Errors(), gcs_pub_sub_);
|
||||
gcs_node_manager_ = std::make_shared<GcsNodeManager>(
|
||||
main_service_, redis_gcs_client_->Nodes(), redis_gcs_client_->Errors(),
|
||||
gcs_pub_sub_, gcs_table_storage_);
|
||||
}
|
||||
|
||||
void GcsServer::InitGcsActorManager() {
|
||||
|
||||
@@ -26,8 +26,10 @@ class GcsActorSchedulerTest : public ::testing::Test {
|
||||
raylet_client_ = std::make_shared<GcsServerMocker::MockRayletClient>();
|
||||
worker_client_ = std::make_shared<GcsServerMocker::MockWorkerClient>();
|
||||
gcs_pub_sub_ = std::make_shared<GcsServerMocker::MockGcsPubSub>(redis_client_);
|
||||
gcs_table_storage_ = std::make_shared<gcs::RedisGcsTableStorage>(redis_client_);
|
||||
gcs_node_manager_ = std::make_shared<gcs::GcsNodeManager>(
|
||||
io_service_, node_info_accessor_, error_info_accessor_, gcs_pub_sub_);
|
||||
io_service_, node_info_accessor_, error_info_accessor_, gcs_pub_sub_,
|
||||
gcs_table_storage_);
|
||||
gcs_actor_scheduler_ = std::make_shared<GcsServerMocker::MockedGcsActorScheduler>(
|
||||
io_service_, actor_info_accessor_, *gcs_node_manager_, gcs_pub_sub_,
|
||||
/*schedule_failure_handler=*/
|
||||
@@ -57,6 +59,7 @@ class GcsActorSchedulerTest : public ::testing::Test {
|
||||
std::vector<std::shared_ptr<gcs::GcsActor>> success_actors_;
|
||||
std::vector<std::shared_ptr<gcs::GcsActor>> failure_actors_;
|
||||
std::shared_ptr<GcsServerMocker::MockGcsPubSub> gcs_pub_sub_;
|
||||
std::shared_ptr<gcs::GcsTableStorage> gcs_table_storage_;
|
||||
std::shared_ptr<gcs::RedisClient> redis_client_;
|
||||
};
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace ray {
|
||||
class GcsNodeManagerTest : public ::testing::Test {
|
||||
protected:
|
||||
std::shared_ptr<gcs::GcsPubSub> gcs_pub_sub_;
|
||||
std::shared_ptr<gcs::GcsTableStorage> gcs_table_storage_;
|
||||
};
|
||||
|
||||
TEST_F(GcsNodeManagerTest, TestManagement) {
|
||||
@@ -29,7 +30,7 @@ TEST_F(GcsNodeManagerTest, TestManagement) {
|
||||
auto node_info_accessor = GcsServerMocker::MockedNodeInfoAccessor();
|
||||
auto error_info_accessor = GcsServerMocker::MockedErrorInfoAccessor();
|
||||
gcs::GcsNodeManager node_manager(io_service, node_info_accessor, error_info_accessor,
|
||||
gcs_pub_sub_);
|
||||
gcs_pub_sub_, gcs_table_storage_);
|
||||
// Test Add/Get/Remove functionality.
|
||||
auto node = Mocker::GenNodeInfo();
|
||||
auto node_id = ClientID::FromBinary(node->node_id());
|
||||
@@ -46,7 +47,7 @@ TEST_F(GcsNodeManagerTest, TestListener) {
|
||||
auto node_info_accessor = GcsServerMocker::MockedNodeInfoAccessor();
|
||||
auto error_info_accessor = GcsServerMocker::MockedErrorInfoAccessor();
|
||||
gcs::GcsNodeManager node_manager(io_service, node_info_accessor, error_info_accessor,
|
||||
gcs_pub_sub_);
|
||||
gcs_pub_sub_, gcs_table_storage_);
|
||||
// Test AddNodeAddedListener.
|
||||
int node_count = 1000;
|
||||
std::vector<std::shared_ptr<rpc::GcsNodeInfo>> added_nodes;
|
||||
|
||||
@@ -54,7 +54,8 @@ class GcsObjectManagerTest : public ::testing::Test {
|
||||
void SetUp() override {
|
||||
gcs_table_storage_ = std::make_shared<gcs::InMemoryGcsTableStorage>(io_service_);
|
||||
gcs_node_manager_ = std::make_shared<gcs::GcsNodeManager>(
|
||||
io_service_, node_info_accessor_, error_info_accessor_, gcs_pub_sub_);
|
||||
io_service_, node_info_accessor_, error_info_accessor_, gcs_pub_sub_,
|
||||
gcs_table_storage_);
|
||||
gcs_object_manager_ = std::make_shared<MockedGcsObjectManager>(
|
||||
gcs_table_storage_, gcs_pub_sub_, *gcs_node_manager_);
|
||||
GenTestData();
|
||||
|
||||
Reference in New Issue
Block a user