Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Turbo码先生
redis
提交
6fa9b1a4
R
redis
项目概览
Turbo码先生
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6fa9b1a4
编写于
10月 08, 2013
作者:
A
antirez
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'bettercluster' into unstable
上级
0150c70b
ae2763f5
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
371 addition
and
200 deletion
+371
-200
src/cluster.c
src/cluster.c
+328
-188
src/endianconv.h
src/endianconv.h
+10
-0
src/redis-trib.rb
src/redis-trib.rb
+3
-3
src/redis.c
src/redis.c
+3
-0
src/redis.h
src/redis.h
+26
-6
src/replication.c
src/replication.c
+1
-1
src/sentinel.c
src/sentinel.c
+0
-2
未找到文件。
src/cluster.c
浏览文件 @
6fa9b1a4
此差异已折叠。
点击以展开。
src/endianconv.h
浏览文件 @
6fa9b1a4
...
...
@@ -61,4 +61,14 @@ uint64_t intrev64(uint64_t v);
#define intrev64ifbe(v) intrev64(v)
#endif
/* The functions htonu64() and ntohu64() convert the specified value to
* network byte ordering and back. In big endian systems they are no-ops. */
#if (BYTE_ORDER == BIG_ENDIAN)
#define htonu64(v) (v)
#define ntohu64(v) (v)
#else
#define htonu64(v) intrev64(v)
#define ntohu64(v) intrev64(v)
#endif
#endif
src/redis-trib.rb
浏览文件 @
6fa9b1a4
...
...
@@ -118,8 +118,8 @@ class ClusterNode
nodes
.
each
{
|
n
|
# name addr flags role ping_sent ping_recv link_status slots
split
=
n
.
split
name
,
addr
,
flags
,
role
,
ping_sent
,
ping_recv
,
link_status
=
split
[
0
..
6
]
slots
=
split
[
7
..-
1
]
name
,
addr
,
flags
,
role
,
ping_sent
,
ping_recv
,
config_epoch
,
link_status
=
split
[
0
..
6
]
slots
=
split
[
8
..-
1
]
info
=
{
:name
=>
name
,
:addr
=>
addr
,
...
...
@@ -230,7 +230,7 @@ class ClusterNode
config
=
[]
@r
.
cluster
(
"nodes"
).
each_line
{
|
l
|
s
=
l
.
split
slots
=
s
[
7
..-
1
].
select
{
|
x
|
x
[
0
..
0
]
!=
"["
}
slots
=
s
[
8
..-
1
].
select
{
|
x
|
x
[
0
..
0
]
!=
"["
}
next
if
slots
.
length
==
0
config
<<
s
[
0
]
+
":"
+
(
slots
.
sort
.
join
(
","
))
}
...
...
src/redis.c
浏览文件 @
6fa9b1a4
...
...
@@ -1203,6 +1203,9 @@ void beforeSleep(struct aeEventLoop *eventLoop) {
/* Write the AOF buffer on disk */
flushAppendOnlyFile
(
0
);
/* Call the Redis Cluster before sleep function. */
if
(
server
.
cluster_enabled
)
clusterBeforeSleep
();
}
/* =========================== Server initialization ======================== */
...
...
src/redis.h
浏览文件 @
6fa9b1a4
...
...
@@ -368,6 +368,8 @@
* Data types
*----------------------------------------------------------------------------*/
typedef
long
long
mstime_t
;
/* millisecond time type. */
/* A redis object, that is a type able to hold a string / list / set */
/* The actual Redis Object */
...
...
@@ -581,7 +583,7 @@ typedef struct redisOpArray {
#define REDIS_CLUSTER_FAIL_UNDO_TIME_MULT 2
/* Undo fail if master is back. */
#define REDIS_CLUSTER_FAIL_UNDO_TIME_ADD 10
/* Some additional time. */
#define REDIS_CLUSTER_SLAVE_VALIDITY_MULT 10
/* Slave data validity. */
#define REDIS_CLUSTER_FAILOVER_AUTH_RETRY_MULT
1
/* Auth request retry time. */
#define REDIS_CLUSTER_FAILOVER_AUTH_RETRY_MULT
4
/* Auth request retry time. */
#define REDIS_CLUSTER_FAILOVER_DELAY 5
/* Seconds */
struct
clusterNode
;
...
...
@@ -617,6 +619,7 @@ struct clusterNode {
time_t
ctime
;
/* Node object creation time. */
char
name
[
REDIS_CLUSTER_NAMELEN
];
/* Node name, hex string, sha1-size */
int
flags
;
/* REDIS_NODE_... */
uint64_t
configEpoch
;
/* Last configEpoch observed for this node */
unsigned
char
slots
[
REDIS_CLUSTER_SLOTS
/
8
];
/* 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 */
...
...
@@ -625,6 +628,7 @@ struct clusterNode {
time_t
ping_sent
;
/* Unix time we sent latest ping */
time_t
pong_received
;
/* Unix time we received the pong */
time_t
fail_time
;
/* Unix time when FAIL flag was set */
time_t
voted_time
;
/* Last time we voted for a slave of this master */
char
ip
[
REDIS_IP_STR_LEN
];
/* Latest known IP address of this node */
int
port
;
/* Latest known port of this node */
clusterLink
*
link
;
/* TCP/IP link with this node */
...
...
@@ -634,6 +638,7 @@ typedef struct clusterNode clusterNode;
typedef
struct
{
clusterNode
*
myself
;
/* This node */
uint64_t
currentEpoch
;
int
state
;
/* REDIS_CLUSTER_OK, REDIS_CLUSTER_FAIL, ... */
int
size
;
/* Num of master nodes with at least one slot */
dict
*
nodes
;
/* Hash table of name -> clusterNode structures */
...
...
@@ -641,10 +646,24 @@ typedef struct {
clusterNode
*
importing_slots_from
[
REDIS_CLUSTER_SLOTS
];
clusterNode
*
slots
[
REDIS_CLUSTER_SLOTS
];
zskiplist
*
slots_to_keys
;
int
failover_auth_time
;
/* Time at which we sent the AUTH request. */
int
failover_auth_count
;
/* Number of authorizations received. */
/* The following fields are used to take the slave state on elections. */
mstime_t
failover_auth_time
;
/* Time at which we'll try to get elected in ms*/
int
failover_auth_count
;
/* Number of votes received so far. */
int
failover_auth_sent
;
/* True if we already asked for votes. */
uint64_t
failover_auth_epoch
;
/* Epoch of the current election. */
/* 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(). */
long
long
stats_bus_messages_sent
;
/* Num of msg sent via cluster bus. */
long
long
stats_bus_messages_received
;
/* Num of msg received via cluster bus. */
}
clusterState
;
/* clusterState todo_before_sleep flags. */
#define CLUSTER_TODO_HANDLE_FAILOVER (1<<0)
#define CLUSTER_TODO_UPDATE_STATE (1<<1)
#define CLUSTER_TODO_SAVE_CONFIG (1<<2)
#define CLUSTER_TODO_FSYNC_CONFIG (1<<3)
/* Redis cluster messages header */
/* Note that the PING, PONG and MEET messages are actually the same exact
...
...
@@ -704,9 +723,9 @@ typedef struct {
uint32_t
totlen
;
/* Total length of this message */
uint16_t
type
;
/* Message type */
uint16_t
count
;
/* Only used for some kind of messages. */
uint64_t
time
;
/* Time at which this request was sent (in milliseconds),
this field is copied in reply messages so that the
original sender knows how old the reply is
. */
uint64_t
currentEpoch
;
/* The epoch accordingly to the sending node. */
uint64_t
configEpoch
;
/* The config epoch if it's a master, or the last epoch
advertised by its master if it is a slave
. */
char
sender
[
REDIS_CLUSTER_NAMELEN
];
/* Name of the sender node */
unsigned
char
myslots
[
REDIS_CLUSTER_SLOTS
/
8
];
char
slaveof
[
REDIS_CLUSTER_NAMELEN
];
...
...
@@ -1367,6 +1386,7 @@ void clusterCron(void);
clusterNode
*
getNodeByQuery
(
redisClient
*
c
,
struct
redisCommand
*
cmd
,
robj
**
argv
,
int
argc
,
int
*
hashslot
,
int
*
ask
);
void
clusterPropagatePublish
(
robj
*
channel
,
robj
*
message
);
void
migrateCloseTimedoutSockets
(
void
);
void
clusterBeforeSleep
(
void
);
/* Sentinel */
void
initSentinelConfig
(
void
);
...
...
src/replication.c
浏览文件 @
6fa9b1a4
...
...
@@ -343,7 +343,7 @@ int masterTryPartialResynchronization(redisClient *c) {
/* Run id "?" is used by slaves that want to force a full resync. */
if
(
master_runid
[
0
]
!=
'?'
)
{
redisLog
(
REDIS_NOTICE
,
"Partial resynchronization not accepted: "
"Runid mismatch (Client asked for
'%s', I'm
'%s')"
,
"Runid mismatch (Client asked for
runid '%s', my runid is
'%s')"
,
master_runid
,
server
.
runid
);
}
else
{
redisLog
(
REDIS_NOTICE
,
"Full resync requested by slave."
);
...
...
src/sentinel.c
浏览文件 @
6fa9b1a4
...
...
@@ -43,8 +43,6 @@ extern char **environ;
/* ======================== Sentinel global state =========================== */
typedef
long
long
mstime_t
;
/* millisecond time type. */
/* Address object, used to describe an ip:port pair. */
typedef
struct
sentinelAddr
{
char
*
ip
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录