summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/os/DBObjectMap.cc25
-rw-r--r--src/os/DBObjectMap.h23
-rw-r--r--src/os/FileStore.cc40
-rw-r--r--src/os/ObjectMap.h25
-rw-r--r--src/test/ObjectMap/test_object_map.cc268
5 files changed, 107 insertions, 274 deletions
diff --git a/src/os/DBObjectMap.cc b/src/os/DBObjectMap.cc
index c40d14c61cf..da2f3cd938d 100644
--- a/src/os/DBObjectMap.cc
+++ b/src/os/DBObjectMap.cc
@@ -12,7 +12,6 @@
#include <vector>
#include <tr1/memory>
-#include "IndexManager.h"
#include "ObjectMap.h"
#include "KeyValueDB.h"
#include "DBObjectMap.h"
@@ -313,8 +312,7 @@ int DBObjectMap::DBObjectMapIteratorImpl::init()
}
ObjectMap::ObjectMapIterator DBObjectMap::get_iterator(
- const hobject_t &hoid,
- Index index)
+ const hobject_t &hoid)
{
Header header = lookup_map_header(hoid);
if (!header)
@@ -500,7 +498,6 @@ int DBObjectMap::DBObjectMapIteratorImpl::status()
}
int DBObjectMap::set_keys(const hobject_t &hoid,
- Index index,
const map<string, bufferlist> &set)
{
KeyValueDB::Transaction t = db->get_transaction();
@@ -514,7 +511,6 @@ int DBObjectMap::set_keys(const hobject_t &hoid,
}
int DBObjectMap::set_header(const hobject_t &hoid,
- Index index,
const bufferlist &bl)
{
KeyValueDB::Transaction t = db->get_transaction();
@@ -534,7 +530,6 @@ void DBObjectMap::_set_header(Header header, const bufferlist &bl,
}
int DBObjectMap::get_header(const hobject_t &hoid,
- Index index,
bufferlist *bl)
{
Header header = lookup_map_header(hoid);
@@ -569,8 +564,7 @@ int DBObjectMap::_get_header(Header header,
return 0;
}
-int DBObjectMap::clear(const hobject_t &hoid,
- Index index)
+int DBObjectMap::clear(const hobject_t &hoid)
{
KeyValueDB::Transaction t = db->get_transaction();
Header header = lookup_map_header(hoid);
@@ -689,7 +683,6 @@ int DBObjectMap::need_parent(DBObjectMapIterator iter)
}
int DBObjectMap::rm_keys(const hobject_t &hoid,
- Index index,
const set<string> &to_clear)
{
Header header = lookup_map_header(hoid);
@@ -762,7 +755,6 @@ int DBObjectMap::rm_keys(const hobject_t &hoid,
}
int DBObjectMap::get(const hobject_t &hoid,
- Index index,
bufferlist *_header,
map<string, bufferlist> *out)
{
@@ -780,13 +772,12 @@ int DBObjectMap::get(const hobject_t &hoid,
}
int DBObjectMap::get_keys(const hobject_t &hoid,
- Index index,
set<string> *keys)
{
Header header = lookup_map_header(hoid);
if (!header)
return -ENOENT;
- ObjectMapIterator iter = get_iterator(hoid, index);
+ ObjectMapIterator iter = get_iterator(hoid);
for (; iter->valid(); iter->next()) {
if (iter->status())
return iter->status();
@@ -818,7 +809,6 @@ int DBObjectMap::scan(Header header,
}
int DBObjectMap::get_values(const hobject_t &hoid,
- Index index,
const set<string> &keys,
map<string, bufferlist> *out)
{
@@ -829,7 +819,6 @@ int DBObjectMap::get_values(const hobject_t &hoid,
}
int DBObjectMap::check_keys(const hobject_t &hoid,
- Index index,
const set<string> &keys,
set<string> *out)
{
@@ -840,7 +829,6 @@ int DBObjectMap::check_keys(const hobject_t &hoid,
}
int DBObjectMap::get_xattrs(const hobject_t &hoid,
- Index index,
const set<string> &to_get,
map<string, bufferlist> *out)
{
@@ -851,7 +839,6 @@ int DBObjectMap::get_xattrs(const hobject_t &hoid,
}
int DBObjectMap::get_all_xattrs(const hobject_t &hoid,
- Index index,
set<string> *out)
{
Header header = lookup_map_header(hoid);
@@ -866,7 +853,6 @@ int DBObjectMap::get_all_xattrs(const hobject_t &hoid,
}
int DBObjectMap::set_xattrs(const hobject_t &hoid,
- Index index,
const map<string, bufferlist> &to_set)
{
KeyValueDB::Transaction t = db->get_transaction();
@@ -878,7 +864,6 @@ int DBObjectMap::set_xattrs(const hobject_t &hoid,
}
int DBObjectMap::remove_xattrs(const hobject_t &hoid,
- Index index,
const set<string> &to_remove)
{
KeyValueDB::Transaction t = db->get_transaction();
@@ -890,9 +875,7 @@ int DBObjectMap::remove_xattrs(const hobject_t &hoid,
}
int DBObjectMap::clone(const hobject_t &hoid,
- Index index,
- const hobject_t &target,
- Index target_index)
+ const hobject_t &target)
{
if (hoid == target)
return 0;
diff --git a/src/os/DBObjectMap.h b/src/os/DBObjectMap.h
index f9e143fd33b..1ff87f1289d 100644
--- a/src/os/DBObjectMap.h
+++ b/src/os/DBObjectMap.h
@@ -12,7 +12,6 @@
#include <tr1/memory>
#include <boost/scoped_ptr.hpp>
-#include "IndexManager.h"
#include "ObjectMap.h"
#include "KeyValueDB.h"
#include "osd/osd_types.h"
@@ -76,90 +75,75 @@ public:
int set_keys(
const hobject_t &hoid,
- Index index,
const map<string, bufferlist> &set
);
int set_header(
const hobject_t &hoid,
- Index index,
const bufferlist &bl
);
int get_header(
const hobject_t &hoid,
- Index index,
bufferlist *bl
);
int clear(
- const hobject_t &hoid,
- Index index
+ const hobject_t &hoid
);
int rm_keys(
const hobject_t &hoid,
- Index index,
const set<string> &to_clear
);
int get(
const hobject_t &hoid,
- Index index,
bufferlist *header,
map<string, bufferlist> *out
);
int get_keys(
const hobject_t &hoid,
- Index index,
set<string> *keys
);
int get_values(
const hobject_t &hoid,
- Index index,
const set<string> &keys,
map<string, bufferlist> *out
);
int check_keys(
const hobject_t &hoid,
- Index index,
const set<string> &keys,
set<string> *out
);
int get_xattrs(
const hobject_t &hoid,
- Index index,
const set<string> &to_get,
map<string, bufferlist> *out
);
int get_all_xattrs(
const hobject_t &hoid,
- Index index,
set<string> *out
);
int set_xattrs(
const hobject_t &hoid,
- Index index,
const map<string, bufferlist> &to_set
);
int remove_xattrs(
const hobject_t &hoid,
- Index index,
const set<string> &to_remove
);
int clone(
const hobject_t &hoid,
- Index index,
- const hobject_t &target,
- Index target_index
+ const hobject_t &target
);
/// Read initial state from backing store
@@ -174,8 +158,7 @@ public:
/// Ensure that all previous operations are durable
int sync();
- ObjectMapIterator get_iterator(const hobject_t &hoid,
- Index index);
+ ObjectMapIterator get_iterator(const hobject_t &hoid);
static const string USER_PREFIX;
static const string XATTR_PREFIX;
diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc
index ba2df957996..540ecdcdaa3 100644
--- a/src/os/FileStore.cc
+++ b/src/os/FileStore.cc
@@ -385,7 +385,7 @@ int FileStore::lfn_unlink(coll_t cid, const hobject_t& o)
return -errno;
}
if (st.st_nlink == 1) {
- r = object_map->clear(o, path->get_index());
+ r = object_map->clear(o);
if (r < 0 && r != -ENOENT)
return r;
}
@@ -3249,7 +3249,7 @@ int FileStore::_clone(coll_t cid, const hobject_t& oldoid, const hobject_t& newo
goto out3;
}
dout(20) << "objectmap clone" << dendl;
- r = object_map->clone(oldoid, from->get_index(), newoid, to->get_index());
+ r = object_map->clone(oldoid, newoid);
if (r < 0 && r != -ENOENT)
goto out3;
}
@@ -4028,7 +4028,7 @@ int FileStore::getattr(coll_t cid, const hobject_t& oid, const char *name, buffe
dout(10) << __func__ << " could not get index r = " << r << dendl;
return r;
}
- r = object_map->get_xattrs(oid, index, to_get, &got);
+ r = object_map->get_xattrs(oid, to_get, &got);
if (r < 0 && r != -ENOENT) {
dout(10) << __func__ << " get_xattrs err r =" << r << dendl;
return r;
@@ -4058,12 +4058,12 @@ int FileStore::getattrs(coll_t cid, const hobject_t& oid, map<string,bufferptr>&
dout(10) << __func__ << " could not get index r = " << r << dendl;
return r;
}
- r = object_map->get_all_xattrs(oid, index, &omap_attrs);
+ r = object_map->get_all_xattrs(oid, &omap_attrs);
if (r < 0 && r != -ENOENT) {
dout(10) << __func__ << " could not get omap_attrs r = " << r << dendl;
return r;
}
- r = object_map->get_xattrs(oid, index, omap_attrs, &omap_aset);
+ r = object_map->get_xattrs(oid, omap_attrs, &omap_aset);
if (r < 0 && r != -ENOENT) {
dout(10) << __func__ << " could not get omap_attrs r = " << r << dendl;
return r;
@@ -4151,12 +4151,12 @@ int FileStore::_setattrs(coll_t cid, const hobject_t& oid, map<string,bufferptr>
dout(10) << __func__ << " could not get index r = " << r << dendl;
return r;
}
- r = object_map->remove_xattrs(oid, index, omap_remove);
+ r = object_map->remove_xattrs(oid, omap_remove);
if (r < 0 && r != -ENOENT) {
dout(10) << __func__ << " could not remove_xattrs r = " << r << dendl;
return r;
}
- r = object_map->set_xattrs(oid, index, omap_set);
+ r = object_map->set_xattrs(oid, omap_set);
if (r < 0) {
dout(10) << __func__ << " could not set_xattrs r = " << r << dendl;
return r;
@@ -4182,7 +4182,7 @@ int FileStore::_rmattr(coll_t cid, const hobject_t& oid, const char *name)
}
set<string> to_remove;
to_remove.insert(string(name));
- r = object_map->remove_xattrs(oid, index, to_remove);
+ r = object_map->remove_xattrs(oid, to_remove);
if (r < 0 && r != -ENOENT) {
dout(10) << __func__ << " could not remove_xattrs index r = " << r << dendl;
return r;
@@ -4215,12 +4215,12 @@ int FileStore::_rmattrs(coll_t cid, const hobject_t& oid)
dout(10) << __func__ << " could not get index r = " << r << dendl;
return r;
}
- r = object_map->get_all_xattrs(oid, index, &omap_attrs);
+ r = object_map->get_all_xattrs(oid, &omap_attrs);
if (r < 0 && r != -ENOENT) {
dout(10) << __func__ << " could not get omap_attrs r = " << r << dendl;
return r;
}
- r = object_map->remove_xattrs(oid, index, omap_attrs);
+ r = object_map->remove_xattrs(oid, omap_attrs);
if (r < 0 && r != -ENOENT) {
dout(10) << __func__ << " could not remove omap_attrs r = " << r << dendl;
return r;
@@ -4486,7 +4486,7 @@ int FileStore::omap_get(coll_t c, const hobject_t &hoid,
int r = lfn_find(c, hoid, &path);
if (r < 0)
return r;
- r = object_map->get(hoid, path->get_index(), header, out);
+ r = object_map->get(hoid, header, out);
if (r < 0 && r != -ENOENT)
return r;
return 0;
@@ -4500,7 +4500,7 @@ int FileStore::omap_get_header(coll_t c, const hobject_t &hoid,
int r = lfn_find(c, hoid, &path);
if (r < 0)
return r;
- r = object_map->get_header(hoid, path->get_index(), bl);
+ r = object_map->get_header(hoid, bl);
if (r < 0 && r != -ENOENT)
return r;
return 0;
@@ -4513,7 +4513,7 @@ int FileStore::omap_get_keys(coll_t c, const hobject_t &hoid, set<string> *keys)
int r = lfn_find(c, hoid, &path);
if (r < 0)
return r;
- r = object_map->get_keys(hoid, path->get_index(), keys);
+ r = object_map->get_keys(hoid, keys);
if (r < 0 && r != -ENOENT)
return r;
return 0;
@@ -4528,7 +4528,7 @@ int FileStore::omap_get_values(coll_t c, const hobject_t &hoid,
int r = lfn_find(c, hoid, &path);
if (r < 0)
return r;
- r = object_map->get_values(hoid, path->get_index(), keys, out);
+ r = object_map->get_values(hoid, keys, out);
if (r < 0 && r != -ENOENT)
return r;
return 0;
@@ -4543,7 +4543,7 @@ int FileStore::omap_check_keys(coll_t c, const hobject_t &hoid,
int r = lfn_find(c, hoid, &path);
if (r < 0)
return r;
- r = object_map->check_keys(hoid, path->get_index(), keys, out);
+ r = object_map->check_keys(hoid, keys, out);
if (r < 0 && r != -ENOENT)
return r;
return 0;
@@ -4557,7 +4557,7 @@ ObjectMap::ObjectMapIterator FileStore::get_omap_iterator(coll_t c,
int r = lfn_find(c, hoid, &path);
if (r < 0)
return ObjectMap::ObjectMapIterator();
- return object_map->get_iterator(hoid, path->get_index());
+ return object_map->get_iterator(hoid);
}
int FileStore::_create_collection(coll_t c)
@@ -4661,7 +4661,7 @@ int FileStore::_omap_clear(coll_t cid, const hobject_t &hoid) {
int r = lfn_find(cid, hoid, &path);
if (r < 0)
return r;
- r = object_map->clear(hoid, path->get_index());
+ r = object_map->clear(hoid);
if (r < 0 && r != -ENOENT)
return r;
return 0;
@@ -4673,7 +4673,7 @@ int FileStore::_omap_setkeys(coll_t cid, const hobject_t &hoid,
int r = lfn_find(cid, hoid, &path);
if (r < 0)
return r;
- return object_map->set_keys(hoid, path->get_index(), aset);
+ return object_map->set_keys(hoid, aset);
}
int FileStore::_omap_rmkeys(coll_t cid, const hobject_t &hoid,
const set<string> &keys) {
@@ -4682,7 +4682,7 @@ int FileStore::_omap_rmkeys(coll_t cid, const hobject_t &hoid,
int r = lfn_find(cid, hoid, &path);
if (r < 0)
return r;
- r = object_map->rm_keys(hoid, path->get_index(), keys);
+ r = object_map->rm_keys(hoid, keys);
if (r < 0 && r != -ENOENT)
return r;
return 0;
@@ -4695,7 +4695,7 @@ int FileStore::_omap_setheader(coll_t cid, const hobject_t &hoid,
int r = lfn_find(cid, hoid, &path);
if (r < 0)
return r;
- return object_map->set_header(hoid, path->get_index(), bl);
+ return object_map->set_header(hoid, bl);
}
diff --git a/src/os/ObjectMap.h b/src/os/ObjectMap.h
index ea6c78ec9ea..8e52fbb6ea0 100644
--- a/src/os/ObjectMap.h
+++ b/src/os/ObjectMap.h
@@ -15,12 +15,11 @@
#ifndef OS_KEYVALUESTORE_H
#define OS_KEYVALUESTORE_H
+#include "IndexManager.h"
#include <string>
#include <vector>
#include <tr1/memory>
-#include "IndexManager.h"
-
/**
* Encapsulates the FileStore key value store
*
@@ -31,41 +30,35 @@ public:
/// Set keys and values from specified map
virtual int set_keys(
const hobject_t &hoid, ///< [in] object containing map
- Index index, ///< [in] Path to hoid
const map<string, bufferlist> &set ///< [in] key to value map to set
) = 0;
/// Set header
virtual int set_header(
const hobject_t &hoid, ///< [in] object containing map
- Index index, ///< [in] Path to hoid
const bufferlist &bl ///< [in] header to set
) = 0;
/// Retrieve header
virtual int get_header(
const hobject_t &hoid, ///< [in] object containing map
- Index index, ///< [in] Path to hoid
bufferlist *bl ///< [out] header to set
) = 0;
/// Clear all map keys and values from hoid
virtual int clear(
- const hobject_t &hoid, ///< [in] object containing map
- Index index ///< [in] Path to hoid
+ const hobject_t &hoid ///< [in] object containing map
) = 0;
/// Clear all map keys and values from hoid
virtual int rm_keys(
const hobject_t &hoid, ///< [in] object containing map
- Index index, ///< [in] Path to hoid
const set<string> &to_clear ///< [in] Keys to clear
) = 0;
/// Get all keys and values
virtual int get(
const hobject_t &hoid, ///< [in] object containing map
- Index index, ///< [in] Path to hoid
bufferlist *header, ///< [out] Returned Header
map<string, bufferlist> *out ///< [out] Returned keys and values
) = 0;
@@ -73,14 +66,12 @@ public:
/// Get values for supplied keys
virtual int get_keys(
const hobject_t &hoid, ///< [in] object containing map
- Index index, ///< [in] Path to hoid
set<string> *keys ///< [out] Keys defined on hoid
) = 0;
/// Get values for supplied keys
virtual int get_values(
const hobject_t &hoid, ///< [in] object containing map
- Index index, ///< [in] Path to hoid
const set<string> &keys, ///< [in] Keys to get
map<string, bufferlist> *out ///< [out] Returned keys and values
) = 0;
@@ -88,7 +79,6 @@ public:
/// Check key existence
virtual int check_keys(
const hobject_t &hoid, ///< [in] object containing map
- Index index, ///< [in] Path to hoid
const set<string> &keys, ///< [in] Keys to check
set<string> *out ///< [out] Subset of keys defined on hoid
) = 0;
@@ -96,7 +86,6 @@ public:
/// Get xattrs
virtual int get_xattrs(
const hobject_t &hoid, ///< [in] object
- Index index, ///< [in] path to hoid
const set<string> &to_get, ///< [in] keys to get
map<string, bufferlist> *out ///< [out] subset of attrs/vals defined
) = 0;
@@ -104,21 +93,18 @@ public:
/// Get all xattrs
virtual int get_all_xattrs(
const hobject_t &hoid, ///< [in] object
- Index index, ///< [in] path to hoid
set<string> *out ///< [out] attrs and values
) = 0;
/// set xattrs in to_set
virtual int set_xattrs(
const hobject_t &hoid, ///< [in] object
- Index index, ///< [in] path to object
const map<string, bufferlist> &to_set ///< [in] attrs/values to set
) = 0;
/// remove xattrs in to_remove
virtual int remove_xattrs(
const hobject_t &hoid, ///< [in] object
- Index index, ///< [in] path to hoid
const set<string> &to_remove ///< [in] attrs to remove
) = 0;
@@ -126,9 +112,7 @@ public:
/// Clone keys efficiently from hoid map to target map
virtual int clone(
const hobject_t &hoid, ///< [in] object containing map
- Index index, ///< [in] Path to hoid
- const hobject_t &target, ///< [in] target of clone
- Index target_index ///< [in] path to target
+ const hobject_t &target ///< [in] target of clone
) { return 0; }
/// Ensure all previous writes are durable
@@ -149,8 +133,7 @@ public:
virtual ~ObjectMapIteratorImpl() {}
};
typedef std::tr1::shared_ptr<ObjectMapIteratorImpl> ObjectMapIterator;
- virtual ObjectMapIterator get_iterator(const hobject_t &hoid,
- Index index) {
+ virtual ObjectMapIterator get_iterator(const hobject_t &hoid) {
return ObjectMapIterator();
}
diff --git a/src/test/ObjectMap/test_object_map.cc b/src/test/ObjectMap/test_object_map.cc
index ee7bd979b66..a89ad23f06a 100644
--- a/src/test/ObjectMap/test_object_map.cc
+++ b/src/test/ObjectMap/test_object_map.cc
@@ -4,7 +4,6 @@
#include <set>
#include <boost/scoped_ptr.hpp>
-#include "os/IndexManager.h"
#include "include/buffer.h"
#include "test/ObjectMap/KeyValueDBMemory.h"
#include "os/KeyValueDB.h"
@@ -48,7 +47,6 @@ public:
map<string, map<string, string> > omap;
map<string, string > hmap;
map<string, map<string, string> > xattrs;
- Index def_collection;
unsigned seq;
ObjectMapTester() : db(0), seq(0) {}
@@ -58,56 +56,56 @@ public:
}
void set_key(const string &objname, const string &key, const string &value) {
- set_key(hobject_t(sobject_t(objname, CEPH_NOSNAP)), def_collection,
+ set_key(hobject_t(sobject_t(objname, CEPH_NOSNAP)),
key, value);
}
void set_xattr(const string &objname, const string &key, const string &value) {
- set_xattr(hobject_t(sobject_t(objname, CEPH_NOSNAP)), def_collection,
+ set_xattr(hobject_t(sobject_t(objname, CEPH_NOSNAP)),
key, value);
}
- void set_key(hobject_t hoid, Index path,
+ void set_key(hobject_t hoid,
string key, string value) {
map<string, bufferlist> to_write;
bufferptr bp(value.c_str(), value.size());
bufferlist bl;
bl.append(bp);
to_write.insert(make_pair(key, bl));
- db->set_keys(hoid, path, to_write);
+ db->set_keys(hoid, to_write);
}
- void set_xattr(hobject_t hoid, Index path,
+ void set_xattr(hobject_t hoid,
string key, string value) {
map<string, bufferlist> to_write;
bufferptr bp(value.c_str(), value.size());
bufferlist bl;
bl.append(bp);
to_write.insert(make_pair(key, bl));
- db->set_xattrs(hoid, path, to_write);
+ db->set_xattrs(hoid, to_write);
}
void set_header(const string &objname, const string &value) {
- set_header(hobject_t(sobject_t(objname, CEPH_NOSNAP)), def_collection,
+ set_header(hobject_t(sobject_t(objname, CEPH_NOSNAP)),
value);
}
- void set_header(hobject_t hoid, Index path,
+ void set_header(hobject_t hoid,
const string &value) {
bufferlist header;
header.append(bufferptr(value.c_str(), value.size() + 1));
- db->set_header(hoid, path, header);
+ db->set_header(hoid, header);
}
int get_header(const string &objname, string *value) {
- return get_header(hobject_t(sobject_t(objname, CEPH_NOSNAP)), def_collection,
+ return get_header(hobject_t(sobject_t(objname, CEPH_NOSNAP)),
value);
}
- int get_header(hobject_t hoid, Index path,
+ int get_header(hobject_t hoid,
string *value) {
bufferlist header;
- int r = db->get_header(hoid, path, &header);
+ int r = db->get_header(hoid, &header);
if (r < 0)
return r;
if (header.length())
@@ -118,16 +116,16 @@ public:
}
int get_xattr(const string &objname, const string &key, string *value) {
- return get_xattr(hobject_t(sobject_t(objname, CEPH_NOSNAP)), def_collection,
+ return get_xattr(hobject_t(sobject_t(objname, CEPH_NOSNAP)),
key, value);
}
- int get_xattr(hobject_t hoid, Index path,
+ int get_xattr(hobject_t hoid,
string key, string *value) {
set<string> to_get;
to_get.insert(key);
map<string, bufferlist> got;
- db->get_xattrs(hoid, path, to_get, &got);
+ db->get_xattrs(hoid, to_get, &got);
if (got.size()) {
*value = string(got.begin()->second.c_str(),
got.begin()->second.length());
@@ -138,16 +136,16 @@ public:
}
int get_key(const string &objname, const string &key, string *value) {
- return get_key(hobject_t(sobject_t(objname, CEPH_NOSNAP)), def_collection,
+ return get_key(hobject_t(sobject_t(objname, CEPH_NOSNAP)),
key, value);
}
- int get_key(hobject_t hoid, Index path,
+ int get_key(hobject_t hoid,
string key, string *value) {
set<string> to_get;
to_get.insert(key);
map<string, bufferlist> got;
- db->get_values(hoid, path, to_get, &got);
+ db->get_values(hoid, to_get, &got);
if (got.size()) {
*value = string(got.begin()->second.c_str(),
got.begin()->second.length());
@@ -158,45 +156,45 @@ public:
}
void remove_key(const string &objname, const string &key) {
- remove_key(hobject_t(sobject_t(objname, CEPH_NOSNAP)), def_collection,
+ remove_key(hobject_t(sobject_t(objname, CEPH_NOSNAP)),
key);
}
- void remove_key(hobject_t hoid, Index path,
+ void remove_key(hobject_t hoid,
string key) {
set<string> to_remove;
to_remove.insert(key);
- db->rm_keys(hoid, path, to_remove);
+ db->rm_keys(hoid, to_remove);
}
void remove_xattr(const string &objname, const string &key) {
- remove_xattr(hobject_t(sobject_t(objname, CEPH_NOSNAP)), def_collection,
+ remove_xattr(hobject_t(sobject_t(objname, CEPH_NOSNAP)),
key);
}
- void remove_xattr(hobject_t hoid, Index path,
+ void remove_xattr(hobject_t hoid,
string key) {
set<string> to_remove;
to_remove.insert(key);
- db->remove_xattrs(hoid, path, to_remove);
+ db->remove_xattrs(hoid, to_remove);
}
void clone(const string &objname, const string &target) {
- clone(hobject_t(sobject_t(objname, CEPH_NOSNAP)), def_collection,
- hobject_t(sobject_t(target, CEPH_NOSNAP)), def_collection);
+ clone(hobject_t(sobject_t(objname, CEPH_NOSNAP)),
+ hobject_t(sobject_t(target, CEPH_NOSNAP)));
}
- void clone(hobject_t hoid, Index path,
- hobject_t hoid2, Index path2) {
- db->clone(hoid, path, hoid2, path2);
+ void clone(hobject_t hoid,
+ hobject_t hoid2) {
+ db->clone(hoid, hoid2);
}
void clear(const string &objname) {
- clear(hobject_t(sobject_t(objname, CEPH_NOSNAP)), def_collection);
+ clear(hobject_t(sobject_t(objname, CEPH_NOSNAP)));
}
- void clear(hobject_t hoid, Index path) {
- db->clear(hoid, path);
+ void clear(hobject_t hoid) {
+ db->clear(hoid);
}
void def_init() {
@@ -206,7 +204,6 @@ public:
for (unsigned i = 0; i < 1000; ++i) {
object_name_space.insert("name_" + num_str(i));
}
- init_default_collection("def_collection");
}
void init_key_set(const set<string> &keys) {
@@ -217,14 +214,6 @@ public:
object_name_space = onamespace;
}
- void init_default_collection(const string &coll_name) {
- def_collection = Index(new HashIndex(coll_t(coll_name),
- ("/" + coll_name).c_str(),
- 2,
- 2,
- CollectionIndex::HASH_INDEX_TAG_2));
- }
-
void auto_set_xattr(ostream &out) {
set<string>::iterator key = rand_choose(key_space);
set<string>::iterator object = rand_choose(object_name_space);
@@ -556,11 +545,6 @@ int main(int argc, char **argv) {
TEST_F(ObjectMapTest, CreateOneObject) {
hobject_t hoid(sobject_t("foo", CEPH_NOSNAP));
- Index path = Index(new HashIndex(coll_t("foo_coll"),
- string("/bar").c_str(),
- 2,
- 2,
- CollectionIndex::HASH_INDEX_TAG_2));
map<string, bufferlist> to_set;
string key("test");
string val("test_val");
@@ -568,136 +552,126 @@ TEST_F(ObjectMapTest, CreateOneObject) {
bufferlist bl;
bl.append(bp);
to_set.insert(make_pair(key, bl));
- ASSERT_FALSE(db->set_keys(hoid, path, to_set));
+ ASSERT_FALSE(db->set_keys(hoid, to_set));
map<string, bufferlist> got;
set<string> to_get;
to_get.insert(key);
to_get.insert("not there");
- db->get_values(hoid, path, to_get, &got);
+ db->get_values(hoid, to_get, &got);
ASSERT_EQ(got.size(), (unsigned)1);
ASSERT_EQ(string(got[key].c_str(), got[key].length()), val);
bufferlist header;
got.clear();
- db->get(hoid, path, &header, &got);
+ db->get(hoid, &header, &got);
ASSERT_EQ(got.size(), (unsigned)1);
ASSERT_EQ(string(got[key].c_str(), got[key].length()), val);
ASSERT_EQ(header.length(), (unsigned)0);
- db->rm_keys(hoid, path, to_get);
+ db->rm_keys(hoid, to_get);
got.clear();
- db->get(hoid, path, &header, &got);
+ db->get(hoid, &header, &got);
ASSERT_EQ(got.size(), (unsigned)0);
- db->clear(hoid, path);
- db->get(hoid, path, &header, &got);
+ db->clear(hoid);
+ db->get(hoid, &header, &got);
ASSERT_EQ(got.size(), (unsigned)0);
}
TEST_F(ObjectMapTest, CloneOneObject) {
hobject_t hoid(sobject_t("foo", CEPH_NOSNAP));
hobject_t hoid2(sobject_t("foo2", CEPH_NOSNAP));
- Index path = Index(new HashIndex(coll_t("foo_coll"),
- string("/bar").c_str(),
- 2,
- 2,
- CollectionIndex::HASH_INDEX_TAG_2));
-
- tester.set_key(hoid, path, "foo", "bar");
- tester.set_key(hoid, path, "foo2", "bar2");
+
+ tester.set_key(hoid, "foo", "bar");
+ tester.set_key(hoid, "foo2", "bar2");
string result;
- int r = tester.get_key(hoid, path, "foo", &result);
+ int r = tester.get_key(hoid, "foo", &result);
ASSERT_EQ(r, 1);
ASSERT_EQ(result, "bar");
- db->clone(hoid, path, hoid2, path);
- r = tester.get_key(hoid, path, "foo", &result);
+ db->clone(hoid, hoid2);
+ r = tester.get_key(hoid, "foo", &result);
ASSERT_EQ(r, 1);
ASSERT_EQ(result, "bar");
- r = tester.get_key(hoid2, path, "foo", &result);
+ r = tester.get_key(hoid2, "foo", &result);
ASSERT_EQ(r, 1);
ASSERT_EQ(result, "bar");
- tester.remove_key(hoid, path, "foo");
- r = tester.get_key(hoid2, path, "foo", &result);
+ tester.remove_key(hoid, "foo");
+ r = tester.get_key(hoid2, "foo", &result);
ASSERT_EQ(r, 1);
ASSERT_EQ(result, "bar");
- r = tester.get_key(hoid, path, "foo", &result);
+ r = tester.get_key(hoid, "foo", &result);
ASSERT_EQ(r, 0);
- r = tester.get_key(hoid, path, "foo2", &result);
+ r = tester.get_key(hoid, "foo2", &result);
ASSERT_EQ(r, 1);
ASSERT_EQ(result, "bar2");
- tester.set_key(hoid, path, "foo", "baz");
- tester.remove_key(hoid, path, "foo");
- r = tester.get_key(hoid, path, "foo", &result);
+ tester.set_key(hoid, "foo", "baz");
+ tester.remove_key(hoid, "foo");
+ r = tester.get_key(hoid, "foo", &result);
ASSERT_EQ(r, 0);
- tester.set_key(hoid, path, "foo2", "baz");
- tester.remove_key(hoid, path, "foo2");
- r = tester.get_key(hoid, path, "foo2", &result);
+ tester.set_key(hoid, "foo2", "baz");
+ tester.remove_key(hoid, "foo2");
+ r = tester.get_key(hoid, "foo2", &result);
ASSERT_EQ(r, 0);
map<string, bufferlist> got;
bufferlist header;
got.clear();
- db->clear(hoid, path);
- db->get(hoid, path, &header, &got);
+ db->clear(hoid);
+ db->get(hoid, &header, &got);
ASSERT_EQ(got.size(), (unsigned)0);
got.clear();
- r = db->clear(hoid2, path);
+ r = db->clear(hoid2);
ASSERT_EQ(0, r);
- db->get(hoid2, path, &header, &got);
+ db->get(hoid2, &header, &got);
ASSERT_EQ(got.size(), (unsigned)0);
- tester.set_key(hoid, path, "baz", "bar");
+ tester.set_key(hoid, "baz", "bar");
got.clear();
- db->get(hoid, path, &header, &got);
+ db->get(hoid, &header, &got);
ASSERT_EQ(got.size(), (unsigned)1);
- db->clear(hoid, path);
- db->clear(hoid2, path);
+ db->clear(hoid);
+ db->clear(hoid2);
}
TEST_F(ObjectMapTest, OddEvenClone) {
hobject_t hoid(sobject_t("foo", CEPH_NOSNAP));
hobject_t hoid2(sobject_t("foo2", CEPH_NOSNAP));
- Index path = Index(new HashIndex(coll_t("foo_coll"),
- string("/bar").c_str(),
- 2,
- 2,
- CollectionIndex::HOBJECT_WITH_POOL));
for (unsigned i = 0; i < 1000; ++i) {
- tester.set_key(hoid, path, "foo" + num_str(i), "bar" + num_str(i));
+ tester.set_key(hoid, "foo" + num_str(i), "bar" + num_str(i));
}
- db->clone(hoid, path, hoid2, path);
+ db->clone(hoid, hoid2);
int r = 0;
for (unsigned i = 0; i < 1000; ++i) {
string result;
- r = tester.get_key(hoid, path, "foo" + num_str(i), &result);
+ r = tester.get_key(hoid, "foo" + num_str(i), &result);
ASSERT_EQ(1, r);
ASSERT_EQ("bar" + num_str(i), result);
- r = tester.get_key(hoid2, path, "foo" + num_str(i), &result);
+ r = tester.get_key(hoid2, "foo" + num_str(i), &result);
ASSERT_EQ(1, r);
ASSERT_EQ("bar" + num_str(i), result);
if (i % 2) {
- tester.remove_key(hoid, path, "foo" + num_str(i));
+ tester.remove_key(hoid, "foo" + num_str(i));
} else {
- tester.remove_key(hoid2, path, "foo" + num_str(i));
+ tester.remove_key(hoid2, "foo" + num_str(i));
}
}
for (unsigned i = 0; i < 1000; ++i) {
string result;
string result2;
- r = tester.get_key(hoid, path, "foo" + num_str(i), &result);
- int r2 = tester.get_key(hoid2, path, "foo" + num_str(i), &result2);
+ r = tester.get_key(hoid, "foo" + num_str(i), &result);
+ int r2 = tester.get_key(hoid2, "foo" + num_str(i), &result2);
if (i % 2) {
ASSERT_EQ(0, r);
ASSERT_EQ(1, r2);
@@ -710,7 +684,7 @@ TEST_F(ObjectMapTest, OddEvenClone) {
}
{
- ObjectMap::ObjectMapIterator iter = db->get_iterator(hoid, path);
+ ObjectMap::ObjectMapIterator iter = db->get_iterator(hoid);
iter->seek_to_first();
for (unsigned i = 0; i < 1000; ++i) {
if (!(i % 2)) {
@@ -722,7 +696,7 @@ TEST_F(ObjectMapTest, OddEvenClone) {
}
{
- ObjectMap::ObjectMapIterator iter2 = db->get_iterator(hoid2, path);
+ ObjectMap::ObjectMapIterator iter2 = db->get_iterator(hoid2);
iter2->seek_to_first();
for (unsigned i = 0; i < 1000; ++i) {
if (i % 2) {
@@ -733,98 +707,8 @@ TEST_F(ObjectMapTest, OddEvenClone) {
}
}
- db->clear(hoid, path);
- db->clear(hoid2, path);
-}
-
-TEST(Upgrade, UpgradeTest) {
- KeyValueDBMemory *map1 = new KeyValueDBMemory();
- KeyValueDBMemory *map2 = new KeyValueDBMemory();
- ObjectMapTester tester;
- {
- boost::scoped_ptr< ObjectMap > db;
- db.reset(new DBObjectMapv0(map1));
- tester.db = db.get();
- tester.def_init();
- for (unsigned i = 0; i < 5000; ++i) {
- unsigned val = rand();
- val <<= 8;
- val %= 100;
- if (!(i%100))
- std::cout << "on op " << i
- << " val is " << val << std::endl;
-
- if (val < 7) {
- tester.auto_write_header(std::cerr);
- } else if (val < 14) {
- ASSERT_TRUE(tester.auto_verify_header(std::cerr));
- } else if (val < 30) {
- tester.auto_set_key(std::cerr);
- } else if (val < 42) {
- tester.auto_set_xattr(std::cerr);
- } else if (val < 55) {
- ASSERT_TRUE(tester.auto_check_present_key(std::cerr));
- } else if (val < 62) {
- ASSERT_TRUE(tester.auto_check_present_xattr(std::cerr));
- } else if (val < 70) {
- ASSERT_TRUE(tester.auto_check_absent_key(std::cerr));
- } else if (val < 73) {
- ASSERT_TRUE(tester.auto_check_absent_xattr(std::cerr));
- } else if (val < 76) {
- tester.auto_delete_object(std::cerr);
- } else if (val < 85) {
- tester.auto_clone_key(std::cerr);
- } else if (val < 92) {
- tester.auto_remove_xattr(std::cerr);
- } else {
- tester.auto_remove_key(std::cerr);
- }
- }
- *map2 = *map1;
- }
-
- std::cout << "Populated, upgrading" << std::endl;
- {
- boost::scoped_ptr< ObjectMap > db;
- DBObjectMap *_db = new DBObjectMap(map2);
- assert(!_db->init(true));
- db.reset(_db);
- tester.db = db.get();
- for (unsigned i = 0; i < 5000; ++i) {
- unsigned val = rand();
- val <<= 8;
- val %= 100;
- if (!(i%100))
- std::cout << "on op " << i
- << " val is " << val << std::endl;
-
- if (val < 7) {
- tester.auto_write_header(std::cerr);
- } else if (val < 14) {
- ASSERT_TRUE(tester.auto_verify_header(std::cerr));
- } else if (val < 30) {
- tester.auto_set_key(std::cerr);
- } else if (val < 42) {
- tester.auto_set_xattr(std::cerr);
- } else if (val < 55) {
- ASSERT_TRUE(tester.auto_check_present_key(std::cerr));
- } else if (val < 62) {
- ASSERT_TRUE(tester.auto_check_present_xattr(std::cerr));
- } else if (val < 70) {
- ASSERT_TRUE(tester.auto_check_absent_key(std::cerr));
- } else if (val < 73) {
- ASSERT_TRUE(tester.auto_check_absent_xattr(std::cerr));
- } else if (val < 76) {
- tester.auto_delete_object(std::cerr);
- } else if (val < 85) {
- tester.auto_clone_key(std::cerr);
- } else if (val < 92) {
- tester.auto_remove_xattr(std::cerr);
- } else {
- tester.auto_remove_key(std::cerr);
- }
- }
- }
+ db->clear(hoid);
+ db->clear(hoid2);
}
TEST_F(ObjectMapTest, RandomTest) {