From 7868b30ad2a11ebc1c62d78303ede70bd3a0c7a1 Mon Sep 17 00:00:00 2001 From: Nikita Date: Thu, 15 Feb 2018 07:37:06 +0300 Subject: [PATCH 01/18] [maven-release-plugin] prepare release redisson-2.11.1 --- pom.xml | 4 ++-- redisson-all/pom.xml | 4 ++-- redisson-tomcat/pom.xml | 2 +- redisson-tomcat/redisson-tomcat-6/pom.xml | 2 +- redisson-tomcat/redisson-tomcat-7/pom.xml | 2 +- redisson-tomcat/redisson-tomcat-8/pom.xml | 2 +- redisson-tomcat/redisson-tomcat-9/pom.xml | 2 +- redisson/pom.xml | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index e292de56b..055649712 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.redisson redisson-parent - 2.11.1-SNAPSHOT + 2.11.1 pom Redisson @@ -27,7 +27,7 @@ scm:git:git@github.com:redisson/redisson.git scm:git:git@github.com:redisson/redisson.git scm:git:git@github.com:redisson/redisson.git - HEAD + redisson-2.11.1 diff --git a/redisson-all/pom.xml b/redisson-all/pom.xml index bf33af98c..cd40d5699 100644 --- a/redisson-all/pom.xml +++ b/redisson-all/pom.xml @@ -4,7 +4,7 @@ org.redisson redisson-parent - 2.11.1-SNAPSHOT + 2.11.1 ../ @@ -26,7 +26,7 @@ scm:git:git@github.com:mrniko/redisson.git scm:git:git@github.com:mrniko/redisson.git scm:git:git@github.com:mrniko/redisson.git - redisson-parent-0.9.0 + redisson-2.11.1 diff --git a/redisson-tomcat/pom.xml b/redisson-tomcat/pom.xml index 7254cd562..3d7739f9a 100644 --- a/redisson-tomcat/pom.xml +++ b/redisson-tomcat/pom.xml @@ -4,7 +4,7 @@ org.redisson redisson-parent - 2.11.1-SNAPSHOT + 2.11.1 ../ diff --git a/redisson-tomcat/redisson-tomcat-6/pom.xml b/redisson-tomcat/redisson-tomcat-6/pom.xml index fb3233633..c94817376 100644 --- a/redisson-tomcat/redisson-tomcat-6/pom.xml +++ b/redisson-tomcat/redisson-tomcat-6/pom.xml @@ -4,7 +4,7 @@ org.redisson redisson-tomcat - 2.11.1-SNAPSHOT + 2.11.1 ../ diff --git a/redisson-tomcat/redisson-tomcat-7/pom.xml b/redisson-tomcat/redisson-tomcat-7/pom.xml index 28d71d5ed..69e0c73c3 100644 --- a/redisson-tomcat/redisson-tomcat-7/pom.xml +++ b/redisson-tomcat/redisson-tomcat-7/pom.xml @@ -4,7 +4,7 @@ org.redisson redisson-tomcat - 2.11.1-SNAPSHOT + 2.11.1 ../ diff --git a/redisson-tomcat/redisson-tomcat-8/pom.xml b/redisson-tomcat/redisson-tomcat-8/pom.xml index dd30c107c..eb8d6f2da 100644 --- a/redisson-tomcat/redisson-tomcat-8/pom.xml +++ b/redisson-tomcat/redisson-tomcat-8/pom.xml @@ -4,7 +4,7 @@ org.redisson redisson-tomcat - 2.11.1-SNAPSHOT + 2.11.1 ../ diff --git a/redisson-tomcat/redisson-tomcat-9/pom.xml b/redisson-tomcat/redisson-tomcat-9/pom.xml index 2a2d76742..c84b25679 100644 --- a/redisson-tomcat/redisson-tomcat-9/pom.xml +++ b/redisson-tomcat/redisson-tomcat-9/pom.xml @@ -4,7 +4,7 @@ org.redisson redisson-tomcat - 2.11.1-SNAPSHOT + 2.11.1 ../ diff --git a/redisson/pom.xml b/redisson/pom.xml index 0da109a92..2ddec67c7 100644 --- a/redisson/pom.xml +++ b/redisson/pom.xml @@ -4,7 +4,7 @@ org.redisson redisson-parent - 2.11.1-SNAPSHOT + 2.11.1 ../ From 7d6f768849262c529001a1963c943fd1fbc17259 Mon Sep 17 00:00:00 2001 From: Nikita Date: Thu, 15 Feb 2018 07:37:15 +0300 Subject: [PATCH 02/18] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- redisson-all/pom.xml | 4 ++-- redisson-tomcat/pom.xml | 2 +- redisson-tomcat/redisson-tomcat-6/pom.xml | 2 +- redisson-tomcat/redisson-tomcat-7/pom.xml | 2 +- redisson-tomcat/redisson-tomcat-8/pom.xml | 2 +- redisson-tomcat/redisson-tomcat-9/pom.xml | 2 +- redisson/pom.xml | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 055649712..ca4fa4d4f 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.redisson redisson-parent - 2.11.1 + 2.11.2-SNAPSHOT pom Redisson @@ -27,7 +27,7 @@ scm:git:git@github.com:redisson/redisson.git scm:git:git@github.com:redisson/redisson.git scm:git:git@github.com:redisson/redisson.git - redisson-2.11.1 + HEAD diff --git a/redisson-all/pom.xml b/redisson-all/pom.xml index cd40d5699..e490139f3 100644 --- a/redisson-all/pom.xml +++ b/redisson-all/pom.xml @@ -4,7 +4,7 @@ org.redisson redisson-parent - 2.11.1 + 2.11.2-SNAPSHOT ../ @@ -26,7 +26,7 @@ scm:git:git@github.com:mrniko/redisson.git scm:git:git@github.com:mrniko/redisson.git scm:git:git@github.com:mrniko/redisson.git - redisson-2.11.1 + redisson-parent-0.9.0 diff --git a/redisson-tomcat/pom.xml b/redisson-tomcat/pom.xml index 3d7739f9a..9d48e8f11 100644 --- a/redisson-tomcat/pom.xml +++ b/redisson-tomcat/pom.xml @@ -4,7 +4,7 @@ org.redisson redisson-parent - 2.11.1 + 2.11.2-SNAPSHOT ../ diff --git a/redisson-tomcat/redisson-tomcat-6/pom.xml b/redisson-tomcat/redisson-tomcat-6/pom.xml index c94817376..75e8ed28a 100644 --- a/redisson-tomcat/redisson-tomcat-6/pom.xml +++ b/redisson-tomcat/redisson-tomcat-6/pom.xml @@ -4,7 +4,7 @@ org.redisson redisson-tomcat - 2.11.1 + 2.11.2-SNAPSHOT ../ diff --git a/redisson-tomcat/redisson-tomcat-7/pom.xml b/redisson-tomcat/redisson-tomcat-7/pom.xml index 69e0c73c3..991a3cccc 100644 --- a/redisson-tomcat/redisson-tomcat-7/pom.xml +++ b/redisson-tomcat/redisson-tomcat-7/pom.xml @@ -4,7 +4,7 @@ org.redisson redisson-tomcat - 2.11.1 + 2.11.2-SNAPSHOT ../ diff --git a/redisson-tomcat/redisson-tomcat-8/pom.xml b/redisson-tomcat/redisson-tomcat-8/pom.xml index eb8d6f2da..1f4ca4f95 100644 --- a/redisson-tomcat/redisson-tomcat-8/pom.xml +++ b/redisson-tomcat/redisson-tomcat-8/pom.xml @@ -4,7 +4,7 @@ org.redisson redisson-tomcat - 2.11.1 + 2.11.2-SNAPSHOT ../ diff --git a/redisson-tomcat/redisson-tomcat-9/pom.xml b/redisson-tomcat/redisson-tomcat-9/pom.xml index c84b25679..dbf6b7d03 100644 --- a/redisson-tomcat/redisson-tomcat-9/pom.xml +++ b/redisson-tomcat/redisson-tomcat-9/pom.xml @@ -4,7 +4,7 @@ org.redisson redisson-tomcat - 2.11.1 + 2.11.2-SNAPSHOT ../ diff --git a/redisson/pom.xml b/redisson/pom.xml index 2ddec67c7..88906c8c0 100644 --- a/redisson/pom.xml +++ b/redisson/pom.xml @@ -4,7 +4,7 @@ org.redisson redisson-parent - 2.11.1 + 2.11.2-SNAPSHOT ../ From 95197e08fd60f6e68c020bb1230ea815bb5ca2d2 Mon Sep 17 00:00:00 2001 From: Nikita Date: Thu, 15 Feb 2018 10:53:37 +0300 Subject: [PATCH 03/18] refactoring --- .../org/redisson/spring/cache/RedissonCache.java | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/redisson/src/main/java/org/redisson/spring/cache/RedissonCache.java b/redisson/src/main/java/org/redisson/spring/cache/RedissonCache.java index 49a9d0282..8f9fbeb1a 100644 --- a/redisson/src/main/java/org/redisson/spring/cache/RedissonCache.java +++ b/redisson/src/main/java/org/redisson/spring/cache/RedissonCache.java @@ -16,7 +16,6 @@ package org.redisson.spring.cache; import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; @@ -47,10 +46,9 @@ public class RedissonCache implements Cache { private final AtomicLong misses = new AtomicLong(); public RedissonCache(RMapCache mapCache, CacheConfig config, boolean allowNullValues) { + this(mapCache, allowNullValues); this.mapCache = mapCache; - this.map = mapCache; this.config = config; - this.allowNullValues = allowNullValues; } public RedissonCache(RMap map, boolean allowNullValues) { @@ -98,11 +96,7 @@ public class RedissonCache implements Cache { @Override public void put(Object key, Object value) { if (!allowNullValues && value == null) { - if (mapCache != null) { - mapCache.remove(key); - } else { - map.remove(key); - } + map.remove(key); return; } @@ -117,11 +111,7 @@ public class RedissonCache implements Cache { public ValueWrapper putIfAbsent(Object key, Object value) { Object prevValue; if (!allowNullValues && value == null) { - if (mapCache != null) { - prevValue = mapCache.get(key); - } else { - prevValue = map.get(key); - } + prevValue = map.get(key); } else { value = toStoreValue(value); if (mapCache != null) { From a31bd33ab37f6304f37113856ae84669aa42fa31 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Thu, 15 Feb 2018 11:30:20 +0300 Subject: [PATCH 04/18] Update CHANGELOG.md --- CHANGELOG.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5dd9a670..a606a285a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,23 @@ Redisson Releases History Try __[Redisson PRO](https://redisson.pro)__ version. +### 15-Feb-2018 - versions 2.11.1 and 3.6.1 released + +Feature - `rangeTailReversed`, `rangeHeadReversed` and `rangeReversed` methods added to `RLexSortedSet` object +Feature - `RBucketsAsync` interface added +Feature - `scanInterval` setting added for Sentinel mode +Feature - `RLocalCachedMap.clearLocalCache` method added +Fixed - remove hset command invocation during entry loading +Fixed - buffer leak in `replace` and `remove` methods of `RLocalCachedMap` object +Fixed - `RRemoteService` object throws NPE +Fixed - Multimap cluster compatibility +Fixed - Enum support for Live Objects +Fixed - Jackson 2.9 compatibility +Fixed - `RTopic.removeAllListeners` got blocked on invocation +Fixed - possible pubsub listeners leak +Fixed - `RBatch` throws NPE with big pipeline in atomic mode +Fixed - Warning about `CommandDecoder.decode()` method + ### 29-Jan-2018 - versions 2.11.0 and 3.6.0 released Feature - __`atomic` setting added to RBatch object__ Please read [documentation](https://github.com/redisson/redisson/wiki/10.-additional-features#103-execution-batches-of-commands) for more details From 5a080f2d6aa50b3129f5427309cce7ad5a402fef Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Thu, 15 Feb 2018 11:33:50 +0300 Subject: [PATCH 05/18] Update README.md --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 69b580b35..ca8bf8e00 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ Based on high-performance async and lock-free Java Redis client and [Netty](http | Stable
Release Version | Release Date | JDK Version
compatibility | `CompletionStage`
support | `ProjectReactor` version
compatibility | | ------------- | ------------- | ------------| -----------| -----------| -| 3.6.0 | 29.01.2018 | 1.8+ | Yes | 3.1.x | -| 2.11.0 | 29.01.2018 | 1.6, 1.7, 1.8 and Android | No | 2.0.8 | +| 3.6.1 | 15.02.2018 | 1.8, 1.9+ | Yes | 3.1.x | +| 2.11.1 | 15.02.2018 | 1.6, 1.7, 1.8, 1.9 and Android | No | 2.0.8 | Features @@ -88,23 +88,23 @@ Quick start org.redisson redisson - 3.6.0 + 3.6.1 org.redisson redisson - 2.11.0 + 2.11.1 #### Gradle // JDK 1.8+ compatible - compile 'org.redisson:redisson:3.6.0' + compile 'org.redisson:redisson:3.6.1' // JDK 1.6+ compatible - compile 'org.redisson:redisson:2.11.0' + compile 'org.redisson:redisson:2.11.1' #### Java @@ -129,11 +129,11 @@ RExecutorService executor = redisson.getExecutorService("myExecutorService"); Downloads =============================== -[Redisson 3.6.0](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson&v=3.6.0&e=jar), -[Redisson node 3.6.0](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-all&v=3.6.0&e=jar) +[Redisson 3.6.1](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson&v=3.6.1&e=jar), +[Redisson node 3.6.1](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-all&v=3.6.1&e=jar) -[Redisson 2.11.0](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson&v=2.11.0&e=jar), -[Redisson node 2.11.0](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-all&v=2.11.0&e=jar) +[Redisson 2.11.1](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson&v=2.11.1&e=jar), +[Redisson node 2.11.1](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-all&v=2.11.1&e=jar) ### Supported by From 2f41394063b9b81fb9029875d1e9755f30ffb0b2 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Thu, 15 Feb 2018 11:35:57 +0300 Subject: [PATCH 06/18] Update README.md --- redisson-tomcat/README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/redisson-tomcat/README.md b/redisson-tomcat/README.md index d7b01ef6e..606b9571d 100644 --- a/redisson-tomcat/README.md +++ b/redisson-tomcat/README.md @@ -33,23 +33,23 @@ Usage **2** Copy two jars into `TOMCAT_BASE/lib` directory: 1. __For JDK 1.8+__ - [redisson-all-3.6.0.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-all&v=3.6.0&e=jar) + [redisson-all-3.6.1.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-all&v=3.6.1&e=jar) for Tomcat 6.x - [redisson-tomcat-6-3.6.0.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-6&v=3.6.0&e=jar) + [redisson-tomcat-6-3.6.1.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-6&v=3.6.1&e=jar) for Tomcat 7.x - [redisson-tomcat-7-3.6.0.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-7&v=3.6.0&e=jar) + [redisson-tomcat-7-3.6.1.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-7&v=3.6.1&e=jar) for Tomcat 8.x - [redisson-tomcat-8-3.6.0.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-8&v=3.6.0&e=jar) + [redisson-tomcat-8-3.6.1.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-8&v=3.6.1&e=jar) for Tomcat 9.x - [redisson-tomcat-9-3.6.0.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-9&v=3.6.0&e=jar) + [redisson-tomcat-9-3.6.1.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-9&v=3.6.1&e=jar) 2. __For JDK 1.6+__ - [redisson-all-2.11.0.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-all&v=2.11.0&e=jar) + [redisson-all-2.11.1.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-all&v=2.11.1&e=jar) for Tomcat 6.x - [redisson-tomcat-6-2.11.0.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-6&v=2.11.0&e=jar) + [redisson-tomcat-6-2.11.1.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-6&v=2.11.1&e=jar) for Tomcat 7.x - [redisson-tomcat-7-2.11.0.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-7&v=2.11.0&e=jar) + [redisson-tomcat-7-2.11.1.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-7&v=2.11.1&e=jar) From 2a1095b57d9780cc198ee3ab674e86c8c4dc5f2f Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Thu, 15 Feb 2018 12:21:54 +0300 Subject: [PATCH 07/18] Update README.md --- redisson-tomcat/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/redisson-tomcat/README.md b/redisson-tomcat/README.md index 606b9571d..ffa1abd70 100644 --- a/redisson-tomcat/README.md +++ b/redisson-tomcat/README.md @@ -51,5 +51,6 @@ Usage [redisson-tomcat-6-2.11.1.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-6&v=2.11.1&e=jar) for Tomcat 7.x [redisson-tomcat-7-2.11.1.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-7&v=2.11.1&e=jar) + [redisson-tomcat-8-2.11.1.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-8&v=2.11.1&e=jar) From ad6237cbbfa27d91b62ffe32b44434e199290cd4 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Thu, 15 Feb 2018 12:22:14 +0300 Subject: [PATCH 08/18] Update README.md --- redisson-tomcat/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/redisson-tomcat/README.md b/redisson-tomcat/README.md index ffa1abd70..102c7686e 100644 --- a/redisson-tomcat/README.md +++ b/redisson-tomcat/README.md @@ -51,6 +51,7 @@ Usage [redisson-tomcat-6-2.11.1.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-6&v=2.11.1&e=jar) for Tomcat 7.x [redisson-tomcat-7-2.11.1.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-7&v=2.11.1&e=jar) + for Tomcat 8.x [redisson-tomcat-8-2.11.1.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-8&v=2.11.1&e=jar) From e99b26fcde805d14b5a1e8502bb2a99fba00be39 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Thu, 15 Feb 2018 13:14:02 +0300 Subject: [PATCH 09/18] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a606a285a..f4ffa1f5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Try __[Redisson PRO](https://redisson.pro)__ version. ### 15-Feb-2018 - versions 2.11.1 and 3.6.1 released +Feature - `RedissonClusteredSpringLocalCachedCacheManager` added. Please read [documentation](https://github.com/redisson/redisson/wiki/14.-Integration-with-frameworks/#1421-spring-cache-local-cache-and-data-partitioning) for more details Feature - `rangeTailReversed`, `rangeHeadReversed` and `rangeReversed` methods added to `RLexSortedSet` object Feature - `RBucketsAsync` interface added Feature - `scanInterval` setting added for Sentinel mode From b8113a3b07cf81b1f25e919721b1147137dda88e Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Thu, 15 Feb 2018 13:14:14 +0300 Subject: [PATCH 10/18] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4ffa1f5f..3057077c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Try __[Redisson PRO](https://redisson.pro)__ version. ### 15-Feb-2018 - versions 2.11.1 and 3.6.1 released -Feature - `RedissonClusteredSpringLocalCachedCacheManager` added. Please read [documentation](https://github.com/redisson/redisson/wiki/14.-Integration-with-frameworks/#1421-spring-cache-local-cache-and-data-partitioning) for more details +Feature - `RedissonClusteredSpringLocalCachedCacheManager` added. Please read [documentation](https://github.com/redisson/redisson/wiki/14.-Integration-with-frameworks/#1421-spring-cache-local-cache-and-data-partitioning) for more details Feature - `rangeTailReversed`, `rangeHeadReversed` and `rangeReversed` methods added to `RLexSortedSet` object Feature - `RBucketsAsync` interface added Feature - `scanInterval` setting added for Sentinel mode From 6ed4e844fd2793e9ca637dd86873c90d068d9556 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Thu, 15 Feb 2018 15:08:27 +0300 Subject: [PATCH 11/18] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3057077c8..5dec73ac7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ Feature - `rangeTailReversed`, `rangeHeadReversed` and `rangeReversed` methods a Feature - `RBucketsAsync` interface added Feature - `scanInterval` setting added for Sentinel mode Feature - `RLocalCachedMap.clearLocalCache` method added -Fixed - remove hset command invocation during entry loading +Fixed - remove `hset` command invocation during `RMapCache` entry loading Fixed - buffer leak in `replace` and `remove` methods of `RLocalCachedMap` object Fixed - `RRemoteService` object throws NPE Fixed - Multimap cluster compatibility From a55562c672c8c50eab67d81bd5b18b81f6e664cd Mon Sep 17 00:00:00 2001 From: Nikita Date: Fri, 16 Feb 2018 07:33:50 +0300 Subject: [PATCH 12/18] UpdateMode.AFTER_REQUEST mode optimization. #1302 --- .../java/org/redisson/tomcat/RedissonSession.java | 9 ++++++--- .../redisson/tomcat/RedissonSessionManager.java | 13 ++++--------- .../java/org/redisson/tomcat/TomcatServer.java | 5 ++++- .../java/org/redisson/tomcat/RedissonSession.java | 10 +++++++--- .../redisson/tomcat/RedissonSessionManager.java | 15 +++++---------- .../java/org/redisson/tomcat/RedissonSession.java | 9 ++++++--- .../redisson/tomcat/RedissonSessionManager.java | 13 ++++--------- .../java/org/redisson/tomcat/RedissonSession.java | 9 ++++++--- .../redisson/tomcat/RedissonSessionManager.java | 13 ++++--------- 9 files changed, 46 insertions(+), 50 deletions(-) diff --git a/redisson-tomcat/redisson-tomcat-6/src/main/java/org/redisson/tomcat/RedissonSession.java b/redisson-tomcat/redisson-tomcat-6/src/main/java/org/redisson/tomcat/RedissonSession.java index 28ca6f373..b5ea0e153 100644 --- a/redisson-tomcat/redisson-tomcat-6/src/main/java/org/redisson/tomcat/RedissonSession.java +++ b/redisson-tomcat/redisson-tomcat-6/src/main/java/org/redisson/tomcat/RedissonSession.java @@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit; import org.apache.catalina.session.StandardSession; import org.redisson.api.RMap; import org.redisson.tomcat.RedissonSessionManager.ReadMode; +import org.redisson.tomcat.RedissonSessionManager.UpdateMode; /** * Redisson Session object for Apache Tomcat @@ -37,11 +38,13 @@ public class RedissonSession extends StandardSession { private final Map attrs; private RMap map; private final RedissonSessionManager.ReadMode readMode; + private final UpdateMode updateMode; - public RedissonSession(RedissonSessionManager manager, RedissonSessionManager.ReadMode readMode) { + public RedissonSession(RedissonSessionManager manager, ReadMode readMode, UpdateMode updateMode) { super(manager); this.redissonManager = manager; this.readMode = readMode; + this.updateMode = updateMode; try { Field attr = StandardSession.class.getDeclaredField("attributes"); @@ -144,7 +147,7 @@ public class RedissonSession extends StandardSession { public void setAttribute(String name, Object value, boolean notify) { super.setAttribute(name, value, notify); - if (map != null && value != null) { + if (updateMode == UpdateMode.DEFAULT && map != null && value != null) { map.fastPut(name, value); } } @@ -153,7 +156,7 @@ public class RedissonSession extends StandardSession { protected void removeAttributeInternal(String name, boolean notify) { super.removeAttributeInternal(name, notify); - if (map != null) { + if (updateMode == UpdateMode.DEFAULT && map != null) { map.fastRemove(name); } } diff --git a/redisson-tomcat/redisson-tomcat-6/src/main/java/org/redisson/tomcat/RedissonSessionManager.java b/redisson-tomcat/redisson-tomcat-6/src/main/java/org/redisson/tomcat/RedissonSessionManager.java index c7857430a..3211c9ffe 100644 --- a/redisson-tomcat/redisson-tomcat-6/src/main/java/org/redisson/tomcat/RedissonSessionManager.java +++ b/redisson-tomcat/redisson-tomcat-6/src/main/java/org/redisson/tomcat/RedissonSessionManager.java @@ -17,7 +17,6 @@ package org.redisson.tomcat; import java.io.File; import java.io.IOException; -import java.util.Enumeration; import java.util.Map; import javax.servlet.http.HttpSession; @@ -159,7 +158,7 @@ public class RedissonSessionManager extends ManagerBase implements Lifecycle { @Override public Session createEmptySession() { - return new RedissonSession(this, readMode); + return new RedissonSession(this, readMode, updateMode); } @Override @@ -218,18 +217,14 @@ public class RedissonSessionManager extends ManagerBase implements Lifecycle { lifecycle.fireLifecycleEvent(STOP_EVENT, null); } - public void store(HttpSession session) { + public void store(HttpSession session) throws IOException { if (session == null) { return; } if (updateMode == UpdateMode.AFTER_REQUEST) { - Enumeration names = session.getAttributeNames(); - while (names.hasMoreElements()) { - String name = names.nextElement(); - Object value = session.getAttribute(name); - session.setAttribute(name, value); - } + RedissonSession sess = (RedissonSession) findSession(session.getId()); + sess.save(); } } diff --git a/redisson-tomcat/redisson-tomcat-6/src/test/java/org/redisson/tomcat/TomcatServer.java b/redisson-tomcat/redisson-tomcat-6/src/test/java/org/redisson/tomcat/TomcatServer.java index 62c0525fb..c514aea2d 100644 --- a/redisson-tomcat/redisson-tomcat-6/src/test/java/org/redisson/tomcat/TomcatServer.java +++ b/redisson-tomcat/redisson-tomcat-6/src/test/java/org/redisson/tomcat/TomcatServer.java @@ -1,5 +1,7 @@ package org.redisson.tomcat; +import java.nio.file.Paths; + import org.apache.catalina.Engine; import org.apache.catalina.Host; import org.apache.catalina.LifecycleException; @@ -56,7 +58,8 @@ public class TomcatServer { localHost.setAutoDeploy(false); StandardContext rootContext = (StandardContext) server.createContext(contextPath, "webapp"); - rootContext.setDefaultWebXml("web.xml"); + String s = Paths.get("").toAbsolutePath().resolve("src/test/webapp/META-INF/context.xml").toString(); + rootContext.setDefaultContextXml(s); localHost.addChild(rootContext); Engine engine = server.createEngine(); diff --git a/redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSession.java b/redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSession.java index ef5d6b6fb..5850bd9b9 100644 --- a/redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSession.java +++ b/redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSession.java @@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit; import org.apache.catalina.session.StandardSession; import org.redisson.api.RMap; import org.redisson.tomcat.RedissonSessionManager.ReadMode; +import org.redisson.tomcat.RedissonSessionManager.UpdateMode; /** * Redisson Session object for Apache Tomcat @@ -37,11 +38,14 @@ public class RedissonSession extends StandardSession { private final Map attrs; private RMap map; private final RedissonSessionManager.ReadMode readMode; + private final UpdateMode updateMode; - public RedissonSession(RedissonSessionManager manager, RedissonSessionManager.ReadMode readMode) { + public RedissonSession(RedissonSessionManager manager, ReadMode readMode, UpdateMode updateMode) { super(manager); this.redissonManager = manager; this.readMode = readMode; + this.updateMode = updateMode; + try { Field attr = StandardSession.class.getDeclaredField("attributes"); attrs = (Map) attr.get(this); @@ -148,7 +152,7 @@ public class RedissonSession extends StandardSession { public void setAttribute(String name, Object value, boolean notify) { super.setAttribute(name, value, notify); - if (map != null && value != null) { + if (updateMode == UpdateMode.DEFAULT && map != null && value != null) { map.fastPut(name, value); } } @@ -157,7 +161,7 @@ public class RedissonSession extends StandardSession { protected void removeAttributeInternal(String name, boolean notify) { super.removeAttributeInternal(name, notify); - if (map != null) { + if (updateMode == UpdateMode.DEFAULT && map != null) { map.fastRemove(name); } } diff --git a/redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSessionManager.java b/redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSessionManager.java index 0279933c6..8f891839d 100644 --- a/redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSessionManager.java +++ b/redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSessionManager.java @@ -17,12 +17,11 @@ package org.redisson.tomcat; import java.io.File; import java.io.IOException; -import java.util.Enumeration; import java.util.Map; -import org.apache.catalina.Context; import javax.servlet.http.HttpSession; +import org.apache.catalina.Context; import org.apache.catalina.LifecycleException; import org.apache.catalina.LifecycleState; import org.apache.catalina.Session; @@ -138,7 +137,7 @@ public class RedissonSessionManager extends ManagerBase { @Override public Session createEmptySession() { - return new RedissonSession(this, readMode); + return new RedissonSession(this, readMode, updateMode); } @Override @@ -213,18 +212,14 @@ public class RedissonSessionManager extends ManagerBase { } - public void store(HttpSession session) { + public void store(HttpSession session) throws IOException { if (session == null) { return; } if (updateMode == UpdateMode.AFTER_REQUEST) { - Enumeration names = session.getAttributeNames(); - while (names.hasMoreElements()) { - String name = names.nextElement(); - Object value = session.getAttribute(name); - session.setAttribute(name, value); - } + RedissonSession sess = (RedissonSession) findSession(session.getId()); + sess.save(); } } diff --git a/redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSession.java b/redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSession.java index a88e29561..573363700 100644 --- a/redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSession.java +++ b/redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSession.java @@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit; import org.apache.catalina.session.StandardSession; import org.redisson.api.RMap; import org.redisson.tomcat.RedissonSessionManager.ReadMode; +import org.redisson.tomcat.RedissonSessionManager.UpdateMode; /** * Redisson Session object for Apache Tomcat @@ -37,11 +38,13 @@ public class RedissonSession extends StandardSession { private final Map attrs; private RMap map; private final RedissonSessionManager.ReadMode readMode; + private final UpdateMode updateMode; - public RedissonSession(RedissonSessionManager manager, RedissonSessionManager.ReadMode readMode) { + public RedissonSession(RedissonSessionManager manager, RedissonSessionManager.ReadMode readMode, UpdateMode updateMode) { super(manager); this.redissonManager = manager; this.readMode = readMode; + this.updateMode = updateMode; try { Field attr = StandardSession.class.getDeclaredField("attributes"); @@ -149,7 +152,7 @@ public class RedissonSession extends StandardSession { public void setAttribute(String name, Object value, boolean notify) { super.setAttribute(name, value, notify); - if (map != null && value != null) { + if (updateMode == UpdateMode.DEFAULT && map != null && value != null) { map.fastPut(name, value); } } @@ -158,7 +161,7 @@ public class RedissonSession extends StandardSession { protected void removeAttributeInternal(String name, boolean notify) { super.removeAttributeInternal(name, notify); - if (map != null) { + if (updateMode == UpdateMode.DEFAULT && map != null) { map.fastRemove(name); } } diff --git a/redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSessionManager.java b/redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSessionManager.java index 39995c076..2ec25c10f 100644 --- a/redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSessionManager.java +++ b/redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSessionManager.java @@ -17,7 +17,6 @@ package org.redisson.tomcat; import java.io.File; import java.io.IOException; -import java.util.Enumeration; import java.util.Map; import javax.servlet.http.HttpSession; @@ -138,7 +137,7 @@ public class RedissonSessionManager extends ManagerBase { @Override public Session createEmptySession() { - return new RedissonSession(this, readMode); + return new RedissonSession(this, readMode, updateMode); } @Override @@ -208,18 +207,14 @@ public class RedissonSessionManager extends ManagerBase { } - public void store(HttpSession session) { + public void store(HttpSession session) throws IOException { if (session == null) { return; } if (updateMode == UpdateMode.AFTER_REQUEST) { - Enumeration names = session.getAttributeNames(); - while (names.hasMoreElements()) { - String name = names.nextElement(); - Object value = session.getAttribute(name); - session.setAttribute(name, value); - } + RedissonSession sess = (RedissonSession) findSession(session.getId()); + sess.save(); } } diff --git a/redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSession.java b/redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSession.java index a88e29561..573363700 100644 --- a/redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSession.java +++ b/redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSession.java @@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit; import org.apache.catalina.session.StandardSession; import org.redisson.api.RMap; import org.redisson.tomcat.RedissonSessionManager.ReadMode; +import org.redisson.tomcat.RedissonSessionManager.UpdateMode; /** * Redisson Session object for Apache Tomcat @@ -37,11 +38,13 @@ public class RedissonSession extends StandardSession { private final Map attrs; private RMap map; private final RedissonSessionManager.ReadMode readMode; + private final UpdateMode updateMode; - public RedissonSession(RedissonSessionManager manager, RedissonSessionManager.ReadMode readMode) { + public RedissonSession(RedissonSessionManager manager, RedissonSessionManager.ReadMode readMode, UpdateMode updateMode) { super(manager); this.redissonManager = manager; this.readMode = readMode; + this.updateMode = updateMode; try { Field attr = StandardSession.class.getDeclaredField("attributes"); @@ -149,7 +152,7 @@ public class RedissonSession extends StandardSession { public void setAttribute(String name, Object value, boolean notify) { super.setAttribute(name, value, notify); - if (map != null && value != null) { + if (updateMode == UpdateMode.DEFAULT && map != null && value != null) { map.fastPut(name, value); } } @@ -158,7 +161,7 @@ public class RedissonSession extends StandardSession { protected void removeAttributeInternal(String name, boolean notify) { super.removeAttributeInternal(name, notify); - if (map != null) { + if (updateMode == UpdateMode.DEFAULT && map != null) { map.fastRemove(name); } } diff --git a/redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSessionManager.java b/redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSessionManager.java index 39995c076..2ec25c10f 100644 --- a/redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSessionManager.java +++ b/redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSessionManager.java @@ -17,7 +17,6 @@ package org.redisson.tomcat; import java.io.File; import java.io.IOException; -import java.util.Enumeration; import java.util.Map; import javax.servlet.http.HttpSession; @@ -138,7 +137,7 @@ public class RedissonSessionManager extends ManagerBase { @Override public Session createEmptySession() { - return new RedissonSession(this, readMode); + return new RedissonSession(this, readMode, updateMode); } @Override @@ -208,18 +207,14 @@ public class RedissonSessionManager extends ManagerBase { } - public void store(HttpSession session) { + public void store(HttpSession session) throws IOException { if (session == null) { return; } if (updateMode == UpdateMode.AFTER_REQUEST) { - Enumeration names = session.getAttributeNames(); - while (names.hasMoreElements()) { - String name = names.nextElement(); - Object value = session.getAttribute(name); - session.setAttribute(name, value); - } + RedissonSession sess = (RedissonSession) findSession(session.getId()); + sess.save(); } } From b177e94d5eca141109c08776b8d91e705034bf50 Mon Sep 17 00:00:00 2001 From: Nikita Date: Mon, 19 Feb 2018 05:30:02 +0300 Subject: [PATCH 13/18] expire, expireAt and clearExpire commands aren't implemented properly for RBloomFilter object. #1305 --- .../org/redisson/RedissonBloomFilter.java | 60 +++++++++++++------ 1 file changed, 43 insertions(+), 17 deletions(-) diff --git a/redisson/src/main/java/org/redisson/RedissonBloomFilter.java b/redisson/src/main/java/org/redisson/RedissonBloomFilter.java index 4cd41f22f..9ae9ce054 100644 --- a/redisson/src/main/java/org/redisson/RedissonBloomFilter.java +++ b/redisson/src/main/java/org/redisson/RedissonBloomFilter.java @@ -19,6 +19,7 @@ import java.math.BigDecimal; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.concurrent.TimeUnit; import org.redisson.api.RBitSetAsync; import org.redisson.api.RBloomFilter; @@ -54,15 +55,18 @@ public class RedissonBloomFilter extends RedissonExpirable implements RBloomF private volatile int hashIterations; private final CommandExecutor commandExecutor; + private final String configName; protected RedissonBloomFilter(CommandExecutor commandExecutor, String name) { super(commandExecutor, name); this.commandExecutor = commandExecutor; + this.configName = suffixName(getName(), "config"); } protected RedissonBloomFilter(Codec codec, CommandExecutor commandExecutor, String name) { super(codec, commandExecutor, name); this.commandExecutor = commandExecutor; + this.configName = suffixName(getName(), "config"); } private int optimalNumOfHashFunctions(long n, long m) { @@ -179,18 +183,18 @@ public class RedissonBloomFilter extends RedissonExpirable implements RBloomF } private void addConfigCheck(int hashIterations, long size, CommandBatchService executorService) { - executorService.evalReadAsync(getConfigName(), codec, RedisCommands.EVAL_VOID, + executorService.evalReadAsync(configName, codec, RedisCommands.EVAL_VOID, "local size = redis.call('hget', KEYS[1], 'size');" + "local hashIterations = redis.call('hget', KEYS[1], 'hashIterations');" + "assert(size == ARGV[1] and hashIterations == ARGV[2], 'Bloom filter config has been changed')", - Arrays.asList(getConfigName()), size, hashIterations); + Arrays.asList(configName), size, hashIterations); } @Override public long count() { CommandBatchService executorService = new CommandBatchService(commandExecutor.getConnectionManager()); - RFuture> configFuture = executorService.readAsync(getConfigName(), StringCodec.INSTANCE, - new RedisCommand>("HGETALL", new ObjectMapReplayDecoder()), getConfigName()); + RFuture> configFuture = executorService.readAsync(configName, StringCodec.INSTANCE, + new RedisCommand>("HGETALL", new ObjectMapReplayDecoder()), configName); RBitSetAsync bs = createBitSet(executorService); RFuture cardinalityFuture = bs.cardinalityAsync(); executorService.execute(); @@ -202,12 +206,12 @@ public class RedissonBloomFilter extends RedissonExpirable implements RBloomF @Override public RFuture deleteAsync() { - return commandExecutor.writeAsync(getName(), RedisCommands.DEL_OBJECTS, getName(), getConfigName()); + return commandExecutor.writeAsync(getName(), RedisCommands.DEL_OBJECTS, getName(), configName); } private void readConfig() { - RFuture> future = commandExecutor.readAsync(getConfigName(), StringCodec.INSTANCE, - new RedisCommand>("HGETALL", new ObjectMapReplayDecoder()), getConfigName()); + RFuture> future = commandExecutor.readAsync(configName, StringCodec.INSTANCE, + new RedisCommand>("HGETALL", new ObjectMapReplayDecoder()), configName); Map config = commandExecutor.get(future); readConfig(config); @@ -245,13 +249,13 @@ public class RedissonBloomFilter extends RedissonExpirable implements RBloomF hashIterations = optimalNumOfHashFunctions(expectedInsertions, size); CommandBatchService executorService = new CommandBatchService(commandExecutor.getConnectionManager()); - executorService.evalReadAsync(getConfigName(), codec, RedisCommands.EVAL_VOID, + executorService.evalReadAsync(configName, codec, RedisCommands.EVAL_VOID, "local size = redis.call('hget', KEYS[1], 'size');" + "local hashIterations = redis.call('hget', KEYS[1], 'hashIterations');" + "assert(size == false and hashIterations == false, 'Bloom filter config has been changed')", - Arrays.asList(getConfigName()), size, hashIterations); - executorService.writeAsync(getConfigName(), StringCodec.INSTANCE, - new RedisCommand("HMSET", new VoidReplayConvertor()), getConfigName(), + Arrays.asList(configName), size, hashIterations); + executorService.writeAsync(configName, StringCodec.INSTANCE, + new RedisCommand("HMSET", new VoidReplayConvertor()), configName, "size", size, "hashIterations", hashIterations, "expectedInsertions", expectedInsertions, "falseProbability", BigDecimal.valueOf(falseProbability).toPlainString()); try { @@ -267,31 +271,53 @@ public class RedissonBloomFilter extends RedissonExpirable implements RBloomF return true; } - private String getConfigName() { - return suffixName(getName(), "config"); + @Override + public RFuture expireAsync(long timeToLive, TimeUnit timeUnit) { + return commandExecutor.evalWriteAsync(getName(), LongCodec.INSTANCE, RedisCommands.EVAL_BOOLEAN, + "redis.call('pexpire', KEYS[1], ARGV[1]); " + + "return redis.call('pexpire', KEYS[2], ARGV[1]); ", + Arrays.asList(getName(), configName), + timeUnit.toMillis(timeToLive)); + } + + @Override + public RFuture expireAtAsync(long timestamp) { + return commandExecutor.evalWriteAsync(getName(), LongCodec.INSTANCE, RedisCommands.EVAL_BOOLEAN, + "redis.call('pexpireat', KEYS[1], ARGV[1]); " + + "return redis.call('pexpireat', KEYS[2], ARGV[1]); ", + Arrays.asList(getName(), configName), + timestamp); } + @Override + public RFuture clearExpireAsync() { + return commandExecutor.evalWriteAsync(getName(), LongCodec.INSTANCE, RedisCommands.EVAL_BOOLEAN, + "redis.call('persist', KEYS[1]); " + + "return redis.call('persist', KEYS[2]); ", + Arrays.asList(getName(), configName)); + } + @Override public long getExpectedInsertions() { - Long result = commandExecutor.read(getConfigName(), LongCodec.INSTANCE, RedisCommands.HGET, getConfigName(), "expectedInsertions"); + Long result = commandExecutor.read(configName, LongCodec.INSTANCE, RedisCommands.HGET, configName, "expectedInsertions"); return check(result); } @Override public double getFalseProbability() { - Double result = commandExecutor.read(getConfigName(), DoubleCodec.INSTANCE, RedisCommands.HGET, getConfigName(), "falseProbability"); + Double result = commandExecutor.read(configName, DoubleCodec.INSTANCE, RedisCommands.HGET, configName, "falseProbability"); return check(result); } @Override public long getSize() { - Long result = commandExecutor.read(getConfigName(), LongCodec.INSTANCE, RedisCommands.HGET, getConfigName(), "size"); + Long result = commandExecutor.read(configName, LongCodec.INSTANCE, RedisCommands.HGET, configName, "size"); return check(result); } @Override public int getHashIterations() { - Integer result = commandExecutor.read(getConfigName(), IntegerCodec.INSTANCE, RedisCommands.HGET, getConfigName(), "hashIterations"); + Integer result = commandExecutor.read(configName, IntegerCodec.INSTANCE, RedisCommands.HGET, configName, "hashIterations"); return check(result); } From 38238cfe694421cde5318fb8443d0469b63e278c Mon Sep 17 00:00:00 2001 From: Nikita Date: Mon, 19 Feb 2018 05:31:51 +0300 Subject: [PATCH 14/18] expire, expireAt and clearExpire aren't implemented properly for RDelayedQueue, RFairLock, RLocalCachedMap and RPermitExpirableSemaphore objects --- .../org/redisson/RedissonDelayedQueue.java | 82 ++++++++++++------- .../java/org/redisson/RedissonFairLock.java | 54 ++++++++---- .../org/redisson/RedissonLocalCachedMap.java | 16 ++-- .../RedissonPermitExpirableSemaphore.java | 28 ++++++- 4 files changed, 126 insertions(+), 54 deletions(-) diff --git a/redisson/src/main/java/org/redisson/RedissonDelayedQueue.java b/redisson/src/main/java/org/redisson/RedissonDelayedQueue.java index d5e3c8aaa..f4791c994 100644 --- a/redisson/src/main/java/org/redisson/RedissonDelayedQueue.java +++ b/redisson/src/main/java/org/redisson/RedissonDelayedQueue.java @@ -33,7 +33,6 @@ import org.redisson.command.CommandAsyncExecutor; import org.redisson.misc.RedissonPromise; import io.netty.util.internal.PlatformDependent; -import io.netty.util.internal.ThreadLocalRandom; /** * @@ -44,9 +43,15 @@ import io.netty.util.internal.ThreadLocalRandom; public class RedissonDelayedQueue extends RedissonExpirable implements RDelayedQueue { private final QueueTransferService queueTransferService; + private final String channelName; + private final String queueName; + private final String timeoutSetName; protected RedissonDelayedQueue(QueueTransferService queueTransferService, Codec codec, final CommandAsyncExecutor commandExecutor, String name) { super(codec, commandExecutor, name); + channelName = prefixName("redisson_delay_queue_channel", getName()); + queueName = prefixName("redisson_delay_queue", getName()); + timeoutSetName = prefixName("redisson_delay_queue_timeout", getName()); QueueTransferTask task = new QueueTransferTask(commandExecutor.getConnectionManager()) { @@ -68,33 +73,21 @@ public class RedissonDelayedQueue extends RedissonExpirable implements RDelay + "return v[2]; " + "end " + "return nil;", - Arrays.asList(getName(), getTimeoutSetName(), getQueueName()), + Arrays.asList(getName(), timeoutSetName, queueName), System.currentTimeMillis(), 100); } @Override protected RTopic getTopic() { - return new RedissonTopic(LongCodec.INSTANCE, commandExecutor, getChannelName()); + return new RedissonTopic(LongCodec.INSTANCE, commandExecutor, channelName); } }; - queueTransferService.schedule(getQueueName(), task); + queueTransferService.schedule(queueName, task); this.queueTransferService = queueTransferService; } - private String getChannelName() { - return prefixName("redisson_delay_queue_channel", getName()); - } - - private String getQueueName() { - return prefixName("redisson_delay_queue", getName()); - } - - private String getTimeoutSetName() { - return prefixName("redisson_delay_queue_timeout", getName()); - } - public void offer(V e, long delay, TimeUnit timeUnit) { get(offerAsync(e, delay, timeUnit)); } @@ -115,7 +108,7 @@ public class RedissonDelayedQueue extends RedissonExpirable implements RDelay + "redis.call('publish', KEYS[4], ARGV[1]); " + "end;" , - Arrays.asList(getName(), getTimeoutSetName(), getQueueName(), getChannelName()), + Arrays.asList(getName(), timeoutSetName, queueName, channelName), timeout, randomId, encode(e)); } @@ -180,7 +173,7 @@ public class RedissonDelayedQueue extends RedissonExpirable implements RDelay + "return value; " + "end " + "return nil;", - Arrays.asList(getQueueName()), index)); + Arrays.asList(queueName), index)); } void remove(int index) { @@ -191,7 +184,7 @@ public class RedissonDelayedQueue extends RedissonExpirable implements RDelay "redis.call('lrem', KEYS[1], 1, v);" + "redis.call('zrem', KEYS[2], v);" + "end; ", - Arrays.asList(getQueueName(), getTimeoutSetName()), index)); + Arrays.asList(queueName, timeoutSetName), index)); } @Override @@ -268,7 +261,7 @@ public class RedissonDelayedQueue extends RedissonExpirable implements RDelay + "table.insert(result, value);" + "end; " + "return result; ", - Collections.singletonList(getQueueName())); + Collections.singletonList(queueName)); } @Override @@ -294,7 +287,7 @@ public class RedissonDelayedQueue extends RedissonExpirable implements RDelay + "end; " + "end;" + "return 0;", - Arrays.asList(getQueueName(), getTimeoutSetName()), encode(o)); + Arrays.asList(queueName, timeoutSetName), encode(o)); } @Override @@ -316,7 +309,7 @@ public class RedissonDelayedQueue extends RedissonExpirable implements RDelay + "end; " + "end;" + "return #ARGV == 0 and 1 or 0;", - Collections.singletonList(getQueueName()), encode(c).toArray()); + Collections.singletonList(queueName), encode(c).toArray()); } @Override @@ -356,7 +349,7 @@ public class RedissonDelayedQueue extends RedissonExpirable implements RDelay + "i = i + 1;" + "end; " + "return result;", - Arrays.asList(getQueueName(), getTimeoutSetName()), encode(c).toArray()); + Arrays.asList(queueName, timeoutSetName), encode(c).toArray()); } @Override @@ -395,7 +388,7 @@ public class RedissonDelayedQueue extends RedissonExpirable implements RDelay + "i = i + 1; " + "end; " + "return changed; ", - Collections.singletonList(getQueueName()), encode(c).toArray()); + Collections.singletonList(queueName), encode(c).toArray()); } @Override @@ -405,9 +398,36 @@ public class RedissonDelayedQueue extends RedissonExpirable implements RDelay @Override public RFuture deleteAsync() { - return commandExecutor.writeAsync(getName(), RedisCommands.DEL_OBJECTS, getQueueName(), getTimeoutSetName()); + return commandExecutor.writeAsync(getName(), RedisCommands.DEL_OBJECTS, queueName, timeoutSetName); + } + + @Override + public RFuture expireAsync(long timeToLive, TimeUnit timeUnit) { + return commandExecutor.evalWriteAsync(getName(), LongCodec.INSTANCE, RedisCommands.EVAL_BOOLEAN, + "redis.call('pexpire', KEYS[1], ARGV[1]); " + + "return redis.call('pexpire', KEYS[2], ARGV[1]); ", + Arrays.asList(queueName, timeoutSetName), + timeUnit.toMillis(timeToLive)); + } + + @Override + public RFuture expireAtAsync(long timestamp) { + return commandExecutor.evalWriteAsync(getName(), LongCodec.INSTANCE, RedisCommands.EVAL_BOOLEAN, + "redis.call('pexpireat', KEYS[1], ARGV[1]); " + + "return redis.call('pexpireat', KEYS[2], ARGV[1]); ", + Arrays.asList(queueName, timeoutSetName), + timestamp); } + @Override + public RFuture clearExpireAsync() { + return commandExecutor.evalWriteAsync(getName(), LongCodec.INSTANCE, RedisCommands.EVAL_BOOLEAN, + "redis.call('persist', KEYS[1]); " + + "return redis.call('persist', KEYS[2]); ", + Arrays.asList(queueName, timeoutSetName)); + } + + @Override public RFuture peekAsync() { return commandExecutor.evalReadAsync(getName(), codec, RedisCommands.EVAL_OBJECT, @@ -417,7 +437,7 @@ public class RedissonDelayedQueue extends RedissonExpirable implements RDelay + "return value; " + "end " + "return nil;", - Arrays.asList(getQueueName())); + Arrays.asList(queueName)); } @Override @@ -430,7 +450,7 @@ public class RedissonDelayedQueue extends RedissonExpirable implements RDelay + "return value; " + "end " + "return nil;", - Arrays.asList(getQueueName(), getTimeoutSetName())); + Arrays.asList(queueName, timeoutSetName)); } @Override @@ -449,7 +469,7 @@ public class RedissonDelayedQueue extends RedissonExpirable implements RDelay + "return value; " + "end " + "return nil;", - Arrays.asList(getQueueName(), getTimeoutSetName(), queueName)); + Arrays.asList(this.queueName, timeoutSetName, queueName)); } @Override @@ -464,12 +484,12 @@ public class RedissonDelayedQueue extends RedissonExpirable implements RDelay + "end; " + "end;" + "return 0;", - Collections.singletonList(getQueueName()), encode(o)); + Collections.singletonList(queueName), encode(o)); } @Override public RFuture sizeAsync() { - return commandExecutor.readAsync(getName(), codec, RedisCommands.LLEN_INT, getQueueName()); + return commandExecutor.readAsync(getName(), codec, RedisCommands.LLEN_INT, queueName); } @Override @@ -489,7 +509,7 @@ public class RedissonDelayedQueue extends RedissonExpirable implements RDelay @Override public void destroy() { - queueTransferService.remove(getQueueName()); + queueTransferService.remove(queueName); } } diff --git a/redisson/src/main/java/org/redisson/RedissonFairLock.java b/redisson/src/main/java/org/redisson/RedissonFairLock.java index f7872cfde..85680ac17 100644 --- a/redisson/src/main/java/org/redisson/RedissonFairLock.java +++ b/redisson/src/main/java/org/redisson/RedissonFairLock.java @@ -42,18 +42,14 @@ public class RedissonFairLock extends RedissonLock implements RLock { private final long threadWaitTime = 5000; private final CommandExecutor commandExecutor; + private final String threadsQueueName; + private final String timeoutSetName; protected RedissonFairLock(CommandExecutor commandExecutor, String name, UUID id) { super(commandExecutor, name, id); this.commandExecutor = commandExecutor; - } - - String getThreadsQueueName() { - return prefixName("redisson_lock_queue", getName()); - } - - String getTimeoutSetName() { - return prefixName("redisson_lock_timeout", getName()); + threadsQueueName = prefixName("redisson_lock_queue", name); + timeoutSetName = prefixName("redisson_lock_timeout", name); } @Override @@ -85,7 +81,7 @@ public class RedissonFairLock extends RedissonLock implements RLock { "end;" + "redis.call('zrem', KEYS[2], ARGV[1]); " + "redis.call('lrem', KEYS[1], 0, ARGV[1]); ", - Arrays.asList(getThreadsQueueName(), getTimeoutSetName()), + Arrays.asList(threadsQueueName, timeoutSetName), getLockName(threadId), threadWaitTime); } @@ -126,7 +122,7 @@ public class RedissonFairLock extends RedissonLock implements RLock { "return nil; " + "end; " + "return 1;", - Arrays.asList(getName(), getThreadsQueueName(), getTimeoutSetName()), + Arrays.asList(getName(), threadsQueueName, timeoutSetName), internalLockLeaseTime, getLockName(threadId), currentTime); } @@ -174,7 +170,7 @@ public class RedissonFairLock extends RedissonLock implements RLock { "redis.call('rpush', KEYS[2], ARGV[2]);" + "end; " + "return ttl;", - Arrays.asList(getName(), getThreadsQueueName(), getTimeoutSetName()), + Arrays.asList(getName(), threadsQueueName, timeoutSetName), internalLockLeaseTime, getLockName(threadId), currentTime + threadWaitTime, currentTime); } @@ -221,7 +217,7 @@ public class RedissonFairLock extends RedissonLock implements RLock { "redis.call('publish', KEYS[4] .. ':' .. nextThreadId, ARGV[1]); " + "end; " + "return 1; ", - Arrays.asList(getName(), getThreadsQueueName(), getTimeoutSetName(), getChannelName()), + Arrays.asList(getName(), threadsQueueName, timeoutSetName, getChannelName()), LockPubSub.unlockMessage, internalLockLeaseTime, getLockName(threadId), System.currentTimeMillis()); } @@ -232,9 +228,39 @@ public class RedissonFairLock extends RedissonLock implements RLock { @Override public RFuture deleteAsync() { - return commandExecutor.writeAsync(getName(), RedisCommands.DEL_OBJECTS, getName(), getThreadsQueueName(), getTimeoutSetName()); + return commandExecutor.writeAsync(getName(), RedisCommands.DEL_OBJECTS, getName(), threadsQueueName, timeoutSetName); } + @Override + public RFuture expireAsync(long timeToLive, TimeUnit timeUnit) { + return commandExecutor.evalWriteAsync(getName(), LongCodec.INSTANCE, RedisCommands.EVAL_BOOLEAN, + "redis.call('pexpire', KEYS[1], ARGV[1]); " + + "redis.call('pexpire', KEYS[2], ARGV[1]); " + + "return redis.call('pexpire', KEYS[3], ARGV[1]); ", + Arrays.asList(getName(), threadsQueueName, timeoutSetName), + timeUnit.toMillis(timeToLive)); + } + + @Override + public RFuture expireAtAsync(long timestamp) { + return commandExecutor.evalWriteAsync(getName(), LongCodec.INSTANCE, RedisCommands.EVAL_BOOLEAN, + "redis.call('pexpireat', KEYS[1], ARGV[1]); " + + "redis.call('pexpireat', KEYS[2], ARGV[1]); " + + "return redis.call('pexpireat', KEYS[3], ARGV[1]); ", + Arrays.asList(getName(), threadsQueueName, timeoutSetName), + timestamp); + } + + @Override + public RFuture clearExpireAsync() { + return commandExecutor.evalWriteAsync(getName(), LongCodec.INSTANCE, RedisCommands.EVAL_BOOLEAN, + "redis.call('persist', KEYS[1]); " + + "redis.call('persist', KEYS[2]); " + + "return redis.call('persist', KEYS[3]); ", + Arrays.asList(getName(), threadsQueueName, timeoutSetName)); + } + + @Override public RFuture forceUnlockAsync() { cancelExpirationRenewal(); @@ -263,7 +289,7 @@ public class RedissonFairLock extends RedissonLock implements RLock { "return 1; " + "end; " + "return 0;", - Arrays.asList(getName(), getThreadsQueueName(), getTimeoutSetName(), getChannelName()), + Arrays.asList(getName(), threadsQueueName, timeoutSetName, getChannelName()), LockPubSub.unlockMessage, System.currentTimeMillis()); } diff --git a/redisson/src/main/java/org/redisson/RedissonLocalCachedMap.java b/redisson/src/main/java/org/redisson/RedissonLocalCachedMap.java index 2d3e70b04..ce9871e60 100644 --- a/redisson/src/main/java/org/redisson/RedissonLocalCachedMap.java +++ b/redisson/src/main/java/org/redisson/RedissonLocalCachedMap.java @@ -180,8 +180,8 @@ public class RedissonLocalCachedMap extends RedissonMap implements R private RTopic invalidationTopic; private Cache cache; private int invalidateEntryOnChange; - private int invalidationListenerId; - private int invalidationStatusListenerId; + private int syncListenerId; + private int reconnectionListenerId; private volatile long lastInvalidate; private SyncStrategy syncStrategy; private final Codec topicCodec = new LocalCachedMessageCodec(); @@ -218,7 +218,7 @@ public class RedissonLocalCachedMap extends RedissonMap implements R invalidationTopic = new RedissonTopic(topicCodec, commandExecutor, suffixName(name, "topic")); if (options.getReconnectionStrategy() != ReconnectionStrategy.NONE) { - invalidationStatusListenerId = invalidationTopic.addListener(new BaseStatusListener() { + reconnectionListenerId = invalidationTopic.addListener(new BaseStatusListener() { @Override public void onSubscribe(String channel) { if (options.getReconnectionStrategy() == ReconnectionStrategy.CLEAR) { @@ -272,7 +272,7 @@ public class RedissonLocalCachedMap extends RedissonMap implements R } if (options.getSyncStrategy() != SyncStrategy.NONE) { - invalidationListenerId = invalidationTopic.addListener(new MessageListener() { + syncListenerId = invalidationTopic.addListener(new MessageListener() { @Override public void onMessage(String channel, Object msg) { if (msg instanceof LocalCachedMapClear) { @@ -481,11 +481,11 @@ public class RedissonLocalCachedMap extends RedissonMap implements R @Override public void destroy() { - if (invalidationListenerId != 0) { - invalidationTopic.removeListener(invalidationListenerId); + if (syncListenerId != 0) { + invalidationTopic.removeListener(syncListenerId); } - if (invalidationStatusListenerId != 0) { - invalidationTopic.removeListener(invalidationStatusListenerId); + if (reconnectionListenerId != 0) { + invalidationTopic.removeListener(reconnectionListenerId); } } diff --git a/redisson/src/main/java/org/redisson/RedissonPermitExpirableSemaphore.java b/redisson/src/main/java/org/redisson/RedissonPermitExpirableSemaphore.java index 8741bc213..00dc71702 100644 --- a/redisson/src/main/java/org/redisson/RedissonPermitExpirableSemaphore.java +++ b/redisson/src/main/java/org/redisson/RedissonPermitExpirableSemaphore.java @@ -53,7 +53,7 @@ public class RedissonPermitExpirableSemaphore extends RedissonExpirable implemen protected RedissonPermitExpirableSemaphore(CommandExecutor commandExecutor, String name, SemaphorePubSub semaphorePubSub) { super(commandExecutor, name); - this.timeoutName = "{" + name + "}:timeout"; + this.timeoutName = suffixName(name, "timeout"); this.commandExecutor = commandExecutor; this.semaphorePubSub = semaphorePubSub; } @@ -635,6 +635,32 @@ public class RedissonPermitExpirableSemaphore extends RedissonExpirable implemen return commandExecutor.writeAsync(getName(), RedisCommands.DEL_OBJECTS, getName(), timeoutName); } + @Override + public RFuture expireAsync(long timeToLive, TimeUnit timeUnit) { + return commandExecutor.evalWriteAsync(getName(), LongCodec.INSTANCE, RedisCommands.EVAL_BOOLEAN, + "redis.call('pexpire', KEYS[1], ARGV[1]); " + + "return redis.call('pexpire', KEYS[2], ARGV[1]); ", + Arrays.asList(getName(), timeoutName), + timeUnit.toMillis(timeToLive)); + } + + @Override + public RFuture expireAtAsync(long timestamp) { + return commandExecutor.evalWriteAsync(getName(), LongCodec.INSTANCE, RedisCommands.EVAL_BOOLEAN, + "redis.call('pexpireat', KEYS[1], ARGV[1]); " + + "return redis.call('pexpireat', KEYS[2], ARGV[1]); ", + Arrays.asList(getName(), timeoutName), + timestamp); + } + + @Override + public RFuture clearExpireAsync() { + return commandExecutor.evalWriteAsync(getName(), LongCodec.INSTANCE, RedisCommands.EVAL_BOOLEAN, + "redis.call('persist', KEYS[1]); " + + "return redis.call('persist', KEYS[2]); ", + Arrays.asList(getName(), timeoutName)); + } + @Override public RFuture releaseAsync(final String permitId) { final RPromise result = new RedissonPromise(); From 6f32edceff059315d20b8a979b93429a51f129c2 Mon Sep 17 00:00:00 2001 From: Nikita Date: Mon, 19 Feb 2018 05:36:26 +0300 Subject: [PATCH 15/18] kryo version updated --- redisson/pom.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/redisson/pom.xml b/redisson/pom.xml index 88906c8c0..312e46b30 100644 --- a/redisson/pom.xml +++ b/redisson/pom.xml @@ -170,7 +170,7 @@ com.esotericsoftware kryo - 3.0.3 + 4.0.1 provided true @@ -248,6 +248,13 @@ provided true + + org.springframework + spring-tx + [3.1,5.0) + provided + true + org.springframework.session spring-session From 27fb531c0c4cb771ef580be2c48ac0ae99f78b5c Mon Sep 17 00:00:00 2001 From: Nikita Date: Mon, 19 Feb 2018 06:16:47 +0300 Subject: [PATCH 16/18] RMapCache.remainTimeToLive(key) method added. #1210 --- .../java/org/redisson/RedissonMapCache.java | 41 +++++++++++++++++++ .../main/java/org/redisson/api/RMapCache.java | 9 ++++ .../java/org/redisson/api/RMapCacheAsync.java | 10 +++++ .../org/redisson/RedissonMapCacheTest.java | 13 ++++++ 4 files changed, 73 insertions(+) diff --git a/redisson/src/main/java/org/redisson/RedissonMapCache.java b/redisson/src/main/java/org/redisson/RedissonMapCache.java index 5a31c6b10..77086fac0 100644 --- a/redisson/src/main/java/org/redisson/RedissonMapCache.java +++ b/redisson/src/main/java/org/redisson/RedissonMapCache.java @@ -970,6 +970,47 @@ public class RedissonMapCache extends RedissonMap implements RMapCac System.currentTimeMillis(), ttlTimeout, maxIdleTimeout, maxIdleDelta, encodeMapKey(key), encodeMapValue(value)); return future; } + + @Override + public long remainTimeToLive(K key) { + return get(remainTimeToLiveAsync(key)); + } + + @Override + public RFuture remainTimeToLiveAsync(K key) { + checkKey(key); + + return commandExecutor.evalWriteAsync(getName(key), codec, RedisCommands.EVAL_LONG, + "local value = redis.call('hget', KEYS[1], ARGV[2]); " + + "if value == false then " + + "return -2; " + + "end; " + + "local t, val = struct.unpack('dLc0', value); " + + "local expireDate = 92233720368547758; " + + "local expireDateScore = redis.call('zscore', KEYS[2], ARGV[2]); " + + "if expireDateScore ~= false then " + + "expireDate = tonumber(expireDateScore) " + + "end; " + + "if t ~= 0 then " + + "local expireIdle = redis.call('zscore', KEYS[3], ARGV[2]); " + + "if expireIdle ~= false then " + + "expireDate = math.min(expireDate, tonumber(expireIdle)) " + + "end; " + + "end; " + + + "if expireDate == 92233720368547758 then " + + "return -1; " + + "end;" + + "if expireDate > tonumber(ARGV[1]) then " + + "return ARGV[1] - expireDate; " + + "else " + + "return -2; " + + "end; " + + "return val; ", + Arrays.asList(getName(key), getTimeoutSetNameByKey(key), getIdleSetNameByKey(key)), + System.currentTimeMillis(), encodeMapKey(key)); + + } String getTimeoutSetNameByKey(Object key) { return prefixName("redisson__timeout__set", getName(key)); diff --git a/redisson/src/main/java/org/redisson/api/RMapCache.java b/redisson/src/main/java/org/redisson/api/RMapCache.java index 7ccdc490f..28c7f95f3 100644 --- a/redisson/src/main/java/org/redisson/api/RMapCache.java +++ b/redisson/src/main/java/org/redisson/api/RMapCache.java @@ -260,5 +260,14 @@ public interface RMapCache extends RMap, RMapCacheAsync { * @param listenerId - listener id */ void removeListener(int listenerId); + + /** + * Remaining time to live of map entry associated with a key. + * + * @return time in milliseconds + * -2 if the key does not exist. + * -1 if the key exists but has no associated expire. + */ + long remainTimeToLive(K key); } diff --git a/redisson/src/main/java/org/redisson/api/RMapCacheAsync.java b/redisson/src/main/java/org/redisson/api/RMapCacheAsync.java index cc4a716bf..623b6b1a1 100644 --- a/redisson/src/main/java/org/redisson/api/RMapCacheAsync.java +++ b/redisson/src/main/java/org/redisson/api/RMapCacheAsync.java @@ -220,4 +220,14 @@ public interface RMapCacheAsync extends RMapAsync { */ @Override RFuture sizeAsync(); + + /** + * Remaining time to live of map entry associated with a key. + * + * @return time in milliseconds + * -2 if the key does not exist. + * -1 if the key exists but has no associated expire. + */ + RFuture remainTimeToLiveAsync(K key); + } diff --git a/redisson/src/test/java/org/redisson/RedissonMapCacheTest.java b/redisson/src/test/java/org/redisson/RedissonMapCacheTest.java index c6cb7204b..2017085e9 100644 --- a/redisson/src/test/java/org/redisson/RedissonMapCacheTest.java +++ b/redisson/src/test/java/org/redisson/RedissonMapCacheTest.java @@ -57,6 +57,19 @@ public class RedissonMapCacheTest extends BaseMapTest { return redisson.getMapCache("test", options); } + @Test + public void testRemainTimeToLive() { + RMapCache map = redisson.getMapCache("test"); + map.put("1", "2", 2, TimeUnit.SECONDS); + assertThat(map.remainTimeToLive("1")).isLessThan(1900); + map.put("3", "4"); + assertThat(map.remainTimeToLive("3")).isEqualTo(-1); + assertThat(map.remainTimeToLive("0")).isEqualTo(-2); + + map.put("5", "6", 20, TimeUnit.SECONDS, 10, TimeUnit.SECONDS); + assertThat(map.remainTimeToLive("1")).isLessThan(9900); + } + @Test public void testWriterPutIfAbsentTTL() { Map store = new HashMap<>(); From 89c391c9d775a14536b466add3a020cb0d0a2b93 Mon Sep 17 00:00:00 2001 From: Nikita Date: Mon, 19 Feb 2018 06:37:19 +0300 Subject: [PATCH 17/18] javadocs fixed --- redisson/src/main/java/org/redisson/api/RExpirable.java | 2 +- .../src/main/java/org/redisson/api/RExpirableAsync.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/redisson/src/main/java/org/redisson/api/RExpirable.java b/redisson/src/main/java/org/redisson/api/RExpirable.java index 295b3dbaa..4023d73cd 100644 --- a/redisson/src/main/java/org/redisson/api/RExpirable.java +++ b/redisson/src/main/java/org/redisson/api/RExpirable.java @@ -64,7 +64,7 @@ public interface RExpirable extends RObject, RExpirableAsync { boolean clearExpire(); /** - * Remaining time to live of Redisson object that has a timeout + * Remaining time to live of Redisson object that has a timeout * * @return time in milliseconds * -2 if the key does not exist. diff --git a/redisson/src/main/java/org/redisson/api/RExpirableAsync.java b/redisson/src/main/java/org/redisson/api/RExpirableAsync.java index a8ea0e953..1dcc617dc 100644 --- a/redisson/src/main/java/org/redisson/api/RExpirableAsync.java +++ b/redisson/src/main/java/org/redisson/api/RExpirableAsync.java @@ -64,9 +64,11 @@ public interface RExpirableAsync extends RObjectAsync { RFuture clearExpireAsync(); /** - * Get remaining time to live of object in seconds. + * Remaining time to live of Redisson object that has a timeout * - * @return -1 if object does not exist or time in seconds + * @return time in milliseconds + * -2 if the key does not exist. + * -1 if the key exists but has no associated expire. */ RFuture remainTimeToLiveAsync(); From 9670f19b0f0a23dc6ffdb954955dfb8cf2c91731 Mon Sep 17 00:00:00 2001 From: Nikita Date: Mon, 19 Feb 2018 06:46:53 +0300 Subject: [PATCH 18/18] Fixed - clients duplication during discovering ip change of hostname. #1304 --- .../org/redisson/connection/DNSMonitor.java | 11 ++++++++-- .../redisson/connection/MasterSlaveEntry.java | 20 +++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/redisson/src/main/java/org/redisson/connection/DNSMonitor.java b/redisson/src/main/java/org/redisson/connection/DNSMonitor.java index 174bd7e18..0a773e17e 100644 --- a/redisson/src/main/java/org/redisson/connection/DNSMonitor.java +++ b/redisson/src/main/java/org/redisson/connection/DNSMonitor.java @@ -136,7 +136,14 @@ public class DNSMonitor { log.info("Detected DNS change. Slave {} has changed ip from {} to {}", entry.getKey().getHost(), currentSlaveAddr.getAddress().getHostAddress(), newSlaveAddr.getAddress().getHostAddress()); for (final MasterSlaveEntry masterSlaveEntry : connectionManager.getEntrySet()) { - if (masterSlaveEntry.hasSlave(currentSlaveAddr)) { + if (!masterSlaveEntry.hasSlave(currentSlaveAddr)) { + continue; + } + + if (masterSlaveEntry.hasSlave(newSlaveAddr)) { + masterSlaveEntry.slaveUp(newSlaveAddr, FreezeReason.MANAGER); + masterSlaveEntry.slaveDown(currentSlaveAddr, FreezeReason.MANAGER); + } else { RFuture addFuture = masterSlaveEntry.addSlave(newSlaveAddr, entry.getKey()); addFuture.addListener(new FutureListener() { @Override @@ -149,8 +156,8 @@ public class DNSMonitor { masterSlaveEntry.slaveDown(currentSlaveAddr, FreezeReason.MANAGER); } }); - break; } + break; } slaves.put(entry.getKey(), newSlaveAddr); } diff --git a/redisson/src/main/java/org/redisson/connection/MasterSlaveEntry.java b/redisson/src/main/java/org/redisson/connection/MasterSlaveEntry.java index ab3db3cbf..370a7af36 100644 --- a/redisson/src/main/java/org/redisson/connection/MasterSlaveEntry.java +++ b/redisson/src/main/java/org/redisson/connection/MasterSlaveEntry.java @@ -428,7 +428,7 @@ public class MasterSlaveEntry { // exclude master from slaves if (!config.checkSkipSlavesInit() && !addr.equals(entry.getClient().getAddr())) { - slaveDown(masterEntry.getClient().getAddr(), FreezeReason.SYSTEM); + slaveDown(addr, FreezeReason.SYSTEM); log.info("master {} excluded from slaves", addr); } return true; @@ -443,11 +443,27 @@ public class MasterSlaveEntry { // exclude master from slaves if (!config.checkSkipSlavesInit() && !URIBuilder.compare(addr, address)) { - slaveDown(masterEntry.getClient().getAddr(), FreezeReason.SYSTEM); + slaveDown(addr, FreezeReason.SYSTEM); log.info("master {} excluded from slaves", addr); } return true; } + + public boolean slaveUp(InetSocketAddress address, FreezeReason freezeReason) { + if (!slaveBalancer.unfreeze(address, freezeReason)) { + return false; + } + + InetSocketAddress addr = masterEntry.getClient().getAddr(); + // exclude master from slaves + if (!config.checkSkipSlavesInit() + && !addr.equals(address)) { + slaveDown(addr, FreezeReason.SYSTEM); + log.info("master {} excluded from slaves", addr); + } + return true; + } + /** * Freeze slave with redis(s)://host:port from slaves list.