Commit Graph

456 Commits

Author SHA1 Message Date
Mark Paluch
36f680ff5b DATAREDIS-481 - Polishing.
Reduce visibility of DefaultRedisCacheWriter as trivial implementation. Replace ConnectionCallback with Java 8 functions. Increase visibility of the RedisCache constructor to allow subclassing. Move factory methods to create DefaultRedisCacheWriter to RedisCacheWriter interface.

Refactor RedisCacheManagerConfigurator to stateful RedisCacheManagerBuilder. Remove RedisCache.setTransactionAware override in RedisCacheManagerConfigurator removing behavior not compliant with AbstractTransactionSupportingCacheManager. Terminate interrupted cache wait loop with exception. Javadoc, formatting, reorder methods.

Allow ConversionService configuration via RedisCacheConfiguration. Accept cache keys that are either convertible to String or that override toString to obtain the String representation of the cache key.

Original pull request: #252.
2017-07-13 10:08:46 +02:00
Christoph Strobl
a9c2b1cdda DATAREDIS-481 - Revise RedisCache.
RedisCache now operates directly with RedisConnectionFactory allowing each Cache to use its own SerializationPair for cache key and value conversion.

A RedisCacheManager with default settings is created with RedisCacheManager.create(connectionFactory). Use RedisCacheManager.builder(…) to obtain a builder to customize cache settings.

RedisCacheManager cm = RedisCacheManager.builder(connectionFactory)
  .cacheDefaults(defaultCacheConfig())
  .initialCacheConfigurations(singletonMap("predefined", defaultCacheConfig().disableCachingNullValues()))
  .transactionAware()
  .build();

The behavior of a single RedisCache is defined via its RedisCacheConfiguration. Starting from defaultCacheConfig() the configuration can be altered as needed.

RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig()
  .entryTtl(Duration.ofSeconds(1))
  .disableCachingNullValues();

RedisCacheManager defaults to a lock-free RedisCacheWriter for reading & writing binary values. Lock-free caching improves throughput. The lack of entry locking can lead to overlapping, non atomic commands, for putIfAbsent and clean methods as those require multiple commands sent to Redis. The locking counterpart prevents command overlap by setting an explicit lock key and checking against presence of this key, which leads to additional requests and potential command wait times.

Original pull request: #252.
2017-07-13 10:08:36 +02:00
Christoph Strobl
eb3ad1e351 DATAREDIS-659 - Polishing.
Update JavaDoc and assert nullability contract.
Use slowlog-max-len in tests instead of maxclients avoiding potential ulimit errors.

Original Pull Request: #253
2017-07-07 14:22:51 +02:00
Mark Paluch
4c88fe1794 DATAREDIS-659 - Polishing.
Replace anonymous inner classes with lambdas. Reformat.

Original Pull Request: #253
2017-07-07 14:22:37 +02:00
Mark Paluch
1f2610ba91 DATAREDIS-659 - Provide ReactiveServerCommands for basic server interaction.
Original Pull Request: #253
2017-07-07 14:22:17 +02:00
Mark Paluch
772d412ba8 DATAREDIS-660 - Adapt to API changes in mapping subsystem. 2017-07-04 14:34:47 +02:00
Mark Paluch
3185173805 DATAREDIS-656 - Reduce default LettuceConnectionFactory shutdown timeout to 100ms.
Reducing the default to 100 milliseconds is a good compromise to retain a quiet time in for parallel execution and optimize for default, single-threaded execution (such as test execution or regular application shutdown). The shutdown timeout can be adjusted to fit specific application needs.

Previously, LettuceConnectionFactory used different defaults: 2 seconds if used LettuceClientConfiguration and 60 seconds without LettuceClientConfiguration. In any case, defaults delay shutdown and cause severe delays in total. The driver default of two seconds provides enough time to complete long-running tasks before the actual thread pool shutdown.

Original Pull Request: #251
2017-06-20 14:45:07 +02:00
Christoph Strobl
5755ee392d DATAREDIS-647 - Polishing.
Use List#toArray(T[] a) instead of Collection#stream().toArray().

Original Pull Request: #250
2017-06-12 14:18:23 +02:00
Mark Paluch
78e5b89d1b DATAREDIS-647 - Correct SDIFF & SINTER behavior.
We now consider the last key in SDIFF command execution on Redis Cluster to correctly compute the set difference. 
For reactive connections we collect the result sets entirely before applying further computation. Previously, the zip function could return a previous view of the result that caused too many/too few results.

Original Pull Request: #250
2017-06-12 14:08:01 +02:00
Mark Paluch
95768983b6 DATAREDIS-645 - Polishing.
Migrate LettuceReactiveStringCommandsTests to StepVerifier and replace Collection.stream().toArray(…) with Collection.toArray(…).

Original Pull Request: #249
2017-06-12 13:26:03 +02:00
Mark Paluch
d6ea867e37 DATAREDIS-645 - Introduce absent values in ReactiveStringCommands.
We now return AbsentByteBufferResponse to indicate absence of a Redis key when retrieving the key as top-level element. CommandResponse indicates via isPresent its presence or absence of a response value. Omission of absent values can cause a stream with a different response structure compared to the request. Retaining the stream sequence is required for response to request correlation.

GET and GETSET commands use presence of CommandResponse to filter response emission. Both commands return a single element so absence does not interferes with the request structure.

Previously, we just returned an empty byte-array that caused downstream errors deserializing and emitting null values that are prohibited in Reactive Streams.

Original Pull Request: #249
2017-06-12 13:04:13 +02:00
Christoph Strobl
5f9cb22ad5 DATAREDIS-574 - Polishing.
Updated reference Documentation, JavaDoc and add some minor code changes (rename methods, fix return types, diamond  operators,…).

Original Pull Request: #236
2017-06-08 10:55:12 +02:00
Mark Paluch
3819ded01c DATAREDIS-574 - Introduce RedisPassword value object.
Encapsulate Redis passwords within a GC-friendly container that allows mapping and consumption in a functional style.

Original Pull Request: #236
2017-06-08 10:54:21 +02:00
Mark Paluch
a403a530d3 DATAREDIS-574 - Introduce dedicated RedisClientConfiguration for Jedis & Lettuce.
We added Jedis-/LettuceClientConfiguration and mutable Jedis-/LettuceClientConfiguration to encapsulate Jedis/Lettuce specific client features. Those should be used for ConnectionFactory configuration.

Additionally we added RedisStandaloneConfiguration next to the existing configurations for Sentinel and Cluster.

Along the way we also removed superfluous test system properties and Gemfire specific hooks and truststore customization.

Original Pull Request: #236
2017-06-08 10:53:04 +02:00
Christoph Strobl
00c433c74f DATAREDIS-640 - Adapt to API changes in repository interfaces.
We now follow a more consistent naming scheme for the methods in repository that are driven by the following guidelines:

* Methods referring to an identifier now all end on …ById(…).
* Methods taking or returning a collection are named …All(…)

Please see DATACMNS-944 for details.
2017-05-03 18:05:01 +02:00
Mark Paluch
1216134ce2 DATAREDIS-637 - Shut down connection-exclusive ClusterCommandExecutor.
We now shut down ClusterCommandExecutor via LettuceClusterConnection and JedisClusterConnection if the ClusterCommandExecutor was created through the connection instance. In such case ClusterCommandExecutor is managed through Lettuce/JedisClusterConnection and disposed on connection close.

Previously ClusterCommandExecutor created through a ClusterConnection was not disposed.

Original pull request: #247.
2017-05-03 14:23:20 +02:00
Mark Paluch
4e2fb1b7a0 DATAREDIS-626 - Polishing.
Refactor server and scripting commands to their own implementations and interfaces.

Fix JavaDoc indentations. Fix typos. Replace explicit type arguments with diamond syntax. Replace anonymous inner classes with method references and lambdas, where possible. Use shared ClientResources with LettuceConnectionFactory tests.

Align reactive command implementation visibility with blocking command implementation visibility to package-protected. These implementations are not an extension point and subject to be used through their interfaces.

Original pull request: #247.
2017-05-03 14:23:13 +02:00
Christoph Strobl
c636400104 DATAREDIS-626 - Refactor RedisConnection implementations to Redis feature-specific interfaces.
We refactored JedisConnection and LettuceConnection from monolithic connection classes into modular classes that organize methods according the Redis feature group and created segregated interfaces per Redis feature group. Segregated interfaces reduce the number of methods available on the interface to the used data type. This refactoring reduces the responsibility of JedisConnection/LettuceConnection and JedisClusterConnection/LettuceClusterConnection to a minimum of commands.

To preserve backwards-compatibility with users of the connection classes, we introduced DefaultedRedisConnection and DefaultedRedisClusterConnection to forward calls from the connection facade to the specific implementation. Deprecation of connection facade method assists migration off these methods towards using methods on the feature group interface.

LettuceConnection connection = …

connection.keyCommands().del(key);

connection.hashCommands().hSet(key, field, value);

Original pull request: #247.
2017-05-03 14:23:01 +02:00
Mark Paluch
016af63dd4 DATAREDIS-636 - Adapt to Range API changes.
Related ticket: DATACMNS-1050.
2017-04-26 18:21:24 +02:00
Mark Paluch
cd789f9722 DATAREDIS-634 - Adapt to moved CustomConversions to Spring Data Commons.
Introduce RedisCustomConversions extending o.s.d.convert.CustomConversions.

Remove o.s.d.mongo.core.convert.CustomConversions implementation code and utility classes and let it extend RedisCustomConversions. Replace references to o.s.d.r.c.c.CustomConversions with o.s.d.convert.CustomConversions. Adapt tests.

Introduce constructors for ObjectHashMapper and RedisKeyValueAdapter requiring o.s.d.convert.CustomConversions and deprecate constructors accepting o.s.d.r.c.c.CustomConversions.

Related ticket: DATACMNS-1035.
2017-04-24 14:50:38 +02:00
Mark Paluch
be74bbebde DATAREDIS-633 - Adapt to renamed KeyValueQuery.getCriteria() method.
Original Pull Request: #246
2017-04-24 10:38:28 +02:00
Mark Paluch
eeac253c06 DATAREDIS-629 - Adopt changed Mono and Flux error handling API.
Replace Flux/Mono.onErrorResumeWith(…) with Flux/Mono.onErrorMap(…) and turn translateException into a method returning a mapping function instead of a reactive type emitting the mapped exception. Replace otherwiseIfEmpty(…) with switchIfEmpty(…) and otherwiseReturn(…) with onErrorReturn(…).
2017-04-19 15:33:15 +02:00
Mark Paluch
31e0c39c41 DATAREDIS-613 - Polishing.
Simplify next().flatMapMany(…) to flatMap(…).

Original pull request: #244.
2017-04-13 10:32:47 +02:00
Christoph Strobl
42c87e24f9 DATAREDIS-613 - Stream results instead of returning collections where possible.
Allow streaming where possible without breaking Redis API contract. This means we keep the list collection for those operations potentially returning NULL to indicate a value is not present but was requested (eg MGET).

Additionally remove the Spring 4 related travis builds.

Original pull request: #244.
2017-04-13 10:32:16 +02:00
Christoph Strobl
87d6aa2042 DATAREDIS-624 - Upgrade to Lettuce 5.0.0.BUILD-SNAPSHOT.
Upgrade to Lettuce using Reactor 3.1.0.BUILD-SNAPSHOT, requires change to io.lettuce:lettuce-core, so we also needed to change imports from com.lambdaworks.redis to io.lettuce.core.

Original pull request: #245.
2017-04-12 14:32:41 +02:00
Christoph Strobl
2c14460643 DATAREDIS-624 - Upgrade to Reactor 3.1.0.BUILD-SNAPSHOT.
Translate `Mono.then` -> `flatMap`, `Mono.flatMap` -> `flatMapMany`.
This still fails as we also need a compatible version of lettuce.

Original pull request: #245.
2017-04-12 14:32:18 +02:00
Christoph Strobl
07984271d8 DATAREDIS-602 - Polishing.
Remove mutable state from `ReactiveRedisTemplate`.
Set up required args constructors for passing `RedisSerializationContext` and `ConnectionFactory` while removing `InitializingBean` and `ClassLoaderAware` interfaces forcing the template to hold mutable state.
Introduced some tiny static helpers for creating `RedisSerializationContext` from Serializers and added defaulting.

Moving forward `RedisTemplate` should also be migrated to using the SerializationContext getting rid of mutable state.

Additionally some minor renames, JavaDoc updates and refactored methods to lambda style.

Original Pull Request: #239
2017-04-03 18:32:48 +02:00
Mark Paluch
81657c530b DATAREDIS-602 - Provide Reactive Redis Template.
Add ReactiveRedisTemplate, add tests abd add SerializerFunction and DeserializerFunction for functional Redis argument serialization.

Introduce ReactiveRedisConnectionFactory and remove reactive RedisConnectionFactory methods to break the dependency to reactive types. We now no longer require Project Reactor for blocking Redis use. ReactiveRedisTemplate accepts ReactiveRedisConnectionFactory to operate on a reactive connection. The only implementation of ReactiveRedisConnectionFactory is LettuceConnectionFactory which requires by default Project Reactor.

Original Pull Request: #239
2017-04-03 18:30:48 +02:00
Mark Paluch
bf1a7ac8a3 DATAREDIS-618 - Polishing.
Remove superfluous line breaks and trailing whitespaces. Create dedicated tests for RedisServer.

Original pull request: #241.
2017-03-31 11:11:11 +02:00
Franjo Zilic
f377d2c35d DATAREDIS-618 - Read number of sentinels via RedisServer from num-other-sentinels.
We now read values for NUMBER_OTHER_SENTINELS to using num-other-sentinels. Previously, the property key was multi.

Original pull request: #241.
2017-03-31 10:58:43 +02:00
Christoph Strobl
d772c9dac4 DATAREDIS-595 - Adapt to API changes in Spring Data Commons. 2017-03-24 10:14:23 +01:00
Christoph Strobl
00b4009553 DATAREDIS-595 - Integrate DATACMNS Java 8 upgrade.
Integrate DATACMNS-867 and DATAKV-159 branches.
2017-03-24 10:14:06 +01:00
Christoph Strobl
f8eb3134e2 DATAREDIS-617 - Remove dependency to org.codehaus.jackson.
Remove already deprecated jackson 1 dependency and related RedisSerializer / HashMapper implementations.

Original pull request: #240.
2017-03-13 09:47:44 +01:00
Christoph Strobl
b749ae0c9c DATAREDIS-599 - Remove references to single-argument assertion methods of Spring. 2017-02-01 15:04:27 +01:00
Mark Paluch
35bc928fc7 DATAREDIS-593 - Use Enum.name() to represent enum values.
We now serialize Enum values using their name (Enum.name()) instead of using their string representation (Enum.toString()). toString can be customized in Enums to no longer report their name but a different value. A customized value cannot be used to reinstantiate the Enum value, only its name.

This change affects serialization and will only affect new/updated values. Stored values with a customized toString representation still can't be deserialized until they were updated in Redis.

Original Pull Request: #235
2017-01-20 11:30:47 +01:00
Mark Paluch
d3a0c34904 DATAREDIS-592 - Consider expiry timeout in synchronized RedisCache mode.
We now consider the element expiry when retrieving cache elements with a value loader. Previously, all cache elements that were cached using `@Cacheable(sync=true)` or used `RedisCache.get(Object, Callable)` directly were considered eternal without setting a TTL.

Original Pull Request: #234
2017-01-20 10:21:53 +01:00
Christoph Strobl
9b6ff3779c DATAREDIS-564 - Polishing.
Remove white spaces, update license header.
Add ticket reference to existing testcase.

Original Pull Request: #228
2017-01-13 10:29:55 +01:00
Mark Paluch
1fd9aadd70 DATAREDIS-564 - Delegate expire(…) to pExpire if timeout exceeds Integer.MAX_VALUE.
Remove pExpireAt workaround that can lead to NullPointerException if called within a transaction/pipeline. Calls to expire(…) with a timeout greater Integer.MAX_VALUE are delegated to pExpire converting seconds to milliseconds.

Related ticket: DATAREDIS-286.
Original Pull Request: #228
2017-01-13 10:29:44 +01:00
Mark Paluch
05809febb9 DATAREDIS-589 - Polishing.
Run expiry tests only when executing long-running tests. Guard RedisConnectionFactory against multiple initializations. Synchronize key expiry. Remove unused code. Extend years in license header.

Original pull request: #232.
2017-01-12 15:01:59 +01:00
Christoph Strobl
639b1e2b55 DATAREDIS-589 - Move secondary index cleanup to MappingExpirationListener.
We now no longer rely on ApplicationEvents captured in the RedisKeyValueAdapter for performing cleanup operations for expired keys, but do this along with the phantom key removal. This removes a flaw when initializing a non repository related KeyspaceEventListener publishing events that actually are unrelated to the Adapter.

Additionally upgraded test infrastructure to utilize Redis 3.2.6 with disabled protected-mode and enabled keyspace-events.

Original pull request: #232.
2017-01-12 14:52:59 +01:00
Mark Paluch
253c281205 DATAREDIS-532 - Enhance JavaDoc and convert links to Redis documentation.
Extend JavaDoc documentation for Command/Connection/Operation interfaces. Align method ordering in operation interfaces with connection/commands interfaces.
2017-01-12 14:52:59 +01:00
Mark Paluch
ceea66e17e DATAREDIS-563 - Migrate ticket references in test code to Spring Framework style.
Fix license headers by removing the dot after the year.
2017-01-12 14:52:53 +01:00
Oliver Gierke
f61bdfbcd6 DATAREDIS-583 - Adapt API in RedisRepositoryFactoryBean.
Related tickets: DATACMNS-891.
2016-12-15 16:24:34 +01:00
Mark Paluch
3788ad7235 DATAREDIS-552 - Polishing.
Apply client name to Sentinel and unpooled connections if set. Add ticket references to JavaDoc. Add tests. Fix existing JavaDoc letter casing and punctuation. Rearrange isClusterAware/isRedisSentinelAware methods.

Original pull request: #219.
2016-12-01 09:01:45 +01:00
Fu Jian
dbb3473d0d DATAREDIS-552 - Support client name configuration for JedisConnectionFactory.
Motivation:
JedisConnectionFactory should support setting clientName for Jedis connections
so to improve troubleshooting.

Result:
Easier to troubleshooting with connection name.

Original pull request: #219.
2016-12-01 09:01:45 +01:00
Mark Paluch
b172c237e4 DATAREDIS-525 - Polishing.
Enhance JavaDoc. Improve assertions. Reduce accepted collection-type boundary to Collection for commands that do not enforce a specific order. Add ByteUtil.getBytes(ByteBuffer) utility method. Reformat code. Extend documentation

Fix parameter ambiguity in LettuceConnection.watch().

Original pull request: #229.
2016-11-17 20:17:10 +01:00
Mark Paluch
62b1354e02 DATAREDIS-525 - Upgrade to lettuce 5.0.0.Beta1.
- Replace deprecated method usage by using newly introduced API.
- Improve converter names, remove unused code, fix generics.

Original pull request: #229.
2016-11-17 20:17:05 +01:00
Christoph Strobl
d257ae1074 DATAREDIS-525 - Add support for ReactiveRedisConnection & ReactiveRedisClusterConnection.
We introduced reactor based reactive connection support via ReactiveRedisConnection and ReactiveRedisClusterConnection.

A reactive connection can be obtained via the ConnectionFactory. This is currently only possible when using the Lettuce Redis driver.

Original pull request: #229.
2016-11-17 20:10:03 +01:00
Christoph Strobl
f6411b3811 DATAREDIS-567 - Remove Support for SRP and JRedis. 2016-11-07 15:34:12 +01:00
Mark Paluch
aa3c40780a DATAREDIS-528 - Polishing.
Extend date ranges in license headers. Add author tags. Update documentation.

Original pull request: #222.
2016-10-12 16:34:13 +02:00