Commit Graph

794 Commits

Author SHA1 Message Date
Christoph Strobl
4c7e405f7b DATAREDIS-344 - Assert RedisCache works with Spring 4.1.
Added `putIfAbsent` to `RedisCache` to satisfy compatibility with newly introduced method.

Original pull request: #102.
2014-09-04 15:02:19 +02:00
Thomas Darimont
5abfa8716e DATAREDIS-337 - Improve handling of overridden methods in MessageListenerAdapter.
Previously overriding message handler methods of the delegate passed to MessageListenerAdapter resulted in the message handler method called multiple times. We now make sure that a message handler method is only found and invoked  once.

Original pull request: #95.
2014-08-13 08:53:49 +02:00
Christoph Strobl
fd361a1868 DATAREDIS-330 - Add support for SENTINEL commands.
add support for commands:
  SENTINEL FAILOVER master
  SENTINEL SLAVES master
  SENTINEL REMOVE name
  SENTINEL MONITOR name ip port quorum

Original pull request: #92.
2014-08-11 09:12:12 +02:00
Christoph Strobl
55ff415a71 DATAREDIS-324 - Add Redis Sentinel support.
We’ve added RedisSentinelConfiguration holding required information for connecting to redis sentinels. This can be used to set up ConnectionFeactory for HA environments.

**Using Jedis**
Providing RedisSentinelConfiguration will force the JedisConnectionFactory to use JedisSentinelPool for managing resources.

**Using Lettuce/JRedis/SRP**
There’s currently no support for sentinel in those clients.

**CI Build**
We’ve added makefile to build and set up redis instances for testing sentinel support on travis-ci. There’s already a section for redis cluster.
The cluster section is for whatever reason currently not working as the cluster nodes won’t start.
This will be fixed when we add redis-cluster support.

_side note:_ there’s an alternative fork of lettuce at mp911de/lettuce that already has sentinel support.
2014-08-05 09:00:15 +02:00
Thomas Darimont
5f48ea8ed4 DATAREDIS-317 - Report inappropriate RedisTemplate more eagerly in RedisAtomic wrappers.
We now validate the given RedisTemplate in the constructor of RedisAtomicLong/RedisAtomicInteger/RedisAtomicDouble to report an inappropriate RedisTemplate more eagerly.

Original pull request: #83.
2014-06-30 08:13:26 +02:00
Christoph Strobl
42ff3ee1e1 DATAREDIS-314 - Add SCAN commands to Collection types.
Add scan to RedisMap / RedisSet / RedisZSet.
Lua scritps have to be assembled in binary way in order to avoid script errors when executing.
Add missing rules/profiles to run properly in a 2.6.x redis environment.

Original pull request: #82.
2014-06-17 10:18:28 +02:00
Christoph Strobl
d8b53a4c96 DATAREDIS-313 - Overhaul SCAN, HSCAN, SSCAN, ZSCAN operations.
Unify naming and return types. Update supported commands documentation. Remove key from BoundHashOperations and use getKey() instead.

Original pull request: #81.
2014-06-10 16:10:28 +02:00
Christoph Strobl
c939c8a9ff DATAREDIS-306 - Add support for ZSCAN.
ZSCAN is directly supported by jedis and can be emulated for lettuce via eval.

SRP and JRedis will throw UnsupportedOperationException.

Original pull request: #80.
2014-06-06 01:15:26 +02:00
Christoph Strobl
ba88249188 DATAREDIS-305 - Add support for HSCAN.
HSCAN is directly supported by jedis and can be emulated for lettuce via eval.

SRP and JRedis will throw UnsupportedOperationException.

We have modified the ScanCursor implementation to take Collection instead of List.

Currently naming for scan commands is not consistent for scan, sscan and hscan. There’s a clean up task for those commands when done with all scan related commands.

Original pull request: #78.
2014-06-03 11:50:55 +02:00
Thomas Darimont
1831ae9db7 DATAREDIS-296 - Upgrade jedis to recent version.
Upgrading to latest jedis version 2.5.1. Added new conversion for Long to byte[] in JedisConverters to be able to convert long cursorIds to byte[].

Original pull request: #77.
2014-06-02 08:27:43 +02:00
Thomas Darimont
29e70b8cd8 DATAREDIS-309 - Refactor test profiles to support more than 2 versions.
We’ve added a customized SpringJUnit4Runner and TestRule that allow us to use a more relaxed strategy when dealing with @IfProfileValue. Basically we have added ‘+’ as sort of wildcard indicating tests should be executed for version X and all its successor.

This allows us to run test valid starting 2.6 for 2.8 as well, while those only valid for 2.8 are not executed against eg. redis 2.6.17.

Fixed compile error in ScanCursor with Java 6.

Orignal pull request: #76.
2014-05-28 18:24:37 +02:00
Christoph Strobl
34d1759b4e DATAREDIS-304 - Add support for SSCAN command.
SSCAN command is natively supported by jedis and can be emulated for lettuce.
JRedis and SRP will throw UnsupportedOperationException.

sScan is available on RedisConneciton and RedisSetOperations returning basically a Cursor that allows iteration over the defined values for a given key.

Currently the jedis driver does not directly expose the binary version of sscan which leads to invalid results when using a non String compatible converter along with the RedisTemplate. We’ll change this as soon as a newer version of jedis is available.

Along the way loading behavior of ScanCursor has been fixed, preventing it from indicating next values available when there effectively are no more.

Orignal pull request: #76.
2014-05-28 14:34:18 +02:00
Christoph Strobl
d427928386 DATAREDIS-290 - Add support for SCAN command.
SCAN is currently only supported by jedis but can be emulated for
lettuce via eval.
Srp and JRedis will respond with UnsupportedOperationException.

We provide a Cursor implementation allowing to scroll through the
responses provided by the underlying connection. The cursor will fetch
additional results from redis server whenever its starting point has not
been reached and there are no more already loaded items available.

Only values returned by the last call to redis server are kept in memory
which allows scrolling through the entire collection without potentially
running into memory issues.

Original pull request: #71.
2014-05-23 14:07:11 +02:00
Andy Wilkinson
bdea1051de DATAREDIS-299 - Assert compatibility with Spring IO.
Upgrade to JUnit 4.11

Upgrade to JUnit 4.11 and remove use of a matcher in an internal
package in favour of the Hamcrest equivalent. To avoid a clash between
JUnit 4.11's Hamcrest dependency and the version of Hamcrest that's
bundled in mockito-all, use of mockito-all has been replaced with
mockito-core

Add the Spring IO plugin

Configure the Spring IO plugin such that it's only applied when the
build is run with -PplatformVersion=<version>. This platformVersion
property is used to determine the version of the Platform that will
be used when running the springIoCheck task. The plugin can be used
by running a build as follows:

./gradlew clean springIoCheck -PplatformVersion=1.0.0.BUILD-SNAPSHOT -PJDK7_HOME=… -PJDK8_HOME=…

This will test the project on JDK7 and JDK 8 using the dependencies
defined in the latest snapshot of Spring IO Platform 1.0.0.

Address Java 6 compilation problem

The JUnit and Hamcrest upgrades caused a compilation error on Java 6
due to a bug in the compiler’s handling of generics. This commit adds
more type information to help to guide the compiler around the problem.

Additionally, deprecation warnings caused by the JUnit and Hamcrest
upgrades have also been addressed.

Original pull request: #72.
2014-05-19 09:59:06 +02:00
Christoph Strobl
c38c5f3c09 DATAREDIS-300 - Fix inconsistency with connection open() and close().
Redis connections have been left open when calling RedisTemplate.execute as the connection might have been bound to a thread, released but never been unbound. We now only bind and unbind connections in case of enabled transaction support, while just getting and releasing it for all other purposes.

Original pull request: #69.
2014-05-16 14:22:06 +02:00
Christoph Strobl
ce8d932a46 DATAREDIS-226 - Syntax exceptions using lettuce should be reported immediately.
If running in transaction mode we now do a rudimentary check if the provided number of arguments matches the ones defined for the RedisCommand to execute.

If the command passes this first check and causes an error on redis server one has to check results for Command.getOutput().hasError().

Original Pull Request: #66.
2014-04-29 13:23:20 +02:00
Christoph Strobl
bc1bbd1d39 DATAREDIS-73 - Add support for spring managed transactions.
RedisTemplate now supports enabling of transaction support, which is disabled by default.

In case of enabled transaction support the RedisConnections will be bound to the current thread during ongoing outer transactions. We call MULTI at the beginning and depending on transaction state EXEC or DISCARD at its end.

To support read operations during the transaction we wrap a proxy around the bound connection piping read operations to a new (non thread bound) connection obtained by the underlying RedisConnectionFactory.

Transaction support is available for jedis, lettuce and srp, while had to be skipped for jredis due to the lack of support for MULTI.

Original pull request: #64.
2014-04-25 13:53:36 +02:00
Christoph Strobl
4e4a2961da DATAREDIS-294 - TypedTuple should allow sorting using java sort().
Updated Comparable type information to allow usage with standard java sort.
2014-04-25 13:12:18 +02:00
icedrake
6d7c5ce9cd DATAREDIS-293 - JedisConnection, allow bulk addition with same score.
Added version check for jedis library as the operation had been introduced in 2.4.

Original Pull Request: #63
2014-04-11 11:02:31 +02:00
reta
aa739f4135 DATAREDIS-289 - Avoid NPE in DefaultValueOperations#append() in case of pipelining or/and multi/exec calls.
We now return null if DefaultValueOperations#append() was applied to a non-existing list and thus returned null. Previously a NPE was thrown in case of pipelining or/and multi/exec calls.

Original pull request: #48.
2014-03-26 14:00:16 +01:00
Christoph Strobl
f366ffc94e DATAREDIS-284 - Add support for zCard to ZSetOperations.
'zCard' has been introduced in addition to 'size' as it feels more natural for people using redis. 'size' in 'ZSetOperations' / 'BoundZsetOperations' now delegate to 'zCard'.

Original Pull Request: #55
2014-03-26 13:22:55 +01:00
Christoph Strobl
d35375ec74 DATAREDIS-277 - Add support for 'SLAVEOF'.
'SLAVEOF' and 'SLAVEOF NO ONE' are available via 'RedisConnection' and 'RedisOperations' for 'jedis', 'jredis', 'lettuce' and 'srp'.

Original Pull Request: #57
2014-03-26 13:15:33 +01:00
Christoph Strobl
2b280e57e8 DATAREDIS-287 - 'setBit' should return boolean value.
SetBit now returns the original bit value stored at the offset. The result will also be added in pipeline and transaction mode which means that the final result collection may now contain more entries than in prior versions.

Original Pull Request: #58
2014-03-26 12:54:38 +01:00
Christoph Strobl
2679405e96 DATAREDIS-268 - Add support for 'CLIENT LIST'.
'RedisConnection' and 'RedisTemplate' have been extended by 'getClientList' retrieving client informations from redis. 'RedisClientInfo' provides access via specified getters as well as an more general approach directly using the keys (like 'qubuf').

The operation is available for 'jedis', 'lettuce' and 'srp'.

Original Pull Request: #53
2014-03-26 12:42:09 +01:00
Christoph Strobl
4bf438f563 DATAREDIS-270 - Add support for 'CLIENT GETNAME'.
Support for getting client connection name has been added for 'jedis', 'jredis' and 'srp' drivers.

Using 'jredis' will throw 'UnsupportedOperationException'.

Original Pull Request: #51
2014-03-26 12:05:28 +01:00
Christoph Strobl
e280a23550 DATAREDIS-269 - Add support for 'CLIENT SETNAME'.
Setting client name is possible for 'jedis', 'lettuce' and 'srp'.
Using 'jredis' throws 'UnspupportedOperationException'.

Original Pull Request: #54
2014-03-26 11:44:01 +01:00
Christoph Strobl
6a6d03eb4c DATAREDIS-267 - Add support for 'CLIENT KILL'.
Killing a client connection can be done via 'RedisConnection' and 'RedisOperations' using 'jedis', 'lettuce' and 'srp'.

We use dedicated parameters for host and port building up the redis format (host:port) for connection identification.

Original Pull Request: #56
2014-03-26 11:33:35 +01:00
Christoph Strobl
1c47330ec9 DATAREDIS-286 - Avoid overflow in JedisConnection#expire / #pexpire.
Added unit test to verify that 'time()' is called prior to 'pExpireAt'.
2014-03-24 11:29:53 +01:00
Thomas Darimont
59582f1910 DATAREDIS-286 - Avoid overflow in JedisConnection#expire / #pexpire.
Workaround Jedis issue https://github.com/xetorthio/jedis/pull/575.
We now delegate calls to expire(...) to pExpireAt(...) in case the seconds parameter is > than Integer.MAX_VALUE.
We query the server time to compute the new expiration date.

Original pull request: #52.
2014-03-24 11:28:40 +01:00
Christoph Strobl
408b52a449 DATAREDIS-261 - Upgrade to commons-pool2.
'JRedisPool' and 'DefaultLettucePool' have been migrated to 'commons-pool2'.

'PoolConfig' has been deprecated, and will be removed in '1.4', as all required operations are available via 'GenericObjectPoolConfig'.

Along the way a minor bug within 'LettuceConnection' has been resolved, which prevented 'RedisAsyncConnections' from being properly closed/returned to pool.

Original Pull Request: #50
2014-03-20 13:07:05 +01:00
Christoph Strobl
d116d3825a DATAREDIS-184 - Add support for 'SAVE/NOSAVE' to shutdown.
Created and added 'ShutdownOptions' to 'RedisServerCommands'. The full implementation is available for 'lettuce' and 'srp'.

When using 'jedis' the command is emulated using lua script via 'eval'.

For 'jredis' the method is not available and will throw 'UnsupportedOperationException'.

Original Pull Request: #47
2014-03-20 12:49:41 +01:00
Christoph Strobl
4b2ccbecb9 DATAREDIS-271 - Add support for 'pSetEx'.
Support for 'pSetEx' has been added for 'jedis' & 'srp'.
For 'lettuce' the command is emulated using 'eval'.

There is no support for 'pSetEx' when using 'jredis'.

'DefaultValueOperations.set' used with 'TimeUnit.MILLISECONDS' will fallback to 'setEx' in case 'pSetEx' is not supported by the driver in use.

Original pull request: #46.
2014-03-20 12:36:09 +01:00
Christoph Strobl
a3ac8d0899 DATAREDIS-285 - LettuceConnection.execute should fully read response.
'LettuceConnection' used 'ByteArrayOutput' as default for execute which did not fully read all values that might be included in the response.

To overcome this issue 'TypeHints' have been added which map a given 'CommandType' to the most recent 'CommandOutput'.  As not all commands could be mapped that way due to the result depending on input parameters in some cases, it might be required to manually provide the type hint when calling execute.

Additional tests have been added to assert 'execute' works properly for 'jedis', 'jredis' and 'srp'.

Original Pull Request: #49
2014-03-19 11:26:19 +01:00
Thomas Darimont
9cf484d25a DATAREDIS-283 - RedisCacheManager.loadCaches overrides already defined cache names in afterPropertiesSet().
We now retain the potentially already configured caches during the initialisation of the RedisCacheManager bean. Previously we discarded the already configured caches which was an undesired side-effect.

Original pull request: #45.
2014-03-13 06:33:37 +01:00
Thomas Darimont
0f8c68c251 DATAREDIS-282 - PubSubResubscribeTests should use jedis without pool.
Disabled jedis pooling in PubSubResubscribeTests since all the other tests also don't use a pool.

Original pull request #43.
2014-03-03 14:36:06 +01:00
Christoph Strobl
e003ef6ca3 DATAREDIS-206 - Add support for TIME operation.
Enhanced RedisServerCommands to reflect time operation and added empty implementation to recent RedisConnection abstractions.
Added implementation of time() for Srp, Jedis, Lettuce (emulated via eval).
Added UnsupportedOperation of time() JRedis since it doesn't support time command or sending scripts or sending raw commands via the underlying connection.
Added implementation for DefaultStringRedisConnection to delegate time() operation to native connection.
Added integration test to abstract base class. Ignored the test for those connections not supporting time command.

Original pull request: #34
2014-02-18 10:14:46 +01:00
Christoph Strobl
82578066e8 DATAREDIS-246 - RedisCacheManager.getCache() does not match the logical of CompositeCacheManager.
By default RedisCacheManager lazily initializes RedisCaches when requested. To put it into static mode a defined set of cache names has to be passed to the CacheManager.

We changed the implementation so it  makes use of AbstractTransactionalCache introduced in Spring 3.2 which properly registers caches. Additionally the loadRemoteCachesOnStartup switch allows to retrieve and initialize existing caches by loading keys form redis server.

Further on RedisCacheManager can be set in transaction aware mode so that values are only put into cache after successful commit of surrounding transaction.

Original pull request: #33
2014-02-17 13:39:18 +01:00
Christoph Strobl
5466a70034 DATAREDIS-260 - Upgrade to jedis 2.3.1.
Jedis upgraded from commons-pool to commons-pool2. Required changes have been introduced. Currently there are both commons-pool and commons-pool2 in class-path which is no problem as those dependencies are optional.

Original pull request: #31
2014-02-06 18:26:05 +01:00
Christoph Strobl
dea6403c24 DATAREDIS-166 - Corrupted i/o streams subscribing to both patterns and channels.
The issue has already been fixed in DATAREDIS-242 (see PR: #25), which now allows to reenable the previously failing test.
Additionally the tests now run against all supported client libraries except JRedis which does not support 'publish'.

Original pull request: #30
2014-02-06 09:54:24 +01:00
Christoph Strobl
d4c5990831 DATAREDIS-170 - Cancel SubscriptionTask can leave connection open.
RedisMessageListenerContainer did not properly close connections if the subscription was canceled immediately after staring the container. Since DARAREDIS-242 the container waits for the subscription to complete and therefor no more connections remain open.

Additionally added missing parameters to run tests with JRedis.

Original pull request: #29
2014-02-05 18:22:27 +01:00
Thomas Darimont
eaf249af90 DATAREDIS-188 - Infinite loop renaming a non-existent Collection when using Lettuce.
We run into an infinite loop in org.springframework.data.redis.support.collections.CollectionUtils.rename(K, K, RedisOperations<K, ?>) if no value was associated with the key which leads to operations.hasKey(...) always returning false which prevents the actual renaming. RedisCollections will only send rename command if values are present as empty collections cannot be stored and therefor cannot be renamed.

Original pull request: #28
2014-02-05 09:50:32 +01:00
Christoph Strobl
e0524379d6 DATAREDIS-254 - Clean up codebase to match spring-data conventions
format code with spring data formatter
2014-01-28 10:55:00 +01:00
Thomas Darimont
b5adde7430 DATAREDIS-242 - Listener Container start() Returns Before Container is Really Started.
We now wait for the subscription to be present in the connection in case of async connections by periodically checking whether the subscription is available in 100ms intervals. The max time to wait for the async subscription can be configured and is set to 2 seconds by default.

Moved SpinBarrier and TestCondition from test packages as static inner classes into RedisMessageListenerContainer. Included ConnectionUtils from tests into official API.
2014-01-20 14:23:18 +01:00
Thomas Darimont
c6d2d7f9c9 DATAREDIS-241 - Add a Jackson2 based RedisSerializer.
Introduced Jackson2JsonRedisSerializer and added optional dependency for Jackson2 core/databind (fasterxml) library.
Added additional parameterised test cases. Needed to increase the max active connections limit for the connection pools used in RedisMapTests.
2014-01-17 12:04:05 +01:00
Jennifer Hickey
e1b421f942 DATAREDIS-237 - Upgrade to Jedis 2.2.1.
Update to Jedis 2.2.1 and Implement newly supported Operations.
Handle removed BinaryTransaction class.
Handle some Jedis return types changed from String to bytes.
Handle some Jedis arg types changed from int to long by removing casting.
Remove ignored tests for issues fixed in Jedis 2.2.1
Throw UnsupportedOpException on multi-arg bitOp NOT
Ensure consistent results across all drivers when bitOp is called with NOT and more than one arg.
2014-01-16 14:34:02 +01:00
Thomas Darimont
2870df0cdc DATAREDIS-251 - Fix tests to work against Redis 2.8.x.
Since Redis 2.8.x keyOps#getExpire() returns -2 for empty collections (RedisList/RedisSet/RedisMap). 
We're now adding a dummy entry to keep the test version agnostic. Previously getExpire() returned -1.
We also have to set the RedisAtomic(Integer|Long) to a value other than 0 to get  the value stored appropriately.

For reference see the discussion in http://redis.io/commands/ttl
2014-01-16 13:43:36 +01:00
Thomas Darimont
168713aae1 DATAREDIS-253 - Avoid usage of deprecated API.
Changed usage of TypeFactory to the recommended API.
2014-01-16 10:39:52 +01:00
Thomas Darimont
b5137e6dd4 DATAREDIS-245 - Prevent Excessive Thread creation in tests.
Rewritten testPubSubWithPatterns in order to make it pass reliably by keeping the original test semantics.
2014-01-16 09:31:17 +01:00
Thomas Darimont
2af23692f3 DATAREDIS-251 - Fix tests to work against Redis 2.8.x.
Since Redis 2.8.x keyOps#getExpire() now returns -2 for empty collections (RedisList/RedisSet/RedisMap) we add a dummy entry to keep the test version agnostic. Previously getExpire() returned -1.

For reference see the discussion in http://redis.io/commands/ttl
2014-01-15 19:36:22 +01:00
Thomas Darimont
2c9e34330b DATAREDIS-245 - Prevent Excessive Thread creation in tests.
Rewritten testPubSubWithNamedChannels in order to make it pass reliably by keeping the original test semantics.
2014-01-15 19:22:25 +01:00