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
c202ba2b
Commit
c202ba2b
authored
Sep 19, 2018
by
antirez
Browse files
Module cluster flags: add hooks for NO_REDIRECTION flag.
parent
744fe7f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/cluster.c
View file @
c202ba2b
...
@@ -1589,6 +1589,12 @@ void clusterUpdateSlotsConfigWith(clusterNode *sender, uint64_t senderConfigEpoc
...
@@ -1589,6 +1589,12 @@ void clusterUpdateSlotsConfigWith(clusterNode *sender, uint64_t senderConfigEpoc
}
}
}
}
/* After updating the slots configuration, don't do any actual change
* in the state of the server if a module disabled Redis Cluster
* keys redirections. */
if
(
server
.
cluster_module_flags
&
CLUSTER_MODULE_FLAG_NO_REDIRECTION
)
return
;
/* If at least one slot was reassigned from a node to another node
/* If at least one slot was reassigned from a node to another node
* with a greater configEpoch, it is possible that:
* with a greater configEpoch, it is possible that:
* 1) We are a master left without slots. This means that we were
* 1) We are a master left without slots. This means that we were
...
@@ -5435,6 +5441,10 @@ clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, in
...
@@ -5435,6 +5441,10 @@ clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, in
multiCmd
mc
;
multiCmd
mc
;
int
i
,
slot
=
0
,
migrating_slot
=
0
,
importing_slot
=
0
,
missing_keys
=
0
;
int
i
,
slot
=
0
,
migrating_slot
=
0
,
importing_slot
=
0
,
missing_keys
=
0
;
/* Allow any key to be set if a module disabled cluster redirections. */
if
(
server
.
cluster_module_flags
&
CLUSTER_MODULE_FLAG_NO_REDIRECTION
)
return
myself
;
/* Set error code optimistically for the base case. */
/* Set error code optimistically for the base case. */
if
(
error_code
)
*
error_code
=
CLUSTER_REDIR_NONE
;
if
(
error_code
)
*
error_code
=
CLUSTER_REDIR_NONE
;
...
...
src/cluster.h
View file @
c202ba2b
...
@@ -103,9 +103,9 @@ typedef struct clusterLink {
...
@@ -103,9 +103,9 @@ typedef struct clusterLink {
/* Flags that a module can set in order to prevent certain Redis Cluster
/* Flags that a module can set in order to prevent certain Redis Cluster
* features to be enabled. Useful when implementing a different distributed
* features to be enabled. Useful when implementing a different distributed
* system on top of Redis Cluster message bus, using modules. */
* system on top of Redis Cluster message bus, using modules. */
#define
MODULE_
CLUSTER_FLAG_NONE 0
#define CLUSTER
_MODULE
_FLAG_NONE 0
#define
MODULE_
CLUSTER_FLAG_NO_FAILOVER (1<<1)
#define CLUSTER
_MODULE
_FLAG_NO_FAILOVER (1<<1)
#define
MODULE_
CLUSTER_FLAG_NO_REDIRECTION (1<<2)
#define CLUSTER
_MODULE
_FLAG_NO_REDIRECTION (1<<2)
/* This structure represent elements of node->fail_reports. */
/* This structure represent elements of node->fail_reports. */
typedef
struct
clusterNodeFailReport
{
typedef
struct
clusterNodeFailReport
{
...
...
src/server.c
View file @
c202ba2b
...
@@ -1621,7 +1621,7 @@ void initServerConfig(void) {
...
@@ -1621,7 +1621,7 @@ void initServerConfig(void) {
server
.
cluster_announce_ip
=
CONFIG_DEFAULT_CLUSTER_ANNOUNCE_IP
;
server
.
cluster_announce_ip
=
CONFIG_DEFAULT_CLUSTER_ANNOUNCE_IP
;
server
.
cluster_announce_port
=
CONFIG_DEFAULT_CLUSTER_ANNOUNCE_PORT
;
server
.
cluster_announce_port
=
CONFIG_DEFAULT_CLUSTER_ANNOUNCE_PORT
;
server
.
cluster_announce_bus_port
=
CONFIG_DEFAULT_CLUSTER_ANNOUNCE_BUS_PORT
;
server
.
cluster_announce_bus_port
=
CONFIG_DEFAULT_CLUSTER_ANNOUNCE_BUS_PORT
;
server
.
cluster_module_flags
=
MODULE_
CLUSTER_FLAG_NONE
;
server
.
cluster_module_flags
=
CLUSTER
_MODULE
_FLAG_NONE
;
server
.
migrate_cached_sockets
=
dictCreate
(
&
migrateCacheDictType
,
NULL
);
server
.
migrate_cached_sockets
=
dictCreate
(
&
migrateCacheDictType
,
NULL
);
server
.
next_client_id
=
1
;
/* Client IDs, start from 1 .*/
server
.
next_client_id
=
1
;
/* Client IDs, start from 1 .*/
server
.
loading_process_events_interval_bytes
=
(
1024
*
1024
*
2
);
server
.
loading_process_events_interval_bytes
=
(
1024
*
1024
*
2
);
...
...
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