mirror of
https://github.com/fluencelabs/redis
synced 2025-04-05 01:01:04 +00:00
RDMF: more names updated.
This commit is contained in:
parent
32f80e2f1b
commit
3325a9b11f
@ -198,7 +198,7 @@ ssize_t aofRewriteBufferWrite(int fd) {
|
|||||||
/* Starts a background task that performs fsync() against the specified
|
/* Starts a background task that performs fsync() against the specified
|
||||||
* file descriptor (the one of the AOF file) in another thread. */
|
* file descriptor (the one of the AOF file) in another thread. */
|
||||||
void aof_background_fsync(int fd) {
|
void aof_background_fsync(int fd) {
|
||||||
bioCreateBackgroundJob(REDIS_BIO_AOF_FSYNC,(void*)(long)fd,NULL,NULL);
|
bioCreateBackgroundJob(BIO_AOF_FSYNC,(void*)(long)fd,NULL,NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called when the user switches from "appendonly yes" to "appendonly no"
|
/* Called when the user switches from "appendonly yes" to "appendonly no"
|
||||||
@ -278,7 +278,7 @@ void flushAppendOnlyFile(int force) {
|
|||||||
if (sdslen(server.aof_buf) == 0) return;
|
if (sdslen(server.aof_buf) == 0) return;
|
||||||
|
|
||||||
if (server.aof_fsync == AOF_FSYNC_EVERYSEC)
|
if (server.aof_fsync == AOF_FSYNC_EVERYSEC)
|
||||||
sync_in_progress = bioPendingJobsOfType(REDIS_BIO_AOF_FSYNC) != 0;
|
sync_in_progress = bioPendingJobsOfType(BIO_AOF_FSYNC) != 0;
|
||||||
|
|
||||||
if (server.aof_fsync == AOF_FSYNC_EVERYSEC && !force) {
|
if (server.aof_fsync == AOF_FSYNC_EVERYSEC && !force) {
|
||||||
/* With this append fsync policy we do background fsyncing.
|
/* With this append fsync policy we do background fsyncing.
|
||||||
@ -1454,7 +1454,7 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) {
|
|||||||
server.aof_state = AOF_ON;
|
server.aof_state = AOF_ON;
|
||||||
|
|
||||||
/* Asynchronously close the overwritten AOF. */
|
/* Asynchronously close the overwritten AOF. */
|
||||||
if (oldfd != -1) bioCreateBackgroundJob(REDIS_BIO_CLOSE_FILE,(void*)(long)oldfd,NULL,NULL);
|
if (oldfd != -1) bioCreateBackgroundJob(BIO_CLOSE_FILE,(void*)(long)oldfd,NULL,NULL);
|
||||||
|
|
||||||
serverLog(LL_VERBOSE,
|
serverLog(LL_VERBOSE,
|
||||||
"Background AOF rewrite signal handler took %lldus", ustime()-now);
|
"Background AOF rewrite signal handler took %lldus", ustime()-now);
|
||||||
|
22
src/bio.c
22
src/bio.c
@ -61,17 +61,17 @@
|
|||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "bio.h"
|
#include "bio.h"
|
||||||
|
|
||||||
static pthread_t bio_threads[REDIS_BIO_NUM_OPS];
|
static pthread_t bio_threads[BIO_NUM_OPS];
|
||||||
static pthread_mutex_t bio_mutex[REDIS_BIO_NUM_OPS];
|
static pthread_mutex_t bio_mutex[BIO_NUM_OPS];
|
||||||
static pthread_cond_t bio_condvar[REDIS_BIO_NUM_OPS];
|
static pthread_cond_t bio_condvar[BIO_NUM_OPS];
|
||||||
static list *bio_jobs[REDIS_BIO_NUM_OPS];
|
static list *bio_jobs[BIO_NUM_OPS];
|
||||||
/* The following array is used to hold the number of pending jobs for every
|
/* The following array is used to hold the number of pending jobs for every
|
||||||
* OP type. This allows us to export the bioPendingJobsOfType() API that is
|
* OP type. This allows us to export the bioPendingJobsOfType() API that is
|
||||||
* useful when the main thread wants to perform some operation that may involve
|
* useful when the main thread wants to perform some operation that may involve
|
||||||
* objects shared with the background thread. The main thread will just wait
|
* objects shared with the background thread. The main thread will just wait
|
||||||
* that there are no longer jobs of this type to be executed before performing
|
* that there are no longer jobs of this type to be executed before performing
|
||||||
* the sensible operation. This data is also useful for reporting. */
|
* the sensible operation. This data is also useful for reporting. */
|
||||||
static unsigned long long bio_pending[REDIS_BIO_NUM_OPS];
|
static unsigned long long bio_pending[BIO_NUM_OPS];
|
||||||
|
|
||||||
/* This structure represents a background Job. It is only used locally to this
|
/* This structure represents a background Job. It is only used locally to this
|
||||||
* file as the API does not expose the internals at all. */
|
* file as the API does not expose the internals at all. */
|
||||||
@ -96,7 +96,7 @@ void bioInit(void) {
|
|||||||
int j;
|
int j;
|
||||||
|
|
||||||
/* Initialization of state vars and objects */
|
/* Initialization of state vars and objects */
|
||||||
for (j = 0; j < REDIS_BIO_NUM_OPS; j++) {
|
for (j = 0; j < BIO_NUM_OPS; j++) {
|
||||||
pthread_mutex_init(&bio_mutex[j],NULL);
|
pthread_mutex_init(&bio_mutex[j],NULL);
|
||||||
pthread_cond_init(&bio_condvar[j],NULL);
|
pthread_cond_init(&bio_condvar[j],NULL);
|
||||||
bio_jobs[j] = listCreate();
|
bio_jobs[j] = listCreate();
|
||||||
@ -113,7 +113,7 @@ void bioInit(void) {
|
|||||||
/* Ready to spawn our threads. We use the single argument the thread
|
/* Ready to spawn our threads. We use the single argument the thread
|
||||||
* function accepts in order to pass the job ID the thread is
|
* function accepts in order to pass the job ID the thread is
|
||||||
* responsible of. */
|
* responsible of. */
|
||||||
for (j = 0; j < REDIS_BIO_NUM_OPS; j++) {
|
for (j = 0; j < BIO_NUM_OPS; j++) {
|
||||||
void *arg = (void*)(unsigned long) j;
|
void *arg = (void*)(unsigned long) j;
|
||||||
if (pthread_create(&thread,&attr,bioProcessBackgroundJobs,arg) != 0) {
|
if (pthread_create(&thread,&attr,bioProcessBackgroundJobs,arg) != 0) {
|
||||||
serverLog(LL_WARNING,"Fatal: Can't initialize Background Jobs.");
|
serverLog(LL_WARNING,"Fatal: Can't initialize Background Jobs.");
|
||||||
@ -143,7 +143,7 @@ void *bioProcessBackgroundJobs(void *arg) {
|
|||||||
sigset_t sigset;
|
sigset_t sigset;
|
||||||
|
|
||||||
/* Check that the type is within the right interval. */
|
/* Check that the type is within the right interval. */
|
||||||
if (type >= REDIS_BIO_NUM_OPS) {
|
if (type >= BIO_NUM_OPS) {
|
||||||
serverLog(LL_WARNING,
|
serverLog(LL_WARNING,
|
||||||
"Warning: bio thread started with wrong type %lu",type);
|
"Warning: bio thread started with wrong type %lu",type);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -179,9 +179,9 @@ void *bioProcessBackgroundJobs(void *arg) {
|
|||||||
pthread_mutex_unlock(&bio_mutex[type]);
|
pthread_mutex_unlock(&bio_mutex[type]);
|
||||||
|
|
||||||
/* Process the job accordingly to its type. */
|
/* Process the job accordingly to its type. */
|
||||||
if (type == REDIS_BIO_CLOSE_FILE) {
|
if (type == BIO_CLOSE_FILE) {
|
||||||
close((long)job->arg1);
|
close((long)job->arg1);
|
||||||
} else if (type == REDIS_BIO_AOF_FSYNC) {
|
} else if (type == BIO_AOF_FSYNC) {
|
||||||
aof_fsync((long)job->arg1);
|
aof_fsync((long)job->arg1);
|
||||||
} else {
|
} else {
|
||||||
serverPanic("Wrong job type in bioProcessBackgroundJobs().");
|
serverPanic("Wrong job type in bioProcessBackgroundJobs().");
|
||||||
@ -212,7 +212,7 @@ unsigned long long bioPendingJobsOfType(int type) {
|
|||||||
void bioKillThreads(void) {
|
void bioKillThreads(void) {
|
||||||
int err, j;
|
int err, j;
|
||||||
|
|
||||||
for (j = 0; j < REDIS_BIO_NUM_OPS; j++) {
|
for (j = 0; j < BIO_NUM_OPS; j++) {
|
||||||
if (pthread_cancel(bio_threads[j]) == 0) {
|
if (pthread_cancel(bio_threads[j]) == 0) {
|
||||||
if ((err = pthread_join(bio_threads[j],NULL)) != 0) {
|
if ((err = pthread_join(bio_threads[j],NULL)) != 0) {
|
||||||
serverLog(LL_WARNING,
|
serverLog(LL_WARNING,
|
||||||
|
@ -36,6 +36,6 @@ time_t bioOlderJobOfType(int type);
|
|||||||
void bioKillThreads(void);
|
void bioKillThreads(void);
|
||||||
|
|
||||||
/* Background job opcodes */
|
/* Background job opcodes */
|
||||||
#define REDIS_BIO_CLOSE_FILE 0 /* Deferred close(2) syscall. */
|
#define BIO_CLOSE_FILE 0 /* Deferred close(2) syscall. */
|
||||||
#define REDIS_BIO_AOF_FSYNC 1 /* Deferred AOF fsync. */
|
#define BIO_AOF_FSYNC 1 /* Deferred AOF fsync. */
|
||||||
#define REDIS_BIO_NUM_OPS 2
|
#define BIO_NUM_OPS 2
|
||||||
|
352
src/cluster.c
352
src/cluster.c
File diff suppressed because it is too large
Load Diff
124
src/cluster.h
124
src/cluster.h
@ -1,37 +1,37 @@
|
|||||||
#ifndef __REDIS_CLUSTER_H
|
#ifndef __CLUSTER_H
|
||||||
#define __REDIS_CLUSTER_H
|
#define __CLUSTER_H
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------
|
/*-----------------------------------------------------------------------------
|
||||||
* Redis cluster data structures, defines, exported API.
|
* Redis cluster data structures, defines, exported API.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#define REDIS_CLUSTER_SLOTS 16384
|
#define CLUSTER_SLOTS 16384
|
||||||
#define REDIS_CLUSTER_OK 0 /* Everything looks ok */
|
#define CLUSTER_OK 0 /* Everything looks ok */
|
||||||
#define REDIS_CLUSTER_FAIL 1 /* The cluster can't work */
|
#define CLUSTER_FAIL 1 /* The cluster can't work */
|
||||||
#define REDIS_CLUSTER_NAMELEN 40 /* sha1 hex length */
|
#define CLUSTER_NAMELEN 40 /* sha1 hex length */
|
||||||
#define REDIS_CLUSTER_PORT_INCR 10000 /* Cluster port = baseport + PORT_INCR */
|
#define CLUSTER_PORT_INCR 10000 /* Cluster port = baseport + PORT_INCR */
|
||||||
|
|
||||||
/* The following defines are amount of time, sometimes expressed as
|
/* The following defines are amount of time, sometimes expressed as
|
||||||
* multiplicators of the node timeout value (when ending with MULT). */
|
* multiplicators of the node timeout value (when ending with MULT). */
|
||||||
#define REDIS_CLUSTER_DEFAULT_NODE_TIMEOUT 15000
|
#define CLUSTER_DEFAULT_NODE_TIMEOUT 15000
|
||||||
#define REDIS_CLUSTER_DEFAULT_SLAVE_VALIDITY 10 /* Slave max data age factor. */
|
#define CLUSTER_DEFAULT_SLAVE_VALIDITY 10 /* Slave max data age factor. */
|
||||||
#define REDIS_CLUSTER_DEFAULT_REQUIRE_FULL_COVERAGE 1
|
#define CLUSTER_DEFAULT_REQUIRE_FULL_COVERAGE 1
|
||||||
#define REDIS_CLUSTER_FAIL_REPORT_VALIDITY_MULT 2 /* Fail report validity. */
|
#define CLUSTER_FAIL_REPORT_VALIDITY_MULT 2 /* Fail report validity. */
|
||||||
#define REDIS_CLUSTER_FAIL_UNDO_TIME_MULT 2 /* Undo fail if master is back. */
|
#define CLUSTER_FAIL_UNDO_TIME_MULT 2 /* Undo fail if master is back. */
|
||||||
#define REDIS_CLUSTER_FAIL_UNDO_TIME_ADD 10 /* Some additional time. */
|
#define CLUSTER_FAIL_UNDO_TIME_ADD 10 /* Some additional time. */
|
||||||
#define REDIS_CLUSTER_FAILOVER_DELAY 5 /* Seconds */
|
#define CLUSTER_FAILOVER_DELAY 5 /* Seconds */
|
||||||
#define REDIS_CLUSTER_DEFAULT_MIGRATION_BARRIER 1
|
#define CLUSTER_DEFAULT_MIGRATION_BARRIER 1
|
||||||
#define REDIS_CLUSTER_MF_TIMEOUT 5000 /* Milliseconds to do a manual failover. */
|
#define CLUSTER_MF_TIMEOUT 5000 /* Milliseconds to do a manual failover. */
|
||||||
#define REDIS_CLUSTER_MF_PAUSE_MULT 2 /* Master pause manual failover mult. */
|
#define CLUSTER_MF_PAUSE_MULT 2 /* Master pause manual failover mult. */
|
||||||
|
|
||||||
/* Redirection errors returned by getNodeByQuery(). */
|
/* Redirection errors returned by getNodeByQuery(). */
|
||||||
#define REDIS_CLUSTER_REDIR_NONE 0 /* Node can serve the request. */
|
#define CLUSTER_REDIR_NONE 0 /* Node can serve the request. */
|
||||||
#define REDIS_CLUSTER_REDIR_CROSS_SLOT 1 /* -CROSSSLOT request. */
|
#define CLUSTER_REDIR_CROSS_SLOT 1 /* -CROSSSLOT request. */
|
||||||
#define REDIS_CLUSTER_REDIR_UNSTABLE 2 /* -TRYAGAIN redirection required */
|
#define CLUSTER_REDIR_UNSTABLE 2 /* -TRYAGAIN redirection required */
|
||||||
#define REDIS_CLUSTER_REDIR_ASK 3 /* -ASK redirection required. */
|
#define CLUSTER_REDIR_ASK 3 /* -ASK redirection required. */
|
||||||
#define REDIS_CLUSTER_REDIR_MOVED 4 /* -MOVED redirection required. */
|
#define CLUSTER_REDIR_MOVED 4 /* -MOVED redirection required. */
|
||||||
#define REDIS_CLUSTER_REDIR_DOWN_STATE 5 /* -CLUSTERDOWN, global state. */
|
#define CLUSTER_REDIR_DOWN_STATE 5 /* -CLUSTERDOWN, global state. */
|
||||||
#define REDIS_CLUSTER_REDIR_DOWN_UNBOUND 6 /* -CLUSTERDOWN, unbound slot. */
|
#define CLUSTER_REDIR_DOWN_UNBOUND 6 /* -CLUSTERDOWN, unbound slot. */
|
||||||
|
|
||||||
struct clusterNode;
|
struct clusterNode;
|
||||||
|
|
||||||
@ -45,32 +45,32 @@ typedef struct clusterLink {
|
|||||||
} clusterLink;
|
} clusterLink;
|
||||||
|
|
||||||
/* Cluster node flags and macros. */
|
/* Cluster node flags and macros. */
|
||||||
#define REDIS_NODE_MASTER 1 /* The node is a master */
|
#define CLUSTER_NODE_MASTER 1 /* The node is a master */
|
||||||
#define REDIS_NODE_SLAVE 2 /* The node is a slave */
|
#define CLUSTER_NODE_SLAVE 2 /* The node is a slave */
|
||||||
#define REDIS_NODE_PFAIL 4 /* Failure? Need acknowledge */
|
#define CLUSTER_NODE_PFAIL 4 /* Failure? Need acknowledge */
|
||||||
#define REDIS_NODE_FAIL 8 /* The node is believed to be malfunctioning */
|
#define CLUSTER_NODE_FAIL 8 /* The node is believed to be malfunctioning */
|
||||||
#define REDIS_NODE_MYSELF 16 /* This node is myself */
|
#define CLUSTER_NODE_MYSELF 16 /* This node is myself */
|
||||||
#define REDIS_NODE_HANDSHAKE 32 /* We have still to exchange the first ping */
|
#define CLUSTER_NODE_HANDSHAKE 32 /* We have still to exchange the first ping */
|
||||||
#define REDIS_NODE_NOADDR 64 /* We don't know the address of this node */
|
#define CLUSTER_NODE_NOADDR 64 /* We don't know the address of this node */
|
||||||
#define REDIS_NODE_MEET 128 /* Send a MEET message to this node */
|
#define CLUSTER_NODE_MEET 128 /* Send a MEET message to this node */
|
||||||
#define REDIS_NODE_PROMOTED 256 /* Master was a slave promoted by failover */
|
#define CLUSTER_NODE_PROMOTED 256 /* Master was a slave promoted by failover */
|
||||||
#define REDIS_NODE_NULL_NAME "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
#define CLUSTER_NODE_NULL_NAME "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||||
|
|
||||||
#define nodeIsMaster(n) ((n)->flags & REDIS_NODE_MASTER)
|
#define nodeIsMaster(n) ((n)->flags & CLUSTER_NODE_MASTER)
|
||||||
#define nodeIsSlave(n) ((n)->flags & REDIS_NODE_SLAVE)
|
#define nodeIsSlave(n) ((n)->flags & CLUSTER_NODE_SLAVE)
|
||||||
#define nodeInHandshake(n) ((n)->flags & REDIS_NODE_HANDSHAKE)
|
#define nodeInHandshake(n) ((n)->flags & CLUSTER_NODE_HANDSHAKE)
|
||||||
#define nodeHasAddr(n) (!((n)->flags & REDIS_NODE_NOADDR))
|
#define nodeHasAddr(n) (!((n)->flags & CLUSTER_NODE_NOADDR))
|
||||||
#define nodeWithoutAddr(n) ((n)->flags & REDIS_NODE_NOADDR)
|
#define nodeWithoutAddr(n) ((n)->flags & CLUSTER_NODE_NOADDR)
|
||||||
#define nodeTimedOut(n) ((n)->flags & REDIS_NODE_PFAIL)
|
#define nodeTimedOut(n) ((n)->flags & CLUSTER_NODE_PFAIL)
|
||||||
#define nodeFailed(n) ((n)->flags & REDIS_NODE_FAIL)
|
#define nodeFailed(n) ((n)->flags & CLUSTER_NODE_FAIL)
|
||||||
|
|
||||||
/* Reasons why a slave is not able to failover. */
|
/* Reasons why a slave is not able to failover. */
|
||||||
#define REDIS_CLUSTER_CANT_FAILOVER_NONE 0
|
#define CLUSTER_CANT_FAILOVER_NONE 0
|
||||||
#define REDIS_CLUSTER_CANT_FAILOVER_DATA_AGE 1
|
#define CLUSTER_CANT_FAILOVER_DATA_AGE 1
|
||||||
#define REDIS_CLUSTER_CANT_FAILOVER_WAITING_DELAY 2
|
#define CLUSTER_CANT_FAILOVER_WAITING_DELAY 2
|
||||||
#define REDIS_CLUSTER_CANT_FAILOVER_EXPIRED 3
|
#define CLUSTER_CANT_FAILOVER_EXPIRED 3
|
||||||
#define REDIS_CLUSTER_CANT_FAILOVER_WAITING_VOTES 4
|
#define CLUSTER_CANT_FAILOVER_WAITING_VOTES 4
|
||||||
#define REDIS_CLUSTER_CANT_FAILOVER_RELOG_PERIOD (60*5) /* seconds. */
|
#define CLUSTER_CANT_FAILOVER_RELOG_PERIOD (60*5) /* seconds. */
|
||||||
|
|
||||||
/* This structure represent elements of node->fail_reports. */
|
/* This structure represent elements of node->fail_reports. */
|
||||||
typedef struct clusterNodeFailReport {
|
typedef struct clusterNodeFailReport {
|
||||||
@ -80,10 +80,10 @@ typedef struct clusterNodeFailReport {
|
|||||||
|
|
||||||
typedef struct clusterNode {
|
typedef struct clusterNode {
|
||||||
mstime_t ctime; /* Node object creation time. */
|
mstime_t ctime; /* Node object creation time. */
|
||||||
char name[REDIS_CLUSTER_NAMELEN]; /* Node name, hex string, sha1-size */
|
char name[CLUSTER_NAMELEN]; /* Node name, hex string, sha1-size */
|
||||||
int flags; /* REDIS_NODE_... */
|
int flags; /* CLUSTER_NODE_... */
|
||||||
uint64_t configEpoch; /* Last configEpoch observed for this node */
|
uint64_t configEpoch; /* Last configEpoch observed for this node */
|
||||||
unsigned char slots[REDIS_CLUSTER_SLOTS/8]; /* slots handled by this node */
|
unsigned char slots[CLUSTER_SLOTS/8]; /* slots handled by this node */
|
||||||
int numslots; /* Number of slots handled by this node */
|
int numslots; /* Number of slots handled by this node */
|
||||||
int numslaves; /* Number of slave nodes, if this is a master */
|
int numslaves; /* Number of slave nodes, if this is a master */
|
||||||
struct clusterNode **slaves; /* pointers to slave nodes */
|
struct clusterNode **slaves; /* pointers to slave nodes */
|
||||||
@ -103,13 +103,13 @@ typedef struct clusterNode {
|
|||||||
typedef struct clusterState {
|
typedef struct clusterState {
|
||||||
clusterNode *myself; /* This node */
|
clusterNode *myself; /* This node */
|
||||||
uint64_t currentEpoch;
|
uint64_t currentEpoch;
|
||||||
int state; /* REDIS_CLUSTER_OK, REDIS_CLUSTER_FAIL, ... */
|
int state; /* CLUSTER_OK, CLUSTER_FAIL, ... */
|
||||||
int size; /* Num of master nodes with at least one slot */
|
int size; /* Num of master nodes with at least one slot */
|
||||||
dict *nodes; /* Hash table of name -> clusterNode structures */
|
dict *nodes; /* Hash table of name -> clusterNode structures */
|
||||||
dict *nodes_black_list; /* Nodes we don't re-add for a few seconds. */
|
dict *nodes_black_list; /* Nodes we don't re-add for a few seconds. */
|
||||||
clusterNode *migrating_slots_to[REDIS_CLUSTER_SLOTS];
|
clusterNode *migrating_slots_to[CLUSTER_SLOTS];
|
||||||
clusterNode *importing_slots_from[REDIS_CLUSTER_SLOTS];
|
clusterNode *importing_slots_from[CLUSTER_SLOTS];
|
||||||
clusterNode *slots[REDIS_CLUSTER_SLOTS];
|
clusterNode *slots[CLUSTER_SLOTS];
|
||||||
zskiplist *slots_to_keys;
|
zskiplist *slots_to_keys;
|
||||||
/* The following fields are used to take the slave state on elections. */
|
/* The following fields are used to take the slave state on elections. */
|
||||||
mstime_t failover_auth_time; /* Time of previous or next election. */
|
mstime_t failover_auth_time; /* Time of previous or next election. */
|
||||||
@ -162,7 +162,7 @@ typedef struct clusterState {
|
|||||||
* to the first node, using the getsockname() function. Then we'll use this
|
* to the first node, using the getsockname() function. Then we'll use this
|
||||||
* address for all the next messages. */
|
* address for all the next messages. */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char nodename[REDIS_CLUSTER_NAMELEN];
|
char nodename[CLUSTER_NAMELEN];
|
||||||
uint32_t ping_sent;
|
uint32_t ping_sent;
|
||||||
uint32_t pong_received;
|
uint32_t pong_received;
|
||||||
char ip[NET_IP_STR_LEN]; /* IP address last time it was seen */
|
char ip[NET_IP_STR_LEN]; /* IP address last time it was seen */
|
||||||
@ -173,7 +173,7 @@ typedef struct {
|
|||||||
} clusterMsgDataGossip;
|
} clusterMsgDataGossip;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char nodename[REDIS_CLUSTER_NAMELEN];
|
char nodename[CLUSTER_NAMELEN];
|
||||||
} clusterMsgDataFail;
|
} clusterMsgDataFail;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -187,8 +187,8 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint64_t configEpoch; /* Config epoch of the specified instance. */
|
uint64_t configEpoch; /* Config epoch of the specified instance. */
|
||||||
char nodename[REDIS_CLUSTER_NAMELEN]; /* Name of the slots owner. */
|
char nodename[CLUSTER_NAMELEN]; /* Name of the slots owner. */
|
||||||
unsigned char slots[REDIS_CLUSTER_SLOTS/8]; /* Slots bitmap. */
|
unsigned char slots[CLUSTER_SLOTS/8]; /* Slots bitmap. */
|
||||||
} clusterMsgDataUpdate;
|
} clusterMsgDataUpdate;
|
||||||
|
|
||||||
union clusterMsgData {
|
union clusterMsgData {
|
||||||
@ -229,9 +229,9 @@ typedef struct {
|
|||||||
slave. */
|
slave. */
|
||||||
uint64_t offset; /* Master replication offset if node is a master or
|
uint64_t offset; /* Master replication offset if node is a master or
|
||||||
processed replication offset if node is a slave. */
|
processed replication offset if node is a slave. */
|
||||||
char sender[REDIS_CLUSTER_NAMELEN]; /* Name of the sender node */
|
char sender[CLUSTER_NAMELEN]; /* Name of the sender node */
|
||||||
unsigned char myslots[REDIS_CLUSTER_SLOTS/8];
|
unsigned char myslots[CLUSTER_SLOTS/8];
|
||||||
char slaveof[REDIS_CLUSTER_NAMELEN];
|
char slaveof[CLUSTER_NAMELEN];
|
||||||
char notused1[32]; /* 32 bytes reserved for future usage. */
|
char notused1[32]; /* 32 bytes reserved for future usage. */
|
||||||
uint16_t port; /* Sender TCP base port */
|
uint16_t port; /* Sender TCP base port */
|
||||||
uint16_t flags; /* Sender node flags */
|
uint16_t flags; /* Sender node flags */
|
||||||
@ -253,4 +253,4 @@ clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, in
|
|||||||
int clusterRedirectBlockedClientIfNeeded(client *c);
|
int clusterRedirectBlockedClientIfNeeded(client *c);
|
||||||
void clusterRedirectClient(client *c, clusterNode *n, int hashslot, int error_code);
|
void clusterRedirectClient(client *c, clusterNode *n, int hashslot, int error_code);
|
||||||
|
|
||||||
#endif /* __REDIS_CLUSTER_H */
|
#endif /* __CLUSTER_H */
|
||||||
|
@ -1798,10 +1798,10 @@ int rewriteConfig(char *path) {
|
|||||||
rewriteConfigNumericalOption(state,"lua-time-limit",server.lua_time_limit,LUA_SCRIPT_TIME_LIMIT);
|
rewriteConfigNumericalOption(state,"lua-time-limit",server.lua_time_limit,LUA_SCRIPT_TIME_LIMIT);
|
||||||
rewriteConfigYesNoOption(state,"cluster-enabled",server.cluster_enabled,0);
|
rewriteConfigYesNoOption(state,"cluster-enabled",server.cluster_enabled,0);
|
||||||
rewriteConfigStringOption(state,"cluster-config-file",server.cluster_configfile,CONFIG_DEFAULT_CLUSTER_CONFIG_FILE);
|
rewriteConfigStringOption(state,"cluster-config-file",server.cluster_configfile,CONFIG_DEFAULT_CLUSTER_CONFIG_FILE);
|
||||||
rewriteConfigYesNoOption(state,"cluster-require-full-coverage",server.cluster_require_full_coverage,REDIS_CLUSTER_DEFAULT_REQUIRE_FULL_COVERAGE);
|
rewriteConfigYesNoOption(state,"cluster-require-full-coverage",server.cluster_require_full_coverage,CLUSTER_DEFAULT_REQUIRE_FULL_COVERAGE);
|
||||||
rewriteConfigNumericalOption(state,"cluster-node-timeout",server.cluster_node_timeout,REDIS_CLUSTER_DEFAULT_NODE_TIMEOUT);
|
rewriteConfigNumericalOption(state,"cluster-node-timeout",server.cluster_node_timeout,CLUSTER_DEFAULT_NODE_TIMEOUT);
|
||||||
rewriteConfigNumericalOption(state,"cluster-migration-barrier",server.cluster_migration_barrier,REDIS_CLUSTER_DEFAULT_MIGRATION_BARRIER);
|
rewriteConfigNumericalOption(state,"cluster-migration-barrier",server.cluster_migration_barrier,CLUSTER_DEFAULT_MIGRATION_BARRIER);
|
||||||
rewriteConfigNumericalOption(state,"cluster-slave-validity-factor",server.cluster_slave_validity_factor,REDIS_CLUSTER_DEFAULT_SLAVE_VALIDITY);
|
rewriteConfigNumericalOption(state,"cluster-slave-validity-factor",server.cluster_slave_validity_factor,CLUSTER_DEFAULT_SLAVE_VALIDITY);
|
||||||
rewriteConfigNumericalOption(state,"slowlog-log-slower-than",server.slowlog_log_slower_than,CONFIG_DEFAULT_SLOWLOG_LOG_SLOWER_THAN);
|
rewriteConfigNumericalOption(state,"slowlog-log-slower-than",server.slowlog_log_slower_than,CONFIG_DEFAULT_SLOWLOG_LOG_SLOWER_THAN);
|
||||||
rewriteConfigNumericalOption(state,"latency-monitor-threshold",server.latency_monitor_threshold,CONFIG_DEFAULT_LATENCY_MONITOR_THRESHOLD);
|
rewriteConfigNumericalOption(state,"latency-monitor-threshold",server.latency_monitor_threshold,CONFIG_DEFAULT_LATENCY_MONITOR_THRESHOLD);
|
||||||
rewriteConfigNumericalOption(state,"slowlog-max-len",server.slowlog_max_len,CONFIG_DEFAULT_SLOWLOG_MAX_LEN);
|
rewriteConfigNumericalOption(state,"slowlog-max-len",server.slowlog_max_len,CONFIG_DEFAULT_SLOWLOG_MAX_LEN);
|
||||||
|
14
src/server.c
14
src/server.c
@ -1486,10 +1486,10 @@ void initServerConfig(void) {
|
|||||||
server.repl_min_slaves_to_write = CONFIG_DEFAULT_MIN_SLAVES_TO_WRITE;
|
server.repl_min_slaves_to_write = CONFIG_DEFAULT_MIN_SLAVES_TO_WRITE;
|
||||||
server.repl_min_slaves_max_lag = CONFIG_DEFAULT_MIN_SLAVES_MAX_LAG;
|
server.repl_min_slaves_max_lag = CONFIG_DEFAULT_MIN_SLAVES_MAX_LAG;
|
||||||
server.cluster_enabled = 0;
|
server.cluster_enabled = 0;
|
||||||
server.cluster_node_timeout = REDIS_CLUSTER_DEFAULT_NODE_TIMEOUT;
|
server.cluster_node_timeout = CLUSTER_DEFAULT_NODE_TIMEOUT;
|
||||||
server.cluster_migration_barrier = REDIS_CLUSTER_DEFAULT_MIGRATION_BARRIER;
|
server.cluster_migration_barrier = CLUSTER_DEFAULT_MIGRATION_BARRIER;
|
||||||
server.cluster_slave_validity_factor = REDIS_CLUSTER_DEFAULT_SLAVE_VALIDITY;
|
server.cluster_slave_validity_factor = CLUSTER_DEFAULT_SLAVE_VALIDITY;
|
||||||
server.cluster_require_full_coverage = REDIS_CLUSTER_DEFAULT_REQUIRE_FULL_COVERAGE;
|
server.cluster_require_full_coverage = CLUSTER_DEFAULT_REQUIRE_FULL_COVERAGE;
|
||||||
server.cluster_configfile = zstrdup(CONFIG_DEFAULT_CLUSTER_CONFIG_FILE);
|
server.cluster_configfile = zstrdup(CONFIG_DEFAULT_CLUSTER_CONFIG_FILE);
|
||||||
server.lua_caller = NULL;
|
server.lua_caller = NULL;
|
||||||
server.lua_time_limit = LUA_SCRIPT_TIME_LIMIT;
|
server.lua_time_limit = LUA_SCRIPT_TIME_LIMIT;
|
||||||
@ -2226,9 +2226,9 @@ int processCommand(client *c) {
|
|||||||
{
|
{
|
||||||
int hashslot;
|
int hashslot;
|
||||||
|
|
||||||
if (server.cluster->state != REDIS_CLUSTER_OK) {
|
if (server.cluster->state != CLUSTER_OK) {
|
||||||
flagTransaction(c);
|
flagTransaction(c);
|
||||||
clusterRedirectClient(c,NULL,0,REDIS_CLUSTER_REDIR_DOWN_STATE);
|
clusterRedirectClient(c,NULL,0,CLUSTER_REDIR_DOWN_STATE);
|
||||||
return C_OK;
|
return C_OK;
|
||||||
} else {
|
} else {
|
||||||
int error_code;
|
int error_code;
|
||||||
@ -2855,7 +2855,7 @@ sds genRedisInfoString(char *section) {
|
|||||||
server.aof_rewrite_scheduled,
|
server.aof_rewrite_scheduled,
|
||||||
sdslen(server.aof_buf),
|
sdslen(server.aof_buf),
|
||||||
aofRewriteBufferSize(),
|
aofRewriteBufferSize(),
|
||||||
bioPendingJobsOfType(REDIS_BIO_AOF_FSYNC),
|
bioPendingJobsOfType(BIO_AOF_FSYNC),
|
||||||
server.aof_delayed_fsync);
|
server.aof_delayed_fsync);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
src/syncio.c
10
src/syncio.c
@ -40,7 +40,7 @@
|
|||||||
*
|
*
|
||||||
* All the functions take the timeout in milliseconds. */
|
* All the functions take the timeout in milliseconds. */
|
||||||
|
|
||||||
#define REDIS_SYNCIO_RESOLUTION 10 /* Resolution in milliseconds */
|
#define SYNCIO__RESOLUTION 10 /* Resolution in milliseconds */
|
||||||
|
|
||||||
/* Write the specified payload to 'fd'. If writing the whole payload will be
|
/* Write the specified payload to 'fd'. If writing the whole payload will be
|
||||||
* done within 'timeout' milliseconds the operation succeeds and 'size' is
|
* done within 'timeout' milliseconds the operation succeeds and 'size' is
|
||||||
@ -52,8 +52,8 @@ ssize_t syncWrite(int fd, char *ptr, ssize_t size, long long timeout) {
|
|||||||
long long remaining = timeout;
|
long long remaining = timeout;
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
long long wait = (remaining > REDIS_SYNCIO_RESOLUTION) ?
|
long long wait = (remaining > SYNCIO__RESOLUTION) ?
|
||||||
remaining : REDIS_SYNCIO_RESOLUTION;
|
remaining : SYNCIO__RESOLUTION;
|
||||||
long long elapsed;
|
long long elapsed;
|
||||||
|
|
||||||
/* Optimistically try to write before checking if the file descriptor
|
/* Optimistically try to write before checking if the file descriptor
|
||||||
@ -89,8 +89,8 @@ ssize_t syncRead(int fd, char *ptr, ssize_t size, long long timeout) {
|
|||||||
|
|
||||||
if (size == 0) return 0;
|
if (size == 0) return 0;
|
||||||
while(1) {
|
while(1) {
|
||||||
long long wait = (remaining > REDIS_SYNCIO_RESOLUTION) ?
|
long long wait = (remaining > SYNCIO__RESOLUTION) ?
|
||||||
remaining : REDIS_SYNCIO_RESOLUTION;
|
remaining : SYNCIO__RESOLUTION;
|
||||||
long long elapsed;
|
long long elapsed;
|
||||||
|
|
||||||
/* Optimistically try to read before checking if the file descriptor
|
/* Optimistically try to read before checking if the file descriptor
|
||||||
|
Loading…
x
Reference in New Issue
Block a user