1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_TEST_MEM_CLUSTER_H
5 #define CEPH_TEST_MEM_CLUSTER_H
7 #include "test/librados_test_stub/TestCluster.h"
8 #include "include/buffer.h"
9 #include "include/interval_set.h"
10 #include "include/int_types.h"
11 #include "common/Cond.h"
12 #include "common/Mutex.h"
13 #include "common/RefCountedObj.h"
14 #include "common/RWLock.h"
15 #include <boost/shared_ptr.hpp>
23 class TestMemCluster : public TestCluster {
25 typedef std::map<std::string, bufferlist> OMap;
26 typedef std::map<std::string, OMap> FileOMaps;
27 typedef std::map<std::string, bufferlist> FileTMaps;
28 typedef std::map<std::string, bufferlist> XAttrs;
29 typedef std::map<std::string, XAttrs> FileXAttrs;
33 File(const File &rhs);
39 std::vector<uint64_t> snaps;
40 interval_set<uint64_t> snap_overlap;
45 typedef boost::shared_ptr<File> SharedFile;
47 typedef std::list<SharedFile> FileSnapshots;
48 typedef std::map<std::string, FileSnapshots> Files;
50 typedef std::set<uint64_t> SnapSeqs;
51 struct Pool : public RefCountedObject {
63 FileXAttrs file_xattrs;
67 ~TestMemCluster() override;
69 TestRadosClient *create_rados_client(CephContext *cct) override;
71 int pool_create(const std::string &pool_name);
72 int pool_delete(const std::string &pool_name);
73 int pool_get_base_tier(int64_t pool_id, int64_t* base_tier);
74 int pool_list(std::list<std::pair<int64_t, std::string> >& v);
75 int64_t pool_lookup(const std::string &name);
76 int pool_reverse_lookup(int64_t id, std::string *name);
78 Pool *get_pool(int64_t pool_id);
79 Pool *get_pool(const std::string &pool_name);
81 void allocate_client(uint32_t *nonce, uint64_t *global_id);
82 void deallocate_client(uint32_t nonce);
84 bool is_blacklisted(uint32_t nonce) const;
85 void blacklist(uint32_t nonce);
87 void transaction_start(const std::string &oid);
88 void transaction_finish(const std::string &oid);
92 typedef std::map<std::string, Pool*> Pools;
93 typedef std::set<uint32_t> Blacklist;
98 int64_t m_pool_id = 0;
100 uint32_t m_next_nonce;
101 uint64_t m_next_global_id = 1234;
103 Blacklist m_blacklist;
105 Cond m_transaction_cond;
106 std::set<std::string> m_transactions;
110 } // namespace librados
112 #endif // CEPH_TEST_MEM_CLUSTER_H