]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: compilation and other fixes following rebase
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 15 Dec 2016 00:09:13 +0000 (16:09 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 9 Mar 2017 17:18:54 +0000 (09:18 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_data_sync.cc
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/test/rgw/test_rgw_manifest.cc
src/test/rgw/test_rgw_obj.cc

index 66a3b20e46ac93b61390a32194ea728e9a1d538d..732fa8114d7381cb4ec8e503775f8badbe4750fa 100644 (file)
@@ -3083,8 +3083,8 @@ int DataLogTrimPollCR::operate()
       // prevent other gateways from attempting to trim for the duration
       set_status("acquiring trim lock");
       yield call(new RGWSimpleRadosLockCR(store->get_async_rados(), store,
-                                          store->get_zone_params().log_pool,
-                                          lock_oid, "data_trim", lock_cookie,
+                                          rgw_raw_obj(store->get_zone_params().log_pool, lock_oid),
+                                          "data_trim", lock_cookie,
                                           interval.sec()));
       if (retcode < 0) {
         // if the lock is already held, go back to sleep and try again later
index 91bbf216ed36078f69b5c916f502ccc5ad794856..72629986fd962afb73e586c4857d99852b7e4bf7 100644 (file)
@@ -5272,8 +5272,7 @@ void RGWDeleteMultiObj::execute()
   for (iter = multi_delete->objects.begin();
         iter != multi_delete->objects.end() && num_processed < max_to_delete;
         ++iter, num_processed++) {
-    rgw_obj obj(bucket, iter->name);
-    obj.set_instance(iter->instance);
+    rgw_obj obj(bucket, *iter);
 
     obj_ctx->obj.set_atomic(obj);
 
index 964cff81f3d5686911e40aa3c379593d8a99d287..ab7b32521e86edcd12b7d4c1dd68568fc8c057c2 100644 (file)
@@ -11401,8 +11401,7 @@ int RGWRados::omap_get_all(rgw_raw_obj& obj, bufferlist& header,
                           std::map<string, bufferlist>& m)
 {
   rgw_rados_ref ref;
-  rgw_bucket bucket;
-  int r = get_obj_ref(obj, &ref, &bucket);
+  int r = get_raw_obj_ref(obj, &ref);
   if (r < 0) {
     return r;
   }
index 3d4e40c619ff35f7ed7adc28b5ff7ff83541cfca..6bbb105c832d6d52884a27595618de94fb614dc9 100644 (file)
@@ -128,7 +128,7 @@ void append_stripes(list<rgw_obj> *objs, RGWObjManifest& manifest, uint64_t obj_
 }
 
 static void gen_obj(test_rgw_env& env, uint64_t obj_size, uint64_t head_max_size, uint64_t stripe_size,
-                    RGWObjManifest *manifest, rgw_bucket *bucket, rgw_obj *head, RGWObjManifest::generator *gen,
+                    RGWObjManifest *manifest, const string& placement_id, rgw_bucket *bucket, rgw_obj *head, RGWObjManifest::generator *gen,
                     list<rgw_obj> *test_objs)
 {
   manifest->set_trivial_rule(head_max_size, stripe_size);
@@ -136,7 +136,7 @@ static void gen_obj(test_rgw_env& env, uint64_t obj_size, uint64_t head_max_size
   test_rgw_init_bucket(bucket, "buck");
 
   *head = rgw_obj(*bucket, "oid");
-  gen->create_begin(g_ceph_context, manifest, *bucket, *head);
+  gen->create_begin(g_ceph_context, manifest, placement_id, *bucket, *head);
 
   append_head(test_objs, *head);
   cout << "test_objs.size()=" << test_objs->size() << std::endl;
@@ -153,9 +153,8 @@ static void gen_obj(test_rgw_env& env, uint64_t obj_size, uint64_t head_max_size
 
   while (ofs < obj_size) {
     rgw_raw_obj obj = gen->get_cur_obj(env.zonegroup, env.zone_params);
-cout << "obj=" << obj << std::endl;
-    rgw_raw_obj test_raw;
-    rgw_obj_to_raw(env.zonegroup, env.zone_params, *iter, &test_raw);
+    cout << "obj=" << obj << std::endl;
+    rgw_raw_obj test_raw = rgw_obj_select(*iter).get_raw_obj(env.zonegroup, env.zone_params);
     ASSERT_TRUE(obj == test_raw);
 
     ofs = MIN(ofs + gen->cur_stripe_max_size(), obj_size);
@@ -169,8 +168,7 @@ cout << "obj=" << obj << std::endl;
 
   if (manifest->has_tail()) {
     rgw_raw_obj obj = gen->get_cur_obj(env.zonegroup, env.zone_params);
-    rgw_raw_obj test_raw;
-    rgw_obj_to_raw(env.zonegroup, env.zone_params, *iter, &test_raw);
+    rgw_raw_obj test_raw = rgw_obj_select(*iter).get_raw_obj(env.zonegroup, env.zone_params);
     ASSERT_TRUE(obj == test_raw);
     ++iter;
   }
@@ -227,7 +225,7 @@ TEST(TestRGWManifest, head_only_obj) {
 
   list<rgw_obj> objs;
 
-  gen_obj(env, obj_size, 512 * 1024, 4 * 1024 * 1024, &manifest, &bucket, &head, &gen, &objs);
+  gen_obj(env, obj_size, 512 * 1024, 4 * 1024 * 1024, &manifest, env.zonegroup.default_placement, &bucket, &head, &gen, &objs);
 
   cout <<  " manifest.get_obj_size()=" << manifest.get_obj_size() << std::endl;
   cout <<  " manifest.get_head_size()=" << manifest.get_head_size() << std::endl;
@@ -263,7 +261,7 @@ TEST(TestRGWManifest, obj_with_head_and_tail) {
   int stripe_size = 4 * 1024 * 1024;
   int head_size = 512 * 1024;
 
-  gen_obj(env, obj_size, head_size, stripe_size, &manifest, &bucket, &head, &gen, &objs);
+  gen_obj(env, obj_size, head_size, stripe_size, &manifest, env.zonegroup.default_placement, &bucket, &head, &gen, &objs);
 
   list<rgw_obj>::iterator liter;
 
@@ -315,7 +313,7 @@ TEST(TestRGWManifest, multipart) {
     rgw_obj head;
     for (ofs = 0; ofs < part_size; ofs += stripe_size) {
       if (ofs == 0) {
-        int r = gen.create_begin(g_ceph_context, &manifest, bucket, head);
+        int r = gen.create_begin(g_ceph_context, &manifest, env.zonegroup.default_placement, bucket, head);
         ASSERT_EQ(r, 0);
         continue;
       }
@@ -398,8 +396,7 @@ int main(int argc, char **argv) {
   argv_to_vec(argc, (const char **)argv, args);
   env_to_vec(args);
 
-  vector<const char*> def_args;
-  global_init(&def_args, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+  auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
   common_init_finish(g_ceph_context);
   ::testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
index 115b0ce6bbb6bd4f6968db82e7683bbe6844f5f4..0a83536a5f1acd76fd273486e864baf540efa94c 100644 (file)
@@ -35,38 +35,34 @@ using namespace std;
 void check_parsed_correctly(rgw_obj& obj, const string& name, const string& ns, const string& instance)
 {
   /* parse_raw_oid() */
-  string parsed_name, parsed_ns, parsed_instance;
-  ASSERT_EQ(true, rgw_obj::parse_raw_oid(obj.get_object(), &parsed_name, &parsed_instance, &parsed_ns));
+  rgw_obj_key parsed_key;
+  ASSERT_EQ(true, rgw_obj_key::parse_raw_oid(obj.get_oid(), &parsed_key));
 
-  cout << "parsed: " << parsed_name << " ns=" << parsed_ns << " i=" << parsed_instance << std::endl;
+  cout << "parsed: " << parsed_key << std::endl;
 
-  ASSERT_EQ(name, parsed_name);
-  ASSERT_EQ(ns, parsed_ns);
-  ASSERT_EQ(instance, parsed_instance);
+  ASSERT_EQ(name, parsed_key.name);
+  ASSERT_EQ(ns, parsed_key.ns);
+  ASSERT_EQ(instance, parsed_key.instance);
 
   /* translate_raw_obj_to_obj_in_ns() */
-  string tname = obj.get_object();
+  rgw_obj_key tkey = parsed_key;
   string tns = ns + "foo";
-  string tinstance;
-  ASSERT_EQ(0, rgw_obj::translate_raw_obj_to_obj_in_ns(tname, tinstance, tns));
-  ASSERT_EQ(name, tname);
-  ASSERT_EQ(instance, tinstance);
+  ASSERT_EQ(0, rgw_obj_key::oid_to_key_in_ns(obj.get_oid(), &tkey, tns));
 
-  tname = obj.get_object();
+  tkey = rgw_obj_key();
   tns = ns;
-  ASSERT_EQ(true, rgw_obj::translate_raw_obj_to_obj_in_ns(tname, tinstance, tns));
+  ASSERT_EQ(true, rgw_obj_key::oid_to_key_in_ns(obj.get_oid(), &tkey, tns));
 
-  cout << "parsed: " << parsed_name << " ns=" << parsed_ns << " i=" << parsed_instance << std::endl;
+  cout << "parsed: " << tkey << std::endl;
 
-  ASSERT_EQ(name, tname);
-  ASSERT_EQ(instance, tinstance);
+  ASSERT_EQ(obj.key, tkey);
 
   /* strip_namespace_from_object() */
 
-  string strip_name = obj.get_object();
+  string strip_name = obj.get_oid();
   string strip_ns, strip_instance;
 
-  ASSERT_EQ(true, rgw_obj::strip_namespace_from_object(strip_name, strip_ns, strip_instance));
+  ASSERT_EQ(true, rgw_obj_key::strip_namespace_from_name(strip_name, strip_ns, strip_instance));
 
   cout << "stripped: " << strip_name << " ns=" << strip_ns << " i=" << strip_instance << std::endl;
 
@@ -87,10 +83,10 @@ void test_obj(const string& name, const string& ns, const string& instance)
   rgw_obj obj1(o);
 
   if (!instance.empty()) {
-    obj1.set_instance(instance);
+    obj1.key.instance = instance;
   }
   if (!ns.empty()) {
-    obj1.set_ns(ns);
+    obj1.key.ns = ns;
   }
   
   check_parsed_correctly(obj1, name, ns, instance);
@@ -112,10 +108,10 @@ void test_obj(const string& name, const string& ns, const string& instance)
   encode_json("obj3", obj3, formatter);
 
   if (!instance.empty()) {
-    obj3.set_instance(instance);
+    obj3.key.instance = instance;
   }
   if (!ns.empty()) {
-    obj3.set_ns(ns);
+    obj3.key.ns = ns;
   }
   check_parsed_correctly(obj3, name, ns, instance);
 
@@ -130,8 +126,8 @@ void test_obj(const string& name, const string& ns, const string& instance)
 
 
   /* rgw_obj_key conversion */
-  rgw_obj_key k;
-  obj1.get_index_key(&k);
+  rgw_obj_index_key k;
+  obj1.key.get_index_key(&k);
 
   rgw_obj new_obj(b, k);
 
@@ -169,12 +165,11 @@ static void test_obj_to_raw(test_rgw_env& env, const rgw_bucket& b,
 {
   JSONFormatter f(true);
   dump(f, "bucket", b);
-  rgw_obj obj = test_rgw_create_obj(b, name, instance, ns, placement_id);
+  rgw_obj obj = test_rgw_create_obj(b, name, instance, ns);
   dump(f, "obj", obj);
 
-  rgw_raw_obj raw_obj;
-
-  rgw_obj_to_raw(env.zonegroup, env.zone_params, obj, &raw_obj);
+  rgw_obj_select s(obj);
+  rgw_raw_obj raw_obj = s.get_raw_obj(env.zonegroup, env.zone_params);
   dump(f, "raw_obj", raw_obj);
 
   if (!placement_id.empty()) {
@@ -262,12 +257,23 @@ TEST(TestRGWObj, old_to_raw) {
           bufferlist::iterator iter = bl.begin();
           ::decode(new_obj2, iter);
 
+          /*
+            can't decode raw obj here, because we didn't encode an old versioned
+            object
+           */
+
+          bl.clear();
+          ::encode(raw_obj, bl);
           iter = bl.begin();
           ::decode(raw_obj2, iter);
         } catch (buffer::error& err) {
           ASSERT_TRUE(false);
         }
 
+        dump(f, "raw_obj2", raw_obj2);
+        dump(f, "new_obj2", new_obj2);
+        cout << "raw2=" << raw_obj2 << std::endl;
+
         ASSERT_EQ(new_obj, new_obj2);
         ASSERT_EQ(raw_obj, raw_obj2);
       }