Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -643,12 +643,12 @@ public class BinaryClient extends Connection {
|
|||||||
sendCommand(SLAVEOF, NO.raw, ONE.raw);
|
sendCommand(SLAVEOF, NO.raw, ONE.raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void configGet(final String pattern) {
|
public void configGet(final byte[] pattern) {
|
||||||
sendCommand(CONFIG, Keyword.GET.name(), pattern);
|
sendCommand(CONFIG, Keyword.GET.raw, pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void configSet(final String parameter, final String value) {
|
public void configSet(final byte[] parameter, final byte[] value) {
|
||||||
sendCommand(CONFIG, Keyword.SET.name(), parameter, value);
|
sendCommand(CONFIG, Keyword.SET.raw, parameter, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void strlen(final byte[] key) {
|
public void strlen(final byte[] key) {
|
||||||
|
|||||||
@@ -2822,9 +2822,9 @@ public class BinaryJedis implements BinaryJedisCommands {
|
|||||||
* @param pattern
|
* @param pattern
|
||||||
* @return Bulk reply.
|
* @return Bulk reply.
|
||||||
*/
|
*/
|
||||||
public List<String> configGet(final String pattern) {
|
public List<byte[]> configGet(final byte[] pattern) {
|
||||||
client.configGet(pattern);
|
client.configGet(pattern);
|
||||||
return client.getMultiBulkReply();
|
return client.getBinaryMultiBulkReply();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2871,9 +2871,9 @@ public class BinaryJedis implements BinaryJedisCommands {
|
|||||||
* @param value
|
* @param value
|
||||||
* @return Status code reply
|
* @return Status code reply
|
||||||
*/
|
*/
|
||||||
public String configSet(final String parameter, final String value) {
|
public byte[] configSet(final byte[] parameter, final byte[] value) {
|
||||||
client.configSet(parameter, value);
|
client.configSet(parameter, value);
|
||||||
return client.getStatusCodeReply();
|
return client.getBinaryBulkReply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
@@ -2959,9 +2959,9 @@ public class BinaryJedis implements BinaryJedisCommands {
|
|||||||
* @param value
|
* @param value
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Long setbit(byte[] key, long offset, byte[] value) {
|
public Boolean setbit(byte[] key, long offset, byte[] value) {
|
||||||
client.setbit(key, offset, value);
|
client.setbit(key, offset, value);
|
||||||
return client.getIntegerReply();
|
return client.getIntegerReply() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2971,12 +2971,12 @@ public class BinaryJedis implements BinaryJedisCommands {
|
|||||||
* @param offset
|
* @param offset
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Long getbit(byte[] key, long offset) {
|
public Boolean getbit(byte[] key, long offset) {
|
||||||
client.getbit(key, offset);
|
client.getbit(key, offset);
|
||||||
return client.getIntegerReply();
|
return client.getIntegerReply() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long setrange(byte[] key, long offset, byte[] value) {
|
public Long setrange(byte[] key, long offset, byte[] value) {
|
||||||
client.setrange(key, offset, value);
|
client.setrange(key, offset, value);
|
||||||
return client.getIntegerReply();
|
return client.getIntegerReply();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -563,4 +563,89 @@ public class BinaryTransaction extends Queable {
|
|||||||
client.brpoplpush(source, destination, timeout);
|
client.brpoplpush(source, destination, timeout);
|
||||||
return getResponse(BuilderFactory.BYTE_ARRAY);
|
return getResponse(BuilderFactory.BYTE_ARRAY);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public Response<String> select(final int index) {
|
||||||
|
client.select(index);
|
||||||
|
return getResponse(BuilderFactory.STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response<String> flushDB() {
|
||||||
|
client.flushDB();
|
||||||
|
return getResponse(BuilderFactory.STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response<String> flushAll() {
|
||||||
|
client.flushAll();
|
||||||
|
return getResponse(BuilderFactory.STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response<String> save() {
|
||||||
|
client.save();
|
||||||
|
return getResponse(BuilderFactory.STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response<String> info() {
|
||||||
|
client.info();
|
||||||
|
return getResponse(BuilderFactory.STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response<Long> lastsave() {
|
||||||
|
client.lastsave();
|
||||||
|
return getResponse(BuilderFactory.LONG);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response<Long> dbSize() {
|
||||||
|
client.dbSize();
|
||||||
|
return getResponse(BuilderFactory.LONG);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response<List<byte[]>> configGet(final byte[] pattern) {
|
||||||
|
client.configGet(pattern);
|
||||||
|
return getResponse(BuilderFactory.BYTE_ARRAY_LIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response<byte[]> configSet(final byte[] parameter, final byte[] value) {
|
||||||
|
client.configSet(parameter, value);
|
||||||
|
return getResponse(BuilderFactory.BYTE_ARRAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response<String> configResetStat() {
|
||||||
|
client.configResetStat();
|
||||||
|
return getResponse(BuilderFactory.STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response<String> shutdown() {
|
||||||
|
client.shutdown();
|
||||||
|
return getResponse(BuilderFactory.STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response<Boolean> getbit(final byte[] key, final long offset) {
|
||||||
|
client.getbit(key, offset);
|
||||||
|
return getResponse(BuilderFactory.BOOLEAN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response<Boolean> setbit(final byte[] key, final long offset, final byte[] value) {
|
||||||
|
client.setbit(key, offset, value);
|
||||||
|
return getResponse(BuilderFactory.BOOLEAN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response<String> ping() {
|
||||||
|
client.ping();
|
||||||
|
return getResponse(BuilderFactory.STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response<Long> setrange(byte[] key, long offset, byte[] value) {
|
||||||
|
client.setrange(key, offset, value);
|
||||||
|
return getResponse(BuilderFactory.LONG);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response<String> randomKey() {
|
||||||
|
client.randomKey();
|
||||||
|
return getResponse(BuilderFactory.STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response<Long> publish(byte[] channel, byte[] message) {
|
||||||
|
client.publish(channel, message);
|
||||||
|
return getResponse(BuilderFactory.LONG);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -587,4 +587,12 @@ public class Client extends BinaryClient implements Commands {
|
|||||||
}
|
}
|
||||||
subscribe(cs);
|
subscribe(cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void configSet(String parameter, String value) {
|
||||||
|
configSet(SafeEncoder.encode(parameter), SafeEncoder.encode(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void configGet(String pattern) {
|
||||||
|
configGet(SafeEncoder.encode(pattern));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -226,18 +226,6 @@ public class Jedis extends BinaryJedis implements JedisCommands {
|
|||||||
return client.getIntegerReply();
|
return client.getIntegerReply();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the number of keys in the currently selected database.
|
|
||||||
*
|
|
||||||
* @return Integer reply
|
|
||||||
*/
|
|
||||||
|
|
||||||
public Long dbSize() {
|
|
||||||
checkIsInMulti();
|
|
||||||
client.dbSize();
|
|
||||||
return client.getIntegerReply();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a timeout on the specified key. After the timeout the key will be
|
* Set a timeout on the specified key. After the timeout the key will be
|
||||||
* automatically deleted by the server. A key with an associated timeout is
|
* automatically deleted by the server. A key with an associated timeout is
|
||||||
@@ -2595,7 +2583,7 @@ public class Jedis extends BinaryJedis implements JedisCommands {
|
|||||||
* @param value
|
* @param value
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean setbit(String key, long offset, boolean value) {
|
public Boolean setbit(String key, long offset, boolean value) {
|
||||||
client.setbit(key, offset, value);
|
client.setbit(key, offset, value);
|
||||||
return client.getIntegerReply() == 1;
|
return client.getIntegerReply() == 1;
|
||||||
}
|
}
|
||||||
@@ -2607,12 +2595,12 @@ public class Jedis extends BinaryJedis implements JedisCommands {
|
|||||||
* @param offset
|
* @param offset
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean getbit(String key, long offset) {
|
public Boolean getbit(String key, long offset) {
|
||||||
client.getbit(key, offset);
|
client.getbit(key, offset);
|
||||||
return client.getIntegerReply() == 1;
|
return client.getIntegerReply() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long setrange(String key, long offset, String value) {
|
public Long setrange(String key, long offset, String value) {
|
||||||
client.setrange(key, offset, value);
|
client.setrange(key, offset, value);
|
||||||
return client.getIntegerReply();
|
return client.getIntegerReply();
|
||||||
}
|
}
|
||||||
@@ -2621,4 +2609,84 @@ public class Jedis extends BinaryJedis implements JedisCommands {
|
|||||||
client.getrange(key, startOffset, endOffset);
|
client.getrange(key, startOffset, endOffset);
|
||||||
return client.getBulkReply();
|
return client.getBulkReply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the configuration of a running Redis server. Not all the
|
||||||
|
* configuration parameters are supported.
|
||||||
|
* <p>
|
||||||
|
* CONFIG GET returns the current configuration parameters. This sub command
|
||||||
|
* only accepts a single argument, that is glob style pattern. All the
|
||||||
|
* configuration parameters matching this parameter are reported as a list
|
||||||
|
* of key-value pairs.
|
||||||
|
* <p>
|
||||||
|
* <b>Example:</b>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* $ redis-cli config get '*'
|
||||||
|
* 1. "dbfilename"
|
||||||
|
* 2. "dump.rdb"
|
||||||
|
* 3. "requirepass"
|
||||||
|
* 4. (nil)
|
||||||
|
* 5. "masterauth"
|
||||||
|
* 6. (nil)
|
||||||
|
* 7. "maxmemory"
|
||||||
|
* 8. "0\n"
|
||||||
|
* 9. "appendfsync"
|
||||||
|
* 10. "everysec"
|
||||||
|
* 11. "save"
|
||||||
|
* 12. "3600 1 300 100 60 10000"
|
||||||
|
*
|
||||||
|
* $ redis-cli config get 'm*'
|
||||||
|
* 1. "masterauth"
|
||||||
|
* 2. (nil)
|
||||||
|
* 3. "maxmemory"
|
||||||
|
* 4. "0\n"
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param pattern
|
||||||
|
* @return Bulk reply.
|
||||||
|
*/
|
||||||
|
public List<String> configGet(final String pattern) {
|
||||||
|
client.configGet(pattern);
|
||||||
|
return client.getMultiBulkReply();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alter the configuration of a running Redis server. Not all the
|
||||||
|
* configuration parameters are supported.
|
||||||
|
* <p>
|
||||||
|
* The list of configuration parameters supported by CONFIG SET can be
|
||||||
|
* obtained issuing a {@link #configGet(String) CONFIG GET *} command.
|
||||||
|
* <p>
|
||||||
|
* The configuration set using CONFIG SET is immediately loaded by the Redis
|
||||||
|
* server that will start acting as specified starting from the next
|
||||||
|
* command.
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* <b>Parameters value format</b>
|
||||||
|
* <p>
|
||||||
|
* The value of the configuration parameter is the same as the one of the
|
||||||
|
* same parameter in the Redis configuration file, with the following
|
||||||
|
* exceptions:
|
||||||
|
* <p>
|
||||||
|
* <ul>
|
||||||
|
* <li>The save paramter is a list of space-separated integers. Every pair
|
||||||
|
* of integers specify the time and number of changes limit to trigger a
|
||||||
|
* save. For instance the command CONFIG SET save "3600 10 60 10000" will
|
||||||
|
* configure the server to issue a background saving of the RDB file every
|
||||||
|
* 3600 seconds if there are at least 10 changes in the dataset, and every
|
||||||
|
* 60 seconds if there are at least 10000 changes. To completely disable
|
||||||
|
* automatic snapshots just set the parameter as an empty string.
|
||||||
|
* <li>All the integer parameters representing memory are returned and
|
||||||
|
* accepted only using bytes as unit.
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @param parameter
|
||||||
|
* @param value
|
||||||
|
* @return Status code reply
|
||||||
|
*/
|
||||||
|
public String configSet(final String parameter, final String value) {
|
||||||
|
client.configSet(parameter, value);
|
||||||
|
return client.getStatusCodeReply();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ public interface JedisCommands {
|
|||||||
|
|
||||||
Long ttl(String key);
|
Long ttl(String key);
|
||||||
|
|
||||||
boolean setbit(String key, long offset, boolean value);
|
Boolean setbit(String key, long offset, boolean value);
|
||||||
|
|
||||||
boolean getbit(String key, long offset);
|
Boolean getbit(String key, long offset);
|
||||||
|
|
||||||
long setrange(String key, long offset, String value);
|
Long setrange(String key, long offset, String value);
|
||||||
|
|
||||||
String getrange(String key, long startOffset, long endOffset);
|
String getrange(String key, long startOffset, long endOffset);
|
||||||
|
|
||||||
|
|||||||
@@ -40,11 +40,11 @@ public class Pipeline extends Queable {
|
|||||||
List<Object> unformatted = client.getAll();
|
List<Object> unformatted = client.getAll();
|
||||||
List<Object> formatted = new ArrayList<Object>();
|
List<Object> formatted = new ArrayList<Object>();
|
||||||
for (Object o : unformatted) {
|
for (Object o : unformatted) {
|
||||||
try{
|
try {
|
||||||
formatted.add(generateResponse(o).get());
|
formatted.add(generateResponse(o).get());
|
||||||
}catch(JedisDataException e){
|
} catch (JedisDataException e) {
|
||||||
formatted.add(e);
|
formatted.add(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return formatted;
|
return formatted;
|
||||||
}
|
}
|
||||||
@@ -154,9 +154,9 @@ public class Pipeline extends Queable {
|
|||||||
return getResponse(BuilderFactory.STRING);
|
return getResponse(BuilderFactory.STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Response<String> get(byte[] key) {
|
public Response<byte[]> get(byte[] key) {
|
||||||
client.get(key);
|
client.get(key);
|
||||||
return getResponse(BuilderFactory.STRING);
|
return getResponse(BuilderFactory.BYTE_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Response<Boolean> getbit(String key, long offset) {
|
public Response<Boolean> getbit(String key, long offset) {
|
||||||
@@ -175,9 +175,9 @@ public class Pipeline extends Queable {
|
|||||||
return getResponse(BuilderFactory.STRING);
|
return getResponse(BuilderFactory.STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Response<String> getSet(byte[] key, byte[] value) {
|
public Response<byte[]> getSet(byte[] key, byte[] value) {
|
||||||
client.getSet(key, value);
|
client.getSet(key, value);
|
||||||
return getResponse(BuilderFactory.STRING);
|
return getResponse(BuilderFactory.BYTE_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Response<Long> hdel(String key, String field) {
|
public Response<Long> hdel(String key, String field) {
|
||||||
@@ -1191,4 +1191,39 @@ public class Pipeline extends Queable {
|
|||||||
client.publish(channel, message);
|
client.publish(channel, message);
|
||||||
return getResponse(BuilderFactory.LONG);
|
return getResponse(BuilderFactory.LONG);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public Response<String> flushDB() {
|
||||||
|
client.flushDB();
|
||||||
|
return getResponse(BuilderFactory.STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response<String> flushAll() {
|
||||||
|
client.flushAll();
|
||||||
|
return getResponse(BuilderFactory.STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response<String> info() {
|
||||||
|
client.info();
|
||||||
|
return getResponse(BuilderFactory.STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response<Long> dbSize() {
|
||||||
|
client.dbSize();
|
||||||
|
return getResponse(BuilderFactory.LONG);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response<String> shutdown() {
|
||||||
|
client.shutdown();
|
||||||
|
return getResponse(BuilderFactory.STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response<String> ping() {
|
||||||
|
client.ping();
|
||||||
|
return getResponse(BuilderFactory.STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response<String> randomKey() {
|
||||||
|
client.randomKey();
|
||||||
|
return getResponse(BuilderFactory.STRING);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -68,17 +68,17 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
|
|||||||
return j.ttl(key);
|
return j.ttl(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setbit(String key, long offset, boolean value) {
|
public Boolean setbit(String key, long offset, boolean value) {
|
||||||
Jedis j = getShard(key);
|
Jedis j = getShard(key);
|
||||||
return j.setbit(key, offset, value);
|
return j.setbit(key, offset, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getbit(String key, long offset) {
|
public Boolean getbit(String key, long offset) {
|
||||||
Jedis j = getShard(key);
|
Jedis j = getShard(key);
|
||||||
return j.getbit(key, offset);
|
return j.getbit(key, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long setrange(String key, long offset, String value) {
|
public Long setrange(String key, long offset, String value) {
|
||||||
Jedis j = getShard(key);
|
Jedis j = getShard(key);
|
||||||
return j.setrange(key, offset, value);
|
return j.setrange(key, offset, value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -576,5 +576,4 @@ public class Transaction extends BinaryTransaction {
|
|||||||
client.publish(channel, message);
|
client.publish(channel, message);
|
||||||
return getResponse(BuilderFactory.LONG);
|
return getResponse(BuilderFactory.LONG);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -82,8 +82,8 @@ public class PipeliningTest extends Assert {
|
|||||||
assertEquals("foo", zset.get().iterator().next());
|
assertEquals("foo", zset.get().iterator().next());
|
||||||
assertEquals("foo", set.get());
|
assertEquals("foo", set.get());
|
||||||
assertEquals(false, blist.get());
|
assertEquals(false, blist.get());
|
||||||
assertEquals(new Double(2), zincrby.get());
|
assertEquals(Double.valueOf(2), zincrby.get());
|
||||||
assertEquals(new Long(1), zcard.get());
|
assertEquals(Long.valueOf(1), zcard.get());
|
||||||
assertEquals(1, lrange.get().size());
|
assertEquals(1, lrange.get().size());
|
||||||
assertNotNull(hgetAll.get().get("foo"));
|
assertNotNull(hgetAll.get().get("foo"));
|
||||||
assertEquals(1, smembers.get().size());
|
assertEquals(1, smembers.get().size());
|
||||||
@@ -157,4 +157,4 @@ public class PipeliningTest extends Assert {
|
|||||||
}
|
}
|
||||||
assertEquals(r.get(), "bar");
|
assertEquals(r.get(), "bar");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,33 @@
|
|||||||
package redis.clients.jedis.tests;
|
package redis.clients.jedis.tests;
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import redis.clients.jedis.*;
|
|
||||||
import redis.clients.jedis.exceptions.JedisDataException;
|
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import static junit.framework.Assert.assertEquals;
|
import static junit.framework.Assert.assertEquals;
|
||||||
import static junit.framework.Assert.assertNull;
|
import static junit.framework.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
public class SharedJedisPipelineTest {
|
import java.io.UnsupportedEncodingException;
|
||||||
private static HostAndPortUtil.HostAndPort redis1 = HostAndPortUtil.getRedisServers()
|
import java.util.ArrayList;
|
||||||
.get(0);
|
import java.util.List;
|
||||||
private static HostAndPortUtil.HostAndPort redis2 = HostAndPortUtil.getRedisServers()
|
import java.util.Map;
|
||||||
.get(1);
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import redis.clients.jedis.Jedis;
|
||||||
|
import redis.clients.jedis.JedisShardInfo;
|
||||||
|
import redis.clients.jedis.Response;
|
||||||
|
import redis.clients.jedis.ShardedJedis;
|
||||||
|
import redis.clients.jedis.ShardedJedisPipeline;
|
||||||
|
import redis.clients.jedis.Tuple;
|
||||||
|
import redis.clients.jedis.exceptions.JedisDataException;
|
||||||
|
|
||||||
|
public class ShardedJedisPipelineTest {
|
||||||
|
private static HostAndPortUtil.HostAndPort redis1 = HostAndPortUtil
|
||||||
|
.getRedisServers().get(0);
|
||||||
|
private static HostAndPortUtil.HostAndPort redis2 = HostAndPortUtil
|
||||||
|
.getRedisServers().get(1);
|
||||||
|
|
||||||
private ShardedJedis jedis;
|
private ShardedJedis jedis;
|
||||||
|
|
||||||
@@ -86,8 +96,8 @@ public class SharedJedisPipelineTest {
|
|||||||
assertEquals("foo", zset.get().iterator().next());
|
assertEquals("foo", zset.get().iterator().next());
|
||||||
assertEquals("foo", set.get());
|
assertEquals("foo", set.get());
|
||||||
assertFalse(blist.get());
|
assertFalse(blist.get());
|
||||||
assertEquals(new Double(2), zincrby.get());
|
assertEquals(Double.valueOf(2), zincrby.get());
|
||||||
assertEquals(new Long(1), zcard.get());
|
assertEquals(Long.valueOf(1), zcard.get());
|
||||||
assertEquals(1, lrange.get().size());
|
assertEquals(1, lrange.get().size());
|
||||||
assertNotNull(hgetAll.get().get("foo"));
|
assertNotNull(hgetAll.get().get("foo"));
|
||||||
assertEquals(1, smembers.get().size());
|
assertEquals(1, smembers.get().size());
|
||||||
@@ -152,8 +152,8 @@ public class ShardedJedisPoolTest extends Assert {
|
|||||||
shards.set(1, new JedisShardInfo("nohost", 1234));
|
shards.set(1, new JedisShardInfo("nohost", 1234));
|
||||||
pool = new ShardedJedisPool(redisConfig, shards);
|
pool = new ShardedJedisPool(redisConfig, shards);
|
||||||
jedis = pool.getResource();
|
jedis = pool.getResource();
|
||||||
Long actual = new Long(0);
|
Long actual = Long.valueOf(0);
|
||||||
Long fails = new Long(0);
|
Long fails = Long.valueOf(0);
|
||||||
for (int i = 0; i < 1000; i++) {
|
for (int i = 0; i < 1000; i++) {
|
||||||
try {
|
try {
|
||||||
jedis.get("a-test-" + i);
|
jedis.get("a-test-" + i);
|
||||||
@@ -167,4 +167,4 @@ public class ShardedJedisPoolTest extends Assert {
|
|||||||
assertEquals(actual, c1);
|
assertEquals(actual, c1);
|
||||||
assertEquals(fails, c2);
|
assertEquals(fails, c2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ public class BitCommandsTest extends JedisCommandTestBase {
|
|||||||
bit = jedis.getbit("foo", 0);
|
bit = jedis.getbit("foo", 0);
|
||||||
assertEquals(true, bit);
|
assertEquals(true, bit);
|
||||||
|
|
||||||
long bbit = jedis.setbit("bfoo".getBytes(), 0, "1".getBytes());
|
boolean bbit = jedis.setbit("bfoo".getBytes(), 0, "1".getBytes());
|
||||||
assertEquals(0, bbit);
|
assertFalse(bbit);
|
||||||
|
|
||||||
bbit = jedis.getbit("bfoo".getBytes(), 0);
|
bbit = jedis.getbit("bfoo".getBytes(), 0);
|
||||||
assertEquals(1, bbit);
|
assertTrue(bbit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ public abstract class JedisCommandTestBase extends JedisTestBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!contained) {
|
if (!contained) {
|
||||||
throw new ComparisonFailure("element is missing", next
|
throw new ComparisonFailure("element is missing",
|
||||||
.toString(), actual.toString());
|
Arrays.toString(next), actual.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -93,4 +93,4 @@ public abstract class JedisCommandTestBase extends JedisTestBase {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -277,4 +277,22 @@ public class TransactionCommandsTest extends JedisCommandTestBase {
|
|||||||
}
|
}
|
||||||
assertEquals("bar", lr.get(2).get());
|
assertEquals("bar", lr.get(2).get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void select() {
|
||||||
|
jedis.select(1);
|
||||||
|
jedis.set("foo", "bar");
|
||||||
|
jedis.watch("foo");
|
||||||
|
Transaction t = jedis.multi();
|
||||||
|
t.select(0);
|
||||||
|
t.set("bar", "foo");
|
||||||
|
|
||||||
|
Jedis jedis2 = createJedis();
|
||||||
|
jedis2.select(1);
|
||||||
|
jedis2.set("foo", "bar2");
|
||||||
|
|
||||||
|
List<Object> results = t.exec();
|
||||||
|
|
||||||
|
assertNull(results);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user