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
1ac30300
Commit
1ac30300
authored
Oct 20, 2019
by
Guy Korland
Browse files
Merge branch 'unstable' of github.com:antirez/redis into unstable
parents
c1455dc0
673c9d70
Changes
163
Hide whitespace changes
Inline
Side-by-side
utils/create-cluster/create-cluster
View file @
1ac30300
#!/bin/bash
# Settings
CLUSTER_HOST
=
127.0.0.1
PORT
=
30000
TIMEOUT
=
2000
NODES
=
6
REPLICAS
=
1
PROTECTED_MODE
=
yes
# You may want to put the above config parameters into config.sh in order to
# override the defaults without modifying this script.
...
...
@@ -22,7 +24,7 @@ then
while
[
$((
PORT < ENDPORT
))
!=
"0"
]
;
do
PORT
=
$((
PORT+1
))
echo
"Starting
$PORT
"
../../src/redis-server
--port
$PORT
--cluster-enabled
yes
--cluster-config-file
nodes-
${
PORT
}
.conf
--cluster-node-timeout
$TIMEOUT
--appendonly
yes
--appendfilename
appendonly-
${
PORT
}
.aof
--dbfilename
dump-
${
PORT
}
.rdb
--logfile
${
PORT
}
.log
--daemonize
yes
../../src/redis-server
--port
$PORT
--protected-mode
$PROTECTED_MODE
--cluster-enabled
yes
--cluster-config-file
nodes-
${
PORT
}
.conf
--cluster-node-timeout
$TIMEOUT
--appendonly
yes
--appendfilename
appendonly-
${
PORT
}
.aof
--dbfilename
dump-
${
PORT
}
.rdb
--logfile
${
PORT
}
.log
--daemonize
yes
done
exit
0
fi
...
...
@@ -32,7 +34,7 @@ then
HOSTS
=
""
while
[
$((
PORT < ENDPORT
))
!=
"0"
]
;
do
PORT
=
$((
PORT+1
))
HOSTS
=
"
$HOSTS
127.0.0.1
:
$PORT
"
HOSTS
=
"
$HOSTS
$CLUSTER_HOST
:
$PORT
"
done
../../src/redis-cli
--cluster
create
$HOSTS
--cluster-replicas
$REPLICAS
exit
0
...
...
utils/gen-test-certs.sh
0 → 100755
View file @
1ac30300
#!/bin/bash
mkdir
-p
tests/tls
openssl genrsa
-out
tests/tls/ca.key 4096
openssl req
\
-x509
-new
-nodes
-sha256
\
-key
tests/tls/ca.key
\
-days
3650
\
-subj
'/O=Redis Test/CN=Certificate Authority'
\
-out
tests/tls/ca.crt
openssl genrsa
-out
tests/tls/redis.key 2048
openssl req
\
-new
-sha256
\
-key
tests/tls/redis.key
\
-subj
'/O=Redis Test/CN=Server'
|
\
openssl x509
\
-req
-sha256
\
-CA
tests/tls/ca.crt
\
-CAkey
tests/tls/ca.key
\
-CAserial
tests/tls/ca.txt
\
-CAcreateserial
\
-days
365
\
-out
tests/tls/redis.crt
openssl dhparam
-out
tests/tls/redis.dh 2048
utils/tracking_collisions.c
0 → 100644
View file @
1ac30300
/* This is a small program used in order to understand the collison rate
* of CRC64 (ISO version) VS other stronger hashing functions in the context
* of hashing keys for the Redis "tracking" feature (client side caching
* assisted by the server).
*
* The program attempts to hash keys with common names in the form of
*
* prefix:<counter>
*
* And counts the resulting collisons generated in the 24 bits of output
* needed for the tracking feature invalidation table (16 millions + entries)
*
* Compile with:
*
* cc -O2 ./tracking_collisions.c ../src/crc64.c ../src/sha1.c
* ./a.out
*
* --------------------------------------------------------------------------
*
* Copyright (C) 2019 Salvatore Sanfilippo
* This code is released under the BSD 2 clause license.
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include "../src/crc64.h"
#include "../src/sha1.h"
#define TABLE_SIZE (1<<24)
int
Table
[
TABLE_SIZE
];
uint64_t
crc64Hash
(
char
*
key
,
size_t
len
)
{
return
crc64
(
0
,(
unsigned
char
*
)
key
,
len
);
}
uint64_t
sha1Hash
(
char
*
key
,
size_t
len
)
{
SHA1_CTX
ctx
;
unsigned
char
hash
[
20
];
SHA1Init
(
&
ctx
);
SHA1Update
(
&
ctx
,(
unsigned
char
*
)
key
,
len
);
SHA1Final
(
hash
,
&
ctx
);
uint64_t
hash64
;
memcpy
(
&
hash64
,
hash
,
sizeof
(
hash64
));
return
hash64
;
}
/* Test the hashing function provided as callback and return the
* number of collisions found. */
unsigned
long
testHashingFunction
(
uint64_t
(
*
hash
)(
char
*
,
size_t
))
{
unsigned
long
collisions
=
0
;
memset
(
Table
,
0
,
sizeof
(
Table
));
char
*
prefixes
[]
=
{
"object"
,
"message"
,
"user"
,
NULL
};
for
(
int
i
=
0
;
prefixes
[
i
]
!=
NULL
;
i
++
)
{
for
(
int
j
=
0
;
j
<
TABLE_SIZE
/
2
;
j
++
)
{
char
keyname
[
128
];
size_t
keylen
=
snprintf
(
keyname
,
sizeof
(
keyname
),
"%s:%d"
,
prefixes
[
i
],
j
);
uint64_t
bucket
=
hash
(
keyname
,
keylen
)
%
TABLE_SIZE
;
if
(
Table
[
bucket
])
{
collisions
++
;
}
else
{
Table
[
bucket
]
=
1
;
}
}
}
return
collisions
;
}
int
main
(
void
)
{
printf
(
"SHA1 : %lu
\n
"
,
testHashingFunction
(
sha1Hash
));
printf
(
"CRC64: %lu
\n
"
,
testHashingFunction
(
crc64Hash
));
return
0
;
}
Prev
1
…
5
6
7
8
9
Next
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