Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Y
YCSB
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Adnan Ahmad
YCSB
Commits
c4807a93
Commit
c4807a93
authored
6 years ago
by
Jens Ehlers
Committed by
Sean Busbey
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[redis] Redis cluster support (#1072)
parent
7273f152
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pom.xml
+1
-1
1 addition, 1 deletion
pom.xml
redis/README.md
+5
-2
5 additions, 2 deletions
redis/README.md
redis/src/main/java/com/yahoo/ycsb/db/RedisClient.java
+24
-6
24 additions, 6 deletions
redis/src/main/java/com/yahoo/ycsb/db/RedisClient.java
with
30 additions
and
9 deletions
pom.xml
+
1
−
1
View file @
c4807a93
...
...
@@ -101,7 +101,7 @@ LICENSE file.
<openjpa.jdbc.version>
2.1.1
</openjpa.jdbc.version>
<orientdb.version>
2.2.10
</orientdb.version>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<redis.version>
2.
0
.0
</redis.version>
<redis.version>
2.
9
.0
</redis.version>
<riak.version>
2.0.5
</riak.version>
<s3.version>
1.10.20
</s3.version>
<solr.version>
5.5.3
</solr.version>
...
...
This diff is collapsed.
Click to expand it.
redis/README.md
+
5
−
2
View file @
c4807a93
...
...
@@ -33,12 +33,15 @@ Git clone YCSB and compile:
### 4. Provide Redis Connection Parameters
Set the host, port, and password (do not redis auth is not turned on) in the
workload you plan to run.
Set host, port, password, and cluster mode in the workload you plan to run.
-
`redis.host`
-
`redis.port`
-
`redis.password`
*
Don't set the password if redis auth is disabled.
-
`redis.cluster`
*
Set the cluster parameter to
`true`
if redis cluster mode is enabled.
*
Default is
`false`
.
Or, you can set configs with the shell command, EG:
...
...
This diff is collapsed.
Click to expand it.
redis/src/main/java/com/yahoo/ycsb/db/RedisClient.java
+
24
−
6
View file @
c4807a93
...
...
@@ -29,12 +29,18 @@ import com.yahoo.ycsb.DB;
import
com.yahoo.ycsb.DBException
;
import
com.yahoo.ycsb.Status
;
import
com.yahoo.ycsb.StringByteIterator
;
import
redis.clients.jedis.BasicCommands
;
import
redis.clients.jedis.HostAndPort
;
import
redis.clients.jedis.Jedis
;
import
redis.clients.jedis.JedisCluster
;
import
redis.clients.jedis.JedisCommands
;
import
redis.clients.jedis.Protocol
;
import
java.io.Closeable
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Properties
;
...
...
@@ -48,11 +54,12 @@ import java.util.Vector;
*/
public
class
RedisClient
extends
DB
{
private
Jedis
jedis
;
private
Jedis
Commands
jedis
;
public
static
final
String
HOST_PROPERTY
=
"redis.host"
;
public
static
final
String
PORT_PROPERTY
=
"redis.port"
;
public
static
final
String
PASSWORD_PROPERTY
=
"redis.password"
;
public
static
final
String
CLUSTER_PROPERTY
=
"redis.cluster"
;
public
static
final
String
INDEX_KEY
=
"_indices"
;
...
...
@@ -68,17 +75,28 @@ public class RedisClient extends DB {
}
String
host
=
props
.
getProperty
(
HOST_PROPERTY
);
jedis
=
new
Jedis
(
host
,
port
);
jedis
.
connect
();
boolean
clusterEnabled
=
Boolean
.
parseBoolean
(
props
.
getProperty
(
CLUSTER_PROPERTY
));
if
(
clusterEnabled
)
{
Set
<
HostAndPort
>
jedisClusterNodes
=
new
HashSet
<>();
jedisClusterNodes
.
add
(
new
HostAndPort
(
host
,
port
));
jedis
=
new
JedisCluster
(
jedisClusterNodes
);
}
else
{
jedis
=
new
Jedis
(
host
,
port
);
((
Jedis
)
jedis
).
connect
();
}
String
password
=
props
.
getProperty
(
PASSWORD_PROPERTY
);
if
(
password
!=
null
)
{
jedis
.
auth
(
password
);
((
BasicCommands
)
jedis
)
.
auth
(
password
);
}
}
public
void
cleanup
()
throws
DBException
{
jedis
.
disconnect
();
try
{
((
Closeable
)
jedis
).
close
();
}
catch
(
IOException
e
)
{
throw
new
DBException
(
"Closing connection failed."
);
}
}
/*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment