Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
1ad1f001
Commit
1ad1f001
authored
Feb 09, 2018
by
artix
Browse files
Cluster Manager: CLUSTER_MANAGER_NODE_CONNECT macro
parent
2f48d624
Changes
1
Show whitespace changes
Inline
Side-by-side
src/redis-cli.c
View file @
1ad1f001
...
@@ -70,6 +70,8 @@
...
@@ -70,6 +70,8 @@
#define CLUSTER_MANAGER_SLOTS 16384
#define CLUSTER_MANAGER_SLOTS 16384
#define CLUSTER_MANAGER_MODE() (config.cluster_manager_command.name != NULL)
#define CLUSTER_MANAGER_MODE() (config.cluster_manager_command.name != NULL)
#define CLUSTER_MANAGER_MASTERS_COUNT(nodes, replicas) (nodes/(replicas + 1))
#define CLUSTER_MANAGER_MASTERS_COUNT(nodes, replicas) (nodes/(replicas + 1))
#define CLUSTER_MANAGER_NODE_CONNECT(n) \
(n->context = redisConnect(n->ip, n->port));
#define CLUSTER_MANAGER_COMMAND(n,...) \
#define CLUSTER_MANAGER_COMMAND(n,...) \
(reconnectingRedisCommand(n->context, __VA_ARGS__))
(reconnectingRedisCommand(n->context, __VA_ARGS__))
#define CLUSTER_MANAGER_NODE_INFO(n) (CLUSTER_MANAGER_COMMAND(n, "INFO"))
#define CLUSTER_MANAGER_NODE_INFO(n) (CLUSTER_MANAGER_COMMAND(n, "INFO"))
...
@@ -2449,7 +2451,7 @@ node_cmd_err:
...
@@ -2449,7 +2451,7 @@ node_cmd_err:
static int clusterManagerLoadInfoFromNode(clusterManagerNode *node, int opts) {
static int clusterManagerLoadInfoFromNode(clusterManagerNode *node, int opts) {
if (node->context == NULL)
if (node->context == NULL)
node->context = redisConnect(node->ip, node->port
);
CLUSTER_MANAGER_NODE_CONNECT(node
);
if (node->context->err) {
if (node->context->err) {
fprintf(stderr,"Could not connect to Redis at ");
fprintf(stderr,"Could not connect to Redis at ");
fprintf(stderr,"%s:%d: %s\n", node->ip, node->port,
fprintf(stderr,"%s:%d: %s\n", node->ip, node->port,
...
@@ -2491,7 +2493,7 @@ static int clusterManagerLoadInfoFromNode(clusterManagerNode *node, int opts) {
...
@@ -2491,7 +2493,7 @@ static int clusterManagerLoadInfoFromNode(clusterManagerNode *node, int opts) {
clusterManagerNode *friend = ln->value;
clusterManagerNode *friend = ln->value;
if (!friend->ip || !friend->port) goto invalid_friend;
if (!friend->ip || !friend->port) goto invalid_friend;
if (!friend->context)
if (!friend->context)
friend->context = redisConnect(friend->ip, friend->port
);
CLUSTER_MANAGER_NODE_CONNECT(friend
);
if (friend->context->err) goto invalid_friend;
if (friend->context->err) goto invalid_friend;
e = NULL;
e = NULL;
if (clusterManagerNodeLoadInfo(friend, 0, &e)) {
if (clusterManagerNodeLoadInfo(friend, 0, &e)) {
...
@@ -2785,7 +2787,7 @@ static int clusterManagerCommandCreate(int argc, char **argv) {
...
@@ -2785,7 +2787,7 @@ static int clusterManagerCommandCreate(int argc, char **argv) {
char *ip = addr;
char *ip = addr;
int port = atoi(++c);
int port = atoi(++c);
clusterManagerNode *node = clusterManagerNewNode(ip, port);
clusterManagerNode *node = clusterManagerNewNode(ip, port);
node->context = redisConnect(ip, port
);
CLUSTER_MANAGER_NODE_CONNECT(node
);
if (node->context->err) {
if (node->context->err) {
fprintf(stderr,"Could not connect to Redis at ");
fprintf(stderr,"Could not connect to Redis at ");
fprintf(stderr,"%s:%d: %s\n", ip, port, node->context->errstr);
fprintf(stderr,"%s:%d: %s\n", ip, port, node->context->errstr);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment