Derecho  0.9
Distributed systems toolkit for RDMA
ObjectStore.hpp
Go to the documentation of this file.
1 #ifndef OBJECTSTORE_HPP
2 #define OBJECTSTORE_HPP
3 
4 #include <optional>
5 
6 #include "Object.hpp"
7 
8 namespace objectstore {
9 // if object is valid, this is a PUT operation; otherwise, a REMOVE operation.
10 using ObjectWatcher = std::function<void(const OID&, const Object&)>;
12 // The core API. See `test.cpp` for how to use it.
14 private:
15  static std::shared_ptr<IObjectStoreService> singleton;
16 
17 public:
18  virtual const bool isReplica() = 0;
19  // blocking operations: all operations are guaranteed to be finished before
20  // return. Note: the internal implementation of objectstore has two
21  // versions, the client version and replica version. Only the nodes in the
22  // ObjectStore subgroup can use replica version, and other nodes have to
23  // relay the request to a replica node with the client version. On
24  // receiving the request, the replica in turn uses the replica version
25  // to do the real work. Obviously, the replica version is more efficient
26  // because it saves one level of indirection.
27  //
28  // By default, the api use replica version for replica nodes and client
29  // version for the others. To use the client API uniformly, the user can
30  // set the 'force_client' parameter to true.
31  //
32  //
33  // The following API may throw an exception of type "derecho::rpc::remote_exception_occurred",
34  // see include/derecho/core/detail/rpc_utils.hpp:83
35  //
36  // 1 - blocking put
37  // @PARAM object - const reference of the object to be inserted. If
38  // corresponding object id exists, the object is replaced
39  // @PARAM force_client - see above
40  // @RETURN new version of this object
41  virtual std::tuple<version_t,uint64_t> bio_put(const Object& object, const bool &force_client = false) = 0;
42  // 2 - blocking remove
43  // @PARAM oid - const reference of the object id.
44  // @PARAM force_client - see above
45  // @RETURN version of this remove operation
46  virtual std::tuple<version_t,uint64_t> bio_remove(const OID& oid, const bool &force_client = false) = 0;
47  // 3 - blocking get
48  // @PARAM oid - const reference of the object id.
49  // @PARAM ver - the version of the object. default to INVALID_VERSION for the current version.
50  // @PARAM force_client - see above
51  // @RETURN the object of oid, invalid object if corresponding object does not exists.
52  virtual Object bio_get(const OID& oid, const version_t& ver = INVALID_VERSION, const bool& force_client = false) = 0;
53  // 3.1 - temporal get
54  // @PARAM oid - const reference of the object id.
55  // @PARAM ts_us - timestamp.
56  // @RETURN the object of oid, invalid object if corresponding object does not exists.
57  virtual Object bio_get(const OID& oid, const uint64_t& ts_us) = 0;
58 
59  // non blocking operations: the operations will return a future.
60  // The arguments align to the blocking apis.
61  virtual derecho::rpc::QueryResults<std::tuple<version_t,uint64_t>> aio_put(const Object& object, const bool& force_client = false) = 0;
62  virtual derecho::rpc::QueryResults<std::tuple<version_t,uint64_t>> aio_remove(const OID& oid, const bool& force_client = false) = 0;
63  virtual derecho::rpc::QueryResults<const Object> aio_get(const OID& oid, const version_t& ver = INVALID_VERSION, const bool& force_client = false) = 0;
64  virtual derecho::rpc::QueryResults<const Object> aio_get(const OID& oid, const uint64_t& ts_us) = 0;
65 
66  // leave
67  // @PARAM group_shutdown - for group shutdown, this supresses the failure detection once all nodes agree to leave.
68  // default to false.
69  virtual void leave(bool group_shutdown = false) = 0;
70  virtual const ObjectWatcher& getObjectWatcher() = 0;
71 
72  // get singleton
73  static IObjectStoreService& getObjectStoreService(int argc, char** argv, const ObjectWatcher& ow = {});
74 };
75 
76 } // namespace objectstore
77 #endif //OBJECTSTORE_HPP
virtual const ObjectWatcher & getObjectWatcher()=0
The Deserialization Interface to be implemented by user applications.
Definition: rpc_manager.hpp:36
virtual derecho::rpc::QueryResults< std::tuple< version_t, uint64_t > > aio_remove(const OID &oid, const bool &force_client=false)=0
static IObjectStoreService & getObjectStoreService(int argc, char **argv, const ObjectWatcher &ow={})
virtual const bool isReplica()=0
persistent::version_t version_t
Definition: ObjectStore.hpp:11
int argc
virtual derecho::rpc::QueryResults< std::tuple< version_t, uint64_t > > aio_put(const Object &object, const bool &force_client=false)=0
virtual std::tuple< version_t, uint64_t > bio_put(const Object &object, const bool &force_client=false)=0
virtual std::tuple< version_t, uint64_t > bio_remove(const OID &oid, const bool &force_client=false)=0
char ** argv
#define INVALID_VERSION
Definition: PersistLog.hpp:28
std::function< void(const OID &, const Object &)> ObjectWatcher
Definition: ObjectStore.hpp:10
virtual derecho::rpc::QueryResults< const Object > aio_get(const OID &oid, const version_t &ver=INVALID_VERSION, const bool &force_client=false)=0
static std::shared_ptr< IObjectStoreService > singleton
Definition: ObjectStore.hpp:15
uint64_t OID
Definition: Object.hpp:70
Data structure that (indirectly) holds a set of futures for a single RPC function call; there is one ...
Definition: rpc_utils.hpp:158
virtual Object bio_get(const OID &oid, const version_t &ver=INVALID_VERSION, const bool &force_client=false)=0
virtual void leave(bool group_shutdown=false)=0