Motr  M0
rpclib.h File Reference
#include <stdio.h>
#include "motr/setup.h"
#include "reqh/reqh.h"
#include "cob/cob.h"
#include "net/net.h"
#include "net/buffer_pool.h"
#include "rpc/rpc.h"
Include dependency graph for rpclib.h:

Go to the source code of this file.

Data Structures

struct  m0_rpc_server_ctx
 
struct  m0_rpc_client_ctx
 

Macros

#define __MOTR_RPC_RPCLIB_H__
 

Enumerations

enum  { M0_RPCLIB_MAX_RETRIES = 60, M0_RPCLIB_UTIL_CONN_TIMEOUT = 20 }
 

Functions

int m0_rpc_server_start (struct m0_rpc_server_ctx *sctx)
 
void m0_rpc_server_stop (struct m0_rpc_server_ctx *sctx)
 
M0_INTERNAL struct m0_rpc_machinem0_rpc_server_ctx_get_rmachine (struct m0_rpc_server_ctx *sctx)
 
M0_INTERNAL int m0_rpc_client_connect (struct m0_rpc_conn *conn, struct m0_rpc_session *session, struct m0_rpc_machine *rpc_mach, const char *remote_addr, struct m0_fid *svc_fid, uint64_t max_rpcs_in_flight, m0_time_t abs_timeout)
 
M0_INTERNAL int m0_rpc_client_find_connect (struct m0_rpc_conn *conn, struct m0_rpc_session *session, struct m0_rpc_machine *rpc_mach, const char *remote_addr, enum m0_conf_service_type stype, uint64_t max_rpcs_in_flight, m0_time_t abs_timeout)
 
int m0_rpc_client_start (struct m0_rpc_client_ctx *cctx)
 
int m0_rpc_client_stop (struct m0_rpc_client_ctx *cctx)
 
int m0_rpc_client_stop_stats (struct m0_rpc_client_ctx *cctx, void(*printout)(struct m0_rpc_machine *))
 
int m0_rpc_post_sync (struct m0_fop *fop, struct m0_rpc_session *session, const struct m0_rpc_item_ops *ri_ops, m0_time_t deadline)
 
int m0_rpc_post_with_timeout_sync (struct m0_fop *fop, struct m0_rpc_session *session, const struct m0_rpc_item_ops *ri_ops, m0_time_t deadline, m0_time_t timeout)
 

Macro Definition Documentation

◆ __MOTR_RPC_RPCLIB_H__

#define __MOTR_RPC_RPCLIB_H__

Definition at line 26 of file rpclib.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
M0_RPCLIB_MAX_RETRIES 

Maximum number of retries (m0_rpc_item::ri_nr_sent_max) for m0_rpc_post_sync() and m0_rpc_post_with_timeout_sync().

M0_RPCLIB_UTIL_CONN_TIMEOUT 

Timeout in seconds that is used by standalone utilities, such as m0console, m0repair, to connect to a service.

Definition at line 42 of file rpclib.h.

Function Documentation

◆ m0_rpc_client_connect()

M0_INTERNAL int m0_rpc_client_connect ( struct m0_rpc_conn conn,
struct m0_rpc_session session,
struct m0_rpc_machine rpc_mach,
const char *  remote_addr,
struct m0_fid svc_fid,
uint64_t  max_rpcs_in_flight,
m0_time_t  abs_timeout 
)

Establishes RPC connection and creates a session.

Connection automatically handles HA notifications regarding state of service identified by service object, if provided. In case of service death being announced, all rpc items on the connection get cancelled letting connection close safe.

Parameters
[out]conn
[out]session
[in]rpc_mach
[in]remote_addr
[in]serviceobject, optional, can be NULL
[in]max_rpcs_in_flight
[in]abs_timeout

Definition at line 102 of file rpclib.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_rpc_client_find_connect()

M0_INTERNAL int m0_rpc_client_find_connect ( struct m0_rpc_conn conn,
struct m0_rpc_session session,
struct m0_rpc_machine rpc_mach,
const char *  remote_addr,
enum m0_conf_service_type  stype,
uint64_t  max_rpcs_in_flight,
m0_time_t  abs_timeout 
)

A bit more intelligent version of m0_rpc_client_connect(). To be sure client connects to right service, client side provides service fid (optional, can be NULL) and service type along with the remote address. The call internally makes sure the provided address belongs to service of correct fid and type.

However even with service object not found, m0_rpc_client_connect() attempt is ultimately done anyway.

Note
confc contained by REQH, i.e. accessible by m0_reqh2confc(reqh), is used for service object look-up.

Definition at line 134 of file rpclib.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_rpc_client_start()

int m0_rpc_client_start ( struct m0_rpc_client_ctx cctx)

Starts client's rpc machine.

Creates connection to server and establishes an rpc session on top of it. Created session object can be set in an rpc item and used in m0_rpc_post().

Parameters
cctxInitialised rpc context structure.

Definition at line 160 of file rpclib.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_rpc_client_stop()

int m0_rpc_client_stop ( struct m0_rpc_client_ctx cctx)

Terminates RPC session and connection with server and finalises client's RPC machine.

Parameters
cctxInitialised rpc context structure.

Definition at line 217 of file rpclib.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_rpc_client_stop_stats()

int m0_rpc_client_stop_stats ( struct m0_rpc_client_ctx cctx,
void(*)(struct m0_rpc_machine *)  printout 
)

Definition at line 223 of file rpclib.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_rpc_post_sync()

int m0_rpc_post_sync ( struct m0_fop fop,
struct m0_rpc_session session,
const struct m0_rpc_item_ops ri_ops,
m0_time_t  deadline 
)

Sends a fop (an RPC item, to be precise) and waits for reply.

By default, fop is resent after every second until reply is received. To change this behaviour set fop->f_item.ri_nr_sent_max and fop->f_item.ri_resend_interval. They are, maximum number of times fop is sent before failing and interval after which the fop is resent, respectively. Their default values are M0_RPCLIB_MAX_RETRIES and m0_time(1, 0).

To simply timeout fop after N seconds set fop->f_item.ri_nr_sent_max to N before calling m0_rpc_post_sync().

Parameters
fopFop to send. Presumably, fop->f_item.ri_reply will hold the reply upon successful return.
sessionThe session to be used for the client call.
ri_opsPointer to RPC item ops structure.
deadlineAbsolute time after which formation should send the fop as soon as possible. deadline should be 0 if fop shouldn't wait in formation queue and should be sent immediately.

Definition at line 284 of file rpclib.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_rpc_post_with_timeout_sync()

int m0_rpc_post_with_timeout_sync ( struct m0_fop fop,
struct m0_rpc_session session,
const struct m0_rpc_item_ops ri_ops,
m0_time_t  deadline,
m0_time_t  timeout 
)

Definition at line 249 of file rpclib.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_rpc_server_ctx_get_rmachine()

M0_INTERNAL struct m0_rpc_machine* m0_rpc_server_ctx_get_rmachine ( struct m0_rpc_server_ctx sctx)

Definition at line 96 of file rpclib.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_rpc_server_start()

int m0_rpc_server_start ( struct m0_rpc_server_ctx sctx)

Starts server's rpc machine.

Parameters
sctxInitialized rpc context structure.

Definition at line 50 of file rpclib.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_rpc_server_stop()

void m0_rpc_server_stop ( struct m0_rpc_server_ctx sctx)

Stops RPC server.

Parameters
sctxInitialized rpc context structure.

Definition at line 85 of file rpclib.c.

Here is the call graph for this function:
Here is the caller graph for this function: