Commit Graph

657 Commits

Author SHA1 Message Date
Christoph Strobl
087dba0735 DATAREDIS-848 - Polishing.
Original Pull Request: #382
2019-02-28 10:09:35 +01:00
Mark Paluch
cd05e5c0b9 DATAREDIS-848 - Use Lettuce's RestoreArgs to restore a key with replace option.
We now use RestoreArgs instead of constructing a custom command.

Original Pull Request: #382
2019-02-28 10:09:14 +01:00
Christoph Strobl
630ff46b45 DATAREDIS-935 - Allow configuration of a single initial cache in RedisCacheManagerBuilder.
Also, add introspection methods to expose the configured cache names/configurations.

Original pull request: #387.
2019-02-27 15:19:19 +01:00
Mark Paluch
32cc2a60e7 DATAREDIS-932 - Fix typo in exception message. 2019-02-18 08:48:24 +01:00
Mark Paluch
2622f054ab DATAREDIS-930 - Polishing.
Add since tags. Simplify test using Lombok annotations. Reformat code.

Original pull request: #385.
2019-02-15 11:09:38 +01:00
Luis De Bello
34951495ba DATAREDIS-930 - Return port/host of WithHostAndPort configurations using LettuceConnectionFactory.getPort() and getHost().
We now correctly return host and port from configurations that implement WithHostAndPort instead of always using RedisStandaloneConfiguration.

Original pull request: #385.
2019-02-15 11:08:08 +01:00
Mark Paluch
62e48be873 DATAREDIS-918 - Enable Lettuce's global timeouts by default.
LettuceClientConfiguration now enables Lettuce's global timeouts by default to enable timeouts using the reactive API. This change prevents hanging Redis commands due to a blocked connection or when Redis is down. Timeouts are enabled through defaulting so setting ClientOptions or ClusterClientOptions overrides this behavior.

Original Pull Request: #381
2019-01-09 13:38:29 +01:00
Mark Paluch
f253d4128d DATAREDIS-749 - Polishing.
Upgrade to Jedis 3.0. Remove reflective sendCommand calls in favor of public Jedis sendCommand API. Invocations with null arguments by introducing overloads with argument defaulting. Fix exception translation because of a changed exception hierarchy. Fix tests and adapt tests to new transactional results that return null values instead if empty collections for nested array responses.

Reformat code. Add author tags. Add note to reference docs.

Original pull request: #374.
2019-01-08 09:37:34 +01:00
Guy Korland
f4680a180c DATAREDIS-749 - Upgrade to Jedis 3.0.0 M1.
Upgrade dependency version to 3.0.0 M1. Adapt to API changes.

Original pull request: #374.
2019-01-08 09:37:31 +01:00
Mark Paluch
3a07a0d8ed DATAREDIS-917 - Update copyright years to 2019. 2019-01-02 14:16:01 +01:00
Mark Paluch
7ec4641cc1 DATAREDIS-913 - Delete multiple keys through ReactiveRedisTemplate.delete(Publisher) and unlink(Publisher).
We now delete all keys that are emitted by the source publisher when invoking delete(Publisher) and unlink(Publisher). Both methods split incoming keys into chunks of 128 keys to keep a balance between latency and the issued command count.

Previously, delete(Publisher) and unlink(Publisher) only deleted the first key.

Original Pull Request: #379
2018-12-20 09:42:43 +01:00
Mark Paluch
d248c0cd7c DATAREDIS-909 - Fix constructor creation of entities with collection-typed properties.
We now consider the property type in value conversion for constructor arguments to provide the appropriate value type. Previously, we considered the component type which converted a Collection<T> to a single T that caused downstream ClassCastException.

Original Pull Request: #378
2018-12-20 08:54:12 +01:00
Mark Paluch
1f4bb973ea DATAREDIS-865 - Expose GenericJackson2JsonRedisSerializer.registerNullValueSerializer() for ObjectMapper customization.
We now expose registerNullValueSerializer(…) on GenericJackson2JsonRedisSerializer to allow customization of an externally provided ObjectMapper. NullValueSerializer was previously registered only within a constructor that takes classPropertyTypeName and provided no further possibilities to customize ObjectMapper.

Code wishing to provide a custom ObjectMapper can now call GenericJackson2JsonRedisSerializer.registerNullValueSerializer(objectMapper, …) and perform additional customizations before using ObjectMapper with GenericJackson2JsonRedisSerializer.

Original Pull Request: #376
2018-12-20 08:35:30 +01:00
Mark Paluch
ed79d14355 DATAREDIS-905 - Fix race condition in StreamMessageListenerContainer subscription activation.
Stream subscriptions now report reliably their state reflecting regarding activation, cancellation and while being active.

Previously, registering a subscription with immediate cancel could report an inactive subscription although StreamMessageListenerContainer could perform a stream read.

When activating a subscription in StreamMessageListenerContainer, awaiting activation (awaitStart(…)), immediately cancelling the subscription, and reading active state via Subscription.isActive(), Subscription.isActive() could report in this case false. This was because we checked that the status was either running or the stream read has reached event looping. The state was CANCELLED and the task thread had not yet reached the event loop and so there was a gap.

Original Pull Request: #377
2018-12-20 08:20:45 +01:00
chao chang
b510ef0606 DATAREDIS-903 - Remove Javadoc for unused RedisClusterConfiguration settings.
The following configuration keys which are not used in RedisClusterConfiguration, are removed from the Javadoc.
	 * spring.redis.cluster.timeout=5
	 * spring.redis.cluster.password=foobar

Original pull request: #375.
2018-12-06 08:46:59 +01:00
Christoph Strobl
c8bfc71678 DATAREDIS-721 - Polishing.
Original Pull Request: #315
2018-11-30 14:42:31 +01:00
Mark Paluch
b496aab2fb DATAREDIS-721 - Switch to non-blocking connect methods.
We now connect asynchronously to expose non-blocking connection behavior for reactive API usage. We also use a non-blocking, asynchronous pool implementation for connections that are used through a reactive API. Shared connection usage, which is blocking on the very first access can be pre-initialized during connection factory initialization instead of initialization on first access:

LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory();
connectionFactory.setEagerInitialization(true);
connectionFactory.afterPropertiesSet();

We no longer require offloading of blocking connects to a dedicated scheduler which makes reactive API usage fully non-blocking.

Original Pull Request: #315
2018-11-30 12:54:12 +01:00
Mark Paluch
b440dc1f1f DATAREDIS-873 - Polishing.
Add since tags. Add tests. Reformat code. Update docs.

Original pull request: #361.
2018-11-23 12:01:56 +01:00
Dominys
724579b8a9 DATAREDIS-873 - Accept single collection parameter in SetOperations diff/inter/union methods.
We now accept a single collection parameter containing keys for diff/inter/union and their …store methods. Note that diff requires a specific key order to denote the initial set to compare to.

Original pull request: #361.
2018-11-23 12:01:46 +01:00
Mark Paluch
6921ab01bf DATAREDIS-890 - Polishing.
Add author tags. Use try-with-resources to close Jedis.

Original pull request: #373.
2018-11-23 10:18:00 +01:00
ChenGuanqun
9d47c48e22 DATAREDIS-890 - Randomize Redis Cluster node order before topology retrieval.
We now shuffle the set of Redis Cluster nodes before retrieving the topology. This change reduces load on the first node in the known nodes set.

Original pull request: #373.
2018-11-23 10:18:00 +01:00
Christoph Strobl
dc0ce19cd0 DATAREDIS-864 - Polishing.
Update Javadoc, remove unused code and fix some warnings.

Original Pull Request: #356
2018-11-22 10:50:09 +01:00
Mark Paluch
8858e0f1be DATAREDIS-864 - Leave XREAD COUNT unconfigured if not configured through builder.
XREAD does no longer apply a COUNT if the count was left unconfigured on StreamReadOperationsBuilder. This removes the limitation of batch size 1 and allows generally an increased throughput in default configuration.

Original Pull Request: #356
2018-11-22 10:49:27 +01:00
Mark Paluch
eafcb331d8 DATAREDIS-864 - Polishing.
Exract nested Stream types into connection.stream package. Extract common code from Template-API based toObjectRecord handling into StreamObjectMapper.

StreamReceiver and StreamMessageListenerContainer now can emit MapRecord or ObjectRecord for easier consumption of stream records.

Original Pull Request: #356
2018-11-22 10:49:06 +01:00
Christoph Strobl
13648d7c85 DATAREDIS-864 - Allow simple types to be added to Redis Stream.
Move API so the stream is more like the hash having dedicated serializers for fields and their values. Also allow appending simple types such as string directly to a stream without having to go through creating a Map. Those simple types can also be read back.
Provide means to hash complex objects when added to the stream.

Update Documentation.

Original Pull Request: #356
2018-11-22 10:48:16 +01:00
Mark Paluch
65754623f6 DATAREDIS-864 - Add support for Redis Streams.
We now support Redis Streams to add, read and consume stream records. We introduced StreamOperations, BoundStreamOperations, and ReactiveStreamOperations to interact with Redis Streams using imperative and reactive programming models. Record represents items within a stream. There are various flavors of Stream Records:

* MapRecord (maps to the hash body used in stream messages).
* Binary MapRecord: byte[] and ByteBuffer variants of MapRecord.
* ObjectRecord: Simple and Complex Objects mapped onto the stream body hash using ObjectHashMapper.

Redis Streams are supported for the Lettuce client only as Jedis has not received yet Redis Stream support.

Messages can be created as Map or as object:

redisTemplate.opsForStream().add("my-stream", Collections.singletonMap("key", "value"));

redisTemplate.opsForStream().add(ObjectRecord.create("my-logins", new LoginEvent(…)));

Streams can be consumed by using a StreamMessageListenerContainer that allows for stream subscriptions or a StreamReceiver.

Synchronous Message Listener:

StreamMessageListenerContainer<String, MapRecord<String, String, String>> container = StreamMessageListenerContainer
      .create(connectionFactory);
container.start();

Subscription subscription = container.receive(StreamOffset.fromStart("my-stream"), record -> … );

Reactive Message Receiver:

StreamReceiverOptions<String, ObjectRecord<String, LoginEvent>> receiverOptions = StreamReceiverOptions.builder()
      .targetType(LoginEvent.class).build();

StreamReceiver<String, ObjectRecord<String, LoginEvent>> receiver = StreamReceiver.create(connectionFactory, receiverOptions);

Flux<ObjectRecord<String, LoginEvent>> messages = receiver.receive(StreamOffset.fromStart("my-logins"));

Original Pull Request: #356
2018-11-22 10:46:21 +01:00
Mark Paluch
910e34067b DATAREDIS-875 - Polishing.
Reformat code.

Original pull request: #368.
2018-10-25 14:54:31 +02:00
Christoph Strobl
713a12bce9 DATAREDIS-875 - Omit MappingRedisConverter type hint for primitive type properties.
We now additionally check if the target property is a primitive type and do no longer add the type hint if so.

Original pull request: #368.
2018-10-25 14:53:34 +02:00
Mark Paluch
acd8b6bd4a DATAREDIS-872 - Polishing.
Create unit tests for RedisAtomic counter initialization. Refactor setIfAbsent(…) method to initializeIfAbsent() to not expose additional API methods.

Original pull request: #367.
2018-10-19 12:30:03 +02:00
ningwei
2d4fbc9aa0 DATAREDIS-872 - Fix race condition in RedisAtomic counters initialization.
We now use setIfAbsent to initialize RedisAtomic counters if no initial value was given. Using setIfAbsent turns the initialization into a single atomic step that prevents race conditions of the previously check and set method that required two Redis commands.

Previously, concurrent processes (threads, external changes to Redis) could set the initial value between the existence check and the value set operation that caused the last participant to win.

Original pull request: #367.
2018-10-19 12:27:33 +02:00
Mark Paluch
6132799353 DATAREDIS-881 - Polishing.
Add author tags. Reformat code. Javadoc, add tests.

Original pull request: #363.
2018-10-16 15:02:42 +02:00
Yanming Zhou
8e8861cbcd DATAREDIS-881 - Allow configuration of Lettuce's quiet shutdown period.
LettuceClientConfigurationBuilder now allows configuration of the quiet shutdown period to improve shutdown time of the Netty EventLoop when using non-shared ClientResources.

Original pull request: #363.
2018-10-16 15:00:32 +02:00
Mark Paluch
148b1ae582 DATAREDIS-874 - Polishing.
Reformat code. Add since tags. Extend tests.

Align Javadoc tonality across RedisAtomic… types.

Original pull request: #362.
2018-10-16 12:08:07 +02:00
Graham MacMaster
f2107ef81b DATAREDIS-874 - Implement accumulate/update methods on RedisAtomic[*] classes.
This commit adds the following public methods to RedisAtomicInteger,
RedisAtomicLong, and RedisAtomicDouble:

T accumulateAndGet(T updateValue, BinaryOperator<T> accumulatorFunction);
T getAndAccumulate(T updateValue, BinaryOperator<T> accumulatorFunction);
T updateAndGet(UnaryOperator<T> updateFunction);
T getAndUpdate(UnaryOperator<T> updateFunction);

These methods are primarily useful for doing CAS operations with the
help of Binary/UnaryOperators to generate the new value. They mirror
their counterparts on the AtomicInteger and AtomicLong classes
available in the java.util.concurrent.atomic package.

Original pull request: #362.
2018-10-16 12:08:07 +02:00
Christoph Strobl
45cbb21849 DATAREDIS-869 - Polishing.
Rename parameters and add methods with new nomenclature.

Original Pull Request: #355
2018-09-20 10:49:20 +02:00
Mark Paluch
169b1bd174 DATAREDIS-869 - Adapt to nomenclature change about Master/Replica.
We now renamed RedisStaticMasterSlaveConfiguration and StaticMasterSlaveConnectionProvider to RedisStaticMasterReplicaConfiguration respective StaticMasterReplicaConnectionProvider to reflect changes in Redis nomenclature regarding replication.

Original Pull Request: #355
2018-09-20 10:48:46 +02:00
Mark Paluch
eff0d29723 DATAREDIS-852 - Polishing.
Refactor lower/upper bound retrieval into LettuceConverters for a consistent lower/upper boundary return value. Use minus one (-1) as the upper bound index to always retrieve the last element if the upper boundary is not bounded.

Original pull request: #353.
2018-07-24 15:26:04 +02:00
michele
3a7d871119 DATAREDIS-852 - Return always a lower/upper bound range index using Range.Bound.unbounded() with Lettuce.
We now return in List, String, and ZSet commands a lower/upper bound range index to prevent NullPointerException. Previously, unbounded ranges could render null values that were attempted to cast to primitives.

Original pull request: #353.
2018-07-24 15:24:34 +02:00
Christoph Strobl
2dfe1e2b4e DATAREDIS-843 - Polishing.
Remove usage of deprecated methods, enable ignored test and move to AssertJ.

Original Pull Request: #349
2018-07-12 11:02:03 +02:00
Mark Paluch
a0d8b3a4c6 DATAREDIS-843 - Polishing.
Remove unnecessary unboxing and final keywords from arguments in method signatures.

Original Pull Request: #349
2018-07-12 11:02:03 +02:00
Mark Paluch
191244b1a4 DATAREDIS-843 - Adapt compare-and-set to changed transaction rollback response.
We now consider a transactional rollback that returns an empty EXEC result as rollback for the CAS (compare-and-set) operation. Previously, we checked only that the response of EXEC is not null. A rollback returns an empty list which was previously considered a successful CAS operation.

The code for CAS is now extracted to CompareAndSet and is reused from RedisAtomic implementations.

Original Pull Request: #349
2018-07-12 11:02:03 +02:00
Mark Paluch
322cfabb17 DATAREDIS-849 - Add support for immutable objects.
We now support immutable objects for saving (e.g. object without a provided Id) and loading (i.e. persistence constructor declares a subset of properties). New instances are created using wither methods/Kotlin copy(…) methods if an immutable object requires association with an Id.

Association of the Id to its object moved from RedisKeyValueAdapter to RedisKeyValueTemplate.
2018-07-12 10:44:33 +02:00
jsajadi
3defab118e DATAREDIS-850 - Fix assertion for expireTimeout in ReactiveStringCommands.pSetEx(…).
We now correctly assert the expireTimeout parameter.

Original pull request: #351.
2018-07-09 09:41:29 +02:00
Christoph Strobl
9e74556f74 DATAREDIS-696 - Add support for REPLACE option to RESTORE.
We bypass the lack of driver support by directly executing a custom command.

Original pull request: #344.
2018-07-02 11:44:18 +02:00
Christoph Strobl
caeaab508f DATAREDIS-840 - Polishing.
Introduce dedicated Subscription.close() to unsubscribe() and punsubscribe().

Original Pull Request: #346
2018-06-12 10:34:42 +02:00
Mark Paluch
c9e1803c3a DATAREDIS-840 - Polishing.
Fix code comment. Reformat code.

Original Pull Request: #346
2018-06-12 10:24:48 +02:00
Mark Paluch
bb1dd8b379 DATAREDIS-840 - Catch unsubscribe exceptions when stopping RedisMessageListenerContainer.
We now catch exceptions that may occur during unsubscription from the subscribed patterns/channels.
Previously, RuntimeExceptions were not caught and prevented a fast shutdown of the ApplicationContext.

Original Pull Request: #346
2018-06-12 10:24:08 +02:00
Mark Paluch
afd8606e19 DATAREDIS-842 - Polishing.
Reformat code. Add author tags. Add integration test.

Original pull request: #345.
2018-06-06 12:27:12 +02:00
Ruben Cervilla
e61beb441f DATAREDIS-842 - Consider database index when connecting to Redis using Redis Sentinel.
Original pull request: #345.
2018-06-06 12:23:16 +02:00
Mark Paluch
86606be850 DATAREDIS-771 - Polishing.
Improve error message for unsupported PartTree keywords.

Original Pull Request: #342
2018-05-23 11:15:11 +02:00