]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/cache: This commit squashes modifications to base class.
authorPritha Srivastava <prsrivas@redhat.com>
Fri, 2 Jun 2023 10:16:23 +0000 (15:46 +0530)
committerPritha Srivastava <prsrivas@redhat.com>
Tue, 2 Apr 2024 15:54:50 +0000 (21:24 +0530)
1. Rename namespace from rgw::cal to rgw::cache
2. Remove Partition from the CacheDriver constructor.
3. Removing rgw_cache_driver.cc since all methods
are pure virtual in rgw_cache_driver.h.
4. Moving structures Partition and Entry out of
class CacheDriver. And modifying the signatures of methods
get_current_partition_info() and get_free_space().
5. modifying the cache driver base class.

Signed-off-by: Pritha Srivastava <prsrivas@redhat.com>
src/rgw/CMakeLists.txt
src/rgw/rgw_cache_driver.cc [deleted file]
src/rgw/rgw_cache_driver.h

index 43611c8aeffc245599fa9a5620d6d4f3b0da4968..1bf433cb395108b3fbdd5dd73fbce412d1eea3e1 100644 (file)
@@ -116,7 +116,6 @@ set(librgw_common_srcs
   rgw_role.cc
   rgw_sal.cc
   rgw_sal_filter.cc
-  rgw_cache_driver.cc
   rgw_string.cc
   rgw_tag.cc
   rgw_tag_s3.cc
diff --git a/src/rgw/rgw_cache_driver.cc b/src/rgw/rgw_cache_driver.cc
deleted file mode 100644 (file)
index 859e2ee..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#include "rgw_cache_driver.h"
-
-namespace rgw { 
-
-int CacheDriver::initialize(CephContext* cct, const DoutPrefixProvider* dpp) {
-  return 0;
-}
-
-bool CacheDriver::key_exists(const DoutPrefixProvider* dpp, std::string& key) {
-  return false;
-}
-
-int CacheDriver::put(const DoutPrefixProvider* dpp, const std::string& key, bufferlist& bl, uint64_t len, rgw::sal::Attrs& attrs) {
-  return 0;
-}
-
-int CacheDriver::get(const DoutPrefixProvider* dpp, const std::string& key, off_t offset, uint64_t len, bufferlist& bl, rgw::sal::Attrs& attrs) {
-  return 0;
-}
-
-/*rgw::AioResultList CacheDriver::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) {
-  return nullptr;
-}
-
-rgw::AioResultList CacheDriver::put_async(const DoutPrefixProvider* dpp, optional_yield y, rgw::Aio* aio, const std::string& key, bufferlist& bl, uint64_t len, uint64_t cost, uint64_t id) {
-  return nullptr;
-}*/
-
-int CacheDriver::append_data(const DoutPrefixProvider* dpp, const::std::string& key, bufferlist& bl_data) {
-  return 0;
-}
-
-int CacheDriver::delete_data(const DoutPrefixProvider* dpp, const::std::string&        key) {
-  return 0;
-}
-
-int CacheDriver::get_attrs(const DoutPrefixProvider* dpp, const std::string& key, rgw::sal::Attrs& attrs) {
-  return 0;
-}
-
-int CacheDriver::update_attrs(const DoutPrefixProvider* dpp, const std::string& key, rgw::sal::Attrs& attrs) {
-  return 0;
-}
-
-int CacheDriver::delete_attrs(const DoutPrefixProvider* dpp, const std::string& key, rgw::sal::Attrs& del_attrs) {
-  return 0;
-}
-
-std::string CacheDriver::get_attr(const DoutPrefixProvider* dpp, const std::string& key, const std::string& attr_name) {
-  return {};
-}
-
-int CacheDriver::set_attr(const DoutPrefixProvider* dpp, const std::string& key, const std::string& attr_name, const std::string& attr_val) {
-  return 0;
-}
-
-} // namespace rgw::sal
index 1cec378eecc3944bf8b282965d6977569de2a56d..a96b325610073a6af6d2bdb59bf460682363c0f7 100644 (file)
@@ -1,85 +1,47 @@
-#ifndef CEPH_CACHEDRIVER_H
-#define CEPH_CACHEDRIVER_H
+#pragma once
 
-#include <string>
-#include <iostream>
 #include "rgw_common.h"
 
-namespace rgw {
+namespace rgw { namespace cache {
 
-class CacheDriver {
-  /*struct CacheAioRequest {*/
-    /* This will be invoked from rgw_aio.cc, to asynchronously read from / write to the cache backend. We will also need to define ops like the following in rgw_aio.h
-    Aio::OpFunc Aio::cache_read_op(const DoutPrefixProvider* dpp, optional_yield y, off_t ofs, uint64_t len)
-    Aio::OpFunc Aio::cache_write_op(const DoutPrefixProvider* dpp, optional_yield y, bufferlist& bl, uint64_t len)*/
-
-    /*void cache_aio_read_abstract(const DoutPrefixProvider* dpp, boost::asio::io_context& context, yield_context yield, off_t ofs, uint64_t len, rgw::Aio* aio, rgw::AioResult r);
-    void cache_aio_write_abstract(const DoutPrefixProvider* dpp, boost::asio::io_context& context, yield_context yield, bufferlist& bl, uint64_t len, rgw::Aio* aio, rgw::AioResult r);
-  };*/
+struct Partition {
+    std::string name;
+    std::string type;
+    std::string location;
+    uint64_t size;
+};
 
-  /* For Write-back cache*/
-  /*struct DirtyObjectsState {
-    std::string key;
-    ceph::real _time creation_time;
-    ceph::real lifetime; // time after which it will be written out to the store
-                              
-    std::queue<DirtyObjectState> dirty_obs_queue;
-    void write_to_store();
-  };*/
+struct Entry {
+  std::string key;
+  off_t offset;
+  uint64_t len;
+};
 
+class CacheDriver {
   public:
-    struct Entry {
-      std::string key;
-      off_t offset;
-      uint64_t len;
-      std::string location; //???
-
-      int insert_entry(const DoutPrefixProvider* dpp, std::string key, off_t offset, uint64_t len);
-      int remove_entry(const DoutPrefixProvider* dpp, std::string key);
-      Entry& get_entry(const DoutPrefixProvider* dpp, std::string key);
-    };
-
-    struct Partition {
-      std::string name;
-      std::string type;
-      std::string location;
-      uint64_t size;
-
-      //std::unordered_map<std::string, Partition> list_partitions() { return nullptr; }
-      //Partition& get_partition_info(const std::string& name, const std::string& type) { return nullptr; }
-      //Partition& get_current_partition_info() { return nullptr; }
-      uint64_t get_free_space() { return 0; }
-    };
-
-    Partition partition_info;
-
-    CacheDriver(Partition& _partition_info) : partition_info(_partition_info) {}
-    virtual ~CacheDriver() {}
+    CacheDriver() {}
+    virtual ~CacheDriver() = default;
 
     virtual int initialize(CephContext* cct, const DoutPrefixProvider* dpp) = 0;
-    virtual bool key_exists(const DoutPrefixProvider* dpp, std::string& key) = 0;
     virtual int put(const DoutPrefixProvider* dpp, const std::string& key, bufferlist& bl, uint64_t len, rgw::sal::Attrs& attrs) = 0;
     virtual int get(const DoutPrefixProvider* dpp, const std::string& key, off_t offset, uint64_t len, bufferlist& bl, rgw::sal::Attrs& attrs) = 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;
-    /* Assuming that we want to throttle put requests also */
-    //virtual rgw::AioResultList put_async(const DoutPrefixProvider* dpp, optional_yield y, rgw::Aio* aio, const std::string& key, bufferlist& bl, uint64_t len, uint64_t cost, uint64_t id) = 0;
     virtual int append_data(const DoutPrefixProvider* dpp, const::std::string& key, bufferlist& bl_data) = 0;
     virtual int delete_data(const DoutPrefixProvider* dpp, const::std::string& key) = 0;
     virtual int get_attrs(const DoutPrefixProvider* dpp, const std::string& key, rgw::sal::Attrs& attrs) = 0;
+    virtual int set_attrs(const DoutPrefixProvider* dpp, const std::string& key, rgw::sal::Attrs& attrs) = 0;
     virtual int update_attrs(const DoutPrefixProvider* dpp, const std::string& key, rgw::sal::Attrs& attrs) = 0;
     virtual int delete_attrs(const DoutPrefixProvider* dpp, const std::string& key, rgw::sal::Attrs& del_attrs) = 0;
     virtual std::string get_attr(const DoutPrefixProvider* dpp, const std::string& key, const std::string& attr_name) = 0;
     virtual int set_attr(const DoutPrefixProvider* dpp, const std::string& key, const std::string& attr_name, const std::string& attr_val) = 0;
 
     /* Entry */
-    //std::unordered_map<std::string key, Entry>& list_entries(const DoutPrefixProvider* dpp);
-    size_t get_num_entries(const DoutPrefixProvider* dpp) { return 0; }
+    virtual bool key_exists(const DoutPrefixProvider* dpp, const std::string& key) = 0;
+    virtual size_t get_num_entries(const DoutPrefixProvider* dpp) = 0;
 
     /* Partition */
-    //static std::unordered_map<std::string, Partition> partitions() { return nullptr; }
-    int add_partition_info(const std::string& name, const std::string& type, const std::string& location, uint64_t size) { return 0; }
+    virtual Partition get_current_partition_info(const DoutPrefixProvider* dpp) = 0;
+    virtual uint64_t get_free_space(const DoutPrefixProvider* dpp) = 0;
 };
 
-} // namespace rgw::sal
+} } // namespace rgw::cache
 
-#endif