]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add sync state parsing code and REST interface
authorGreg Farnum <greg@inktank.com>
Wed, 17 Jul 2013 19:51:04 +0000 (12:51 -0700)
committerGreg Farnum <greg@inktank.com>
Thu, 25 Jul 2013 23:00:17 +0000 (16:00 -0700)
Specify the param "sync-type" as one of "always", "update-by-version",
"update-by-timestamp". It defaults to always.

Signed-off-by: Greg Farnum <greg@inktank.com>
src/rgw/rgw_metadata.h
src/rgw/rgw_rest_metadata.cc

index b4e1584cf91fa947b5fc55155f9d124ab2bbeeea..56db78d53c844e2dac8748dd73142bd2df81856b 100644 (file)
@@ -50,6 +50,18 @@ public:
     APPLY_UPDATES,
     APPLY_NEWER
   };
+  static bool string_to_sync_type(const string& sync_string,
+                                  sync_type_t& type) {
+    if (sync_string.compare("update-by-version") == 0)
+      type = APPLY_UPDATES;
+    else if (sync_string.compare("update-by-timestamp") == 0)
+      type = APPLY_NEWER;
+    else if (sync_string.compare("always") == 0)
+      type = APPLY_ALWAYS;
+    else
+      return false;
+    return true;
+  }
   virtual ~RGWMetadataHandler() {}
   virtual string get_type() = 0;
 
index 7cf97f5db265c302777ca0180cff05aa65066c2d..d465f48a150b90be944d737e8f1ccbb1b49975bf 100644 (file)
@@ -163,6 +163,17 @@ void RGWOp_Metadata_Put::execute() {
   
   RGWMetadataHandler::sync_type_t sync_type = RGWMetadataHandler::APPLY_ALWAYS;
 
+  bool mode_exists = false;
+  string mode_string = s->info.args.get("sync-type", &mode_exists);
+  if (mode_exists) {
+    bool parsed = RGWMetadataHandler::string_to_sync_type(mode_string,
+                                                          sync_type);
+    if (!parsed) {
+      http_ret = -EINVAL;
+      return;
+    }
+  }
+
   http_ret = store->meta_mgr->put(metadata_key, bl, sync_type);
   if (http_ret < 0) {
     dout(5) << "ERROR: can't put key: " << cpp_strerror(http_ret) << dendl;