Motr
M0
|
#include <conn.h>
Data Fields | |
uint64_t | c_sender_id |
struct m0_uint128 | c_uuid |
uint64_t | c_flags |
struct m0_rpc_machine * | c_rpc_machine |
const struct m0_rpc_conn_ha_cfg * | c_ha_cfg |
uint64_t | c_ha_attempts |
struct m0_sm_timer | c_ha_timer |
struct m0_tlink | c_link |
uint64_t | c_nr_sessions |
struct m0_tl | c_sessions |
struct m0_tl | c_item_sources |
struct m0_rpc_chan * | c_rpcchan |
struct m0_sm | c_sm |
struct m0_sm_ast | c_ast |
bool | c_ast_in_progress |
uint64_t | c_magic |
struct m0_clink | c_ha_clink |
struct m0_clink | c_conf_exp_clink |
struct m0_clink | c_conf_ready_clink |
struct m0_fid | c_svc_fid |
A rpc connection identifies a sender to the receiver. It acts as a parent object within which sessions are created. rpc connection has two identifiers.
UUID being larger in size compared to SenderID, it is efficient to use sender id to locate rpc connection object.
m0_rpc_machine maintains two lists of m0_rpc_conn
Instance of m0_rpc_conn stores a list of all sessions currently active with the service.
At the time of creation of a m0_rpc_conn, a "special" session with SESSION_ID_0 is also created. It is special in the sense that it is "hand-made" and there is no need to communicate to receiver in order to create this session. Receiver assumes that there always exists a session 0 for each rpc connection. Receiver creates session 0 while creating the rpc connection itself. Session 0 is required to send special fops like
State transition diagram:
| m0_rpc_conn_init() m0_rpc_conn_establish() != 0 V +---------------------INITIALISED | | | | m0_rpc_conn_establish() | | | V +---------------------- CONNECTING | time-out || | | reply.rc != 0 | m0_rpc_conn_establish_reply_received() && | | reply.rc == 0 V | FAILED | | ^ V | | ACTIVE | | | | | | m0_rpc_conn_terminate() | | failed || timeout | | | V | +-------------------TERMINATING | | | | m0_rpc_conn_terminate_reply_received() && | | rc== 0 | V | TERMINATED | | |m0_rpc_conn_fini() V m0_rpc_conn_fini() +--------------------->FINALISED
Liveness and Concurrency:
Typical sequence of API execution Note: error checking is omitted.
On receiver side, user is not expected to call any of these APIs. Receiver side rpc-layer will internally allocate/deallocate and manage all the state transitions of conn internally.
m0_rpc_conn:c_ha_timer is armed when an rpc item related to the connection was sent or timed out. If the connection is subscribed to m0_conf_service object and the timer callback is triggered, Motr sends m0_ha_msg to HA about a problem. The message consists of one field that indicates m0_ha_obj_state of the service.
HA is notified about M0_NC_TRANSIENT state in case of item resend or timeout, and M0_NC_ONLINE in the case when a reply is received on the connection. When Motr sends message about M0_NC_TRANSIENT state, the flag RCF_TRANSIENT_SENT is set for the connection. The flag is checked when the timer callback is triggered again, and in case it was already set, then Motr doesn't notify HA repeatedly. The flag is cleared when the reply is received for an item and the service is in M0_NC_TRANSIENT state. This way Motr notifies HA about M0_NC_TRANSIENT state only once per connection trouble no matter how many items are sent over the connection. It is able to send message about M0_NC_TRANSIENT state only when Halon switches the service to this state and then back to M0_NC_ONLINE state.
struct m0_sm_ast c_ast |
Finalises and frees m0_rpc_conn when conn terminate reply is sent over network. Posted in: conn_terminate_reply_sent_cb() Invokes: conn_cleanup_ast() callback
bool c_ast_in_progress |
uint64_t c_flags |
uint64_t c_ha_attempts |
const struct m0_rpc_conn_ha_cfg* c_ha_cfg |
struct m0_sm_timer c_ha_timer |
struct m0_tl c_item_sources |
List of m0_rpc_item_source instances. List link: m0_rpc_item_source::ris_tlink List descriptor: item_source
struct m0_tlink c_link |
list_link to put m0_rpc_conn in either m0_rpc_machine::rm_incoming_conns or m0_rpc_machine::rm_outgoing_conns. List descriptor: rpc_conn
uint64_t c_nr_sessions |
struct m0_rpc_machine* c_rpc_machine |
struct m0_rpc_chan* c_rpcchan |
struct m0_tl c_sessions |
List of all the sessions created under this rpc connection. m0_rpc_session objects are placed in this list using m0_rpc_session::s_link. List descriptor: session
struct m0_sm c_sm |
RPC connection state machine
struct m0_uint128 c_uuid |