From 4a0f427c9d62f99cd06237cc974807c9c229ad29 Mon Sep 17 00:00:00 2001 From: Samarah Date: Thu, 17 Oct 2024 17:20:34 +0000 Subject: [PATCH] rgw/cache: Remove `del` method Signed-off-by: Samarah --- src/rgw/rgw_cache_driver.h | 1 - src/rgw/rgw_redis_driver.cc | 42 +++--------------------------- src/rgw/rgw_redis_driver.h | 1 - src/rgw/rgw_ssd_driver.h | 1 - src/test/rgw/test_redis_driver.cc | 43 ++----------------------------- 5 files changed, 6 insertions(+), 82 deletions(-) diff --git a/src/rgw/rgw_cache_driver.h b/src/rgw/rgw_cache_driver.h index f8d9747cb5f..2ca91538fb9 100644 --- a/src/rgw/rgw_cache_driver.h +++ b/src/rgw/rgw_cache_driver.h @@ -43,7 +43,6 @@ class CacheDriver { virtual int initialize(const DoutPrefixProvider* dpp) = 0; virtual int put(const DoutPrefixProvider* dpp, const std::string& key, const bufferlist& bl, uint64_t len, const rgw::sal::Attrs& attrs, optional_yield y) = 0; virtual int get(const DoutPrefixProvider* dpp, const std::string& key, off_t offset, uint64_t len, bufferlist& bl, rgw::sal::Attrs& attrs, optional_yield y) = 0; - virtual int del(const DoutPrefixProvider* dpp, const std::string& key, optional_yield y) = 0; virtual rgw::AioResultList get_async (const DoutPrefixProvider* dpp, optional_yield y, rgw::Aio* aio, const std::string& key, off_t ofs, uint64_t len, uint64_t cost, uint64_t id) = 0; virtual rgw::AioResultList put_async(const DoutPrefixProvider* dpp, optional_yield y, rgw::Aio* aio, const std::string& key, const bufferlist& bl, uint64_t len, const rgw::sal::Attrs& attrs, uint64_t cost, uint64_t id) = 0; virtual int append_data(const DoutPrefixProvider* dpp, const::std::string& key, const bufferlist& bl_data, optional_yield y) = 0; diff --git a/src/rgw/rgw_redis_driver.cc b/src/rgw/rgw_redis_driver.cc index d785a405a19..3fb93583b61 100644 --- a/src/rgw/rgw_redis_driver.cc +++ b/src/rgw/rgw_redis_driver.cc @@ -162,41 +162,6 @@ int RedisDriver::get(const DoutPrefixProvider* dpp, const std::string& key, off_ return 0; } -int RedisDriver::del(const DoutPrefixProvider* dpp, const std::string& key, optional_yield y) -{ - std::string entry = partition_info.location + key; - response resp; - - try { - boost::system::error_code ec; - response< - ignore_t, - ignore_t, - ignore_t, - response, std::optional> - > resp; - request req; - req.push("MULTI"); - req.push("HSTRLEN", entry, "data"); - req.push("DEL", entry); - req.push("EXEC"); - - redis_exec(conn, ec, req, resp, y); - - if (ec) { - ldpp_dout(dpp, 0) << "RedisDriver::" << __func__ << "(): ERROR: " << ec.what() << dendl; - return -ec.value(); - } - - this->free_space += std::get<0>(std::get<3>(resp).value()).value().value(); - } catch (std::exception &e) { - ldpp_dout(dpp, 0) << "RedisDriver::" << __func__ << "(): ERROR: " << e.what() << dendl; - return -EINVAL; - } - - return 0; -} - int RedisDriver::append_data(const DoutPrefixProvider* dpp, const::std::string& key, const bufferlist& bl_data, optional_yield y) { std::string value = ""; @@ -251,19 +216,20 @@ int RedisDriver::append_data(const DoutPrefixProvider* dpp, const::std::string& int RedisDriver::delete_data(const DoutPrefixProvider* dpp, const::std::string& key, optional_yield y) { std::string entry = partition_info.location + key; + response resp; try { boost::system::error_code ec; - request req; response< ignore_t, ignore_t, ignore_t, response, std::optional> > resp; + request req; req.push("MULTI"); req.push("HSTRLEN", entry, "data"); - req.push("HDEL", entry, "data"); + req.push("DEL", entry); req.push("EXEC"); redis_exec(conn, ec, req, resp, y); @@ -279,7 +245,7 @@ int RedisDriver::delete_data(const DoutPrefixProvider* dpp, const::std::string& return -EINVAL; } - return 0; + return 0; } int RedisDriver::rename(const DoutPrefixProvider* dpp, const::std::string& oldKey, const::std::string& newKey, optional_yield y) { diff --git a/src/rgw/rgw_redis_driver.h b/src/rgw/rgw_redis_driver.h index e100976cace..7889e8fc7d7 100644 --- a/src/rgw/rgw_redis_driver.h +++ b/src/rgw/rgw_redis_driver.h @@ -36,7 +36,6 @@ class RedisDriver : public CacheDriver { const rgw::sal::Attrs& attrs, uint64_t cost, uint64_t id) override; virtual int get(const DoutPrefixProvider* dpp, const std::string& key, off_t offset, uint64_t len, bufferlist& bl, rgw::sal::Attrs& attrs, optional_yield y) override; virtual rgw::AioResultList get_async(const DoutPrefixProvider* dpp, optional_yield y, rgw::Aio* aio, const std::string& key, off_t ofs, uint64_t len, uint64_t cost, uint64_t id) override; - virtual int del(const DoutPrefixProvider* dpp, const std::string& key, optional_yield y) override; virtual int append_data(const DoutPrefixProvider* dpp, const::std::string& key, const bufferlist& bl_data, optional_yield y) override; virtual int delete_data(const DoutPrefixProvider* dpp, const::std::string& key, optional_yield y) override; virtual int rename(const DoutPrefixProvider* dpp, const::std::string& oldKey, const::std::string& newKey, optional_yield y) override; diff --git a/src/rgw/rgw_ssd_driver.h b/src/rgw/rgw_ssd_driver.h index f8a74fb6ab3..dedf539e0ff 100644 --- a/src/rgw/rgw_ssd_driver.h +++ b/src/rgw/rgw_ssd_driver.h @@ -14,7 +14,6 @@ public: virtual int initialize(const DoutPrefixProvider* dpp) override; virtual int put(const DoutPrefixProvider* dpp, const std::string& key, const bufferlist& bl, uint64_t len, const rgw::sal::Attrs& attrs, optional_yield y) override; virtual int get(const DoutPrefixProvider* dpp, const std::string& key, off_t offset, uint64_t len, bufferlist& bl, rgw::sal::Attrs& attrs, optional_yield y) override; - virtual int del(const DoutPrefixProvider* dpp, const std::string& key, optional_yield y) override { return -1; } // TODO: implement virtual rgw::AioResultList get_async (const DoutPrefixProvider* dpp, optional_yield y, rgw::Aio* aio, const std::string& key, off_t ofs, uint64_t len, uint64_t cost, uint64_t id) override; virtual rgw::AioResultList put_async(const DoutPrefixProvider* dpp, optional_yield y, rgw::Aio* aio, const std::string& key, const bufferlist& bl, uint64_t len, const rgw::sal::Attrs& attrs, uint64_t cost, uint64_t id) override; virtual int append_data(const DoutPrefixProvider* dpp, const::std::string& key, const bufferlist& bl_data, optional_yield y) override; diff --git a/src/test/rgw/test_redis_driver.cc b/src/test/rgw/test_redis_driver.cc index 8aefe7fbc39..a811ff031b9 100644 --- a/src/test/rgw/test_redis_driver.cc +++ b/src/test/rgw/test_redis_driver.cc @@ -246,7 +246,7 @@ TEST_F(RedisDriverFixture, GetAsyncYield) io.run(); } -TEST_F(RedisDriverFixture, DelYield) +TEST_F(RedisDriverFixture, DeleteDataYield) { boost::asio::spawn(io, [this] (boost::asio::yield_context yield) { ASSERT_EQ(0, cacheDriver->put(env->dpp, "testName", bl, bl.length(), attrs, yield)); @@ -263,7 +263,7 @@ TEST_F(RedisDriverFixture, DelYield) EXPECT_EQ(std::get<0>(resp).value(), 1); } - ASSERT_EQ(0, cacheDriver->del(env->dpp, "testName", yield)); + ASSERT_EQ(0, cacheDriver->delete_data(env->dpp, "testName", yield)); cacheDriver->shutdown(); { @@ -327,45 +327,6 @@ TEST_F(RedisDriverFixture, AppendDataYield) io.run(); } -TEST_F(RedisDriverFixture, DeleteDataYield) -{ - boost::asio::spawn(io, [this] (boost::asio::yield_context yield) { - ASSERT_EQ(0, cacheDriver->put(env->dpp, "testName", bl, bl.length(), attrs, yield)); - - { - boost::system::error_code ec; - request req; - req.push("HEXISTS", "RedisCache/testName", "data"); - response resp; - - conn->async_exec(req, resp, yield[ec]); - - ASSERT_EQ((bool)ec, false); - EXPECT_EQ(std::get<0>(resp).value(), 1); - } - - ASSERT_EQ(0, cacheDriver->delete_data(env->dpp, "testName", yield)); - cacheDriver->shutdown(); - - { - boost::system::error_code ec; - request req; - req.push("HEXISTS", "RedisCache/testName", "data"); - req.push("FLUSHALL"); - response resp; - - conn->async_exec(req, resp, yield[ec]); - - ASSERT_EQ((bool)ec, false); - EXPECT_EQ(std::get<0>(resp).value(), 0); - } - - conn->cancel(); - }, rethrow); - - io.run(); -} - TEST_F(RedisDriverFixture, RenameYield) { boost::asio::spawn(io, [this] (boost::asio::yield_context yield) { -- 2.39.5