]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/test/objectstore/TestObjectStoreState.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / test / objectstore / TestObjectStoreState.h
index 4eaf76b5c30c2f417a1efad155dd7ef1a17e8358..4383808891c4ba18a70a4d946d2aacc326dc8b79 100644 (file)
 #ifndef TEST_OBJECTSTORE_STATE_H_
 #define TEST_OBJECTSTORE_STATE_H_
 
-#include "os/ObjectStore.h"
 #include <boost/scoped_ptr.hpp>
 #include <boost/random/mersenne_twister.hpp>
 #include <boost/random/uniform_int.hpp>
 #include <map>
 #include <vector>
 
+#include "os/ObjectStore.h"
+#include "common/Cond.h"
+
 typedef boost::mt11213b rngen_t;
 
 class TestObjectStoreState {
 public:
   struct coll_entry_t {
-    int m_id;
     spg_t m_pgid;
-    coll_t m_coll;
+    coll_t m_cid;
     ghobject_t m_meta_obj;
-    ObjectStore::Sequencer m_osr;
+    ObjectStore::CollectionHandle m_ch;
     map<int, hobject_t*> m_objects;
     int m_next_object_id;
 
-    coll_entry_t(int i, char *coll_buf, char *meta_obj_buf)
-      : m_id(i),
-       m_pgid(pg_t(i, 1), shard_id_t::NO_SHARD),
-       m_coll(m_pgid),
+    coll_entry_t(spg_t pgid, ObjectStore::CollectionHandle& ch,
+                char *meta_obj_buf)
+      : m_pgid(pgid),
+       m_cid(m_pgid),
        m_meta_obj(hobject_t(sobject_t(object_t(meta_obj_buf), CEPH_NOSNAP))),
-      m_osr(coll_buf), m_next_object_id(0) {
+       m_ch(ch),
+       m_next_object_id(0) {
+      m_meta_obj.hobj.pool = m_pgid.pool();
+      m_meta_obj.hobj.set_hash(m_pgid.ps());
     }
     ~coll_entry_t();
 
@@ -58,8 +62,8 @@ public:
 
  protected:
   boost::shared_ptr<ObjectStore> m_store;
-  map<int, coll_entry_t*> m_collections;
-  vector<int> m_collections_ids;
+  map<coll_t, coll_entry_t*> m_collections;
+  vector<coll_t> m_collections_ids;
   int m_next_coll_nr;
   int m_num_objs_per_coll;
   int m_num_objects;
@@ -69,6 +73,14 @@ public:
   Mutex m_finished_lock;
   Cond m_finished_cond;
 
+  void rebuild_id_vec() {
+    m_collections_ids.clear();
+    m_collections_ids.reserve(m_collections.size());
+    for (auto& i : m_collections) {
+      m_collections_ids.push_back(i.first);
+    }
+  }
+
   void wait_for_ready() {
     Mutex::Locker locker(m_finished_lock);
     while ((m_max_in_flight > 0) && (m_in_flight >= m_max_in_flight))
@@ -88,7 +100,7 @@ public:
     m_num_objs_per_coll = val;
   }
 
-  coll_entry_t *get_coll(int key, bool erase = false);
+  coll_entry_t *get_coll(coll_t cid, bool erase = false);
   coll_entry_t *get_coll_at(int pos, bool erase = false);
   int get_next_pool_id() { return m_next_pool++; }
 
@@ -104,7 +116,7 @@ public:
     m_store.reset(store);
   }
   ~TestObjectStoreState() { 
-    map<int, coll_entry_t*>::iterator it = m_collections.begin();
+    auto it = m_collections.begin();
     while (it != m_collections.end()) {
       if (it->second)
        delete it->second;
@@ -125,7 +137,7 @@ public:
     return --m_in_flight;
   }
 
-  coll_entry_t *coll_create(int id);
+  coll_entry_t *coll_create(spg_t pgid, ObjectStore::CollectionHandle ch);
 
   class C_OnFinished: public Context {
    protected: