]> git.proxmox.com Git - ceph.git/blob - ceph/src/os/ObjectMap.h
import 15.2.9
[ceph.git] / ceph / src / os / ObjectMap.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
14
15 #ifndef OS_KEYVALUESTORE_H
16 #define OS_KEYVALUESTORE_H
17
18 #include <memory>
19 #include <string>
20 #include <vector>
21 #include "kv/KeyValueDB.h"
22 #include "common/hobject.h"
23
24 class SequencerPosition;
25
26 /**
27 * Encapsulates the FileStore key value store
28 *
29 * Implementations of this interface will be used to implement TMAP
30 */
31 class ObjectMap {
32 public:
33 CephContext* cct;
34 boost::scoped_ptr<KeyValueDB> db;
35 /// std::Set keys and values from specified map
36 virtual int set_keys(
37 const ghobject_t &oid, ///< [in] object containing map
38 const std::map<std::string, ceph::buffer::list> &set, ///< [in] key to value map to set
39 const SequencerPosition *spos=0 ///< [in] sequencer position
40 ) = 0;
41
42 /// std::Set header
43 virtual int set_header(
44 const ghobject_t &oid, ///< [in] object containing map
45 const ceph::buffer::list &bl, ///< [in] header to set
46 const SequencerPosition *spos=0 ///< [in] sequencer position
47 ) = 0;
48
49 /// Retrieve header
50 virtual int get_header(
51 const ghobject_t &oid, ///< [in] object containing map
52 ceph::buffer::list *bl ///< [out] header to set
53 ) = 0;
54
55 /// Clear all map keys and values from oid
56 virtual int clear(
57 const ghobject_t &oid, ///< [in] object containing map
58 const SequencerPosition *spos=0 ///< [in] sequencer position
59 ) = 0;
60
61 /// Clear all map keys and values in to_clear from oid
62 virtual int rm_keys(
63 const ghobject_t &oid, ///< [in] object containing map
64 const std::set<std::string> &to_clear, ///< [in] Keys to clear
65 const SequencerPosition *spos=0 ///< [in] sequencer position
66 ) = 0;
67
68 /// Clear all omap keys and the header
69 virtual int clear_keys_header(
70 const ghobject_t &oid, ///< [in] oid to clear
71 const SequencerPosition *spos=0 ///< [in] sequencer position
72 ) = 0;
73
74 /// Get all keys and values
75 virtual int get(
76 const ghobject_t &oid, ///< [in] object containing map
77 ceph::buffer::list *header, ///< [out] Returned Header
78 std::map<std::string, ceph::buffer::list> *out ///< [out] Returned keys and values
79 ) = 0;
80
81 /// Get values for supplied keys
82 virtual int get_keys(
83 const ghobject_t &oid, ///< [in] object containing map
84 std::set<std::string> *keys ///< [out] Keys defined on oid
85 ) = 0;
86
87 /// Get values for supplied keys
88 virtual int get_values(
89 const ghobject_t &oid, ///< [in] object containing map
90 const std::set<std::string> &keys, ///< [in] Keys to get
91 std::map<std::string, ceph::buffer::list> *out ///< [out] Returned keys and values
92 ) = 0;
93
94 /// Check key existence
95 virtual int check_keys(
96 const ghobject_t &oid, ///< [in] object containing map
97 const std::set<std::string> &keys, ///< [in] Keys to check
98 std::set<std::string> *out ///< [out] Subset of keys defined on oid
99 ) = 0;
100
101 /// Get xattrs
102 virtual int get_xattrs(
103 const ghobject_t &oid, ///< [in] object
104 const std::set<std::string> &to_get, ///< [in] keys to get
105 std::map<std::string, ceph::buffer::list> *out ///< [out] subset of attrs/vals defined
106 ) = 0;
107
108 /// Get all xattrs
109 virtual int get_all_xattrs(
110 const ghobject_t &oid, ///< [in] object
111 std::set<std::string> *out ///< [out] attrs and values
112 ) = 0;
113
114 /// std::set xattrs in to_set
115 virtual int set_xattrs(
116 const ghobject_t &oid, ///< [in] object
117 const std::map<std::string, ceph::buffer::list> &to_set,///< [in] attrs/values to set
118 const SequencerPosition *spos=0 ///< [in] sequencer position
119 ) = 0;
120
121 /// remove xattrs in to_remove
122 virtual int remove_xattrs(
123 const ghobject_t &oid, ///< [in] object
124 const std::set<std::string> &to_remove, ///< [in] attrs to remove
125 const SequencerPosition *spos=0 ///< [in] sequencer position
126 ) = 0;
127
128
129 /// Clone keys from oid map to target map
130 virtual int clone(
131 const ghobject_t &oid, ///< [in] object containing map
132 const ghobject_t &target, ///< [in] target of clone
133 const SequencerPosition *spos=0 ///< [in] sequencer position
134 ) { return 0; }
135
136 /// Rename map because of name change
137 virtual int rename(
138 const ghobject_t &from, ///< [in] object containing map
139 const ghobject_t &to, ///< [in] new name
140 const SequencerPosition *spos=0 ///< [in] sequencer position
141 ) { return 0; }
142
143 /// For testing clone keys from oid map to target map using faster but more complex method
144 virtual int legacy_clone(
145 const ghobject_t &oid, ///< [in] object containing map
146 const ghobject_t &target, ///< [in] target of clone
147 const SequencerPosition *spos=0 ///< [in] sequencer position
148 ) { return 0; }
149
150 /// Ensure all previous writes are durable
151 virtual int sync(
152 const ghobject_t *oid=0, ///< [in] object
153 const SequencerPosition *spos=0 ///< [in] Sequencer
154 ) { return 0; }
155
156 virtual int check(std::ostream &out, bool repair = false, bool force = false) { return 0; }
157
158 virtual void compact() {}
159
160 typedef KeyValueDB::SimplestIteratorImpl ObjectMapIteratorImpl;
161 typedef std::shared_ptr<ObjectMapIteratorImpl> ObjectMapIterator;
162 virtual ObjectMapIterator get_iterator(const ghobject_t &oid) {
163 return ObjectMapIterator();
164 }
165
166 virtual KeyValueDB *get_db() { return nullptr; }
167
168 ObjectMap(CephContext* cct, KeyValueDB *db) : cct(cct), db(db) {}
169 virtual ~ObjectMap() {}
170 };
171
172 #endif