Motr  M0
Redundant Configuration Client (rconfc)

Detailed Functional Specification. More...

Data Structures

struct  rconfc_load_ctx
 
struct  m0_rconfc
 

Typedefs

typedef void(* m0_rconfc_cb_t) (struct m0_rconfc *rconfc)
 

Enumerations

enum  m0_rconfc_state {
  M0_RCS_INIT, M0_RCS_ENTRYPOINT_WAIT, M0_RCS_ENTRYPOINT_CONSUME, M0_RCS_CREDITOR_SETUP,
  M0_RCS_GET_RLOCK, M0_RCS_VERSION_ELECT, M0_RCS_IDLE, M0_RCS_RLOCK_CONFLICT,
  M0_RCS_CONDUCTOR_DRAIN, M0_RCS_CONDUCTOR_DISCONNECT, M0_RCS_STOPPING, M0_RCS_FAILURE,
  M0_RCS_FINAL
}
 

Functions

M0_INTERNAL int m0_rconfc_init (struct m0_rconfc *rconfc, const struct m0_fid *profile, struct m0_sm_group *sm_group, struct m0_rpc_machine *rmach, m0_rconfc_cb_t expired_cb, m0_rconfc_cb_t ready_cb)
 
M0_INTERNAL int m0_rconfc_start (struct m0_rconfc *rconfc)
 
M0_INTERNAL int m0_rconfc_start_wait (struct m0_rconfc *rconfc, uint64_t timeout_ns)
 
static int m0_rconfc_start_sync (struct m0_rconfc *rconfc)
 
M0_INTERNAL void m0_rconfc_stop (struct m0_rconfc *rconfc)
 
M0_INTERNAL void m0_rconfc_stop_sync (struct m0_rconfc *rconfc)
 
M0_INTERNAL void m0_rconfc_fini (struct m0_rconfc *rconfc)
 
M0_INTERNAL void m0_rconfc_lock (struct m0_rconfc *rconfc)
 
M0_INTERNAL void m0_rconfc_unlock (struct m0_rconfc *rconfc)
 
M0_INTERNAL uint64_t m0_rconfc_ver_max_read (struct m0_rconfc *rconfc)
 
M0_INTERNAL void m0_rconfc_fatal_cb_set (struct m0_rconfc *rconfc, m0_rconfc_cb_t cb)
 
M0_INTERNAL int m0_rconfc_confd_endpoints (struct m0_rconfc *rconfc, const char ***eps)
 
M0_INTERNAL int m0_rconfc_rm_endpoint (struct m0_rconfc *rconfc, char **ep)
 
M0_INTERNAL void m0_rconfc_rm_fid (struct m0_rconfc *rconfc, struct m0_fid *out)
 
M0_INTERNAL bool m0_rconfc_is_preloaded (struct m0_rconfc *rconfc)
 
M0_INTERNAL bool m0_rconfc_reading_is_allowed (const struct m0_rconfc *rconfc)
 

Detailed Description

Detailed Functional Specification.

See also
Functional Specification

Typedef Documentation

◆ m0_rconfc_cb_t

typedef void(* m0_rconfc_cb_t) (struct m0_rconfc *rconfc)

Definition at line 215 of file rconfc.h.

Enumeration Type Documentation

◆ m0_rconfc_state

Enumerator
M0_RCS_INIT 
M0_RCS_ENTRYPOINT_WAIT 
M0_RCS_ENTRYPOINT_CONSUME 
M0_RCS_CREDITOR_SETUP 
M0_RCS_GET_RLOCK 
M0_RCS_VERSION_ELECT 
M0_RCS_IDLE 
M0_RCS_RLOCK_CONFLICT 
M0_RCS_CONDUCTOR_DRAIN 
M0_RCS_CONDUCTOR_DISCONNECT 
M0_RCS_STOPPING 
M0_RCS_FAILURE 
M0_RCS_FINAL 

Definition at line 190 of file rconfc.h.

Function Documentation

◆ m0_rconfc_confd_endpoints()

M0_INTERNAL int m0_rconfc_confd_endpoints ( struct m0_rconfc rconfc,
const char ***  eps 
)

Allocates and fills eps with confd endpoints from m0_rconfc::rc_herd list. Returns number of endpoints or -ENOMEM if memory allocation was failed during duplication of an endpoint.

Precondition
rconfc_state(rconfc) != M0_RCS_INIT

Definition at line 3081 of file rconfc.c.

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

◆ m0_rconfc_fatal_cb_set()

M0_INTERNAL void m0_rconfc_fatal_cb_set ( struct m0_rconfc rconfc,
m0_rconfc_cb_t  cb 
)

Installs rconfc fatal callback.

Precondition
rconfc is locked.

Definition at line 3067 of file rconfc.c.

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

◆ m0_rconfc_fini()

M0_INTERNAL void m0_rconfc_fini ( struct m0_rconfc rconfc)

Finalises rconfc instance.

Definition at line 3009 of file rconfc.c.

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

◆ m0_rconfc_init()

M0_INTERNAL int m0_rconfc_init ( struct m0_rconfc rconfc,
const struct m0_fid profile,
struct m0_sm_group sm_group,
struct m0_rpc_machine rmach,
m0_rconfc_cb_t  expired_cb,
m0_rconfc_cb_t  ready_cb 
)

Initialise redundant configuration client instance.

If initialisation fails, then finalisation is done internally. No explicit m0_rconfc_fini() is needed.

Parameters
rconfc- rconfc instance
profile- makes sense for clients only, otherwise - &M0_FID0.
sm_group- state machine group to be used with confc. Opening conf objects later in context of this SM group is prohibited, so providing locality SM group is a bad choice. Use locality0 (m0_locality0_get()) or some dedicated SM group.
rmach- RPC machine to be used to communicate with confd
exp_cb- callback, a "configuration just expired" event
ready_cb- rconfc is ready for reading configuration

Definition at line 2860 of file rconfc.c.

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

◆ m0_rconfc_is_preloaded()

M0_INTERNAL bool m0_rconfc_is_preloaded ( struct m0_rconfc rconfc)

When running 'pre-loaded' mode no communication with a herd of confd instances, reaching quorum, getting read lock, blocking read context, etc. is supposed on such rconfc instance. In this case it just shells the pre-filled rc_confc while having all event mechanisms disabled. In this case rconfc remains to be in M0_RCS_INIT state.

Note
Due to being in M0_RCS_INIT state calling m0_rconfc_ver_max_read(), m0_rconfc_rm_endpoint() and m0_rconfc_confd_endpoints() makes no sense with such rconfc, and therefore, prohibited. Rconfc starting and stopping under the circumstances causes no effect on the internal state machine, which remains in M0_RCS_INIT state during all its life.

Definition at line 3135 of file rconfc.c.

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

◆ m0_rconfc_lock()

M0_INTERNAL void m0_rconfc_lock ( struct m0_rconfc rconfc)

Definition at line 2841 of file rconfc.c.

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

◆ m0_rconfc_reading_is_allowed()

M0_INTERNAL bool m0_rconfc_reading_is_allowed ( const struct m0_rconfc rconfc)

Indicates whether rconfc in M0_RCS_IDLE state or not, In M0_RCS_IDLE state rconfc holds a read lock and a client is able to read configuration.

Definition at line 1241 of file rconfc.c.

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

◆ m0_rconfc_rm_endpoint()

M0_INTERNAL int m0_rconfc_rm_endpoint ( struct m0_rconfc rconfc,
char **  ep 
)

Allocates and fills ep with RM endpoint from m0_rconfc::rc_rlock_ctx::rlc_rm_addr. Returns 0 if success or -ENOMEM if memory allocation was failed during duplication of the endpoint.

Precondition
rconfc_state(rconfc) != M0_RCS_INIT

Definition at line 3106 of file rconfc.c.

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

◆ m0_rconfc_rm_fid()

M0_INTERNAL void m0_rconfc_rm_fid ( struct m0_rconfc rconfc,
struct m0_fid out 
)

Returns the fid of active RM obtained by entrypoint request to HA.

Precondition
rconfc_state(rconfc) != M0_RCS_INIT

Definition at line 3122 of file rconfc.c.

Here is the call graph for this function:

◆ m0_rconfc_start()

M0_INTERNAL int m0_rconfc_start ( struct m0_rconfc rconfc)

Rconfc starts with obtaining all necessary information (cluster "entry point") from HA service.

Rconfc continues with election, where allocated confc instances poll corresponding confd for configuration version number they currently run. At the same time confd availability is tested.

Election ends when some version has a quorum. At the same time the active list is populated with rconfc_link instances which confc points to confd of the newly elected version.

Function is asynchronous, user can wait on rconfc->rc_sm.sm_chan until rconfc->rc_sm.sm_state in (M0_RCS_IDLE, M0_RCS_FAILURE). M0_RCS_FAILURE state means that start failed, return code can be obtained from rconfc->rc_sm.sm_rc.

Note
Even with unsuccessful startup rconfc instance requires for explicit m0_rconfc_stop(). The behavior is to provide an ability to call m0_rconfc_ver_max_read() even after unsuccessful version election.

When m0_rconfc::rc_local_conf is not NULL during start, m0_rconfc::rc_confc is pre-loaded from the local configuration string. Such rconfc instance does not participate in standard rconfc activity like holding read lock, version election etc., and being pre-loaded it can only be stopped and finalised.

Note
if rconfc starts successfully and m0_rconfc::rc_ready_cb is not NULL, then the callback is invoked.
See also
m0_rconfc_is_preloaded()

Definition at line 2928 of file rconfc.c.

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

◆ m0_rconfc_start_sync()

static int m0_rconfc_start_sync ( struct m0_rconfc rconfc)
inlinestatic

Definition at line 502 of file rconfc.h.

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

◆ m0_rconfc_start_wait()

M0_INTERNAL int m0_rconfc_start_wait ( struct m0_rconfc rconfc,
uint64_t  timeout_ns 
)

Synchronous version of m0_rconfc_start() with limited deadline. Use M0_TIME_NEVER value to indicate infinite waiting.

Definition at line 2942 of file rconfc.c.

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

◆ m0_rconfc_stop()

M0_INTERNAL void m0_rconfc_stop ( struct m0_rconfc rconfc)

Finalises dedicated m0_rconfc::rc_confc instance and puts all the acquired resources back.

Function is asynchronous, user should wait on rconfc->rc_sm.sm_chan until rconfc->rc_sm.sm_state is M0_RCS_FINAL.

Note
User is not allowed to call m0_rconfc_start() again on stopped rconfc instance as well as other API. The only calls allowed with stopped instance are m0_rconfc_ver_max_read() and m0_rconfc_fini().

Definition at line 2978 of file rconfc.c.

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

◆ m0_rconfc_stop_sync()

M0_INTERNAL void m0_rconfc_stop_sync ( struct m0_rconfc rconfc)

Synchronous version of m0_rconfc_stop().

Definition at line 2995 of file rconfc.c.

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

◆ m0_rconfc_unlock()

M0_INTERNAL void m0_rconfc_unlock ( struct m0_rconfc rconfc)

Definition at line 2855 of file rconfc.c.

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

◆ m0_rconfc_ver_max_read()

M0_INTERNAL uint64_t m0_rconfc_ver_max_read ( struct m0_rconfc rconfc)

Maximum version number the herd confc elements gathered from their confd peers.

Note
Supposed to be called internally, e.g. by spiel during transaction opening.
Precondition
rconfc_state(rconfc) != M0_RCS_INIT

Definition at line 3052 of file rconfc.c.

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