Commit Graph

794 Commits

Author SHA1 Message Date
Mark Paluch
e4446697cd DATAREDIS-955 - Polishing.
Eliminate warnings. Formatting. Remove test without assertions.

Original pull request: #452.
2019-05-21 14:38:34 +02:00
Christoph Strobl
db2e3bcae6 DATAREDIS-955 - Fix collection initialization when reading nested structures with same name.
We now make sure to not falsely populate instances with null values from nested structures.

Original pull request: #452.
2019-05-21 14:38:23 +02:00
Mark Paluch
f13056c385 DATAREDIS-981 - Fix conversion of unlimited Limit objects for Lettuce.
We now use the proper Limit.unlimited() factory method for unlimited Limits.
2019-05-13 10:03:11 +02:00
Mark Paluch
e0a059f96b DATAREDIS-972 - Polishing.
Add author tags. Reformat code. Split test for exceptions into two methods.

Original pull request: #448.
2019-04-29 12:19:15 +02:00
Oscar Cai
051b1ee820 DATAREDIS-972 - Fix validation for RedisCommand argument count.
Original pull request: #448.
2019-04-29 12:18:35 +02:00
Mark Paluch
647cf25d2b DATAREDIS-956 - Polishing.
Add author tags. Provide override for clientName(…) in LettucePoolingClientConfigurationBuilder. Extend Javadoc. Add and simplify tests.

Original pull request: #446.
2019-04-18 11:41:02 +02:00
longlong.zhao
e3b903ce36 DATAREDIS-956 - Add readFrom(…) override to LettucePoolingClientConfigurationBuilder.
Original pull request: #446.
2019-04-18 11:38:30 +02:00
Mark Paluch
f2a0623d6e DATAREDIS-971 - Polishing.
Add test. Use primitive types instead of wrappers for signed flag. Add author tag.

Original pull request: #447.
2019-04-17 15:33:02 +02:00
Mark Paluch
5cd8bb8e27 DATAREDIS-953 - Release connection after failed validation only once.
We now release a connection after a failed validation only once. Previously, a connection was released twice which caused a failure if the connection was obtained from a pool.

Original Pull Request: #445
2019-03-27 10:38:57 +01:00
Mark Paluch
138198fd0f DATAREDIS-950 - Fix ClassCastException on shared Lettuce Cluster connection validation.
Original Pull Request: #445
2019-03-27 10:30:13 +01:00
Christoph Strobl
70cb773afe DATAREDIS-925 - Add and register binary read/write converter for UUID.
Original pull request: #444.
2019-03-27 09:22:02 +01:00
Mark Paluch
34bcd46620 DATAREDIS-794 - Improve Jedis Cluster Topology caching.
We now made JedisClusterTopologyProvider public and configurable through overriding JedisConnectionFactory.createTopologyProvider(…).

The topology provider accepts a configurable timeout to configure the cache timeout. Alternatively, custom ClusterTopologyProvider implementations can be returned through JedisConnectionFactory.createTopologyProvider(…).

Original Pull Request: #383
2019-03-26 13:47:48 +01:00
Christoph Strobl
a0e3dca1e4 DATAREDIS-949 - Polishing.
Favor AssertJ over Hamcrest.

Original Pull Request: #417
2019-03-26 09:52:07 +01:00
Mark Paluch
50818fbb32 DATAREDIS-949 - Consider max-redirects using Lettuce.
LettuceConnectionFactory now considers the maximal redirection limit for Redis Cluster redirections.

Previously, the max-redirects limit was not configured in Lettuce.

Original Pull Request: #417
2019-03-26 09:51:40 +01:00
Spring Operator
2eb7067e8c DATAREDIS-948 - URL Cleanup.
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener).

# Fixed URLs

## Fixed Success
These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended.

* [ ] http://www.apache.org/licenses/ with 1 occurrences migrated to:
  https://www.apache.org/licenses/ ([https](https://www.apache.org/licenses/) result 200).
* [ ] http://www.apache.org/licenses/LICENSE-2.0 with 763 occurrences migrated to:
  https://www.apache.org/licenses/LICENSE-2.0 ([https](https://www.apache.org/licenses/LICENSE-2.0) result 200).

Original Pull Request: #442
2019-03-22 10:22:27 +01:00
Oliver Drotbohm
77f6582aee DATAREDIS-944 - Move off deprecations in Spring Data Commons.
Related ticket: DATACMNS-1496.
2019-03-14 14:19:54 +01:00
Christoph Strobl
0a4d6222e6 DATAREDIS-888 - Polishing
Original Pull Request: #384
2019-02-28 11:31:54 +01:00
Mark Paluch
22fdaba350 DATAREDIS-888 - Use Lettuce's read-only Partition view for node conversion.
We now use the read-only view of Lettuce's Partition object to convert Lettuce RedisClusterNode objects into Spring Data RedisClusterNode. The read-only view is atomic and does not require external synchronization.

Original Pull Request: #384
2019-02-28 11:31:32 +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
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
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
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
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
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
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
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
5688d56eab DATAREDIS-708 - Move BGREWRITEAOF and BGSAVE tests to unit tests.
Run tests against Lettuce connection mocks to not interfere with running Redis background processes.

Original Pull Request: #347
2018-08-28 09:57:54 +02:00
Mark Paluch
c6ecd4603d DATAREDIS-843 - Polishing.
Improve test stability to not concurrently create atomic counter instances.
2018-07-24 16:25:50 +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
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