Add Redis 2.6 info(section) method to Connections
DATAREDIS-183
This commit is contained in:
@@ -236,6 +236,10 @@ public class DefaultStringRedisConnection implements StringRedisConnection {
|
||||
return delegate.info();
|
||||
}
|
||||
|
||||
public Properties info(String section) {
|
||||
return delegate.info(section);
|
||||
}
|
||||
|
||||
public boolean isClosed() {
|
||||
return delegate.isClosed();
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ public interface RedisServerCommands {
|
||||
|
||||
Properties info();
|
||||
|
||||
Properties info(String section);
|
||||
|
||||
void shutdown();
|
||||
|
||||
List<String> getConfig(String pattern);
|
||||
|
||||
@@ -476,6 +476,11 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
|
||||
public Properties info(String section) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
public Long lastSave() {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
|
||||
@@ -276,6 +276,11 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
|
||||
public Properties info(String section) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
public Long lastSave() {
|
||||
try {
|
||||
return (Long)jredis.lastsave();
|
||||
|
||||
@@ -406,6 +406,19 @@ public class LettuceConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
|
||||
public Properties info(String section) {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
pipeline(getAsyncConnection().info(section));
|
||||
return null;
|
||||
}
|
||||
return LettuceUtils.info(getConnection().info(section));
|
||||
} catch (Exception ex) {
|
||||
throw convertLettuceAccessException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Long lastSave() {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
|
||||
@@ -322,6 +322,19 @@ public class SrpConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
|
||||
public Properties info(String section) {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
pipeline(pipeline.info(section));
|
||||
return null;
|
||||
}
|
||||
return SrpUtils.info(client.info(section));
|
||||
} catch (Exception ex) {
|
||||
throw convertSrpAccessException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Long lastSave() {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
|
||||
@@ -458,6 +458,16 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
assertNotNull(version);
|
||||
}
|
||||
|
||||
@Test
|
||||
@IfProfileValue(name = "redisVersion", value = "2.6")
|
||||
public void testInfoBySection() throws Exception {
|
||||
Properties info = connection.info("server");
|
||||
assertNotNull(info);
|
||||
assertTrue("at least 5 settings should be present", info.size() >= 5);
|
||||
String version = info.getProperty("redis_version");
|
||||
assertNotNull(version);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullKey() throws Exception {
|
||||
try {
|
||||
|
||||
@@ -176,6 +176,12 @@ public class JedisConnectionIntegrationTests extends AbstractConnectionIntegrati
|
||||
super.testSRandMemberCountNegative();
|
||||
}
|
||||
|
||||
@Test(expected=UnsupportedOperationException.class)
|
||||
@IfProfileValue(name = "redisVersion", value = "2.6")
|
||||
public void testInfoBySection() throws Exception {
|
||||
super.testInfoBySection();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIncrDecrByLong() {
|
||||
String key = "test.count";
|
||||
|
||||
@@ -363,6 +363,12 @@ public class JedisConnectionPipelineIntegrationTests extends
|
||||
super.testSRandMemberCountNegative();
|
||||
}
|
||||
|
||||
@Test(expected=UnsupportedOperationException.class)
|
||||
@IfProfileValue(name = "redisVersion", value = "2.6")
|
||||
public void testInfoBySection() throws Exception {
|
||||
super.testInfoBySection();
|
||||
}
|
||||
|
||||
// Overrides, usually due to return values being Long vs Boolean or Set vs
|
||||
// List
|
||||
|
||||
|
||||
@@ -517,6 +517,12 @@ public class JRedisConnectionIntegrationTests extends AbstractConnectionIntegrat
|
||||
super.testSRandMemberCountNegative();
|
||||
}
|
||||
|
||||
@Test(expected=UnsupportedOperationException.class)
|
||||
@IfProfileValue(name = "redisVersion", value = "2.6")
|
||||
public void testInfoBySection() throws Exception {
|
||||
super.testInfoBySection();
|
||||
}
|
||||
|
||||
// Jredis returns null for rPush
|
||||
@Test
|
||||
public void testSort() {
|
||||
|
||||
@@ -174,6 +174,18 @@ public class LettuceConnectionPipelineIntegrationTests extends
|
||||
assertNotNull(version);
|
||||
}
|
||||
|
||||
@Test
|
||||
@IfProfileValue(name = "redisVersion", value = "2.6")
|
||||
public void testInfoBySection() throws Exception {
|
||||
assertNull(connection.info("server"));
|
||||
List<Object> results = getResults();
|
||||
assertEquals(1, results.size());
|
||||
Properties info = LettuceUtils.info((String) results.get(0));
|
||||
assertTrue("at least 5 settings should be present", info.size() >= 5);
|
||||
String version = info.getProperty("redis_version");
|
||||
assertNotNull(version);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMSetNx() {
|
||||
Map<String, String> vals = new HashMap<String, String>();
|
||||
|
||||
@@ -50,6 +50,18 @@ public class LettuceConnectionPipelineTxIntegrationTests extends
|
||||
assertNotNull(version);
|
||||
}
|
||||
|
||||
@Test
|
||||
@IfProfileValue(name = "redisVersion", value = "2.6")
|
||||
public void testInfoBySection() throws Exception {
|
||||
assertNull(connection.info("server"));
|
||||
List<Object> results = getResults();
|
||||
assertEquals(2, results.size());
|
||||
Properties info = LettuceUtils.info((String) results.get(1));
|
||||
assertTrue("at least 5 settings should be present", info.size() >= 5);
|
||||
String version = info.getProperty("redis_version");
|
||||
assertNotNull(version);
|
||||
}
|
||||
|
||||
@Test(expected=RedisPipelineException.class)
|
||||
@IfProfileValue(name = "redisVersion", value = "2.6")
|
||||
public void testRestoreBadData() {
|
||||
|
||||
@@ -119,6 +119,18 @@ public class SrpConnectionPipelineIntegrationTests extends
|
||||
assertNotNull(version);
|
||||
}
|
||||
|
||||
@Test
|
||||
@IfProfileValue(name = "redisVersion", value = "2.6")
|
||||
public void testInfoBySection() throws Exception {
|
||||
assertNull(connection.info("server"));
|
||||
List<Object> results = getResults();
|
||||
assertEquals(1, results.size());
|
||||
Properties info = SrpUtils.info(new BulkReply((byte[]) results.get(0)));
|
||||
assertTrue("at least 5 settings should be present", info.size() >= 5);
|
||||
String version = info.getProperty("redis_version");
|
||||
assertNotNull(version);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExists() {
|
||||
connection.set("existent", "true");
|
||||
|
||||
Reference in New Issue
Block a user