Skip to content

Commit

Permalink
[Core] Redis code cleanup (ray-project#42306)
Browse files Browse the repository at this point in the history
Remove dead redis code

Signed-off-by: Jiajun Yao <[email protected]>
  • Loading branch information
jjyao authored Jan 11, 2024
1 parent 390f5f0 commit 6656512
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RedisGcsTableStorageTest : public gcs::GcsTableStorageTestBase {
void SetUp() override {
gcs::RedisClientOptions options("127.0.0.1", TEST_REDIS_SERVER_PORTS.front(), "");
redis_client_ = std::make_shared<gcs::RedisClient>(options);
RAY_CHECK_OK(redis_client_->Connect(io_service_pool_->GetAll()));
RAY_CHECK_OK(redis_client_->Connect(*io_service_pool_->Get()));

gcs_table_storage_ = std::make_shared<gcs::RedisGcsTableStorage>(redis_client_);
}
Expand Down
9 changes: 1 addition & 8 deletions src/ray/gcs/redis_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,14 @@ static int DoGetNextJobID(redisContext *context) {
RedisClient::RedisClient(const RedisClientOptions &options) : options_(options) {}

Status RedisClient::Connect(instrumented_io_context &io_service) {
std::vector<instrumented_io_context *> io_services;
io_services.emplace_back(&io_service);
return Connect(io_services);
}

Status RedisClient::Connect(std::vector<instrumented_io_context *> io_services) {
RAY_CHECK(!is_connected_);
RAY_CHECK(!io_services.empty());

if (options_.server_ip_.empty()) {
RAY_LOG(ERROR) << "Failed to connect, redis server address is empty.";
return Status::Invalid("Redis server address is invalid!");
}

primary_context_ = std::make_shared<RedisContext>(*io_services[0]);
primary_context_ = std::make_shared<RedisContext>(io_service);

RAY_CHECK_OK(primary_context_->Connect(options_.server_ip_,
options_.server_port_,
Expand Down
10 changes: 0 additions & 10 deletions src/ray/gcs/redis_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,6 @@ class RedisClient {
/// \return Status
Status Connect(instrumented_io_context &io_service);

// TODO(micafan) Maybe it's not necessary to use multi threads.
/// Connect to Redis. Non-thread safe.
/// Call this function before calling other functions.
///
/// \param io_services The event loops for this client. Each RedisContext bind to
/// an event loop. Each io_service must be single-threaded. Because `RedisAsioClient`
/// is non-thread safe.
/// \return Status
Status Connect(std::vector<instrumented_io_context *> io_services);

/// Disconnect with Redis. Non-thread safe.
void Disconnect();

Expand Down
2 changes: 0 additions & 2 deletions src/ray/gcs/redis_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,6 @@ void RedisContext::RunArgvAsync(std::vector<std::string> args,
request_context->Run();
}

void RedisContext::FreeRedisReply(void *reply) { return freeReplyObject(reply); }

} // namespace gcs

} // namespace ray
5 changes: 0 additions & 5 deletions src/ray/gcs/redis_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ class RedisContext {
///
/// \param args The vector of command args to pass to Redis.
/// \param redis_callback The Redis callback function.
/// \return Status.
void RunArgvAsync(std::vector<std::string> args,
RedisCallback redis_callback = nullptr);

Expand All @@ -175,10 +174,6 @@ class RedisContext {
instrumented_io_context &io_service() { return io_service_; }

private:
// These functions avoid problems with dependence on hiredis headers with clang-cl.
static int GetRedisError(redisContext *context);
static void FreeRedisReply(void *reply);

instrumented_io_context &io_service_;

std::unique_ptr<redisContext, RedisContextDeleter> context_;
Expand Down
2 changes: 1 addition & 1 deletion src/ray/gcs/store_client/test/redis_store_client_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class RedisStoreClientTest : public StoreClientTestBase {
void InitStoreClient() override {
RedisClientOptions options("127.0.0.1", TEST_REDIS_SERVER_PORTS.front(), "");
redis_client_ = std::make_shared<RedisClient>(options);
RAY_CHECK_OK(redis_client_->Connect(io_service_pool_->GetAll()));
RAY_CHECK_OK(redis_client_->Connect(*io_service_pool_->Get()));

store_client_ = std::make_shared<RedisStoreClient>(redis_client_);
}
Expand Down

0 comments on commit 6656512

Please sign in to comment.