The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
Macros | Typedefs | Functions
cluster_async.h File Reference

Redis asynchronous cluster management. More...

#include <freeradius-devel/server/trunk.h>
#include <freeradius-devel/io/coord_pair.h>
#include "base.h"
#include "pipeline.h"
+ Include dependency graph for cluster_async.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define KEY_SLOTS   16384
 Maximum number of keyslots (should not change).
 
#define REDIS_ASYNC_COORD_CALLBACKS(_thread_type)
 
#define REDIS_ASYNC_START_RCODE_PROCESS(_rcode, _cluster, _cw, _coord_pair_reg, _error_msg, _error_ret)
 Convenience macro to reduce boilerplate.
 

Typedefs

typedef struct fr_redis_async_cmd_s fr_redis_async_cmd_t
 
typedef struct fr_redis_ct_key_slot_s fr_redis_ct_key_slot_t
 
typedef struct fr_redis_ct_node_s fr_redis_ct_node_t
 

Functions

void fr_redis_async_cmd_cancel (fr_redis_async_cmd_t *cmd)
 Cancel a Redis async command.
 
fr_redis_ct_node_t * fr_redis_async_cmd_node (fr_redis_async_cmd_t *cmd)
 Fetch the cluster node a command was last sent to.
 
fr_redis_async_rcode_t fr_redis_async_cmd_redirect (fr_redis_async_cmd_t *cmd)
 Re-submit a redis async command set on a different node.
 
fr_redis_async_rcode_t fr_redis_async_cmd_resend (fr_redis_async_cmd_t *cmd)
 Re-submit a redis async command set.
 
fr_redis_async_cmd_t * fr_redis_async_cmd_start (TALLOC_CTX *ctx, request_t *request, fr_redis_async_rcode_t *rcode, fr_redis_ct_t *rtcluster, uint8_t const *key, size_t key_len, fr_redis_command_set_t *cmds, bool read_only, fr_redis_ct_node_t *node)
 Start running a command set on an async redis cluster.
 
fr_redis_trunk_t * fr_redis_async_cmd_trunk (fr_redis_async_cmd_t *cmd)
 Fetch the redis trunk a command is associated with.
 
fr_redis_ct_t * fr_redis_ct_alloc (TALLOC_CTX *ctx, CONF_SECTION *tls_conf, fr_event_list_t *el, fr_redis_conf_t *conf, fr_redis_trunk_active_t active, void *active_uctx, bool active_oneshot)
 Allocate per-thread, per-cluster instance.
 
fr_event_list_t * fr_redis_ct_el (fr_redis_ct_t *rtcluster)
 
char const * fr_redis_ct_ipaddr (fr_redis_ct_node_t const *node)
 Return the ipaddr of a particular node.
 
int fr_redis_ct_map_bootstrap (fr_redis_ct_t *rtcluster, fr_coord_worker_t *cw, fr_coord_pair_reg_t *coord_pair_reg)
 Initiate bootstrapping of the cluster map.
 
int fr_redis_ct_map_fail (fr_redis_ct_t *rtcluster, fr_pair_list_t const *list)
 
fr_redis_async_rcode_t fr_redis_ct_map_get (fr_redis_ct_t *rtcluster, fr_coord_worker_t *cw, fr_coord_pair_reg_t *coord_pair_reg, bool force)
 Initiate updating of the cluster map.
 
int fr_redis_ct_map_update (fr_redis_ct_t *thread, fr_pair_list_t const *list)
 Update a Redis cluster map from a pair list returned from a coordinator.
 
fr_redis_ct_node_t const * fr_redis_ct_master (fr_redis_ct_t *thread, fr_redis_ct_key_slot_t const *key_slot)
 Return the master node that would be used for a particular key slot.
 
uint8_t fr_redis_ct_max_redirects (fr_redis_ct_t *rtcluster)
 How many times a command set running on this cluster may be redirected.
 
fr_redis_async_rcode_t fr_redis_ct_node_addr_by_role (TALLOC_CTX *ctx, fr_redis_io_conf_t *out[], uint8_t *count_out, fr_redis_ct_t *rtcluster, bool is_master, bool is_replica)
 
fr_redis_ct_node_t * fr_redis_ct_node_by_addr (fr_redis_ct_t *rtcluster, fr_redis_io_conf_t *addr)
 
int fr_redis_ct_port (uint16_t *out, fr_redis_ct_node_t const *node)
 Return the port of a particular node.
 
fr_redis_ct_node_t const * fr_redis_ct_replica (fr_redis_ct_t *thread, fr_redis_ct_key_slot_t const *key_slot, uint8_t replica_num)
 Return the replica node that would be used for a particular key slot.
 
void fr_redis_ct_request_yield (TALLOC_CTX *ctx, fr_redis_ct_t *rtcluster, request_t *request)
 Add a request to the list of those waiting for the cluster map.
 
fr_redis_ct_key_slot_t const * fr_redis_ct_slot_by_key (fr_redis_ct_t *rtcluster, request_t *request, uint8_t const *key, size_t key_len)
 Resolve key to key slot.
 
trunk_conf_t const * fr_redis_ct_trunk_conf (fr_redis_ct_t *thread)
 

Detailed Description

Redis asynchronous cluster management.

Id
c64a585c076904ca20d9db93794a417605487f67
Author
Arran Cudbard-Bell (a.cud.nosp@m.bard.nosp@m.b@fre.nosp@m.erad.nosp@m.ius.o.nosp@m.rg)

Definition in file cluster_async.h.

Macro Definition Documentation

◆ KEY_SLOTS

#define KEY_SLOTS   16384

Maximum number of keyslots (should not change).

Definition at line 36 of file cluster_async.h.

◆ REDIS_ASYNC_COORD_CALLBACKS

#define REDIS_ASYNC_COORD_CALLBACKS (   _thread_type)

Definition at line 67 of file cluster_async.h.

◆ REDIS_ASYNC_START_RCODE_PROCESS

#define REDIS_ASYNC_START_RCODE_PROCESS (   _rcode,
  _cluster,
  _cw,
  _coord_pair_reg,
  _error_msg,
  _error_ret 
)
Value:
switch (_rcode) { \
fr_redis_ct_map_bootstrap(_cluster, _cw, _coord_pair_reg); \
break; \
fr_redis_ct_map_get(_cluster, _cw, _coord_pair_reg, false); \
break; \
RPERROR(_error_msg); \
return _error_ret; \
default: \
break; \
}
@ REDIS_ASYNC_RCODE_BOOTSTRAP
The caller should issue a request to bootstrap the cluster map.
Definition base.h:83
@ REDIS_ASYNC_RCODE_ERROR
Unrecoverable error.
Definition base.h:82
@ REDIS_ASYNC_RCODE_GETMAP
The caller should issue a request to update the cluster map.
Definition base.h:84
@ REDIS_ASYNC_RCODE_FAIL
The command set trunk request has been failed.
Definition base.h:90

Convenience macro to reduce boilerplate.

Parameters
_rcodeto process.
_clusterRedis cluster thread.
_cwCoordinator worker for cluster bootstrapping.
_coord_pair_regCoordinator pair reg for cluster bootstrapping.
_error_msgMessage to report on error.
_error_retReturn value on error.

Definition at line 51 of file cluster_async.h.

Typedef Documentation

◆ fr_redis_async_cmd_t

Definition at line 40 of file cluster_async.h.

◆ fr_redis_ct_key_slot_t

Definition at line 38 of file cluster_async.h.

◆ fr_redis_ct_node_t

Definition at line 39 of file cluster_async.h.

Function Documentation

◆ fr_redis_async_cmd_cancel()

void fr_redis_async_cmd_cancel ( fr_redis_async_cmd_t *  cmd)

Cancel a Redis async command.

Definition at line 529 of file cluster_async.c.

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

◆ fr_redis_async_cmd_node()

fr_redis_ct_node_t * fr_redis_async_cmd_node ( fr_redis_async_cmd_t *  cmd)

Fetch the cluster node a command was last sent to.

Definition at line 544 of file cluster_async.c.

+ Here is the caller graph for this function:

◆ fr_redis_async_cmd_redirect()

fr_redis_async_rcode_t fr_redis_async_cmd_redirect ( fr_redis_async_cmd_t *  cmd)

Re-submit a redis async command set on a different node.

Using the node returned by a MOVED / ASK response.

Parameters
cmdAsync command set to redirect
Returns
fr_redis_async_rcode_t

Definition at line 556 of file cluster_async.c.

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

◆ fr_redis_async_cmd_resend()

fr_redis_async_rcode_t fr_redis_async_cmd_resend ( fr_redis_async_cmd_t *  cmd)

Re-submit a redis async command set.

To be used following TRYAGAIN responses

Parameters
cmdAsync command set to redirect
Returns
fr_redis_async_rcode_t

Definition at line 579 of file cluster_async.c.

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

◆ fr_redis_async_cmd_start()

fr_redis_async_cmd_t * fr_redis_async_cmd_start ( TALLOC_CTX *  ctx,
request_t *  request,
fr_redis_async_rcode_t *  rcode,
fr_redis_ct_t *  rtcluster,
uint8_t const *  key,
size_t  key_len,
fr_redis_command_set_t *  cmds,
bool  read_only,
fr_redis_ct_node_t *  node 
)

Start running a command set on an async redis cluster.

Parameters
ctxto allocate tracking structure.
requestcurrent request.
rcodeWhere to write the result code.
rtclusterto start the command set on
keyto identify the cluster slot.
key_lenLength of key.
cmdsCommand set to run.
read_onlyShould the command set be run on read only nodes.
nodeSpecific node to run the command set on.
Returns
The async redis command

Definition at line 475 of file cluster_async.c.

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

◆ fr_redis_async_cmd_trunk()

fr_redis_trunk_t * fr_redis_async_cmd_trunk ( fr_redis_async_cmd_t *  cmd)

Fetch the redis trunk a command is associated with.

Definition at line 537 of file cluster_async.c.

+ Here is the caller graph for this function:

◆ fr_redis_ct_alloc()

fr_redis_ct_t * fr_redis_ct_alloc ( TALLOC_CTX *  ctx,
CONF_SECTION *  tls_cs,
fr_event_list_t *  el,
fr_redis_conf_t *  conf,
fr_redis_trunk_active_t  active,
void *  active_uctx,
bool  active_oneshot 
)

Allocate per-thread, per-cluster instance.

This structure represents all the connections for a given thread for a given cluster. The structures holds the trunk connections to talk to each cluster member.

Definition at line 617 of file cluster_async.c.

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

◆ fr_redis_ct_el()

fr_event_list_t * fr_redis_ct_el ( fr_redis_ct_t *  rtcluster)

Definition at line 747 of file cluster_async.c.

+ Here is the caller graph for this function:

◆ fr_redis_ct_ipaddr()

char const * fr_redis_ct_ipaddr ( fr_redis_ct_node_t const *  node)

Return the ipaddr of a particular node.

Parameters
[in]nodeto get ip address from.
Returns
  • IP address of node
  • NULL on failure (node is NULL).

Definition at line 370 of file cluster_async.c.

+ Here is the caller graph for this function:

◆ fr_redis_ct_map_bootstrap()

int fr_redis_ct_map_bootstrap ( fr_redis_ct_t *  rtcluster,
fr_coord_worker_t *  cw,
fr_coord_pair_reg_t *  coord_pair_reg 
)

Initiate bootstrapping of the cluster map.

To be used when a module first wants to fetch a cluster map

Parameters
rtclusterCluster to fetch map for
cwCoord worker to launch request
coord_pair_regCoord pair registration
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1044 of file cluster_async.c.

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

◆ fr_redis_ct_map_fail()

int fr_redis_ct_map_fail ( fr_redis_ct_t *  rtcluster,
fr_pair_list_t const *  list 
)

◆ fr_redis_ct_map_get()

fr_redis_async_rcode_t fr_redis_ct_map_get ( fr_redis_ct_t *  rtcluster,
fr_coord_worker_t *  cw,
fr_coord_pair_reg_t *  coord_pair_reg,
bool  force 
)

Initiate updating of the cluster map.

To be used when a command returns MOVED

Definition at line 1105 of file cluster_async.c.

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

◆ fr_redis_ct_map_update()

int fr_redis_ct_map_update ( fr_redis_ct_t *  rtcluster,
fr_pair_list_t const *  list 
)

Update a Redis cluster map from a pair list returned from a coordinator.

Parameters
rtclusterCluster to update
listpairs sent by a coordinator
Returns
  • 0 om success
  • -1 on error

Definition at line 782 of file cluster_async.c.

+ Here is the call graph for this function:

◆ fr_redis_ct_master()

fr_redis_ct_node_t const * fr_redis_ct_master ( fr_redis_ct_t *  rtcluster,
fr_redis_ct_key_slot_t const *  key_slot 
)

Return the master node that would be used for a particular key slot.

Parameters
[in]rtclusterTo resolve key slot in.
[in]key_slotto resolve to node.
Returns
  • The current master node.
  • NULL if no master node is currently assigned to a particular key slot.

Definition at line 339 of file cluster_async.c.

+ Here is the caller graph for this function:

◆ fr_redis_ct_max_redirects()

uint8_t fr_redis_ct_max_redirects ( fr_redis_ct_t *  rtcluster)

How many times a command set running on this cluster may be redirected.

Parameters
[in]rtclusterto return the configured limit for.
Returns
the value of the max_redirects configuration item.

Definition at line 762 of file cluster_async.c.

+ Here is the caller graph for this function:

◆ fr_redis_ct_node_addr_by_role()

fr_redis_async_rcode_t fr_redis_ct_node_addr_by_role ( TALLOC_CTX *  ctx,
fr_redis_io_conf_t *  out[],
uint8_t *  count_out,
fr_redis_ct_t *  rtcluster,
bool  is_master,
bool  is_replica 
)

Definition at line 1162 of file cluster_async.c.

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

◆ fr_redis_ct_node_by_addr()

fr_redis_ct_node_t * fr_redis_ct_node_by_addr ( fr_redis_ct_t *  rtcluster,
fr_redis_io_conf_t *  addr 
)

Definition at line 1152 of file cluster_async.c.

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

◆ fr_redis_ct_port()

int fr_redis_ct_port ( uint16_t *  out,
fr_redis_ct_node_t const *  node 
)

Return the port of a particular node.

Parameters
[out]outPort of the node.
[in]nodeto get ip address from.
Returns
  • 0 on success.
  • -1 on failure (node is NULL).

Definition at line 385 of file cluster_async.c.

+ Here is the caller graph for this function:

◆ fr_redis_ct_replica()

fr_redis_ct_node_t const * fr_redis_ct_replica ( fr_redis_ct_t *  rtcluster,
fr_redis_ct_key_slot_t const *  key_slot,
uint8_t  replica_num 
)

Return the replica node that would be used for a particular key slot.

Parameters
[in]rtclusterTo resolve key slot in.
[in]key_slotTo resolve to node.
[in]replica_num0..n.
Returns
  • A replica node.
  • NULL if no replica node is assigned, or is at the specific key slot.

Definition at line 355 of file cluster_async.c.

+ Here is the caller graph for this function:

◆ fr_redis_ct_request_yield()

void fr_redis_ct_request_yield ( TALLOC_CTX *  ctx,
fr_redis_ct_t *  rtcluster,
request_t *  request 
)

Add a request to the list of those waiting for the cluster map.

Definition at line 1222 of file cluster_async.c.

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

◆ fr_redis_ct_slot_by_key()

fr_redis_ct_key_slot_t const * fr_redis_ct_slot_by_key ( fr_redis_ct_t *  rtcluster,
request_t *  request,
uint8_t const *  key,
size_t  key_len 
)

Resolve key to key slot.

Parameters
[in]rtclusterto resolve the key slot in.
[in]requestCurrent request (for debugging).
[in]keyto resolve.
[in]key_lenlength of key.
Returns
key slot for the key.

Definition at line 303 of file cluster_async.c.

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

◆ fr_redis_ct_trunk_conf()

trunk_conf_t const * fr_redis_ct_trunk_conf ( fr_redis_ct_t *  thread)

Definition at line 752 of file cluster_async.c.

+ Here is the caller graph for this function: