Skip to content

Commit

Permalink
update dyno-jedis client and use nx() when trying to add an element t…
Browse files Browse the repository at this point in the history
…o unack queue
  • Loading branch information
Viren Baraiya committed Oct 28, 2016
1 parent fc21d19 commit 46ac14f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dyno-queues-redis/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'project-report'
dependencies {
compile project(':dyno-queues-core')
compile "com.google.inject:guice:3.0"
compile "com.netflix.dyno:dyno-jedis:1.4.+"
compile "com.netflix.dyno:dyno-jedis:1.5.5+"
compile "com.netflix.archaius:archaius-core:0.5.6"
compile "com.netflix.servo:servo-core:0.5.5"
compile 'com.netflix.eureka:eureka-client:1.1.110'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

import redis.clients.jedis.JedisCommands;
import redis.clients.jedis.Tuple;
import redis.clients.jedis.params.sortedset.ZAddParams;

/**
*
Expand Down Expand Up @@ -284,10 +285,10 @@ private List<Message> _pop(Set<String> ids, int messageCount) throws Exception {
String unackQueueName = getUnackKey(queueName, shardName);

List<Message> popped = new LinkedList<>();

ZAddParams zParams = ZAddParams.zAddParams().nx();
for (String msgId : ids) {
long added = quorumConn.zadd(unackQueueName, unackScore, msgId);

long added = quorumConn.zadd(unackQueueName, unackScore, msgId, zParams);
if(added == 0){
if (logger.isDebugEnabled()) {
logger.debug("cannot add to the unack shard " + msgId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public void test(){
@Override
public Collection<Host> getHosts() {
List<Host> hosts = new LinkedList<>();
hosts.add(new Host("host1", 8102, Status.Up).setRack("us-east-1a"));
hosts.add(new Host("host2", 8102, Status.Up).setRack("us-east-1b"));
hosts.add(new Host("host3", 8102, Status.Up).setRack("us-east-1d"));
hosts.add(new Host("host1", 8102, "us-east-1a", Status.Up));
hosts.add(new Host("host2", 8102, "us-east-1b", Status.Up));
hosts.add(new Host("host3", 8102, "us-east-1d", Status.Up));
return hosts;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static void setUpBeforeClass() throws Exception {
@Override
public Collection<Host> getHosts() {
List<Host> hosts = new LinkedList<>();
hosts.add(new Host("ec2-11-22-33-444.compute-0.amazonaws.com", 8102, Status.Up).setRack("us-east-1d"));
hosts.add(new Host("ec2-11-22-33-444.compute-0.amazonaws.com", 8102, "us-east-1d", Status.Up));
return hosts;
}
};
Expand Down

0 comments on commit 46ac14f

Please sign in to comment.