Motr
M0
|
#include "lib/trace.h"
#include <errno.h>
#include <stdio.h>
#include "lib/misc.h"
#include "lib/types.h"
#include "lib/memory.h"
#include "lib/assert.h"
#include "rpc/rpc.h"
#include "net/net.h"
#include "net/lnet/lnet.h"
#include "fop/fop.h"
#include "fop/fom_generic.h"
#include "rpc/rpclib.h"
#include "conf/helpers.h"
#include "reqh/reqh.h"
#include "reqh/reqh_service.h"
#include "motr/setup.h"
Go to the source code of this file.
Macros | |
#define | M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_RPC |
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.
[out] | conn | |
[out] | session | |
[in] | rpc_mach | |
[in] | remote_addr | |
[in] | service | object, optional, can be NULL |
[in] | max_rpcs_in_flight | |
[in] | abs_timeout |
Definition at line 102 of file rpclib.c.
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.
Definition at line 134 of file rpclib.c.
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().
cctx | Initialised rpc context structure. |
Definition at line 160 of file rpclib.c.
int m0_rpc_client_stop | ( | struct m0_rpc_client_ctx * | cctx | ) |
int m0_rpc_client_stop_stats | ( | struct m0_rpc_client_ctx * | cctx, |
void(*)(struct m0_rpc_machine *) | printout | ||
) |
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().
fop | Fop to send. Presumably, fop->f_item.ri_reply will hold the reply upon successful return. |
session | The session to be used for the client call. |
ri_ops | Pointer to RPC item ops structure. |
deadline | Absolute 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.
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 | ||
) |
M0_INTERNAL struct m0_rpc_machine* m0_rpc_server_ctx_get_rmachine | ( | struct m0_rpc_server_ctx * | sctx | ) |
int m0_rpc_server_start | ( | struct m0_rpc_server_ctx * | sctx | ) |
void m0_rpc_server_stop | ( | struct m0_rpc_server_ctx * | sctx | ) |