diff options
author | antirez <antirez@gmail.com> | 2014-02-05 13:01:24 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2014-02-05 13:01:24 +0100 |
commit | 4cf0cd57192d07735a1ddd3aeb84151665929f5c (patch) | |
tree | d0c4002fefbf5bfe40c916c2f331fbb7840d29fb /src/cluster.h | |
parent | 4919a13f503ab4ac5ad5611987996c4432c8de08 (diff) | |
download | redis-4cf0cd57192d07735a1ddd3aeb84151665929f5c.tar.gz |
Cluster: manual failover initial implementation.
Diffstat (limited to 'src/cluster.h')
-rw-r--r-- | src/cluster.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/cluster.h b/src/cluster.h index b32916cf6..52edbf780 100644 --- a/src/cluster.h +++ b/src/cluster.h @@ -22,6 +22,8 @@ #define REDIS_CLUSTER_FAILOVER_AUTH_RETRY_MULT 4 /* Auth request retry time. */ #define REDIS_CLUSTER_FAILOVER_DELAY 5 /* Seconds */ #define REDIS_CLUSTER_DEFAULT_MIGRATION_BARRIER 1 +#define REDIS_CLUSTER_MF_TIMEOUT 5000 /* Milliseconds to do a manual failover. */ +#define REDIS_CLUSTER_MF_PAUSE_MULT 2 /* Master pause manual failover mult. */ struct clusterNode; @@ -100,6 +102,16 @@ typedef struct clusterState { int failover_auth_sent; /* True if we already asked for votes. */ int failover_auth_rank; /* This slave rank for current auth request. */ uint64_t failover_auth_epoch; /* Epoch of the current election. */ + /* Manual failover state in common. */ + mstime_t mf_end; /* Manual failover time limit (ms unixtime). + It is zero if there is no MF in progress. */ + /* Manual failover state of master. */ + clusterNode *mf_slave; /* Slave performing the manual failover. */ + /* Manual failover state of slave. */ + long long mf_master_offset; /* Master offset the slave needs to start MF + or zero if stil not received. */ + int mf_can_start; /* If non-zero signal that the manual failover + can start requesting masters vote. */ /* The followign fields are uesd by masters to take state on elections. */ uint64_t last_vote_epoch; /* Epoch of the last vote granted. */ int todo_before_sleep; /* Things to do in clusterBeforeSleep(). */ @@ -127,6 +139,7 @@ typedef struct clusterState { #define CLUSTERMSG_TYPE_FAILOVER_AUTH_REQUEST 5 /* May I failover? */ #define CLUSTERMSG_TYPE_FAILOVER_AUTH_ACK 6 /* Yes, you have my vote */ #define CLUSTERMSG_TYPE_UPDATE 7 /* Another node slots configuration */ +#define CLUSTERMSG_TYPE_MFSTART 8 /* Pause clients for manual failover */ /* Initially we don't know our "name", but we'll find it once we connect * to the first node, using the getsockname() function. Then we'll use this @@ -180,6 +193,7 @@ union clusterMsgData { } update; }; + typedef struct { uint32_t totlen; /* Total length of this message */ uint16_t type; /* Message type */ @@ -197,12 +211,16 @@ typedef struct { uint16_t port; /* Sender TCP base port */ uint16_t flags; /* Sender node flags */ unsigned char state; /* Cluster state from the POV of the sender */ - unsigned char notused2[3]; /* Reserved for future use. For alignment. */ + unsigned char mflags[3]; /* Message flags: CLUSTERMSG_FLAG[012]_... */ union clusterMsgData data; } clusterMsg; #define CLUSTERMSG_MIN_LEN (sizeof(clusterMsg)-sizeof(union clusterMsgData)) +/* Message flags better specify the packet content or are used to + * provide some information about the node state. */ +#define CLUSTERMSG_FLAG0_PAUSED (1<<0) /* Master paused for manual failover. */ + /* ---------------------- API exported outside cluster.c -------------------- */ clusterNode *getNodeByQuery(redisClient *c, struct redisCommand *cmd, robj **argv, int argc, int *hashslot, int *ask); |