Populate the specified info for the node having as ID the specified 'id', * then returns REDISMODULE_OK. Otherwise if the node ID does not exist from * the POV of this local node, REDISMODULE_ERR is returned. * * The arguments `ip`, `master_id`, `port` and `flags` can be NULL in case we don't * need to populate back certain info. If an `ip` and `master_id` (only populated * if the instance i
| 6172 | * * REDISMODULE_NODE_NOFAILOVER: The slave is configured to never failover |
| 6173 | */ |
| 6174 | int RM_GetClusterNodeInfo(RedisModuleCtx *ctx, const char *id, char *ip, char *master_id, int *port, int *flags) { |
| 6175 | UNUSED(ctx); |
| 6176 | |
| 6177 | clusterNode *node = clusterLookupNode(id); |
| 6178 | if (node == NULL || |
| 6179 | node->flags & (CLUSTER_NODE_NOADDR|CLUSTER_NODE_HANDSHAKE)) |
| 6180 | { |
| 6181 | return REDISMODULE_ERR; |
| 6182 | } |
| 6183 | |
| 6184 | if (ip) strncpy(ip,node->ip,NET_IP_STR_LEN); |
| 6185 | |
| 6186 | if (master_id) { |
| 6187 | /* If the information is not available, the function will set the |
| 6188 | * field to zero bytes, so that when the field can't be populated the |
| 6189 | * function kinda remains predictable. */ |
| 6190 | if (node->flags & CLUSTER_NODE_SLAVE && node->slaveof) |
| 6191 | memcpy(master_id,node->slaveof->name,REDISMODULE_NODE_ID_LEN); |
| 6192 | else |
| 6193 | memset(master_id,0,REDISMODULE_NODE_ID_LEN); |
| 6194 | } |
| 6195 | if (port) *port = node->port; |
| 6196 | |
| 6197 | /* As usually we have to remap flags for modules, in order to ensure |
| 6198 | * we can provide binary compatibility. */ |
| 6199 | if (flags) { |
| 6200 | *flags = 0; |
| 6201 | if (node->flags & CLUSTER_NODE_MYSELF) *flags |= REDISMODULE_NODE_MYSELF; |
| 6202 | if (node->flags & CLUSTER_NODE_MASTER) *flags |= REDISMODULE_NODE_MASTER; |
| 6203 | if (node->flags & CLUSTER_NODE_SLAVE) *flags |= REDISMODULE_NODE_SLAVE; |
| 6204 | if (node->flags & CLUSTER_NODE_PFAIL) *flags |= REDISMODULE_NODE_PFAIL; |
| 6205 | if (node->flags & CLUSTER_NODE_FAIL) *flags |= REDISMODULE_NODE_FAIL; |
| 6206 | if (node->flags & CLUSTER_NODE_NOFAILOVER) *flags |= REDISMODULE_NODE_NOFAILOVER; |
| 6207 | } |
| 6208 | return REDISMODULE_OK; |
| 6209 | } |
| 6210 | |
| 6211 | /* Set Redis Cluster flags in order to change the normal behavior of |
| 6212 | * Redis Cluster, especially with the goal of disabling certain functions. |
nothing calls this directly
no test coverage detected