Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
d415f9ff
Commit
d415f9ff
authored
Apr 12, 2011
by
antirez
Browse files
Merge branch 'unstable' of github.com:antirez/redis into unstable
parents
8d727af8
e9ee513b
Changes
4
Show whitespace changes
Inline
Side-by-side
TODO
View file @
d415f9ff
...
...
@@ -36,6 +36,8 @@ OPTIMIZATIONS
* SORT: Don't copy the list into a vector when BY argument is constant.
* Write the hash table size of every db in the dump, so that Redis can resize the hash table just one time when loading a big DB.
* Read-only mode for slaves.
* Redis big lists as linked lists of small ziplists?
Possibly a simple heuristic that join near nodes when some node gets smaller than the low_level, and split it into two if gets bigger than high_level.
REPORTING
=========
...
...
src/cluster.c
View file @
d415f9ff
...
...
@@ -1193,11 +1193,13 @@ void clusterCommand(redisClient *c) {
"cluster_slots_ok:%d
\r\n
"
"cluster_slots_pfail:%d
\r\n
"
"cluster_slots_fail:%d
\r\n
"
"cluster_known_nodes:%lu
\r\n
"
,
statestr
[
server
.
cluster
.
state
],
slots_assigned
,
slots_ok
,
slots_pfail
,
slots_fail
slots_fail
,
dictSize
(
server
.
cluster
.
nodes
)
);
addReplySds
(
c
,
sdscatprintf
(
sdsempty
(),
"$%lu
\r\n
"
,
(
unsigned
long
)
sdslen
(
info
)));
...
...
src/redis-trib.rb
0 → 100755
View file @
d415f9ff
#!/usr/bin/env ruby
require
'rubygems'
require
'redis'
def
xputs
(
s
)
printf
s
STDOUT
.
flush
end
class
ClusterNode
def
initialize
(
addr
)
s
=
addr
.
split
(
":"
)
if
s
.
length
!=
2
puts
"Invalid node name
#{
node
}
"
exit
1
end
@host
=
s
[
0
]
@port
=
s
[
1
]
end
def
to_s
"
#{
@host
}
:
#{
@port
}
"
end
def
connect
xputs
"Connecting to node
#{
self
}
: "
begin
@r
=
Redis
.
new
(
:host
=>
@ost
,
:port
=>
@port
)
@r
.
ping
rescue
puts
"ERROR"
puts
"Sorry, can't connect to node
#{
self
}
"
end
puts
"OK"
end
def
assert_cluster
info
=
@r
.
info
if
!
info
[
"cluster_enabled"
]
||
info
[
"cluster_enabled"
].
to_i
==
0
puts
"Error: Node
#{
self
}
is not configured as a cluster node."
exit
1
end
end
def
assert_empty
if
!
(
@r
.
cluster
(
"info"
).
split
(
"
\r\n
"
).
index
(
"cluster_known_nodes:1"
))
||
(
@r
.
info
[
'db0'
])
puts
"Error: Node
#{
self
}
is not empty. Either the node already knows other nodes (check with nodes-info) or contains some key in database 0."
exit
1
end
end
def
r
@r
end
end
class
RedisTrib
def
check_arity
(
req_args
,
num_args
)
if
((
req_args
>
0
and
num_args
!=
req_args
)
||
(
req_args
<
0
and
num_args
<
req_args
.
abs
))
puts
"Wrong number of arguments for specified sub command"
exit
1
end
end
def
create_cluster
puts
"Creating cluster"
ARGV
[
1
..-
1
].
each
{
|
n
|
node
=
ClusterNode
.
new
(
n
)
node
.
connect
node
.
assert_cluster
node
.
assert_empty
}
end
end
COMMANDS
=
{
"create-cluster"
=>
[
"create_cluster"
,
-
2
]
}
# Sanity check
if
ARGV
.
length
==
0
puts
"Usage: redis-trib <command> <arguments ...>"
exit
1
end
rt
=
RedisTrib
.
new
cmd_spec
=
COMMANDS
[
ARGV
[
0
].
downcase
]
if
!
cmd_spec
puts
"Unknown redis-trib subcommand '
#{
ARGV
[
0
]
}
'"
exit
1
end
rt
.
check_arity
(
cmd_spec
[
1
],
ARGV
.
length
)
# Dispatch
rt
.
send
(
cmd_spec
[
0
])
src/redis.c
View file @
d415f9ff
...
...
@@ -1498,6 +1498,15 @@ sds genRedisInfoString(char *section) {
}
}
/* Clusetr */
if
(
allsections
||
defsections
||
!
strcasecmp
(
section
,
"cluster"
))
{
if
(
sections
++
)
info
=
sdscat
(
info
,
"
\r\n
"
);
info
=
sdscatprintf
(
info
,
"# Cluster
\r\n
"
"cluster_enabled:%d
\r\n
"
,
server
.
cluster_enabled
);
}
/* Key space */
if
(
allsections
||
defsections
||
!
strcasecmp
(
section
,
"keyspace"
))
{
if
(
sections
++
)
info
=
sdscat
(
info
,
"
\r\n
"
);
...
...
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