]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: header cleanup
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 13 Feb 2019 00:31:47 +0000 (16:31 -0800)
committerCasey Bodley <cbodley@redhat.com>
Mon, 29 Jul 2019 19:20:46 +0000 (15:20 -0400)
move implementation out of header.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/services/svc_sys_obj_cache.cc
src/rgw/services/svc_sys_obj_cache.h

index 80925d704487958e2c7221f3012e15dd968bd312..3d3ba08f6ddc715a9eabdd927892962e6a413add 100644 (file)
@@ -1,6 +1,9 @@
+
 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 
+#include "common/admin_socket.h"
+
 #include "svc_sys_obj_cache.h"
 #include "svc_zone.h"
 #include "svc_notify.h"
@@ -493,8 +496,35 @@ static void cache_list_dump_helper(Formatter* f,
   f->dump_unsigned("size", size);
 }
 
+class RGWSI_SysObj_Cache_ASocketHook : public AdminSocketHook {
+  RGWSI_SysObj_Cache *svc;
 
-int RGWSI_SysObj_Cache::ASocketHandler::start()
+  static constexpr const char* admin_commands[4][3] = {
+    { "cache list",
+      "cache list name=filter,type=CephString,req=false",
+      "cache list [filter_str]: list object cache, possibly matching substrings" },
+    { "cache inspect",
+      "cache inspect name=target,type=CephString,req=true",
+      "cache inspect target: print cache element" },
+    { "cache erase",
+      "cache erase name=target,type=CephString,req=true",
+      "cache erase target: erase element from cache" },
+    { "cache zap",
+      "cache zap",
+      "cache zap: erase all elements from cache" }
+  };
+
+public:
+    RGWSI_SysObj_Cache_ASocketHook(RGWSI_SysObj_Cache *_svc) : svc(_svc) {}
+
+    int start();
+    void shutdown();
+
+    bool call(std::string_view command, const cmdmap_t& cmdmap,
+              std::string_view format, bufferlist& out) override;
+};
+
+int RGWSI_SysObj_Cache_ASocketHook::start()
 {
   auto admin_socket = svc->ctx()->get_admin_socket();
   for (auto cmd : admin_commands) {
@@ -509,14 +539,14 @@ int RGWSI_SysObj_Cache::ASocketHandler::start()
   return 0;
 }
 
-void RGWSI_SysObj_Cache::ASocketHandler::shutdown()
+void RGWSI_SysObj_Cache_ASocketHook::shutdown()
 {
   auto admin_socket = svc->ctx()->get_admin_socket();
   admin_socket->unregister_commands(this);
 }
 
-bool RGWSI_SysObj_Cache::ASocketHandler::call(std::string_view command, const cmdmap_t& cmdmap,
-                                              std::string_view format, bufferlist& out)
+bool RGWSI_SysObj_Cache_ASocketHook::call(std::string_view command, const cmdmap_t& cmdmap,
+                                          std::string_view format, bufferlist& out)
 {
   if (command == "cache list"sv) {
     std::optional<std::string> filter;
@@ -526,7 +556,7 @@ bool RGWSI_SysObj_Cache::ASocketHandler::call(std::string_view command, const cm
     std::unique_ptr<Formatter> f(ceph::Formatter::create(format, "table"));
     if (f) {
       f->open_array_section("cache_entries");
-      call_list(filter, f.get());
+      svc->asocket.call_list(filter, f.get());
       f->close_section();
       f->flush(out);
       return true;
@@ -538,7 +568,7 @@ bool RGWSI_SysObj_Cache::ASocketHandler::call(std::string_view command, const cm
     std::unique_ptr<Formatter> f(ceph::Formatter::create(format, "json-pretty"));
     if (f) {
       const auto& target = boost::get<std::string>(cmdmap.at("target"));
-      if (call_inspect(target, f.get())) {
+      if (svc->asocket.call_inspect(target, f.get())) {
         f->flush(out);
         return true;
       } else {
@@ -551,19 +581,38 @@ bool RGWSI_SysObj_Cache::ASocketHandler::call(std::string_view command, const cm
     }
   } else if (command == "cache erase"sv) {
     const auto& target = boost::get<std::string>(cmdmap.at("target"));
-    if (call_erase(target)) {
+    if (svc->asocket.call_erase(target)) {
       return true;
     } else {
       out.append("Unable to find entry "s + target + ".\n");
       return false;
     }
   } else if (command == "cache zap"sv) {
-    call_zap();
+    svc->asocket.call_zap();
     return true;
   }
   return false;
 }
 
+RGWSI_SysObj_Cache::ASocketHandler::ASocketHandler(RGWSI_SysObj_Cache *_svc) : svc(_svc)
+{
+  hook.reset(new RGWSI_SysObj_Cache_ASocketHook(_svc));
+}
+
+RGWSI_SysObj_Cache::ASocketHandler::~ASocketHandler()
+{
+}
+
+int RGWSI_SysObj_Cache::ASocketHandler::start()
+{
+  return hook->start();
+}
+
+void RGWSI_SysObj_Cache::ASocketHandler::shutdown()
+{
+  return hook->shutdown();
+}
+
 void RGWSI_SysObj_Cache::ASocketHandler::call_list(const std::optional<std::string>& filter, Formatter* f)
 {
   svc->cache.for_each(
index af02db0c1973cd83d299595999317b95cf49498e..4c491c1bec7aa680dffc7610aa06ffac078abbd7 100644 (file)
@@ -11,6 +11,7 @@
 class RGWSI_Notify;
 
 class RGWSI_SysObj_Cache_CB;
+class RGWSI_SysObj_Cache_ASocketHook;
 
 class RGWSI_SysObj_Cache : public RGWSI_SysObj_Core
 {
@@ -101,33 +102,18 @@ public:
   void register_chained_cache(RGWChainedCache *cc);
   void unregister_chained_cache(RGWChainedCache *cc);
 
-  class ASocketHandler : public AdminSocketHook {
+  class ASocketHandler {
     RGWSI_SysObj_Cache *svc;
 
-    static constexpr const char* admin_commands[4][3] = {
-      { "cache list",
-        "cache list name=filter,type=CephString,req=false",
-        "cache list [filter_str]: list object cache, possibly matching substrings" },
-      { "cache inspect",
-        "cache inspect name=target,type=CephString,req=true",
-        "cache inspect target: print cache element" },
-      { "cache erase",
-        "cache erase name=target,type=CephString,req=true",
-        "cache erase target: erase element from cache" },
-      { "cache zap",
-        "cache zap",
-        "cache zap: erase all elements from cache" }
-    };
+    std::unique_ptr<RGWSI_SysObj_Cache_ASocketHook> hook;
 
   public:
-    ASocketHandler(RGWSI_SysObj_Cache *_svc) : svc(_svc) {}
+    ASocketHandler(RGWSI_SysObj_Cache *_svc);
+    ~ASocketHandler();
 
     int start();
     void shutdown();
 
-    bool call(std::string_view command, const cmdmap_t& cmdmap,
-              std::string_view format, bufferlist& out) override;
-
     // `call_list` must iterate over all cache entries and call
     // `cache_list_dump_helper` with the supplied Formatter on any that
     // include `filter` as a substring.