summaryrefslogtreecommitdiffstats
path: root/src/test/librados_test_stub/TestMemRadosClient.h
blob: ecd6fedb08eb5572fb149790871a244f1e3ac1e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#ifndef CEPH_TEST_MEM_RADOS_CLIENT_H
#define CEPH_TEST_MEM_RADOS_CLIENT_H

#include "test/librados_test_stub/TestRadosClient.h"
#include "include/ceph_assert.h"
#include <list>
#include <string>

namespace librados {

class AioCompletionImpl;
class TestMemCluster;

class TestMemRadosClient : public TestRadosClient {
public:
  TestMemRadosClient(CephContext *cct, TestMemCluster *test_mem_cluster);
  ~TestMemRadosClient() override;

  TestIoCtxImpl *create_ioctx(int64_t pool_id,
                                      const std::string &pool_name) override;

  uint32_t get_nonce() override {
    return m_nonce;
  }
  uint64_t get_instance_id() override {
    return m_global_id;
  }

  int get_min_compatible_osd(int8_t* require_osd_release) override {
    *require_osd_release = CEPH_RELEASE_OCTOPUS;
    return 0;
  }

  int get_min_compatible_client(int8_t* min_compat_client,
                                int8_t* require_min_compat_client) override {
    *min_compat_client = CEPH_RELEASE_MIMIC;
    *require_min_compat_client = CEPH_RELEASE_MIMIC;
    return 0;
  }

  void object_list(int64_t pool_id,
                   std::list<librados::TestRadosClient::Object> *list) override;

  int service_daemon_register(const std::string& service,
                              const std::string& name,
                              const std::map<std::string,std::string>& metadata) override {
    return 0;
  }
  int service_daemon_update_status(std::map<std::string,std::string>&& status) override {
    return 0;
  }

  int pool_create(const std::string &pool_name) override;
  int pool_delete(const std::string &pool_name) override;
  int pool_get_base_tier(int64_t pool_id, int64_t* base_tier) override;
  int pool_list(std::list<std::pair<int64_t, std::string> >& v) override;
  int64_t pool_lookup(const std::string &name) override;
  int pool_reverse_lookup(int64_t id, std::string *name) override;

  int watch_flush() override;

  bool is_blocklisted() const override;
  int blocklist_add(const std::string& client_address,
                    uint32_t expire_seconds) override;
protected:
  TestMemCluster *get_mem_cluster() {
    return m_mem_cluster;
  }

protected:
  void transaction_start(const std::string& nspace,
                         const std::string &oid) override;
  void transaction_finish(const std::string& nspace,
                          const std::string &oid) override;

private:
  TestMemCluster *m_mem_cluster;
  uint32_t m_nonce;
  uint64_t m_global_id;

};

} // namespace librados

#endif // CEPH_TEST_MEM_RADOS_CLIENT_H