#include <rpc_manager.hpp>
Public Member Functions | |
Replicated (subgroup_type_id_t type_id, node_id_t nid, subgroup_id_t subgroup_id, uint32_t subgroup_index, uint32_t shard_num, rpc::RPCManager &group_rpc_manager, Factory< T > client_object_factory, _Group *group) | |
Constructs a Replicated<T> that enables sending and receiving RPC function calls for an object of type T. More... | |
Replicated (subgroup_type_id_t type_id, node_id_t nid, subgroup_id_t subgroup_id, uint32_t subgroup_index, uint32_t shard_num, rpc::RPCManager &group_rpc_manager, _Group *group) | |
Constructs a Replicated<T> for an object without actually constructing an instance of that object; the resulting Replicated will be in an invalid state until receive_object() is called. More... | |
Replicated (Replicated &&rhs) | |
Replicated (const Replicated &)=delete | |
virtual | ~Replicated () |
virtual bool | is_persistent () const |
bool | is_valid () const |
uint32_t | get_shard_num () const |
template<rpc::FunctionTag tag, typename... Args> | |
auto | p2p_send (node_id_t dest_node, Args &&... args) |
Sends a peer-to-peer message to a single member of the subgroup that replicates this Replicated<T>, invoking the RPC function identified by the FunctionTag template parameter. More... | |
template<rpc::FunctionTag tag, typename... Args> | |
auto | ordered_send (Args &&... args) |
Sends a multicast to the entire subgroup that replicates this Replicated<T>, invoking the RPC function identified by the FunctionTag template parameter. More... | |
void | send (unsigned long long int payload_size, const std::function< void(char *buf)> &msg_generator) |
Submits a call to send a "raw" (byte array) message in a multicast to this object's subgroup; the message will be generated by invoking msg_generator inside this function. More... | |
std::size_t | object_size () const |
void | send_object (tcp::socket &receiver_socket) const |
Serializes and sends the state of the "wrapped" object (of type T) for this Replicated<T> over the given socket. More... | |
void | send_object_raw (tcp::socket &receiver_socket) const |
Serializes and sends the state of the "wrapped" object (of type T) for this Replicated<T> over the given socket without first sending its size. More... | |
std::size_t | receive_object (char *buffer) |
Updates the state of the "wrapped" object by replacing it with the object serialized in a buffer. More... | |
const uint64_t | compute_global_stability_frontier () |
const HLC | getFrontier () |
const persistent::version_t | get_minimum_latest_persisted_version () noexcept(false) |
Returns the minimum among the "latest version" numbers of all Persistent fields of this object, i.e. More... | |
virtual void | make_version (const persistent::version_t &ver, const HLC &hlc) noexcept(false) |
make a version for all the persistent<T> members. More... | |
virtual void | persist (const persistent::version_t version) noexcept(false) |
persist the data to the latest version More... | |
virtual void | trim (const persistent::version_t &earliest_version) noexcept(false) |
trim the logs to a version, inclusively. More... | |
virtual void | truncate (const persistent::version_t &latest_version) |
Truncate the logs of all Persistent<T> members back to the version specified. More... | |
virtual void | post_next_version (const persistent::version_t &version, const uint64_t &ts_us) |
Post the next version to be handled. More... | |
virtual std::tuple< persistent::version_t, uint64_t > | get_next_version () |
Get the next version to be handled. More... | |
virtual void | register_persistent_member (const char *object_name, const persistent::VersionFunc &vf, const persistent::PersistFunc &pf, const persistent::TrimFunc &tf, const persistent::LatestPersistedGetterFunc &gf, persistent::TruncateFunc tcf) noexcept(false) |
Register a persistent member. More... | |
Public Member Functions inherited from derecho::ReplicatedObject | |
virtual | ~ReplicatedObject ()=default |
Public Attributes | |
std::unique_ptr< std::unique_ptr< T > > | user_object_ptr |
The user-provided state object with some RPC methods. More... | |
Private Attributes | |
std::unique_ptr< persistent::PersistentRegistry > | persistent_registry_ptr |
persistent registry for persistent<t> More... | |
const node_id_t | node_id |
The ID of this node. More... | |
const subgroup_id_t | subgroup_id |
The internally-generated subgroup ID of the subgroup that replicates this object. More... | |
const uint32_t | subgroup_index |
const uint32_t | shard_num |
The index, within the subgroup, of the shard that replicates this object. More... | |
rpc::RPCManager & | group_rpc_manager |
Reference to the RPCManager for the Group this Replicated is in. More... | |
std::unique_ptr< rpc::RemoteInvocableOf< T > > | wrapped_this |
The actual implementation of Replicated<T>, hiding its ugly template parameters. More... | |
_Group * | group |
persistent::version_t | next_version = INVALID_VERSION |
The version number being processed and corresponding timestamp. More... | |
uint64_t | next_timestamp_us = 0 |
Definition at line 29 of file rpc_manager.hpp.
derecho::Replicated< T >::Replicated | ( | subgroup_type_id_t | type_id, |
node_id_t | nid, | ||
subgroup_id_t | subgroup_id, | ||
uint32_t | subgroup_index, | ||
uint32_t | shard_num, | ||
rpc::RPCManager & | group_rpc_manager, | ||
Factory< T > | client_object_factory, | ||
_Group * | group | ||
) |
Constructs a Replicated<T> that enables sending and receiving RPC function calls for an object of type T.
type_id | A unique ID for type T within the Group that owns this Replicated<T> |
nid | The ID of the node on which this Replicated<T> is running. |
subgroup_id | The internally-generated subgroup ID for the subgroup that participates in replicating this object |
subgroup_index | The index of the subgroup that replicates this object within (only) the set of subgroups that replicate type T; zero-indexed. |
shard_num | The zero-indexed shard number of the shard (within subgroup subgroup_id) that participates in replicating this object |
group_rpc_manager | A reference to the RPCManager for the Group that owns this Replicated<T> |
client_object_factory | A factory functor that can create instances of T. |
Definition at line 14 of file replicated_impl.hpp.
derecho::Replicated< T >::Replicated | ( | subgroup_type_id_t | type_id, |
node_id_t | nid, | ||
subgroup_id_t | subgroup_id, | ||
uint32_t | subgroup_index, | ||
uint32_t | shard_num, | ||
rpc::RPCManager & | group_rpc_manager, | ||
_Group * | group | ||
) |
Constructs a Replicated<T> for an object without actually constructing an instance of that object; the resulting Replicated will be in an invalid state until receive_object() is called.
This should be used when a new subgroup member expects to receive the replicated object's state after joining.
type_id | A unique ID for type T within the Group that owns this Replicated<T> |
nid | This node's node ID |
subgroup_id | The internally-generated subgroup ID for the subgroup that participates in replicating this object |
subgroup_index | The index of the subgroup that replicates this object within (only) the set of subgroups that replicate type T; zero-indexed. |
shard_num | The zero-indexed shard number of the shard (within subgroup subgroup_id) that participates in replicating this object |
group_rpc_manager | A reference to the RPCManager for the Group that owns this Replicated<T> |
Definition at line 37 of file replicated_impl.hpp.
derecho::Replicated< T >::Replicated | ( | Replicated< T > && | rhs | ) |
Definition at line 54 of file replicated_impl.hpp.
|
delete |
|
virtual |
Definition at line 67 of file replicated_impl.hpp.
const uint64_t derecho::Replicated< T >::compute_global_stability_frontier | ( | ) |
Definition at line 200 of file replicated_impl.hpp.
|
virtualnoexcept |
Returns the minimum among the "latest version" numbers of all Persistent fields of this object, i.e.
the longest consistent cut of all the logs.
Implements derecho::ReplicatedObject.
Definition at line 195 of file replicated_impl.hpp.
|
inlinevirtual |
Get the next version to be handled.
Definition at line 298 of file replicated.hpp.
|
inline |
Definition at line 170 of file replicated.hpp.
|
inlinevirtual |
Implements persistent::ITemporalQueryFrontierProvider.
Definition at line 242 of file replicated.hpp.
|
inlinevirtual |
Implements derecho::ReplicatedObject.
Definition at line 153 of file replicated.hpp.
|
inlinevirtual |
Implements derecho::ReplicatedObject.
Definition at line 162 of file replicated.hpp.
|
inlinevirtualnoexcept |
make a version for all the persistent<T> members.
ver | - the version number to be made |
Implements derecho::ReplicatedObject.
Definition at line 259 of file replicated.hpp.
|
virtual |
Implements derecho::ReplicatedObject.
Definition at line 145 of file replicated_impl.hpp.
auto derecho::Replicated< T >::ordered_send | ( | Args &&... | args | ) |
Sends a multicast to the entire subgroup that replicates this Replicated<T>, invoking the RPC function identified by the FunctionTag template parameter.
The caller must keep the returned QueryResults object in scope in order to receive replies.
args | The arguments to the RPC function |
Definition at line 102 of file replicated_impl.hpp.
auto derecho::Replicated< T >::p2p_send | ( | node_id_t | dest_node, |
Args &&... | args | ||
) |
Sends a peer-to-peer message to a single member of the subgroup that replicates this Replicated<T>, invoking the RPC function identified by the FunctionTag template parameter.
dest_node | The ID of the node that the P2P message should be sent to |
args | The arguments to the RPC function being invoked |
Definition at line 76 of file replicated_impl.hpp.
|
virtualnoexcept |
persist the data to the latest version
Implements derecho::ReplicatedObject.
Definition at line 180 of file replicated_impl.hpp.
|
inlinevirtual |
Post the next version to be handled.
Implements derecho::ReplicatedObject.
Definition at line 290 of file replicated.hpp.
|
virtual |
Updates the state of the "wrapped" object by replacing it with the object serialized in a buffer.
Returns the number of bytes read from the buffer, in case the caller needs to know.
buffer | A buffer containing a serialized T, which will replace this Replicated<T>'s wrapped T |
Implements derecho::ReplicatedObject.
Definition at line 167 of file replicated_impl.hpp.
|
inlinevirtualnoexcept |
Register a persistent member.
vf | - the version function |
pf | - the persistent function |
tf | - the trim function |
Definition at line 308 of file replicated.hpp.
void derecho::Replicated< T >::send | ( | unsigned long long int | payload_size, |
const std::function< void(char *buf)> & | msg_generator | ||
) |
Submits a call to send a "raw" (byte array) message in a multicast to this object's subgroup; the message will be generated by invoking msg_generator inside this function.
Definition at line 139 of file replicated_impl.hpp.
|
virtual |
Serializes and sends the state of the "wrapped" object (of type T) for this Replicated<T> over the given socket.
(This includes sending the object's size before its data, so the receiver knows the size of buffer to allocate).
receiver_socket |
Implements derecho::ReplicatedObject.
Definition at line 150 of file replicated_impl.hpp.
|
virtual |
Serializes and sends the state of the "wrapped" object (of type T) for this Replicated<T> over the given socket without first sending its size.
Should only be used when sending a list of objects, preceded by their total size, otherwise the recipient will have no way of knowing how large a buffer to allocate for this object.
receiver_socket |
Implements derecho::ReplicatedObject.
Definition at line 159 of file replicated_impl.hpp.
|
inlinevirtualnoexcept |
trim the logs to a version, inclusively.
earliest_version | - the version number, before which, logs are going to be trimmed |
Definition at line 273 of file replicated.hpp.
|
inlinevirtual |
Truncate the logs of all Persistent<T> members back to the version specified.
This deletes recently-used data, so it should only be called during failure recovery when some versions must be rolled back.
latest_version | The latest version number that should remain in the logs |
Implements derecho::ReplicatedObject.
Definition at line 283 of file replicated.hpp.
|
private |
Definition at line 96 of file replicated.hpp.
|
private |
Reference to the RPCManager for the Group this Replicated is in.
Definition at line 93 of file replicated.hpp.
|
private |
Definition at line 99 of file replicated.hpp.
|
private |
The version number being processed and corresponding timestamp.
Definition at line 98 of file replicated.hpp.
|
private |
The ID of this node.
Definition at line 82 of file replicated.hpp.
|
private |
persistent registry for persistent<t>
Definition at line 68 of file replicated.hpp.
|
private |
The index, within the subgroup, of the shard that replicates this object.
This needs to be stored in order to detect if a node has moved to a different shard within the same subgroup (and hence its Replicated state is obsolete).
Definition at line 91 of file replicated.hpp.
|
private |
The internally-generated subgroup ID of the subgroup that replicates this object.
Definition at line 84 of file replicated.hpp.
|
private |
Definition at line 85 of file replicated.hpp.
std::unique_ptr<std::unique_ptr<T> > derecho::Replicated< T >::user_object_ptr |
The user-provided state object with some RPC methods.
Stored by pointer-to-pointer because it must stay pinned at a specific location in memory, and otherwise Replicated<T> would be unmoveable.
Definition at line 77 of file replicated.hpp.
|
private |
The actual implementation of Replicated<T>, hiding its ugly template parameters.
Definition at line 95 of file replicated.hpp.