From 1d9c17146fe0c70502cb491c1e5b09ba431b768d Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Sun, 19 Feb 2017 15:40:43 +0300 Subject: [PATCH 01/28] Update CHANGELOG.md --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 787a14664..5759c197f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,19 @@ Redisson Releases History Try __ULTRA-FAST__ [Redisson PRO](https://redisson.pro) edition. +####19-Feb-2017 - versions 2.8.0 and 3.3.0 released + +Feature - __`RClusteredLocalCachedMap` object added__ More details [here](https://github.com/redisson/redisson/wiki/7.-distributed-collections#713-map-data-partitioning) +Feature - __`RClusteredMapCache` object added__ More details [here](https://github.com/redisson/redisson/wiki/7.-distributed-collections#713-map-data-partitioning) +Feature - __`RClusteredSetCache` object added__ More details [here](https://github.com/redisson/redisson/wiki/7.-distributed-collections/#732-set-data-partitioning) +Feature - __`RPriorityQueue` object added__ More details [here](https://github.com/redisson/redisson/wiki/7.-distributed-collections/#715-priority-queue) +Feature - __`RPriorityDeque` object added__ More details [here](https://github.com/redisson/redisson/wiki/7.-distributed-collections/#716-priority-deque) +Feature - `removeAllListeners` and `removeListener` by instance methods added for `RTopic` and `RPatternTopic` +Feature - `RLockAsync` interface added +Improvement - `RRemoteService` is now able to support method overload +Fixed - `RLocalCachedMap` is not Redis cluster compatible + + ####02-Feb-2017 - versions 2.7.4 and 3.2.4 released Feature - Allow to specify Redisson instance/config during JCache cache creation From d9543f29cf4729c457c9b85a5a325bd19da13166 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Sun, 19 Feb 2017 15:42:09 +0300 Subject: [PATCH 02/28] Update README.md --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index db35169e4..fb9eede53 100644 --- a/README.md +++ b/README.md @@ -6,15 +6,15 @@ Redis 2.8+ compatible. | Stable Release Version | JDK Version compatibility | Release Date | | ------------- | ------------- | ------------| -| 3.2.3 | 1.8+ | 19.01.2017 | -| 2.7.3 | 1.6, 1.7, 1.8 and Android | 19.01.2017 | +| 3.3.0 | 1.8+ | 19.02.2017 | +| 2.8.0 | 1.6, 1.7, 1.8 and Android | 19.02.2017 | __NOTE__: Both version lines have same features except `CompletionStage` interface supported by 3.x.x line Please read [documentation](https://github.com/redisson/redisson/wiki) for more details. Redisson [releases history](https://github.com/redisson/redisson/blob/master/CHANGELOG.md) Checkout more [code examples](https://github.com/redisson/redisson-examples) -Browse [javadocs](http://www.javadoc.io/doc/org.redisson/redisson/3.2.2) +Browse [javadocs](http://www.javadoc.io/doc/org.redisson/redisson/3.2.4) Licensed under the Apache License 2.0. @@ -90,23 +90,23 @@ Quick start org.redisson redisson - 3.2.4 + 3.3.0 org.redisson redisson - 2.7.4 + 2.8.0 #### Gradle // JDK 1.8+ compatible - compile 'org.redisson:redisson:3.2.4' + compile 'org.redisson:redisson:3.3.0' // JDK 1.6+ compatible - compile 'org.redisson:redisson:2.7.4' + compile 'org.redisson:redisson:2.8.0' #### Java @@ -131,11 +131,11 @@ RExecutorService executor = redisson.getExecutorService("myExecutorService"); Downloads =============================== -[Redisson 3.2.4](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson&v=3.2.4&e=jar), -[Redisson node 3.2.4](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-all&v=3.2.4&e=jar) +[Redisson 3.3.0](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson&v=3.3.0&e=jar), +[Redisson node 3.3.0](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-all&v=3.3.0&e=jar) -[Redisson 2.7.4](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson&v=2.7.4&e=jar), -[Redisson node 2.7.4](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-all&v=2.7.4&e=jar) +[Redisson 2.8.0](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson&v=2.8.0&e=jar), +[Redisson node 2.8.0](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-all&v=2.8.0&e=jar) ### Supported by From 520a218c490685eb8b9bcb9b2942690275e79d25 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Sun, 19 Feb 2017 15:45:35 +0300 Subject: [PATCH 03/28] Update CHANGELOG.md --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5759c197f..ecbff49b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,9 @@ Feature - `removeAllListeners` and `removeListener` by instance methods added fo Feature - `RLockAsync` interface added Improvement - `RRemoteService` is now able to support method overload Fixed - `RLocalCachedMap` is not Redis cluster compatible - +Fixed - cascade slaves are not supported in cluster mode +Fixed - shutdown checking during master change state check added +Fixed - master isn't checked during new slave discovery in Sentinel mode ####02-Feb-2017 - versions 2.7.4 and 3.2.4 released From 7421ff96b8ed371ba8ebf8ff54b393a3898b1eb4 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Mon, 20 Feb 2017 10:23:53 +0300 Subject: [PATCH 04/28] 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 64e406dde..ff6bad985 100644 --- a/redisson-tomcat/README.md +++ b/redisson-tomcat/README.md @@ -21,22 +21,22 @@ Usage 2. Copy two jars into `TOMCAT_BASE/lib` directory: 1. __For JDK 1.8+__ - [redisson-all-3.2.4.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-all&v=3.2.4&e=jar) + [redisson-all-3.3.0.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-all&v=3.3.0&e=jar) for Tomcat 6.x - [redisson-tomcat-6-3.2.4.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-6&v=3.2.4&e=jar) + [redisson-tomcat-6-3.3.0.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-6&v=3.3.0&e=jar) for Tomcat 7.x - [redisson-tomcat-7-3.2.4.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-7&v=3.2.4&e=jar) + [redisson-tomcat-7-3.3.0.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-7&v=3.3.0&e=jar) for Tomcat 8.x - [redisson-tomcat-8-3.2.4.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-8&v=3.2.4&e=jar) + [redisson-tomcat-8-3.3.0.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-8&v=3.3.0&e=jar) 1. __For JDK 1.6+__ - [redisson-all-2.7.4.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-all&v=2.7.4&e=jar) + [redisson-all-2.8.0.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-all&v=2.8.0&e=jar) for Tomcat 6.x - [redisson-tomcat-6-2.7.4.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-6&v=2.7.4&e=jar) + [redisson-tomcat-6-2.8.0.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-6&v=2.8.0&e=jar) for Tomcat 7.x - [redisson-tomcat-7-2.7.4.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-7&v=2.7.4&e=jar) + [redisson-tomcat-7-2.8.0.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-7&v=2.8.0&e=jar) for Tomcat 8.x - [redisson-tomcat-8-2.7.4.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-8&v=2.7.4&e=jar) + [redisson-tomcat-8-2.8.0.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-8&v=2.8.0&e=jar) From 796eab814d93601d19af9901004df9d8f23b3c29 Mon Sep 17 00:00:00 2001 From: Jarrod Ribble Date: Mon, 20 Feb 2017 18:53:41 -0700 Subject: [PATCH 05/28] Add an option to use soft references for eviction with LocalCachedMap. --- .travis.yml | 2 +- .../org/redisson/RedissonLocalCachedMap.java | 10 ++- .../redisson/api/LocalCachedMapOptions.java | 3 +- .../org/redisson/misc/AbstractCacheMap.java | 50 +------------- .../java/org/redisson/misc/CachedValue.java | 12 ++++ .../java/org/redisson/misc/LFUCacheMap.java | 2 +- .../java/org/redisson/misc/SoftCacheMap.java | 39 +++++++++++ .../org/redisson/misc/SoftCachedValue.java | 35 ++++++++++ .../org/redisson/misc/StdCachedValue.java | 56 ++++++++++++++++ .../org/redisson/misc/NoneCacheMapTest.java | 3 + .../org/redisson/misc/SoftCacheMapTest.java | 65 +++++++++++++++++++ 11 files changed, 219 insertions(+), 58 deletions(-) create mode 100644 redisson/src/main/java/org/redisson/misc/CachedValue.java create mode 100644 redisson/src/main/java/org/redisson/misc/SoftCacheMap.java create mode 100644 redisson/src/main/java/org/redisson/misc/SoftCachedValue.java create mode 100644 redisson/src/main/java/org/redisson/misc/StdCachedValue.java create mode 100644 redisson/src/test/java/org/redisson/misc/SoftCacheMapTest.java diff --git a/.travis.yml b/.travis.yml index d911a0161..855eb09e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -224,4 +224,4 @@ before_script: - export REDIS_VERSION="$(redis-cli INFO SERVER | sed -n 2p)" - echo $REDIS_VERSION - redis-cli SHUTDOWN NOSAVE -script: mvn -Dtest=$REDISSON_TEST -Dsurefire.rerunFailingTestsCount=5 -DargLine="-Xmx2g -DredisBinary=$REDIS_BIN/redis-server -DtravisEnv=true" -Punit-test clean test -e -X +script: mvn -Dtest=$REDISSON_TEST -Dsurefire.rerunFailingTestsCount=5 -DargLine="-Xmx2g -DredisBinary=$REDIS_BIN/redis-server -DtravisEnv=true -XX:SoftRefLRUPolicyMSPerMB=0" -Punit-test clean test -e -X diff --git a/redisson/src/main/java/org/redisson/RedissonLocalCachedMap.java b/redisson/src/main/java/org/redisson/RedissonLocalCachedMap.java index 14ae25699..731118d3c 100644 --- a/redisson/src/main/java/org/redisson/RedissonLocalCachedMap.java +++ b/redisson/src/main/java/org/redisson/RedissonLocalCachedMap.java @@ -48,12 +48,7 @@ import org.redisson.client.protocol.convertor.NumberConvertor; import org.redisson.client.protocol.decoder.ObjectMapEntryReplayDecoder; import org.redisson.client.protocol.decoder.ObjectSetReplayDecoder; import org.redisson.command.CommandAsyncExecutor; -import org.redisson.misc.Cache; -import org.redisson.misc.Hash; -import org.redisson.misc.LFUCacheMap; -import org.redisson.misc.LRUCacheMap; -import org.redisson.misc.NoneCacheMap; -import org.redisson.misc.RPromise; +import org.redisson.misc.*; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.FutureListener; @@ -215,6 +210,9 @@ public class RedissonLocalCachedMap extends RedissonMap implements R if (options.getEvictionPolicy() == EvictionPolicy.LFU) { cache = new LFUCacheMap(options.getCacheSize(), options.getTimeToLiveInMillis(), options.getMaxIdleInMillis()); } + if (options.getEvictionPolicy() == EvictionPolicy.SOFT) { + cache = new SoftCacheMap(options.getTimeToLiveInMillis(), options.getMaxIdleInMillis()); + } invalidationTopic = new RedissonTopic(commandExecutor, suffixName(name, "topic")); if (options.isInvalidateEntryOnChange()) { diff --git a/redisson/src/main/java/org/redisson/api/LocalCachedMapOptions.java b/redisson/src/main/java/org/redisson/api/LocalCachedMapOptions.java index 89a600aa5..523cc5ff5 100644 --- a/redisson/src/main/java/org/redisson/api/LocalCachedMapOptions.java +++ b/redisson/src/main/java/org/redisson/api/LocalCachedMapOptions.java @@ -25,7 +25,7 @@ import java.util.concurrent.TimeUnit; */ public class LocalCachedMapOptions { - public enum EvictionPolicy {NONE, LRU, LFU}; + public enum EvictionPolicy {NONE, LRU, LFU, SOFT}; private boolean invalidateEntryOnChange; private EvictionPolicy evictionPolicy; @@ -115,6 +115,7 @@ public class LocalCachedMapOptions { * @param evictionPolicy *

LRU - uses cache with LRU (least recently used) eviction policy. *

LFU - uses cache with LFU (least frequently used) eviction policy. + *

SOFT - uses cache with soft references. The garbage collector will evict items from the cache when the JVM is running out of memory. *

NONE - doesn't use eviction policy, but timeToLive and maxIdleTime params are still working. * @return LocalCachedMapOptions instance */ diff --git a/redisson/src/main/java/org/redisson/misc/AbstractCacheMap.java b/redisson/src/main/java/org/redisson/misc/AbstractCacheMap.java index 75fecc81c..3a1527e29 100644 --- a/redisson/src/main/java/org/redisson/misc/AbstractCacheMap.java +++ b/redisson/src/main/java/org/redisson/misc/AbstractCacheMap.java @@ -37,54 +37,6 @@ import io.netty.util.internal.PlatformDependent; */ public abstract class AbstractCacheMap implements Cache { - public static class CachedValue { - - private final Object key; - private final Object value; - - long ttl; - long maxIdleTime; - - long creationTime; - long lastAccess; - - public CachedValue(Object key, Object value, long ttl, long maxIdleTime) { - this.value = value; - this.ttl = ttl; - this.key = key; - this.maxIdleTime = maxIdleTime; - creationTime = System.currentTimeMillis(); - lastAccess = creationTime; - } - - public boolean isExpired() { - boolean result = false; - long currentTime = System.currentTimeMillis(); - if (ttl != 0 && creationTime + ttl < currentTime) { - result = true; - } - if (maxIdleTime != 0 && lastAccess + maxIdleTime < currentTime) { - result = true; - } - return result; - } - - public Object getKey() { - return key; - } - - public Object getValue() { - lastAccess = System.currentTimeMillis(); - return value; - } - - @Override - public String toString() { - return "CachedValue [key=" + key + ", value=" + value + "]"; - } - - } - final int size; final ConcurrentMap map = PlatformDependent.newConcurrentHashMap(); private final long timeToLiveInMillis; @@ -237,7 +189,7 @@ public abstract class AbstractCacheMap implements Cache { } protected CachedValue create(K key, V value, long ttl, long maxIdleTime) { - return new CachedValue(key, value, ttl, maxIdleTime); + return new StdCachedValue(key, value, ttl, maxIdleTime); } protected void onValueCreate(CachedValue entry) { diff --git a/redisson/src/main/java/org/redisson/misc/CachedValue.java b/redisson/src/main/java/org/redisson/misc/CachedValue.java new file mode 100644 index 000000000..8fb9b5d24 --- /dev/null +++ b/redisson/src/main/java/org/redisson/misc/CachedValue.java @@ -0,0 +1,12 @@ +package org.redisson.misc; + +/** + * Created by jribble on 2/20/17. + */ +public interface CachedValue { + boolean isExpired(); + + K getKey(); + + V getValue(); +} diff --git a/redisson/src/main/java/org/redisson/misc/LFUCacheMap.java b/redisson/src/main/java/org/redisson/misc/LFUCacheMap.java index 720b46088..52d795a2e 100644 --- a/redisson/src/main/java/org/redisson/misc/LFUCacheMap.java +++ b/redisson/src/main/java/org/redisson/misc/LFUCacheMap.java @@ -57,7 +57,7 @@ public class LFUCacheMap extends AbstractCacheMap { } - public static class LFUCachedValue extends CachedValue { + public static class LFUCachedValue extends StdCachedValue { Long id; long accessCount; diff --git a/redisson/src/main/java/org/redisson/misc/SoftCacheMap.java b/redisson/src/main/java/org/redisson/misc/SoftCacheMap.java new file mode 100644 index 000000000..cab8b0309 --- /dev/null +++ b/redisson/src/main/java/org/redisson/misc/SoftCacheMap.java @@ -0,0 +1,39 @@ +/** + * Copyright 2016 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.misc; + +/** + * + * @author Nikita Koksharov + * + * @param key + * @param value + */ +public class SoftCacheMap extends AbstractCacheMap { + + public SoftCacheMap(long timeToLiveInMillis, long maxIdleInMillis) { + super(0, timeToLiveInMillis, maxIdleInMillis); + } + + protected CachedValue create(K key, V value, long ttl, long maxIdleTime) { + return new SoftCachedValue(key, value, ttl, maxIdleTime); + } + + @Override + protected void onMapFull() { + } + +} diff --git a/redisson/src/main/java/org/redisson/misc/SoftCachedValue.java b/redisson/src/main/java/org/redisson/misc/SoftCachedValue.java new file mode 100644 index 000000000..7ae53a248 --- /dev/null +++ b/redisson/src/main/java/org/redisson/misc/SoftCachedValue.java @@ -0,0 +1,35 @@ +package org.redisson.misc; + +import java.lang.ref.SoftReference; + +/** + * Created by jribble on 2/20/17. + */ + +public class SoftCachedValue implements CachedValue { + StdCachedValue> value; + + public SoftCachedValue(K key, V value, long ttl, long maxIdleTime) { + this.value = new StdCachedValue<>(key, new SoftReference<>(value), ttl, maxIdleTime); + } + + @Override + public boolean isExpired() { + return value.isExpired(); + } + + @Override + public K getKey() { + return value.getKey(); + } + + @Override + public V getValue() { + return value.getValue().get(); + } + + @Override + public String toString() { + return value.toString(); + } +} diff --git a/redisson/src/main/java/org/redisson/misc/StdCachedValue.java b/redisson/src/main/java/org/redisson/misc/StdCachedValue.java new file mode 100644 index 000000000..edf2c67c7 --- /dev/null +++ b/redisson/src/main/java/org/redisson/misc/StdCachedValue.java @@ -0,0 +1,56 @@ +package org.redisson.misc; + +/** + * Created by jribble on 2/20/17. + */ + +public class StdCachedValue implements CachedValue { + + protected final K key; + protected final V value; + + long ttl; + long maxIdleTime; + + long creationTime; + long lastAccess; + + public StdCachedValue(K key, V value, long ttl, long maxIdleTime) { + this.value = value; + this.ttl = ttl; + this.key = key; + this.maxIdleTime = maxIdleTime; + creationTime = System.currentTimeMillis(); + lastAccess = creationTime; + } + + @Override + public boolean isExpired() { + boolean result = false; + long currentTime = System.currentTimeMillis(); + if (ttl != 0 && creationTime + ttl < currentTime) { + result = true; + } + if (maxIdleTime != 0 && lastAccess + maxIdleTime < currentTime) { + result = true; + } + return result; + } + + @Override + public K getKey() { + return key; + } + + @Override + public V getValue() { + lastAccess = System.currentTimeMillis(); + return value; + } + + @Override + public String toString() { + return "CachedValue [key=" + key + ", value=" + value + "]"; + } + +} diff --git a/redisson/src/test/java/org/redisson/misc/NoneCacheMapTest.java b/redisson/src/test/java/org/redisson/misc/NoneCacheMapTest.java index 63f5a58e8..744b3a4c0 100644 --- a/redisson/src/test/java/org/redisson/misc/NoneCacheMapTest.java +++ b/redisson/src/test/java/org/redisson/misc/NoneCacheMapTest.java @@ -1,7 +1,10 @@ package org.redisson.misc; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; +import java.util.ArrayList; +import java.util.Objects; import java.util.concurrent.TimeUnit; import org.junit.Test; diff --git a/redisson/src/test/java/org/redisson/misc/SoftCacheMapTest.java b/redisson/src/test/java/org/redisson/misc/SoftCacheMapTest.java new file mode 100644 index 000000000..788bd6e85 --- /dev/null +++ b/redisson/src/test/java/org/redisson/misc/SoftCacheMapTest.java @@ -0,0 +1,65 @@ +package org.redisson.misc; + +import org.junit.Test; + +import java.util.Objects; +import java.util.concurrent.TimeUnit; + +import static org.assertj.core.api.Assertions.assertThat; + +public class SoftCacheMapTest { + + @Test + public void testMaxIdleTimeEviction() throws InterruptedException { + Cache map = new SoftCacheMap(0, 0); + map.put(1, 0, 0, TimeUnit.MILLISECONDS, 400, TimeUnit.MILLISECONDS); + assertThat(map.get(1)).isEqualTo(0); + Thread.sleep(200); + assertThat(map.get(1)).isEqualTo(0); + Thread.sleep(200); + assertThat(map.get(1)).isEqualTo(0); + Thread.sleep(200); + assertThat(map.get(1)).isEqualTo(0); + Thread.sleep(410); + assertThat(map.keySet()).isEmpty(); + } + + @Test + public void testTTLEviction() throws InterruptedException { + Cache map = new SoftCacheMap(0, 0); + map.put(1, 0, 500, TimeUnit.MILLISECONDS, 0, TimeUnit.MILLISECONDS); + assertThat(map.get(1)).isEqualTo(0); + Thread.sleep(100); + assertThat(map.get(1)).isEqualTo(0); + assertThat(map.keySet()).containsOnly(1); + Thread.sleep(500); + assertThat(map.keySet()).isEmpty(); + } + + @Test + public void testSizeEviction() { + Cache map = new SoftCacheMap(0, 0); + map.put(1, 0); + map.put(2, 0); + + assertThat(map.keySet()).containsOnly(1, 2); + map.put(3, 0); + map.put(4, 0); + + assertThat(map.keySet()).containsOnly(1, 2, 3, 4); + } + + // This test requires using -XX:SoftRefLRUPolicyMSPerMB=0 to pass + @Test + public void testSoftReferences() { + Cache map = new SoftCacheMap(0, 0); + for(int i=0;i<100000;i++) { + map.put(i, new Integer(i)); + } + + assertThat(map.values().stream().filter(Objects::nonNull).count()).isEqualTo(100000); + System.gc(); + assertThat(map.values().stream().filter(Objects::nonNull).count()).isZero(); + } + +} From 3fe75681f246baa04ea943137c395f5d84f8e6c2 Mon Sep 17 00:00:00 2001 From: Rui Gu Date: Tue, 21 Feb 2017 23:15:08 +0000 Subject: [PATCH 06/28] Update README.md added Priority Queue, Priority Deque to description --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fb9eede53..ef8c84583 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Features Object holder, Binary stream holder, Geospatial holder, BitSet, AtomicLong, AtomicDouble, PublishSubscribe, Bloom filter, HyperLogLog * [Distributed collections](https://github.com/redisson/redisson/wiki/7.-Distributed-collections) - Map, Multimap, Set, List, SortedSet, ScoredSortedSet, LexSortedSet, Queue, Deque, Blocking Queue, Bounded Blocking Queue, Blocking Deque, Delayed Queue + Map, Multimap, Set, List, SortedSet, ScoredSortedSet, LexSortedSet, Queue, Deque, Blocking Queue, Bounded Blocking Queue, Blocking Deque, Delayed Queue, Priority Queue, Priority Deque * [Distributed locks and synchronizers](https://github.com/redisson/redisson/wiki/8.-Distributed-locks-and-synchronizers) Lock, FairLock, MultiLock, RedLock, ReadWriteLock, Semaphore, PermitExpirableSemaphore, CountDownLatch * [Distributed services](https://github.com/redisson/redisson/wiki/9.-distributed-services) From 3ea04a59547e2729c0fedbea30d47d133470cf75 Mon Sep 17 00:00:00 2001 From: Nikita Date: Wed, 22 Feb 2017 17:31:50 +0300 Subject: [PATCH 07/28] StackOverflowException in URLBuilder fixed --- .../java/org/redisson/misc/URLBuilder.java | 60 ++++++++++--------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/redisson/src/main/java/org/redisson/misc/URLBuilder.java b/redisson/src/main/java/org/redisson/misc/URLBuilder.java index f27c189db..3c6f0f520 100644 --- a/redisson/src/main/java/org/redisson/misc/URLBuilder.java +++ b/redisson/src/main/java/org/redisson/misc/URLBuilder.java @@ -33,6 +33,35 @@ public class URLBuilder { private static URLStreamHandlerFactory currentFactory; + private static URLStreamHandlerFactory newFactory = new URLStreamHandlerFactory() { + @Override + public URLStreamHandler createURLStreamHandler(String protocol) { + if ("redis".equals(protocol)) { + return new URLStreamHandler() { + @Override + protected URLConnection openConnection(URL u) throws IOException { + throw new UnsupportedOperationException(); + }; + + @Override + protected boolean equals(URL u1, URL u2) { + return u1.toString().equals(u2.toString()); + } + + @Override + protected int hashCode(URL u) { + return u.toString().hashCode(); + } + }; + } + + if (currentFactory != null) { + return currentFactory.createURLStreamHandler(protocol); + } + return null; + } + }; + public static void restoreURLFactory() { try { Field field = URL.class.getDeclaredField("factory"); @@ -52,34 +81,9 @@ public class URLBuilder { field.set(null, null); } - URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() { - @Override - public URLStreamHandler createURLStreamHandler(String protocol) { - if ("redis".equals(protocol)) { - return new URLStreamHandler() { - @Override - protected URLConnection openConnection(URL u) throws IOException { - throw new UnsupportedOperationException(); - }; - - @Override - protected boolean equals(URL u1, URL u2) { - return u1.toString().equals(u2.toString()); - } - - @Override - protected int hashCode(URL u) { - return u.toString().hashCode(); - } - }; - } - - if (currentFactory != null) { - return currentFactory.createURLStreamHandler(protocol); - } - return null; - } - }); + if (currentFactory != newFactory) { + URL.setURLStreamHandlerFactory(newFactory); + } } catch (Exception e) { throw new IllegalStateException(e); } From 641063c9fc4414a954eb83afeea358cd1a35207b Mon Sep 17 00:00:00 2001 From: Nikita Date: Wed, 22 Feb 2017 17:34:04 +0300 Subject: [PATCH 08/28] StackOverflowException in URLBuilder fixed --- redisson/src/main/java/org/redisson/misc/URLBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redisson/src/main/java/org/redisson/misc/URLBuilder.java b/redisson/src/main/java/org/redisson/misc/URLBuilder.java index 3c6f0f520..f7c676da3 100644 --- a/redisson/src/main/java/org/redisson/misc/URLBuilder.java +++ b/redisson/src/main/java/org/redisson/misc/URLBuilder.java @@ -77,7 +77,7 @@ public class URLBuilder { Field field = URL.class.getDeclaredField("factory"); field.setAccessible(true); currentFactory = (URLStreamHandlerFactory) field.get(null); - if (currentFactory != null) { + if (currentFactory != null && currentFactory != newFactory) { field.set(null, null); } From c7798412fdb66b72ace891c0dad65db7faed5a04 Mon Sep 17 00:00:00 2001 From: Nikita Date: Wed, 22 Feb 2017 17:37:18 +0300 Subject: [PATCH 09/28] StackOverflowException in URLBuilder fixed. #776 --- redisson/src/main/java/org/redisson/misc/URLBuilder.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/redisson/src/main/java/org/redisson/misc/URLBuilder.java b/redisson/src/main/java/org/redisson/misc/URLBuilder.java index f7c676da3..fb8757e60 100644 --- a/redisson/src/main/java/org/redisson/misc/URLBuilder.java +++ b/redisson/src/main/java/org/redisson/misc/URLBuilder.java @@ -83,6 +83,8 @@ public class URLBuilder { if (currentFactory != newFactory) { URL.setURLStreamHandlerFactory(newFactory); + } else { + currentFactory = null; } } catch (Exception e) { throw new IllegalStateException(e); From 92e5068fb4e1085dfb20120d803d05c691e74fa9 Mon Sep 17 00:00:00 2001 From: Nikita Date: Wed, 22 Feb 2017 20:36:20 +0300 Subject: [PATCH 10/28] dependencies updated --- redisson/pom.xml | 18 +++++++++--------- .../redisson/RedissonLiveObjectService.java | 16 +++++++++++----- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/redisson/pom.xml b/redisson/pom.xml index 32222c03e..884652062 100644 --- a/redisson/pom.xml +++ b/redisson/pom.xml @@ -151,7 +151,7 @@ org.msgpack jackson-dataformat-msgpack - 0.8.7 + 0.8.11 provided @@ -181,45 +181,45 @@ com.fasterxml.jackson.dataformat jackson-dataformat-yaml - 2.7.6 + 2.8.7 com.fasterxml.jackson.core jackson-core - 2.7.6 + 2.8.7 com.fasterxml.jackson.core jackson-databind - 2.7.6 + 2.8.7 com.fasterxml.jackson.dataformat jackson-dataformat-cbor - 2.7.6 + 2.8.7 provided com.fasterxml.jackson.dataformat jackson-dataformat-smile - 2.7.6 + 2.8.7 provided com.fasterxml.jackson.dataformat jackson-dataformat-avro - 2.7.6 + 2.8.7 provided net.openhft zero-allocation-hashing - 0.5 + 0.7 net.bytebuddy byte-buddy - 1.4.26 + 1.6.8 org.jodd diff --git a/redisson/src/main/java/org/redisson/RedissonLiveObjectService.java b/redisson/src/main/java/org/redisson/RedissonLiveObjectService.java index 92a83e3d0..6a9c69c5d 100644 --- a/redisson/src/main/java/org/redisson/RedissonLiveObjectService.java +++ b/redisson/src/main/java/org/redisson/RedissonLiveObjectService.java @@ -629,12 +629,18 @@ public class RedissonLiveObjectService implements RLiveObjectService { .and(ElementMatchers.isGetter().or(ElementMatchers.isSetter()) .or(ElementMatchers.named("isPhantom")) .or(ElementMatchers.named("delete")))) - .intercept(MethodDelegation.to( - new LiveObjectInterceptor(redisson, codecProvider, entityClass, - getRIdFieldName(entityClass))) - .appendParameterBinder(FieldProxy.Binder + .intercept(MethodDelegation.withDefaultConfiguration() + .withBinders(FieldProxy.Binder .install(LiveObjectInterceptor.Getter.class, - LiveObjectInterceptor.Setter.class))) + LiveObjectInterceptor.Setter.class)) + .to(new LiveObjectInterceptor(redisson, codecProvider, entityClass, + getRIdFieldName(entityClass)))) +// .intercept(MethodDelegation.to( +// new LiveObjectInterceptor(redisson, codecProvider, entityClass, +// getRIdFieldName(entityClass))) +// .appendParameterBinder(FieldProxy.Binder +// .install(LiveObjectInterceptor.Getter.class, +// LiveObjectInterceptor.Setter.class))) .implement(RLiveObject.class) .method(ElementMatchers.isAnnotatedWith(RFieldAccessor.class) .and(ElementMatchers.named("get") From 49a558b4b5c470018af0426612e006b4cc925fee Mon Sep 17 00:00:00 2001 From: Nikita Date: Wed, 22 Feb 2017 20:36:28 +0300 Subject: [PATCH 11/28] polishing --- .../java/org/redisson/misc/CachedValue.java | 15 +++++++++++++++ .../java/org/redisson/misc/SoftCachedValue.java | 17 ++++++++++++++++- .../java/org/redisson/misc/StdCachedValue.java | 15 +++++++++++++++ .../main/java/org/redisson/misc/URLBuilder.java | 2 +- 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/redisson/src/main/java/org/redisson/misc/CachedValue.java b/redisson/src/main/java/org/redisson/misc/CachedValue.java index 8fb9b5d24..de9204ed7 100644 --- a/redisson/src/main/java/org/redisson/misc/CachedValue.java +++ b/redisson/src/main/java/org/redisson/misc/CachedValue.java @@ -1,3 +1,18 @@ +/** + * Copyright 2016 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.redisson.misc; /** diff --git a/redisson/src/main/java/org/redisson/misc/SoftCachedValue.java b/redisson/src/main/java/org/redisson/misc/SoftCachedValue.java index 7ae53a248..8a9d9e9db 100644 --- a/redisson/src/main/java/org/redisson/misc/SoftCachedValue.java +++ b/redisson/src/main/java/org/redisson/misc/SoftCachedValue.java @@ -1,3 +1,18 @@ +/** + * Copyright 2016 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.redisson.misc; import java.lang.ref.SoftReference; @@ -10,7 +25,7 @@ public class SoftCachedValue implements CachedValue { StdCachedValue> value; public SoftCachedValue(K key, V value, long ttl, long maxIdleTime) { - this.value = new StdCachedValue<>(key, new SoftReference<>(value), ttl, maxIdleTime); + this.value = new StdCachedValue>(key, new SoftReference(value), ttl, maxIdleTime); } @Override diff --git a/redisson/src/main/java/org/redisson/misc/StdCachedValue.java b/redisson/src/main/java/org/redisson/misc/StdCachedValue.java index edf2c67c7..6ffc82f4d 100644 --- a/redisson/src/main/java/org/redisson/misc/StdCachedValue.java +++ b/redisson/src/main/java/org/redisson/misc/StdCachedValue.java @@ -1,3 +1,18 @@ +/** + * Copyright 2016 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.redisson.misc; /** diff --git a/redisson/src/main/java/org/redisson/misc/URLBuilder.java b/redisson/src/main/java/org/redisson/misc/URLBuilder.java index fb8757e60..3ddc71e04 100644 --- a/redisson/src/main/java/org/redisson/misc/URLBuilder.java +++ b/redisson/src/main/java/org/redisson/misc/URLBuilder.java @@ -33,7 +33,7 @@ public class URLBuilder { private static URLStreamHandlerFactory currentFactory; - private static URLStreamHandlerFactory newFactory = new URLStreamHandlerFactory() { + private final static URLStreamHandlerFactory newFactory = new URLStreamHandlerFactory() { @Override public URLStreamHandler createURLStreamHandler(String protocol) { if ("redis".equals(protocol)) { From 07ae51add516aed88d193a8c986e17f0531fc82b Mon Sep 17 00:00:00 2001 From: Nikita Date: Wed, 22 Feb 2017 20:45:32 +0300 Subject: [PATCH 12/28] refactoring --- .../src/main/java/org/redisson/RedissonLocalCachedMap.java | 5 +++++ .../java/org/redisson/{misc => cache}/AbstractCacheMap.java | 2 +- .../src/main/java/org/redisson/{misc => cache}/Cache.java | 2 +- .../main/java/org/redisson/{misc => cache}/CachedValue.java | 2 +- .../main/java/org/redisson/{misc => cache}/LFUCacheMap.java | 2 +- .../main/java/org/redisson/{misc => cache}/LRUCacheMap.java | 2 +- .../main/java/org/redisson/{misc => cache}/NoneCacheMap.java | 2 +- .../main/java/org/redisson/{misc => cache}/SoftCacheMap.java | 2 +- .../java/org/redisson/{misc => cache}/SoftCachedValue.java | 2 +- .../java/org/redisson/{misc => cache}/StdCachedValue.java | 2 +- .../test/java/org/redisson/RedissonLocalCachedMapTest.java | 2 +- .../src/test/java/org/redisson/misc/LFUCacheMapTest.java | 2 ++ .../src/test/java/org/redisson/misc/LRUCacheMapTest.java | 2 ++ .../src/test/java/org/redisson/misc/NoneCacheMapTest.java | 2 ++ .../src/test/java/org/redisson/misc/SoftCacheMapTest.java | 2 ++ 15 files changed, 23 insertions(+), 10 deletions(-) rename redisson/src/main/java/org/redisson/{misc => cache}/AbstractCacheMap.java (99%) rename redisson/src/main/java/org/redisson/{misc => cache}/Cache.java (96%) rename redisson/src/main/java/org/redisson/{misc => cache}/CachedValue.java (96%) rename redisson/src/main/java/org/redisson/{misc => cache}/LFUCacheMap.java (99%) rename redisson/src/main/java/org/redisson/{misc => cache}/LRUCacheMap.java (98%) rename redisson/src/main/java/org/redisson/{misc => cache}/NoneCacheMap.java (97%) rename redisson/src/main/java/org/redisson/{misc => cache}/SoftCacheMap.java (97%) rename redisson/src/main/java/org/redisson/{misc => cache}/SoftCachedValue.java (97%) rename redisson/src/main/java/org/redisson/{misc => cache}/StdCachedValue.java (98%) diff --git a/redisson/src/main/java/org/redisson/RedissonLocalCachedMap.java b/redisson/src/main/java/org/redisson/RedissonLocalCachedMap.java index 731118d3c..f1742b304 100644 --- a/redisson/src/main/java/org/redisson/RedissonLocalCachedMap.java +++ b/redisson/src/main/java/org/redisson/RedissonLocalCachedMap.java @@ -38,6 +38,11 @@ import org.redisson.api.RFuture; import org.redisson.api.RLocalCachedMap; import org.redisson.api.RTopic; import org.redisson.api.listener.MessageListener; +import org.redisson.cache.Cache; +import org.redisson.cache.LFUCacheMap; +import org.redisson.cache.LRUCacheMap; +import org.redisson.cache.NoneCacheMap; +import org.redisson.cache.SoftCacheMap; import org.redisson.client.codec.Codec; import org.redisson.client.codec.LongCodec; import org.redisson.client.codec.StringCodec; diff --git a/redisson/src/main/java/org/redisson/misc/AbstractCacheMap.java b/redisson/src/main/java/org/redisson/cache/AbstractCacheMap.java similarity index 99% rename from redisson/src/main/java/org/redisson/misc/AbstractCacheMap.java rename to redisson/src/main/java/org/redisson/cache/AbstractCacheMap.java index 3a1527e29..4383aa13c 100644 --- a/redisson/src/main/java/org/redisson/misc/AbstractCacheMap.java +++ b/redisson/src/main/java/org/redisson/cache/AbstractCacheMap.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.redisson.misc; +package org.redisson.cache; import java.util.AbstractCollection; import java.util.AbstractMap.SimpleEntry; diff --git a/redisson/src/main/java/org/redisson/misc/Cache.java b/redisson/src/main/java/org/redisson/cache/Cache.java similarity index 96% rename from redisson/src/main/java/org/redisson/misc/Cache.java rename to redisson/src/main/java/org/redisson/cache/Cache.java index 2856da98b..87dcdd863 100644 --- a/redisson/src/main/java/org/redisson/misc/Cache.java +++ b/redisson/src/main/java/org/redisson/cache/Cache.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.redisson.misc; +package org.redisson.cache; import java.util.Map; import java.util.concurrent.TimeUnit; diff --git a/redisson/src/main/java/org/redisson/misc/CachedValue.java b/redisson/src/main/java/org/redisson/cache/CachedValue.java similarity index 96% rename from redisson/src/main/java/org/redisson/misc/CachedValue.java rename to redisson/src/main/java/org/redisson/cache/CachedValue.java index de9204ed7..069dbc331 100644 --- a/redisson/src/main/java/org/redisson/misc/CachedValue.java +++ b/redisson/src/main/java/org/redisson/cache/CachedValue.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.redisson.misc; +package org.redisson.cache; /** * Created by jribble on 2/20/17. diff --git a/redisson/src/main/java/org/redisson/misc/LFUCacheMap.java b/redisson/src/main/java/org/redisson/cache/LFUCacheMap.java similarity index 99% rename from redisson/src/main/java/org/redisson/misc/LFUCacheMap.java rename to redisson/src/main/java/org/redisson/cache/LFUCacheMap.java index 52d795a2e..c06b21e94 100644 --- a/redisson/src/main/java/org/redisson/misc/LFUCacheMap.java +++ b/redisson/src/main/java/org/redisson/cache/LFUCacheMap.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.redisson.misc; +package org.redisson.cache; import java.util.Map; import java.util.concurrent.ConcurrentNavigableMap; diff --git a/redisson/src/main/java/org/redisson/misc/LRUCacheMap.java b/redisson/src/main/java/org/redisson/cache/LRUCacheMap.java similarity index 98% rename from redisson/src/main/java/org/redisson/misc/LRUCacheMap.java rename to redisson/src/main/java/org/redisson/cache/LRUCacheMap.java index 8ba4368c1..d90ebf471 100644 --- a/redisson/src/main/java/org/redisson/misc/LRUCacheMap.java +++ b/redisson/src/main/java/org/redisson/cache/LRUCacheMap.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.redisson.misc; +package org.redisson.cache; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; diff --git a/redisson/src/main/java/org/redisson/misc/NoneCacheMap.java b/redisson/src/main/java/org/redisson/cache/NoneCacheMap.java similarity index 97% rename from redisson/src/main/java/org/redisson/misc/NoneCacheMap.java rename to redisson/src/main/java/org/redisson/cache/NoneCacheMap.java index 9b71681f0..db6354222 100644 --- a/redisson/src/main/java/org/redisson/misc/NoneCacheMap.java +++ b/redisson/src/main/java/org/redisson/cache/NoneCacheMap.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.redisson.misc; +package org.redisson.cache; /** * diff --git a/redisson/src/main/java/org/redisson/misc/SoftCacheMap.java b/redisson/src/main/java/org/redisson/cache/SoftCacheMap.java similarity index 97% rename from redisson/src/main/java/org/redisson/misc/SoftCacheMap.java rename to redisson/src/main/java/org/redisson/cache/SoftCacheMap.java index cab8b0309..066b0a7de 100644 --- a/redisson/src/main/java/org/redisson/misc/SoftCacheMap.java +++ b/redisson/src/main/java/org/redisson/cache/SoftCacheMap.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.redisson.misc; +package org.redisson.cache; /** * diff --git a/redisson/src/main/java/org/redisson/misc/SoftCachedValue.java b/redisson/src/main/java/org/redisson/cache/SoftCachedValue.java similarity index 97% rename from redisson/src/main/java/org/redisson/misc/SoftCachedValue.java rename to redisson/src/main/java/org/redisson/cache/SoftCachedValue.java index 8a9d9e9db..05dae153b 100644 --- a/redisson/src/main/java/org/redisson/misc/SoftCachedValue.java +++ b/redisson/src/main/java/org/redisson/cache/SoftCachedValue.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.redisson.misc; +package org.redisson.cache; import java.lang.ref.SoftReference; diff --git a/redisson/src/main/java/org/redisson/misc/StdCachedValue.java b/redisson/src/main/java/org/redisson/cache/StdCachedValue.java similarity index 98% rename from redisson/src/main/java/org/redisson/misc/StdCachedValue.java rename to redisson/src/main/java/org/redisson/cache/StdCachedValue.java index 6ffc82f4d..8d41abdf6 100644 --- a/redisson/src/main/java/org/redisson/misc/StdCachedValue.java +++ b/redisson/src/main/java/org/redisson/cache/StdCachedValue.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.redisson.misc; +package org.redisson.cache; /** * Created by jribble on 2/20/17. diff --git a/redisson/src/test/java/org/redisson/RedissonLocalCachedMapTest.java b/redisson/src/test/java/org/redisson/RedissonLocalCachedMapTest.java index 9a8044c6b..9cbd71abe 100644 --- a/redisson/src/test/java/org/redisson/RedissonLocalCachedMapTest.java +++ b/redisson/src/test/java/org/redisson/RedissonLocalCachedMapTest.java @@ -18,10 +18,10 @@ import org.redisson.RedissonMapTest.SimpleKey; import org.redisson.RedissonMapTest.SimpleValue; import org.redisson.api.LocalCachedMapOptions; import org.redisson.api.LocalCachedMapOptions.EvictionPolicy; +import org.redisson.cache.Cache; import org.redisson.api.RLocalCachedMap; import org.redisson.api.RMap; import org.redisson.api.RedissonClient; -import org.redisson.misc.Cache; import mockit.Deencapsulation; diff --git a/redisson/src/test/java/org/redisson/misc/LFUCacheMapTest.java b/redisson/src/test/java/org/redisson/misc/LFUCacheMapTest.java index f272cc366..bc149256d 100644 --- a/redisson/src/test/java/org/redisson/misc/LFUCacheMapTest.java +++ b/redisson/src/test/java/org/redisson/misc/LFUCacheMapTest.java @@ -5,6 +5,8 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.concurrent.TimeUnit; import org.junit.Test; +import org.redisson.cache.Cache; +import org.redisson.cache.LFUCacheMap; public class LFUCacheMapTest { diff --git a/redisson/src/test/java/org/redisson/misc/LRUCacheMapTest.java b/redisson/src/test/java/org/redisson/misc/LRUCacheMapTest.java index 530827416..c11328862 100644 --- a/redisson/src/test/java/org/redisson/misc/LRUCacheMapTest.java +++ b/redisson/src/test/java/org/redisson/misc/LRUCacheMapTest.java @@ -5,6 +5,8 @@ import static org.assertj.core.api.Assertions.*; import java.util.concurrent.TimeUnit; import org.junit.Test; +import org.redisson.cache.Cache; +import org.redisson.cache.LRUCacheMap; public class LRUCacheMapTest { diff --git a/redisson/src/test/java/org/redisson/misc/NoneCacheMapTest.java b/redisson/src/test/java/org/redisson/misc/NoneCacheMapTest.java index 744b3a4c0..57446e042 100644 --- a/redisson/src/test/java/org/redisson/misc/NoneCacheMapTest.java +++ b/redisson/src/test/java/org/redisson/misc/NoneCacheMapTest.java @@ -8,6 +8,8 @@ import java.util.Objects; import java.util.concurrent.TimeUnit; import org.junit.Test; +import org.redisson.cache.Cache; +import org.redisson.cache.NoneCacheMap; public class NoneCacheMapTest { diff --git a/redisson/src/test/java/org/redisson/misc/SoftCacheMapTest.java b/redisson/src/test/java/org/redisson/misc/SoftCacheMapTest.java index 788bd6e85..ec8a02dc3 100644 --- a/redisson/src/test/java/org/redisson/misc/SoftCacheMapTest.java +++ b/redisson/src/test/java/org/redisson/misc/SoftCacheMapTest.java @@ -1,6 +1,8 @@ package org.redisson.misc; import org.junit.Test; +import org.redisson.cache.Cache; +import org.redisson.cache.SoftCacheMap; import java.util.Objects; import java.util.concurrent.TimeUnit; From 57aea881c52468e95258279afaec7a1c39656107 Mon Sep 17 00:00:00 2001 From: Nikita Date: Thu, 23 Feb 2017 17:20:40 +0300 Subject: [PATCH 13/28] SoftReferences should be deleted automatically. #777 --- .../org/redisson/cache/AbstractCacheMap.java | 41 +++++++++---------- .../redisson/cache/CachedValueReference.java | 34 +++++++++++++++ .../java/org/redisson/cache/SoftCacheMap.java | 20 ++++++++- .../org/redisson/cache/SoftCachedValue.java | 29 ++++--------- .../org/redisson/misc/SoftCacheMapTest.java | 1 + 5 files changed, 81 insertions(+), 44 deletions(-) create mode 100644 redisson/src/main/java/org/redisson/cache/CachedValueReference.java diff --git a/redisson/src/main/java/org/redisson/cache/AbstractCacheMap.java b/redisson/src/main/java/org/redisson/cache/AbstractCacheMap.java index 4383aa13c..1741c6d25 100644 --- a/redisson/src/main/java/org/redisson/cache/AbstractCacheMap.java +++ b/redisson/src/main/java/org/redisson/cache/AbstractCacheMap.java @@ -38,7 +38,7 @@ import io.netty.util.internal.PlatformDependent; public abstract class AbstractCacheMap implements Cache { final int size; - final ConcurrentMap map = PlatformDependent.newConcurrentHashMap(); + final ConcurrentMap> map = PlatformDependent.newConcurrentHashMap(); private final long timeToLiveInMillis; private final long maxIdleInMillis; @@ -52,11 +52,11 @@ public abstract class AbstractCacheMap implements Cache { this.timeToLiveInMillis = timeToLiveInMillis; } - protected void onValueRead(CachedValue value) { + protected void onValueRead(CachedValue value) { } - protected void onValueRemove(CachedValue value) { + protected void onValueRemove(CachedValue value) { } @@ -89,7 +89,7 @@ public abstract class AbstractCacheMap implements Cache { throw new NullPointerException(); } - CachedValue entry = map.get(key); + CachedValue entry = map.get(key); if (entry == null) { return false; } @@ -113,8 +113,8 @@ public abstract class AbstractCacheMap implements Cache { throw new NullPointerException(); } - for (Map.Entry entry : map.entrySet()) { - CachedValue cachedValue = entry.getValue(); + for (Map.Entry> entry : map.entrySet()) { + CachedValue cachedValue = entry.getValue(); if (cachedValue.getValue().equals(value)) { if (cachedValue.isExpired()) { if (map.remove(cachedValue.getKey(), cachedValue)) { @@ -139,7 +139,7 @@ public abstract class AbstractCacheMap implements Cache { throw new NullPointerException(); } - CachedValue entry = map.get(key); + CachedValue entry = map.get(key); if (entry == null) { return null; } @@ -153,8 +153,7 @@ public abstract class AbstractCacheMap implements Cache { return readValue(entry); } - @SuppressWarnings("unchecked") - protected V readValue(CachedValue entry) { + protected V readValue(CachedValue entry) { onValueRead(entry); return (V) entry.getValue(); } @@ -168,17 +167,16 @@ public abstract class AbstractCacheMap implements Cache { return put(key, value, timeToLiveInMillis, TimeUnit.MILLISECONDS, maxIdleInMillis, TimeUnit.MILLISECONDS); } - @SuppressWarnings("unchecked") @Override public V put(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit) { - CachedValue entry = create(key, value, ttlUnit.toMillis(ttl), maxIdleUnit.toMillis(maxIdleTime)); + CachedValue entry = create(key, value, ttlUnit.toMillis(ttl), maxIdleUnit.toMillis(maxIdleTime)); if (isFull(key)) { if (!removeExpiredEntries()) { onMapFull(); } } onValueCreate(entry); - CachedValue prevCachedValue = map.put(key, entry); + CachedValue prevCachedValue = map.put(key, entry); if (prevCachedValue != null) { onValueRemove(prevCachedValue); if (!prevCachedValue.isExpired()) { @@ -188,17 +186,17 @@ public abstract class AbstractCacheMap implements Cache { return null; } - protected CachedValue create(K key, V value, long ttl, long maxIdleTime) { - return new StdCachedValue(key, value, ttl, maxIdleTime); + protected CachedValue create(K key, V value, long ttl, long maxIdleTime) { + return new StdCachedValue(key, value, ttl, maxIdleTime); } - protected void onValueCreate(CachedValue entry) { + protected void onValueCreate(CachedValue entry) { } - private boolean removeExpiredEntries() { + protected boolean removeExpiredEntries() { boolean removed = false; // TODO optimize - for (CachedValue value : map.values()) { + for (CachedValue value : map.values()) { if (value.isExpired()) { if (map.remove(value.getKey(), value)) { onValueRemove(value); @@ -232,10 +230,9 @@ public abstract class AbstractCacheMap implements Cache { * (non-Javadoc) * @see java.util.Map#remove(java.lang.Object) */ - @SuppressWarnings("unchecked") @Override public V remove(Object key) { - CachedValue entry = map.remove(key); + CachedValue entry = map.remove(key); if (entry != null) { onValueRemove(entry); if (!entry.isExpired()) { @@ -298,9 +295,9 @@ public abstract class AbstractCacheMap implements Cache { abstract class MapIterator implements Iterator { - final Iterator> keyIterator = map.entrySet().iterator(); + final Iterator>> keyIterator = map.entrySet().iterator(); - Map.Entry mapEntry; + Map.Entry> mapEntry; @Override public boolean hasNext() { @@ -309,7 +306,7 @@ public abstract class AbstractCacheMap implements Cache { } mapEntry = null; while (keyIterator.hasNext()) { - Map.Entry entry = keyIterator.next(); + Map.Entry> entry = keyIterator.next(); if (entry.getValue().isExpired()) { continue; } diff --git a/redisson/src/main/java/org/redisson/cache/CachedValueReference.java b/redisson/src/main/java/org/redisson/cache/CachedValueReference.java new file mode 100644 index 000000000..c6e0c4bfb --- /dev/null +++ b/redisson/src/main/java/org/redisson/cache/CachedValueReference.java @@ -0,0 +1,34 @@ +/** + * Copyright 2016 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.cache; + +import java.lang.ref.ReferenceQueue; +import java.lang.ref.SoftReference; + +public class CachedValueReference extends SoftReference { + + private final CachedValue owner; + + public CachedValueReference(CachedValue owner, V referent, ReferenceQueue q) { + super(referent, q); + this.owner = owner; + } + + public CachedValue getOwner() { + return owner; + } + +} diff --git a/redisson/src/main/java/org/redisson/cache/SoftCacheMap.java b/redisson/src/main/java/org/redisson/cache/SoftCacheMap.java index 066b0a7de..d861fb37c 100644 --- a/redisson/src/main/java/org/redisson/cache/SoftCacheMap.java +++ b/redisson/src/main/java/org/redisson/cache/SoftCacheMap.java @@ -15,6 +15,8 @@ */ package org.redisson.cache; +import java.lang.ref.ReferenceQueue; + /** * * @author Nikita Koksharov @@ -24,14 +26,28 @@ package org.redisson.cache; */ public class SoftCacheMap extends AbstractCacheMap { + private final ReferenceQueue queue = new ReferenceQueue(); + public SoftCacheMap(long timeToLiveInMillis, long maxIdleInMillis) { super(0, timeToLiveInMillis, maxIdleInMillis); } - protected CachedValue create(K key, V value, long ttl, long maxIdleTime) { - return new SoftCachedValue(key, value, ttl, maxIdleTime); + protected CachedValue create(K key, V value, long ttl, long maxIdleTime) { + return new SoftCachedValue(key, value, ttl, maxIdleTime, queue); } + @Override + protected boolean removeExpiredEntries() { + while (true) { + CachedValueReference value = (CachedValueReference) queue.poll(); + if (value == null) { + break; + } + map.remove(value.getOwner().getKey(), value.getOwner()); + } + return super.removeExpiredEntries(); + } + @Override protected void onMapFull() { } diff --git a/redisson/src/main/java/org/redisson/cache/SoftCachedValue.java b/redisson/src/main/java/org/redisson/cache/SoftCachedValue.java index 05dae153b..efdedc100 100644 --- a/redisson/src/main/java/org/redisson/cache/SoftCachedValue.java +++ b/redisson/src/main/java/org/redisson/cache/SoftCachedValue.java @@ -15,36 +15,25 @@ */ package org.redisson.cache; -import java.lang.ref.SoftReference; +import java.lang.ref.ReferenceQueue; /** * Created by jribble on 2/20/17. */ -public class SoftCachedValue implements CachedValue { - StdCachedValue> value; +public class SoftCachedValue extends StdCachedValue implements CachedValue { + + private final CachedValueReference ref; - public SoftCachedValue(K key, V value, long ttl, long maxIdleTime) { - this.value = new StdCachedValue>(key, new SoftReference(value), ttl, maxIdleTime); - } - - @Override - public boolean isExpired() { - return value.isExpired(); - } - - @Override - public K getKey() { - return value.getKey(); + public SoftCachedValue(K key, V value, long ttl, long maxIdleTime, ReferenceQueue queue) { + super(key, null, ttl, maxIdleTime); + this.ref = new CachedValueReference(this, value, queue); } @Override public V getValue() { - return value.getValue().get(); + super.getValue(); + return ref.get(); } - @Override - public String toString() { - return value.toString(); - } } diff --git a/redisson/src/test/java/org/redisson/misc/SoftCacheMapTest.java b/redisson/src/test/java/org/redisson/misc/SoftCacheMapTest.java index ec8a02dc3..dd074932e 100644 --- a/redisson/src/test/java/org/redisson/misc/SoftCacheMapTest.java +++ b/redisson/src/test/java/org/redisson/misc/SoftCacheMapTest.java @@ -62,6 +62,7 @@ public class SoftCacheMapTest { assertThat(map.values().stream().filter(Objects::nonNull).count()).isEqualTo(100000); System.gc(); assertThat(map.values().stream().filter(Objects::nonNull).count()).isZero(); + assertThat(map.values().size()).isZero(); } } From 94a4dc91832f7cd4de64e3f2a32959e2ce082f1d Mon Sep 17 00:00:00 2001 From: Nikita Date: Fri, 24 Feb 2017 18:45:19 +0300 Subject: [PATCH 14/28] Errors handling during RBatch execution --- .../java/org/redisson/client/handler/CommandDecoder.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/redisson/src/main/java/org/redisson/client/handler/CommandDecoder.java b/redisson/src/main/java/org/redisson/client/handler/CommandDecoder.java index b5024789f..b2411e589 100644 --- a/redisson/src/main/java/org/redisson/client/handler/CommandDecoder.java +++ b/redisson/src/main/java/org/redisson/client/handler/CommandDecoder.java @@ -184,7 +184,7 @@ public class CommandDecoder extends ReplayingDecoder { CommandsData commandBatch) { int i = state().getBatchIndex(); - RedisException error = null; + Throwable error = null; while (in.writerIndex() > in.readerIndex()) { CommandData cmd = null; try { @@ -192,12 +192,12 @@ public class CommandDecoder extends ReplayingDecoder { state().setBatchIndex(i); cmd = (CommandData) commandBatch.getCommands().get(i); decode(in, cmd, null, ctx.channel()); - i++; - } catch (IOException e) { + } catch (Exception e) { cmd.tryFailure(e); } + i++; if (!cmd.isSuccess()) { - error = (RedisException) cmd.cause(); + error = cmd.cause(); } } From da960060b02dfd39d175452b2c80a8dc403f4e7a Mon Sep 17 00:00:00 2001 From: Nikita Date: Mon, 27 Feb 2017 15:20:32 +0300 Subject: [PATCH 15/28] subscriptionMode setting added --- .../org/redisson/client/RedisConnection.java | 5 + .../client/RedisPubSubConnection.java | 5 + .../config/BaseMasterSlaveServersConfig.java | 96 ++++++++++++++----- .../org/redisson/config/ConfigSupport.java | 2 +- .../java/org/redisson/config/ReadMode.java | 5 + .../org/redisson/config/SubscriptionMode.java | 35 +++++++ .../redisson/connection/CountListener.java | 64 +++++++++++++ .../MasterSlaveConnectionManager.java | 5 +- .../redisson/connection/MasterSlaveEntry.java | 34 ++++++- .../connection/SingleConnectionManager.java | 6 +- .../org/redisson/connection/SingleEntry.java | 57 +---------- ...l.java => MasterPubSubConnectionPool.java} | 9 +- .../connection/pool/PubSubConnectionPool.java | 2 +- 13 files changed, 239 insertions(+), 86 deletions(-) create mode 100644 redisson/src/main/java/org/redisson/config/SubscriptionMode.java create mode 100644 redisson/src/main/java/org/redisson/connection/CountListener.java rename redisson/src/main/java/org/redisson/connection/pool/{SinglePubSubConnectionPool.java => MasterPubSubConnectionPool.java} (83%) diff --git a/redisson/src/main/java/org/redisson/client/RedisConnection.java b/redisson/src/main/java/org/redisson/client/RedisConnection.java index 23c64625c..003324b2f 100644 --- a/redisson/src/main/java/org/redisson/client/RedisConnection.java +++ b/redisson/src/main/java/org/redisson/client/RedisConnection.java @@ -38,6 +38,11 @@ import io.netty.util.concurrent.Future; import io.netty.util.concurrent.FutureListener; import io.netty.util.concurrent.ScheduledFuture; +/** + * + * @author Nikita Koksharov + * + */ public class RedisConnection implements RedisCommands { private static final AttributeKey CONNECTION = AttributeKey.valueOf("connection"); diff --git a/redisson/src/main/java/org/redisson/client/RedisPubSubConnection.java b/redisson/src/main/java/org/redisson/client/RedisPubSubConnection.java index 7103d1af0..ea8566ed2 100644 --- a/redisson/src/main/java/org/redisson/client/RedisPubSubConnection.java +++ b/redisson/src/main/java/org/redisson/client/RedisPubSubConnection.java @@ -40,6 +40,11 @@ import io.netty.util.concurrent.Future; import io.netty.util.concurrent.FutureListener; import io.netty.util.internal.PlatformDependent; +/** + * + * @author Nikita Koksharov + * + */ public class RedisPubSubConnection extends RedisConnection { final Queue> listeners = new ConcurrentLinkedQueue>(); diff --git a/redisson/src/main/java/org/redisson/config/BaseMasterSlaveServersConfig.java b/redisson/src/main/java/org/redisson/config/BaseMasterSlaveServersConfig.java index 9965501c8..c79869783 100644 --- a/redisson/src/main/java/org/redisson/config/BaseMasterSlaveServersConfig.java +++ b/redisson/src/main/java/org/redisson/config/BaseMasterSlaveServersConfig.java @@ -31,16 +31,6 @@ public class BaseMasterSlaveServersConfigeach slave node - */ - private int slaveSubscriptionConnectionMinimumIdleSize = 1; - - /** - * Redis 'slave' node maximum subscription (pub/sub) connection pool size for each slave node - */ - private int slaveSubscriptionConnectionPoolSize = 50; - /** * Redis 'slave' node minimum idle connection amount for each slave node */ @@ -62,6 +52,18 @@ public class BaseMasterSlaveServersConfigeach slave node + */ + private int subscriptionConnectionMinimumIdleSize = 1; + + /** + * Redis 'slave' node maximum subscription (pub/sub) connection pool size for each slave node + */ + private int subscriptionConnectionPoolSize = 50; public BaseMasterSlaveServersConfig() { } @@ -71,11 +73,12 @@ public class BaseMasterSlaveServersConfigeach slave node *

* Default is 50 *

- * @see #setSlaveSubscriptionConnectionMinimumIdleSize(int) + * @see #setSubscriptionConnectionMinimumIdleSize(int) * * @param slaveSubscriptionConnectionPoolSize - pool size * @return config */ - public T setSlaveSubscriptionConnectionPoolSize(int slaveSubscriptionConnectionPoolSize) { - this.slaveSubscriptionConnectionPoolSize = slaveSubscriptionConnectionPoolSize; + public T setSubscriptionConnectionPoolSize(int subscriptionConnectionPoolSize) { + this.subscriptionConnectionPoolSize = subscriptionConnectionPoolSize; return (T)this; } - public int getSlaveSubscriptionConnectionPoolSize() { - return slaveSubscriptionConnectionPoolSize; + public int getSubscriptionConnectionPoolSize() { + return subscriptionConnectionPoolSize; } + /** * Redis 'slave' node minimum idle connection amount for each slave node *

@@ -188,24 +207,40 @@ public class BaseMasterSlaveServersConfigeach slave node. *

* Default is 1 *

- * @see #setSlaveSubscriptionConnectionPoolSize(int) + * @see #setSubscriptionConnectionPoolSize(int) * * @param slaveSubscriptionConnectionMinimumIdleSize - pool size * @return config */ - public T setSlaveSubscriptionConnectionMinimumIdleSize(int slaveSubscriptionConnectionMinimumIdleSize) { - this.slaveSubscriptionConnectionMinimumIdleSize = slaveSubscriptionConnectionMinimumIdleSize; + public T setSubscriptionConnectionMinimumIdleSize(int subscriptionConnectionMinimumIdleSize) { + this.subscriptionConnectionMinimumIdleSize = subscriptionConnectionMinimumIdleSize; return (T) this; } - public int getSlaveSubscriptionConnectionMinimumIdleSize() { - return slaveSubscriptionConnectionMinimumIdleSize; + public int getSubscriptionConnectionMinimumIdleSize() { + return subscriptionConnectionMinimumIdleSize; } + /** * Set node type used for read operation. *

@@ -222,4 +257,21 @@ public class BaseMasterSlaveServersConfig + * Default is SLAVE + * + * @param subscriptionMode param + * @return config + */ + public T setSubscriptionMode(SubscriptionMode subscriptionMode) { + this.subscriptionMode = subscriptionMode; + return (T) this; + } + public SubscriptionMode getSubscriptionMode() { + return subscriptionMode; + } + + } diff --git a/redisson/src/main/java/org/redisson/config/ConfigSupport.java b/redisson/src/main/java/org/redisson/config/ConfigSupport.java index 8d08feb1d..6535cf813 100644 --- a/redisson/src/main/java/org/redisson/config/ConfigSupport.java +++ b/redisson/src/main/java/org/redisson/config/ConfigSupport.java @@ -266,7 +266,7 @@ public class ConfigSupport { if (config.getMasterConnectionPoolSize() < config.getMasterConnectionMinimumIdleSize()) { throw new IllegalArgumentException("masterConnectionPoolSize can't be lower than masterConnectionMinimumIdleSize"); } - if (config.getSlaveSubscriptionConnectionPoolSize() < config.getSlaveSubscriptionConnectionMinimumIdleSize()) { + if (config.getSubscriptionConnectionPoolSize() < config.getSubscriptionConnectionMinimumIdleSize()) { throw new IllegalArgumentException("slaveSubscriptionConnectionMinimumIdleSize can't be lower than slaveSubscriptionConnectionPoolSize"); } } diff --git a/redisson/src/main/java/org/redisson/config/ReadMode.java b/redisson/src/main/java/org/redisson/config/ReadMode.java index 51cfe3421..320c7dc82 100644 --- a/redisson/src/main/java/org/redisson/config/ReadMode.java +++ b/redisson/src/main/java/org/redisson/config/ReadMode.java @@ -15,6 +15,11 @@ */ package org.redisson.config; +/** + * + * @author Nikita Koksharov + * + */ public enum ReadMode { /** diff --git a/redisson/src/main/java/org/redisson/config/SubscriptionMode.java b/redisson/src/main/java/org/redisson/config/SubscriptionMode.java new file mode 100644 index 000000000..ec1f0495c --- /dev/null +++ b/redisson/src/main/java/org/redisson/config/SubscriptionMode.java @@ -0,0 +1,35 @@ +/** + * Copyright 2016 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.config; + +/** + * + * @author Nikita Koksharov + * + */ +public enum SubscriptionMode { + + /** + * Subscribe to slave nodes + */ + SLAVE, + + /** + * Subscribe to master node + */ + MASTER + +} diff --git a/redisson/src/main/java/org/redisson/connection/CountListener.java b/redisson/src/main/java/org/redisson/connection/CountListener.java new file mode 100644 index 000000000..ec449beb3 --- /dev/null +++ b/redisson/src/main/java/org/redisson/connection/CountListener.java @@ -0,0 +1,64 @@ +/** + * Copyright 2016 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.connection; + +import java.util.concurrent.atomic.AtomicInteger; + +import org.redisson.api.RFuture; +import org.redisson.misc.RPromise; +import org.redisson.misc.RedissonPromise; + +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.FutureListener; + +/** + * + * @author Nikita Koksharov + * + */ +public class CountListener implements FutureListener { + + private final RPromise res; + + private final AtomicInteger counter; + + public static RPromise create(RFuture... futures) { + RPromise result = new RedissonPromise(); + FutureListener listener = new CountListener(result, futures.length); + for (RFuture future : futures) { + future.addListener(listener); + } + return result; + } + + public CountListener(RPromise res, int amount) { + super(); + this.res = res; + this.counter = new AtomicInteger(amount); + } + + @Override + public void operationComplete(Future future) throws Exception { + if (!future.isSuccess()) { + res.tryFailure(future.cause()); + return; + } + if (counter.decrementAndGet() == 0) { + res.trySuccess(null); + } + } + +} diff --git a/redisson/src/main/java/org/redisson/connection/MasterSlaveConnectionManager.java b/redisson/src/main/java/org/redisson/connection/MasterSlaveConnectionManager.java index 1069f2885..de0392b13 100644 --- a/redisson/src/main/java/org/redisson/connection/MasterSlaveConnectionManager.java +++ b/redisson/src/main/java/org/redisson/connection/MasterSlaveConnectionManager.java @@ -320,7 +320,7 @@ public class MasterSlaveConnectionManager implements ConnectionManager { c.setClientName(cfg.getClientName()); c.setMasterConnectionPoolSize(cfg.getMasterConnectionPoolSize()); c.setSlaveConnectionPoolSize(cfg.getSlaveConnectionPoolSize()); - c.setSlaveSubscriptionConnectionPoolSize(cfg.getSlaveSubscriptionConnectionPoolSize()); + c.setSubscriptionConnectionPoolSize(cfg.getSubscriptionConnectionPoolSize()); c.setSubscriptionsPerConnection(cfg.getSubscriptionsPerConnection()); c.setConnectTimeout(cfg.getConnectTimeout()); c.setIdleConnectionTimeout(cfg.getIdleConnectionTimeout()); @@ -329,8 +329,9 @@ public class MasterSlaveConnectionManager implements ConnectionManager { c.setReconnectionTimeout(cfg.getReconnectionTimeout()); c.setMasterConnectionMinimumIdleSize(cfg.getMasterConnectionMinimumIdleSize()); c.setSlaveConnectionMinimumIdleSize(cfg.getSlaveConnectionMinimumIdleSize()); - c.setSlaveSubscriptionConnectionMinimumIdleSize(cfg.getSlaveSubscriptionConnectionMinimumIdleSize()); + c.setSubscriptionConnectionMinimumIdleSize(cfg.getSubscriptionConnectionMinimumIdleSize()); c.setReadMode(cfg.getReadMode()); + c.setSubscriptionMode(cfg.getSubscriptionMode()); return c; } diff --git a/redisson/src/main/java/org/redisson/connection/MasterSlaveEntry.java b/redisson/src/main/java/org/redisson/connection/MasterSlaveEntry.java index e8d940300..2fab36ea6 100644 --- a/redisson/src/main/java/org/redisson/connection/MasterSlaveEntry.java +++ b/redisson/src/main/java/org/redisson/connection/MasterSlaveEntry.java @@ -37,9 +37,11 @@ import org.redisson.client.protocol.RedisCommands; import org.redisson.cluster.ClusterSlotRange; import org.redisson.config.MasterSlaveServersConfig; import org.redisson.config.ReadMode; +import org.redisson.config.SubscriptionMode; import org.redisson.connection.ClientConnectionsEntry.FreezeReason; import org.redisson.connection.balancer.LoadBalancerManager; import org.redisson.connection.pool.MasterConnectionPool; +import org.redisson.connection.pool.MasterPubSubConnectionPool; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -65,6 +67,8 @@ public class MasterSlaveEntry { final MasterConnectionPool writeConnectionHolder; final Set slots = new HashSet(); + + final MasterPubSubConnectionPool pubSubConnectionHolder; final AtomicBoolean active = new AtomicBoolean(true); @@ -79,6 +83,7 @@ public class MasterSlaveEntry { slaveBalancer = new LoadBalancerManager(config, connectionManager, this); writeConnectionHolder = new MasterConnectionPool(config, connectionManager, this); + pubSubConnectionHolder = new MasterPubSubConnectionPool(config, connectionManager, this); } public List> initSlaveBalancer(Collection disconnectedNodes) { @@ -98,8 +103,20 @@ public class MasterSlaveEntry { public RFuture setupMasterEntry(String host, int port) { RedisClient client = connectionManager.createClient(NodeType.MASTER, host, port); - masterEntry = new ClientConnectionsEntry(client, config.getMasterConnectionMinimumIdleSize(), config.getMasterConnectionPoolSize(), - 0, 0, connectionManager, NodeType.MASTER); + masterEntry = new ClientConnectionsEntry( + client, + config.getMasterConnectionMinimumIdleSize(), + config.getMasterConnectionPoolSize(), + config.getSubscriptionConnectionMinimumIdleSize(), + config.getSubscriptionConnectionPoolSize(), + connectionManager, + NodeType.MASTER); + + if (config.getSubscriptionMode() == SubscriptionMode.MASTER) { + RFuture f = writeConnectionHolder.add(masterEntry); + RFuture s = pubSubConnectionHolder.add(masterEntry); + return CountListener.create(s, f); + } return writeConnectionHolder.add(masterEntry); } @@ -307,8 +324,8 @@ public class MasterSlaveEntry { ClientConnectionsEntry entry = new ClientConnectionsEntry(client, this.config.getSlaveConnectionMinimumIdleSize(), this.config.getSlaveConnectionPoolSize(), - this.config.getSlaveSubscriptionConnectionMinimumIdleSize(), - this.config.getSlaveSubscriptionConnectionPoolSize(), connectionManager, mode); + this.config.getSubscriptionConnectionMinimumIdleSize(), + this.config.getSubscriptionConnectionPoolSize(), connectionManager, mode); if (freezed) { synchronized (entry) { entry.setFreezed(freezed); @@ -352,6 +369,7 @@ public class MasterSlaveEntry { @Override public void operationComplete(Future future) throws Exception { writeConnectionHolder.remove(oldMaster); + pubSubConnectionHolder.remove(oldMaster); slaveDown(oldMaster, FreezeReason.MANAGER); // more than one slave available, so master can be removed from slaves @@ -406,10 +424,18 @@ public class MasterSlaveEntry { } RFuture nextPubSubConnection() { + if (config.getSubscriptionMode() == SubscriptionMode.MASTER) { + return pubSubConnectionHolder.get(); + } + return slaveBalancer.nextPubSubConnection(); } public void returnPubSubConnection(PubSubConnectionEntry entry) { + if (config.getSubscriptionMode() == SubscriptionMode.MASTER) { + pubSubConnectionHolder.returnConnection(masterEntry, entry.getConnection()); + return; + } slaveBalancer.returnPubSubConnection(entry.getConnection()); } diff --git a/redisson/src/main/java/org/redisson/connection/SingleConnectionManager.java b/redisson/src/main/java/org/redisson/connection/SingleConnectionManager.java index 8cb088bf3..b965b54b4 100644 --- a/redisson/src/main/java/org/redisson/connection/SingleConnectionManager.java +++ b/redisson/src/main/java/org/redisson/connection/SingleConnectionManager.java @@ -25,6 +25,7 @@ import org.redisson.config.Config; import org.redisson.config.MasterSlaveServersConfig; import org.redisson.config.ReadMode; import org.redisson.config.SingleServerConfig; +import org.redisson.config.SubscriptionMode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -71,15 +72,16 @@ public class SingleConnectionManager extends MasterSlaveConnectionManager { newconfig.setMasterAddress(addr); newconfig.setMasterConnectionPoolSize(cfg.getConnectionPoolSize()); newconfig.setSubscriptionsPerConnection(cfg.getSubscriptionsPerConnection()); - newconfig.setSlaveSubscriptionConnectionPoolSize(cfg.getSubscriptionConnectionPoolSize()); + newconfig.setSubscriptionConnectionPoolSize(cfg.getSubscriptionConnectionPoolSize()); newconfig.setConnectTimeout(cfg.getConnectTimeout()); newconfig.setIdleConnectionTimeout(cfg.getIdleConnectionTimeout()); newconfig.setFailedAttempts(cfg.getFailedAttempts()); newconfig.setReconnectionTimeout(cfg.getReconnectionTimeout()); newconfig.setMasterConnectionMinimumIdleSize(cfg.getConnectionMinimumIdleSize()); - newconfig.setSlaveSubscriptionConnectionMinimumIdleSize(cfg.getSubscriptionConnectionMinimumIdleSize()); + newconfig.setSubscriptionConnectionMinimumIdleSize(cfg.getSubscriptionConnectionMinimumIdleSize()); newconfig.setReadMode(ReadMode.MASTER); + newconfig.setSubscriptionMode(SubscriptionMode.MASTER); return newconfig; } diff --git a/redisson/src/main/java/org/redisson/connection/SingleEntry.java b/redisson/src/main/java/org/redisson/connection/SingleEntry.java index c5b0c7a5a..5fffe82f6 100644 --- a/redisson/src/main/java/org/redisson/connection/SingleEntry.java +++ b/redisson/src/main/java/org/redisson/connection/SingleEntry.java @@ -17,69 +17,22 @@ package org.redisson.connection; import java.net.InetSocketAddress; import java.util.Set; -import java.util.concurrent.atomic.AtomicInteger; -import org.redisson.api.NodeType; import org.redisson.api.RFuture; -import org.redisson.client.RedisClient; import org.redisson.client.RedisConnection; -import org.redisson.client.RedisPubSubConnection; import org.redisson.client.protocol.RedisCommand; import org.redisson.cluster.ClusterSlotRange; import org.redisson.config.MasterSlaveServersConfig; -import org.redisson.connection.pool.PubSubConnectionPool; -import org.redisson.connection.pool.SinglePubSubConnectionPool; -import org.redisson.misc.RPromise; - -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.FutureListener; +/** + * + * @author Nikita Koksharov + * + */ public class SingleEntry extends MasterSlaveEntry { - final PubSubConnectionPool pubSubConnectionHolder; - public SingleEntry(Set slotRanges, ConnectionManager connectionManager, MasterSlaveServersConfig config) { super(slotRanges, connectionManager, config); - pubSubConnectionHolder = new SinglePubSubConnectionPool(config, connectionManager, this); - } - - @Override - public RFuture setupMasterEntry(String host, int port) { - RedisClient masterClient = connectionManager.createClient(NodeType.MASTER, host, port); - masterEntry = new ClientConnectionsEntry(masterClient, - config.getMasterConnectionMinimumIdleSize(), - config.getMasterConnectionPoolSize(), - config.getSlaveConnectionMinimumIdleSize(), - config.getSlaveSubscriptionConnectionPoolSize(), connectionManager, NodeType.MASTER); - final RPromise res = connectionManager.newPromise(); - RFuture f = writeConnectionHolder.add(masterEntry); - RFuture s = pubSubConnectionHolder.add(masterEntry); - FutureListener listener = new FutureListener() { - AtomicInteger counter = new AtomicInteger(2); - @Override - public void operationComplete(Future future) throws Exception { - if (!future.isSuccess()) { - res.tryFailure(future.cause()); - return; - } - if (counter.decrementAndGet() == 0) { - res.trySuccess(null); - } - } - }; - f.addListener(listener); - s.addListener(listener); - return res; - } - - @Override - RFuture nextPubSubConnection() { - return pubSubConnectionHolder.get(); - } - - @Override - public void returnPubSubConnection(PubSubConnectionEntry entry) { - pubSubConnectionHolder.returnConnection(masterEntry, entry.getConnection()); } @Override diff --git a/redisson/src/main/java/org/redisson/connection/pool/SinglePubSubConnectionPool.java b/redisson/src/main/java/org/redisson/connection/pool/MasterPubSubConnectionPool.java similarity index 83% rename from redisson/src/main/java/org/redisson/connection/pool/SinglePubSubConnectionPool.java rename to redisson/src/main/java/org/redisson/connection/pool/MasterPubSubConnectionPool.java index 08741a488..00cbac51d 100644 --- a/redisson/src/main/java/org/redisson/connection/pool/SinglePubSubConnectionPool.java +++ b/redisson/src/main/java/org/redisson/connection/pool/MasterPubSubConnectionPool.java @@ -26,15 +26,20 @@ import org.redisson.connection.MasterSlaveEntry; * @author Nikita Koksharov * */ -public class SinglePubSubConnectionPool extends PubSubConnectionPool { +public class MasterPubSubConnectionPool extends PubSubConnectionPool { - public SinglePubSubConnectionPool(MasterSlaveServersConfig config, ConnectionManager connectionManager, + public MasterPubSubConnectionPool(MasterSlaveServersConfig config, ConnectionManager connectionManager, MasterSlaveEntry masterSlaveEntry) { super(config, connectionManager, masterSlaveEntry); } + @Override protected ClientConnectionsEntry getEntry() { return entries.get(0); } + public void remove(ClientConnectionsEntry entry) { + entries.remove(entry); + } + } diff --git a/redisson/src/main/java/org/redisson/connection/pool/PubSubConnectionPool.java b/redisson/src/main/java/org/redisson/connection/pool/PubSubConnectionPool.java index 859623a9b..7051d55a6 100644 --- a/redisson/src/main/java/org/redisson/connection/pool/PubSubConnectionPool.java +++ b/redisson/src/main/java/org/redisson/connection/pool/PubSubConnectionPool.java @@ -47,7 +47,7 @@ public class PubSubConnectionPool extends ConnectionPool @Override protected int getMinimumIdleSize(ClientConnectionsEntry entry) { - return config.getSlaveSubscriptionConnectionMinimumIdleSize(); + return config.getSubscriptionConnectionMinimumIdleSize(); } @Override From 204a59472552b5327bfeddb45152391527c3eff4 Mon Sep 17 00:00:00 2001 From: Nikita Date: Tue, 28 Feb 2017 13:59:00 +0300 Subject: [PATCH 16/28] TomcatSessionManager can't be used in Tomcat if it already has been deployed in Application. #784 --- .../tomcat/RedissonSessionManager.java | 4 +- .../tomcat/RedissonSessionManager.java | 4 +- .../tomcat/RedissonSessionManager.java | 4 +- .../main/java/org/redisson/config/Config.java | 21 +++++++++- .../org/redisson/config/ConfigSupport.java | 38 +++++++++++++++---- 5 files changed, 56 insertions(+), 15 deletions(-) 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 6399320c0..693f0350b 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 @@ -143,11 +143,11 @@ public class RedissonSessionManager extends ManagerBase implements Lifecycle { public void start() throws LifecycleException { Config config = null; try { - config = Config.fromJSON(new File(configPath)); + config = Config.fromJSON(new File(configPath), getClass().getClassLoader()); } catch (IOException e) { // trying next format try { - config = Config.fromYAML(new File(configPath)); + config = Config.fromYAML(new File(configPath), getClass().getClassLoader()); } catch (IOException e1) { log.error("Can't parse json config " + configPath, e); throw new LifecycleException("Can't parse yaml config " + configPath, e1); 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 87d41f81a..e17e7ae57 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 @@ -146,11 +146,11 @@ public class RedissonSessionManager extends ManagerBase implements Lifecycle { super.startInternal(); Config config = null; try { - config = Config.fromJSON(new File(configPath)); + config = Config.fromJSON(new File(configPath), getClass().getClassLoader()); } catch (IOException e) { // trying next format try { - config = Config.fromYAML(new File(configPath)); + config = Config.fromYAML(new File(configPath), getClass().getClassLoader()); } catch (IOException e1) { log.error("Can't parse json config " + configPath, e); throw new LifecycleException("Can't parse yaml config " + configPath, e1); 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 87d41f81a..e17e7ae57 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 @@ -146,11 +146,11 @@ public class RedissonSessionManager extends ManagerBase implements Lifecycle { super.startInternal(); Config config = null; try { - config = Config.fromJSON(new File(configPath)); + config = Config.fromJSON(new File(configPath), getClass().getClassLoader()); } catch (IOException e) { // trying next format try { - config = Config.fromYAML(new File(configPath)); + config = Config.fromYAML(new File(configPath), getClass().getClassLoader()); } catch (IOException e1) { log.error("Can't parse json config " + configPath, e); throw new LifecycleException("Can't parse yaml config " + configPath, e1); diff --git a/redisson/src/main/java/org/redisson/config/Config.java b/redisson/src/main/java/org/redisson/config/Config.java index 233778dc0..b15d9a794 100644 --- a/redisson/src/main/java/org/redisson/config/Config.java +++ b/redisson/src/main/java/org/redisson/config/Config.java @@ -556,12 +556,24 @@ public class Config { * Read config object stored in JSON format from File * * @param file object + * @param classLoader class loader * @return config * @throws IOException error */ - public static Config fromJSON(File file) throws IOException { + public static Config fromJSON(File file, ClassLoader classLoader) throws IOException { ConfigSupport support = new ConfigSupport(); - return support.fromJSON(file, Config.class); + return support.fromJSON(file, Config.class, classLoader); + } + + /** + * Read config object stored in JSON format from File + * + * @param file object + * @return config + * @throws IOException error + */ + public static Config fromJSON(File file) throws IOException { + return fromJSON(file); } /** @@ -634,6 +646,11 @@ public class Config { ConfigSupport support = new ConfigSupport(); return support.fromYAML(file, Config.class); } + + public static Config fromYAML(File file, ClassLoader classLoader) throws IOException { + ConfigSupport support = new ConfigSupport(); + return support.fromYAML(file, Config.class, classLoader); + } /** * Read config object stored in YAML format from URL diff --git a/redisson/src/main/java/org/redisson/config/ConfigSupport.java b/redisson/src/main/java/org/redisson/config/ConfigSupport.java index 6535cf813..7c55bb5e4 100644 --- a/redisson/src/main/java/org/redisson/config/ConfigSupport.java +++ b/redisson/src/main/java/org/redisson/config/ConfigSupport.java @@ -26,13 +26,16 @@ import java.util.List; import org.redisson.api.RedissonNodeInitializer; import org.redisson.client.codec.Codec; import org.redisson.cluster.ClusterConnectionManager; +import org.redisson.codec.CodecProvider; import org.redisson.connection.ConnectionManager; import org.redisson.connection.ElasticacheConnectionManager; -import org.redisson.connection.ReplicatedConnectionManager; import org.redisson.connection.MasterSlaveConnectionManager; +import org.redisson.connection.ReplicatedConnectionManager; import org.redisson.connection.SentinelConnectionManager; import org.redisson.connection.SingleConnectionManager; import org.redisson.connection.balancer.LoadBalancer; +import org.redisson.liveobject.provider.ResolverProvider; +import org.redisson.misc.URLBuilder; import com.fasterxml.jackson.annotation.JsonFilter; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -45,10 +48,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ser.FilterProvider; import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; +import com.fasterxml.jackson.databind.type.TypeFactory; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import org.redisson.codec.CodecProvider; -import org.redisson.liveobject.provider.ResolverProvider; -import org.redisson.misc.URLBuilder; /** * @@ -118,8 +119,8 @@ public class ConfigSupport { } - private final ObjectMapper jsonMapper = createMapper(null); - private final ObjectMapper yamlMapper = createMapper(new YAMLFactory()); + private ObjectMapper jsonMapper = createMapper(null, null); + private ObjectMapper yamlMapper = createMapper(new YAMLFactory(), null); public T fromJSON(String content, Class configType) throws IOException { URLBuilder.replaceURLFactory(); @@ -131,8 +132,13 @@ public class ConfigSupport { } public T fromJSON(File file, Class configType) throws IOException { + return fromJSON(file, configType, null); + } + + public T fromJSON(File file, Class configType, ClassLoader classLoader) throws IOException { URLBuilder.replaceURLFactory(); try { + jsonMapper = createMapper(null, classLoader); return jsonMapper.readValue(file, configType); } finally { URLBuilder.restoreURLFactory(); @@ -192,6 +198,17 @@ public class ConfigSupport { URLBuilder.restoreURLFactory(); } } + + public T fromYAML(File file, Class configType, ClassLoader classLoader) throws IOException { + URLBuilder.replaceURLFactory(); + try { + yamlMapper = createMapper(new YAMLFactory(), classLoader); + return yamlMapper.readValue(file, configType); + } finally { + URLBuilder.restoreURLFactory(); + } + } + public T fromYAML(URL url, Class configType) throws IOException { URLBuilder.replaceURLFactory(); @@ -271,7 +288,7 @@ public class ConfigSupport { } } - private ObjectMapper createMapper(JsonFactory mapping) { + private ObjectMapper createMapper(JsonFactory mapping, ClassLoader classLoader) { ObjectMapper mapper = new ObjectMapper(mapping); mapper.addMixIn(MasterSlaveServersConfig.class, MasterSlaveServersConfigMixIn.class); mapper.addMixIn(SingleServerConfig.class, SingleSeverConfigMixIn.class); @@ -285,6 +302,13 @@ public class ConfigSupport { .addFilter("classFilter", SimpleBeanPropertyFilter.filterOutAllExcept()); mapper.setFilterProvider(filterProvider); mapper.setSerializationInclusion(Include.NON_NULL); + + if (classLoader != null) { + TypeFactory tf = TypeFactory.defaultInstance() + .withClassLoader(classLoader); + mapper.setTypeFactory(tf); + } + return mapper; } From af2cd70923c3939e1db1b7731535e1e061573a49 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Tue, 28 Feb 2017 17:45:27 +0300 Subject: [PATCH 17/28] Update README.md --- redisson-tomcat/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/redisson-tomcat/README.md b/redisson-tomcat/README.md index ff6bad985..c7b803901 100644 --- a/redisson-tomcat/README.md +++ b/redisson-tomcat/README.md @@ -1,13 +1,13 @@ Redis based Tomcat Session Manager === -Implements non-sticky session management backed by Redis. +Stores session of Apache Tomcat in Redis and allows to distribute requests across a cluster of Tomcat servers. Implements non-sticky session management backed by Redis. Supports Tomcat 6.x, 7.x, 8.x Advantages === -Current implementation differs from any other Tomcat Session Manager in terms of efficient storage and optimized writes. Each session attribute is written into Redis during each `HttpSession.setAttribute` invocation. While other solutions serialize whole session each time. +Current implementation differs from any other Redis based Tomcat Session Manager in terms of efficient storage and optimized writes. Each session attribute is written into Redis during each `HttpSession.setAttribute` invocation. While other solutions serialize whole session each time. Usage === From 108ded3221688bd70af2f04899ad2dae9305cb1e Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Tue, 28 Feb 2017 17:46:50 +0300 Subject: [PATCH 18/28] Update README.md --- redisson-tomcat/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/redisson-tomcat/README.md b/redisson-tomcat/README.md index c7b803901..bdc8f2fb2 100644 --- a/redisson-tomcat/README.md +++ b/redisson-tomcat/README.md @@ -2,7 +2,8 @@ Redis based Tomcat Session Manager === Stores session of Apache Tomcat in Redis and allows to distribute requests across a cluster of Tomcat servers. Implements non-sticky session management backed by Redis. -Supports Tomcat 6.x, 7.x, 8.x + +Supports Apache Tomcat 6.x, 7.x, 8.x Advantages === From 243616471bc279fb1f0a8efe7a169ec2de0950e5 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Fri, 3 Mar 2017 17:40:39 +0300 Subject: [PATCH 19/28] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ef8c84583..92ce0dcab 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ Features Who uses Redisson ================================ -[Electronic Arts](http://ea.com), [Baidu](http://baidu.com), [New Relic Synthetics](https://newrelic.com/synthetics), [National Australia Bank](https://www.nab.com.au/), [Brookhaven National Laboratory](http://bnl.gov/), [Singtel](http://singtel.com), [Infor](http://www.infor.com/), [Setronica](http://setronica.com/), [Monits](http://monits.com/), [Netflix Dyno client] (https://github.com/Netflix/dyno), [武林Q传](http://www.nbrpg.com/), [Ocous](http://www.ocous.com/), [Invaluable](http://www.invaluable.com/), [Clover](https://www.clover.com/) , [Apache Karaf Decanter](https://karaf.apache.org/projects.html#decanter), [Atmosphere Framework](http://async-io.org/), [BrandsEye](http://brandseye.com), [Datorama](http://datorama.com/), [BrightCloud](http://brightcloud.com/), [Azar](http://azarlive.com/), [Snapfish](http://snapfish.com), [Crimson Hexagon](http://www.crimsonhexagon.com) +[Electronic Arts](http://ea.com), [Baidu](http://baidu.com), [New Relic Synthetics](https://newrelic.com/synthetics), [National Australia Bank](https://www.nab.com.au/), [Brookhaven National Laboratory](http://bnl.gov/), [Singtel](http://singtel.com), [Infor](http://www.infor.com/), [Setronica](http://setronica.com/), [Monits](http://monits.com/), [Netflix Dyno client] (https://github.com/Netflix/dyno), [武林Q传](http://www.nbrpg.com/), [Ocous](http://www.ocous.com/), [Invaluable](http://www.invaluable.com/), [Clover](https://www.clover.com/) , [Apache Karaf Decanter](https://karaf.apache.org/projects.html#decanter), [Atmosphere Framework](http://async-io.org/), [BrandsEye](http://brandseye.com), [Datorama](http://datorama.com/), [BrightCloud](http://brightcloud.com/), [Azar](http://azarlive.com/), [Snapfish](http://snapfish.com), [Crimson Hexagon](http://www.crimsonhexagon.com), [Quby](http://quby.com/), [Base CRM](http://getbase.com) Articles ================================ From bbc7719536eae3b59ef9c7fe43fa6bb73b3747d3 Mon Sep 17 00:00:00 2001 From: Dan Checkoway Date: Fri, 3 Mar 2017 11:38:32 -0500 Subject: [PATCH 20/28] Skip cluster nodes with the "handshake" flag --- .../java/org/redisson/cluster/ClusterConnectionManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java b/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java index e6c5f7b8b..4c4ee586d 100644 --- a/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java +++ b/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java @@ -671,7 +671,7 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager { private Collection parsePartitions(List nodes) { Map partitions = new HashMap(); for (ClusterNodeInfo clusterNodeInfo : nodes) { - if (clusterNodeInfo.containsFlag(Flag.NOADDR)) { + if (clusterNodeInfo.containsFlag(Flag.NOADDR) || clusterNodeInfo.containsFlag(Flag.HANDSHAKE)) { // skip it continue; } From ed9ba25ab6653fef4de33be2295a1c167a7546c0 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Fri, 3 Mar 2017 20:18:38 +0300 Subject: [PATCH 21/28] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 92ce0dcab..3627d4aa4 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ Features Who uses Redisson ================================ -[Electronic Arts](http://ea.com), [Baidu](http://baidu.com), [New Relic Synthetics](https://newrelic.com/synthetics), [National Australia Bank](https://www.nab.com.au/), [Brookhaven National Laboratory](http://bnl.gov/), [Singtel](http://singtel.com), [Infor](http://www.infor.com/), [Setronica](http://setronica.com/), [Monits](http://monits.com/), [Netflix Dyno client] (https://github.com/Netflix/dyno), [武林Q传](http://www.nbrpg.com/), [Ocous](http://www.ocous.com/), [Invaluable](http://www.invaluable.com/), [Clover](https://www.clover.com/) , [Apache Karaf Decanter](https://karaf.apache.org/projects.html#decanter), [Atmosphere Framework](http://async-io.org/), [BrandsEye](http://brandseye.com), [Datorama](http://datorama.com/), [BrightCloud](http://brightcloud.com/), [Azar](http://azarlive.com/), [Snapfish](http://snapfish.com), [Crimson Hexagon](http://www.crimsonhexagon.com), [Quby](http://quby.com/), [Base CRM](http://getbase.com) +[Electronic Arts](http://ea.com), [Baidu](http://baidu.com), [New Relic Synthetics](https://newrelic.com/synthetics), [Brookhaven National Laboratory](http://bnl.gov/), [Singtel](http://singtel.com), [Infor](http://www.infor.com/), [Setronica](http://setronica.com/), [Monits](http://monits.com/), [Netflix Dyno client] (https://github.com/Netflix/dyno), [武林Q传](http://www.nbrpg.com/), [Ocous](http://www.ocous.com/), [Invaluable](http://www.invaluable.com/), [Clover](https://www.clover.com/) , [Apache Karaf Decanter](https://karaf.apache.org/projects.html#decanter), [Atmosphere Framework](http://async-io.org/), [BrandsEye](http://brandseye.com), [Datorama](http://datorama.com/), [BrightCloud](http://brightcloud.com/), [Azar](http://azarlive.com/), [Snapfish](http://snapfish.com), [Crimson Hexagon](http://www.crimsonhexagon.com), [Quby](http://quby.com/), [Base CRM](http://getbase.com) Articles ================================ From 9b5b7f5ac42b68259bebffc0af784f513148acc7 Mon Sep 17 00:00:00 2001 From: Nikita Date: Sat, 4 Mar 2017 11:41:53 +0300 Subject: [PATCH 22/28] LocalCachedMap.putAll optimization --- .../org/redisson/RedissonLocalCachedMap.java | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/redisson/src/main/java/org/redisson/RedissonLocalCachedMap.java b/redisson/src/main/java/org/redisson/RedissonLocalCachedMap.java index f1742b304..a9c45fc07 100644 --- a/redisson/src/main/java/org/redisson/RedissonLocalCachedMap.java +++ b/redisson/src/main/java/org/redisson/RedissonLocalCachedMap.java @@ -53,7 +53,8 @@ import org.redisson.client.protocol.convertor.NumberConvertor; import org.redisson.client.protocol.decoder.ObjectMapEntryReplayDecoder; import org.redisson.client.protocol.decoder.ObjectSetReplayDecoder; import org.redisson.command.CommandAsyncExecutor; -import org.redisson.misc.*; +import org.redisson.misc.Hash; +import org.redisson.misc.RPromise; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.FutureListener; @@ -73,14 +74,14 @@ public class RedissonLocalCachedMap extends RedissonMap implements R public static class LocalCachedMapInvalidate implements Serializable { private byte[] excludedId; - private byte[] keyHash; + private List keyHashes; public LocalCachedMapInvalidate() { } - public LocalCachedMapInvalidate(byte[] excludedId, byte[] keyHash) { + public LocalCachedMapInvalidate(byte[] excludedId, byte[]... keyHash) { super(); - this.keyHash = keyHash; + this.keyHashes = Arrays.asList(keyHash); this.excludedId = excludedId; } @@ -88,8 +89,8 @@ public class RedissonLocalCachedMap extends RedissonMap implements R return excludedId; } - public byte[] getKeyHash() { - return keyHash; + public Collection getKeyHashes() { + return keyHashes; } } @@ -230,8 +231,10 @@ public class RedissonLocalCachedMap extends RedissonMap implements R if (msg instanceof LocalCachedMapInvalidate) { LocalCachedMapInvalidate invalidateMsg = (LocalCachedMapInvalidate)msg; if (!Arrays.equals(invalidateMsg.getExcludedId(), instanceId)) { - CacheKey key = new CacheKey(invalidateMsg.getKeyHash()); - cache.remove(key); + for (byte[] keyHash : invalidateMsg.getKeyHashes()) { + CacheKey key = new CacheKey(keyHash); + cache.remove(key); + } } } } @@ -725,27 +728,30 @@ public class RedissonLocalCachedMap extends RedissonMap implements R } List params = new ArrayList(map.size()*3); - List msgs = new ArrayList(map.size()); params.add(invalidateEntryOnChange); params.add(map.size()*2); + byte[][] hashes = new byte[map.size()][]; + int i = 0; for (java.util.Map.Entry t : map.entrySet()) { byte[] mapKey = encodeMapKey(t.getKey()); byte[] mapValue = encodeMapValue(t.getValue()); params.add(mapKey); params.add(mapValue); CacheKey cacheKey = toCacheKey(mapKey); - byte[] msgEncoded = encode(new LocalCachedMapInvalidate(instanceId, cacheKey.getKeyHash())); - msgs.add(msgEncoded); + hashes[i] = cacheKey.getKeyHash(); + i++; } - params.addAll(msgs); + + byte[] msgEncoded = encode(new LocalCachedMapInvalidate(instanceId, hashes)); + params.add(msgEncoded); final RPromise result = newPromise(); RFuture future = commandExecutor.evalWriteAsync(getName(), codec, RedisCommands.EVAL_VOID, "redis.call('hmset', KEYS[1], unpack(ARGV, 3, tonumber(ARGV[2]) + 2));" + "if ARGV[1] == '1' then " - + "for i = tonumber(ARGV[2]) + 3, #ARGV, 1 do " - + "redis.call('publish', KEYS[2], ARGV[i]); " - + "end; " +// + "for i = tonumber(ARGV[2]) + 3, #ARGV, 1 do " + + "redis.call('publish', KEYS[2], ARGV[#ARGV]); " +// + "end; " + "end;", Arrays.asList(getName(), invalidationTopic.getChannelNames().get(0)), params.toArray()); From be5f46e87e94ce006a280181b8c52fc102860a89 Mon Sep 17 00:00:00 2001 From: Nikita Date: Sat, 4 Mar 2017 11:42:37 +0300 Subject: [PATCH 23/28] Java docs fixed --- .../org/redisson/config/BaseMasterSlaveServersConfig.java | 4 ++-- .../src/main/java/org/redisson/pubsub/PublishSubscribe.java | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/redisson/src/main/java/org/redisson/config/BaseMasterSlaveServersConfig.java b/redisson/src/main/java/org/redisson/config/BaseMasterSlaveServersConfig.java index c79869783..bdc5d7312 100644 --- a/redisson/src/main/java/org/redisson/config/BaseMasterSlaveServersConfig.java +++ b/redisson/src/main/java/org/redisson/config/BaseMasterSlaveServersConfig.java @@ -159,7 +159,7 @@ public class BaseMasterSlaveServersConfig * @see #setSubscriptionConnectionMinimumIdleSize(int) * - * @param slaveSubscriptionConnectionPoolSize - pool size + * @param subscriptionConnectionPoolSize - pool size * @return config */ public T setSubscriptionConnectionPoolSize(int subscriptionConnectionPoolSize) { @@ -229,7 +229,7 @@ public class BaseMasterSlaveServersConfig * @see #setSubscriptionConnectionPoolSize(int) * - * @param slaveSubscriptionConnectionMinimumIdleSize - pool size + * @param subscriptionConnectionMinimumIdleSize - pool size * @return config */ public T setSubscriptionConnectionMinimumIdleSize(int subscriptionConnectionMinimumIdleSize) { diff --git a/redisson/src/main/java/org/redisson/pubsub/PublishSubscribe.java b/redisson/src/main/java/org/redisson/pubsub/PublishSubscribe.java index d15bec4c0..eb9a0fce1 100644 --- a/redisson/src/main/java/org/redisson/pubsub/PublishSubscribe.java +++ b/redisson/src/main/java/org/redisson/pubsub/PublishSubscribe.java @@ -34,7 +34,6 @@ import io.netty.util.internal.PlatformDependent; * * @author Nikita Koksharov * - * @param */ abstract class PublishSubscribe> { From 141236de7f29562f621064fa98102cb53634f53a Mon Sep 17 00:00:00 2001 From: Nikita Date: Sat, 4 Mar 2017 11:43:20 +0300 Subject: [PATCH 24/28] LeaseTimeout calculated in wrong way in case of nested ReadLocks --- .../java/org/redisson/RedissonReadLock.java | 44 +++++++++++++------ .../redisson/RedissonReadWriteLockTest.java | 16 +++++++ 2 files changed, 46 insertions(+), 14 deletions(-) diff --git a/redisson/src/main/java/org/redisson/RedissonReadLock.java b/redisson/src/main/java/org/redisson/RedissonReadLock.java index 8fb3b1202..b76174056 100644 --- a/redisson/src/main/java/org/redisson/RedissonReadLock.java +++ b/redisson/src/main/java/org/redisson/RedissonReadLock.java @@ -65,11 +65,15 @@ public class RedissonReadLock extends RedissonLock implements RLock { "if (mode == false) then " + "redis.call('hset', KEYS[1], 'mode', 'read'); " + "redis.call('hset', KEYS[1], ARGV[2], 1); " + + "redis.call('set', KEYS[1] .. ':timeout:1', 1); " + + "redis.call('pexpire', KEYS[1] .. ':timeout:1', ARGV[1]); " + "redis.call('pexpire', KEYS[1], ARGV[1]); " + "return nil; " + "end; " + "if (mode == 'read') or (mode == 'write' and redis.call('hexists', KEYS[1], ARGV[3]) == 1) then " + - "redis.call('hincrby', KEYS[1], ARGV[2], 1); " + + "local ind = redis.call('hincrby', KEYS[1], ARGV[2], 1); " + + "redis.call('set', KEYS[1] .. ':timeout:' .. ind, 1); " + + "redis.call('pexpire', KEYS[1] .. ':timeout:' .. ind, ARGV[1]); " + "redis.call('pexpire', KEYS[1], ARGV[1]); " + "return nil; " + "end;" + @@ -85,27 +89,39 @@ public class RedissonReadLock extends RedissonLock implements RLock { "redis.call('publish', KEYS[2], ARGV[1]); " + "return 1; " + "end; " + -// "if (mode == 'read') then " + - "local lockExists = redis.call('hexists', KEYS[1], ARGV[3]); " + - "if (lockExists == 0) then " + - "return nil;" + - "else " + - "local counter = redis.call('hincrby', KEYS[1], ARGV[3], -1); " + - "if (counter > 0) then " + - "redis.call('pexpire', KEYS[1], ARGV[2]); " + - "return 0; " + + "local lockExists = redis.call('hexists', KEYS[1], ARGV[2]); " + + "if (lockExists == 0) then " + + "return nil;" + + "else " + + "local counter = redis.call('hincrby', KEYS[1], ARGV[2], -1); " + + "redis.call('del', KEYS[1] .. ':timeout:' .. (counter+1)); " + + "if (counter > 0) then " + + "local maxRemainTime = -3; " + + "for i=counter, 1, -1 do " + + "local remainTime = redis.call('pttl', KEYS[1] .. ':timeout:' .. i); " + + "maxRemainTime = math.max(remainTime, maxRemainTime);" + + "end; " + + "if maxRemainTime > 0 then " + + "redis.call('pexpire', KEYS[1], maxRemainTime); " + "else " + - "redis.call('hdel', KEYS[1], ARGV[3]); " + + "redis.call('hdel', KEYS[1], ARGV[2]); " + "if (redis.call('hlen', KEYS[1]) == 1) then " + "redis.call('del', KEYS[1]); " + "redis.call('publish', KEYS[2], ARGV[1]); " + "end; " + - "return 1; "+ + "end;" + + "return 0; " + + "else " + + "redis.call('hdel', KEYS[1], ARGV[2]); " + + "if (redis.call('hlen', KEYS[1]) == 1) then " + + "redis.call('del', KEYS[1]); " + + "redis.call('publish', KEYS[2], ARGV[1]); " + "end; " + + "return 1; "+ "end; " + -// "end; " + + "end; " + "return nil; ", - Arrays.asList(getName(), getChannelName()), LockPubSub.unlockMessage, internalLockLeaseTime, getLockName(Thread.currentThread().getId())); + Arrays.asList(getName(), getChannelName()), LockPubSub.unlockMessage, getLockName(Thread.currentThread().getId())); if (opStatus == null) { throw new IllegalMonitorStateException("attempt to unlock read lock, not locked by current thread by node id: " + id + " thread-id: " + Thread.currentThread().getId()); diff --git a/redisson/src/test/java/org/redisson/RedissonReadWriteLockTest.java b/redisson/src/test/java/org/redisson/RedissonReadWriteLockTest.java index eb2429e49..6965cf32c 100644 --- a/redisson/src/test/java/org/redisson/RedissonReadWriteLockTest.java +++ b/redisson/src/test/java/org/redisson/RedissonReadWriteLockTest.java @@ -16,6 +16,22 @@ import org.redisson.api.RReadWriteLock; public class RedissonReadWriteLockTest extends BaseConcurrentTest { + @Test + public void testReadLockLeaseTimeout() throws InterruptedException { + RLock readLock = redisson.getReadWriteLock("my_read_write_lock").readLock(); + Assert.assertTrue(readLock.tryLock(1, 4, TimeUnit.SECONDS)); + + Thread.sleep(3000); + RLock readLock2 = redisson.getReadWriteLock("my_read_write_lock").readLock(); + Assert.assertTrue(readLock2.tryLock(1, 4, TimeUnit.SECONDS)); + readLock2.unlock(); + + Thread.sleep(2000); + + RLock writeLock = redisson.getReadWriteLock("my_read_write_lock").writeLock(); + Assert.assertTrue(writeLock.tryLock()); + } + @Test public void testWriteReadReentrancy() throws InterruptedException { RReadWriteLock readWriteLock = redisson.getReadWriteLock("TEST"); From 62c4c7fa151d9ec4973c1df4c5ddeaaff4c0b92c Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Sat, 4 Mar 2017 12:16:54 +0300 Subject: [PATCH 25/28] Update README.md --- README.md | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3627d4aa4..7b0edb9e7 100644 --- a/README.md +++ b/README.md @@ -9,16 +9,9 @@ Redis 2.8+ compatible. | 3.3.0 | 1.8+ | 19.02.2017 | | 2.8.0 | 1.6, 1.7, 1.8 and Android | 19.02.2017 | -__NOTE__: Both version lines have same features except `CompletionStage` interface supported by 3.x.x line +__NOTE__: Both version lines have same features except `CompletionStage` interface added in 3.x.x -Please read [documentation](https://github.com/redisson/redisson/wiki) for more details. -Redisson [releases history](https://github.com/redisson/redisson/blob/master/CHANGELOG.md) -Checkout more [code examples](https://github.com/redisson/redisson-examples) -Browse [javadocs](http://www.javadoc.io/doc/org.redisson/redisson/3.2.4) - -Licensed under the Apache License 2.0. - -Welcome to support chat [![Join the chat at https://gitter.im/mrniko/redisson](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mrniko/redisson?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[Documentation](https://github.com/redisson/redisson/wiki) | [Javadocs](http://www.javadoc.io/doc/org.redisson/redisson/3.3.0) | [Changelog](https://github.com/redisson/redisson/blob/master/CHANGELOG.md) | [Code examples](https://github.com/redisson/redisson-examples) | [Support chat](https://gitter.im/mrniko/redisson) Features From 38b5f8ac76b1b078d17dd8013f4a1025e5f2633d Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Sat, 4 Mar 2017 12:17:23 +0300 Subject: [PATCH 26/28] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 7b0edb9e7..a006409a8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ Redis based In-Memory Data Grid for Java. Redisson. ==== +[Documentation](https://github.com/redisson/redisson/wiki) | [Javadocs](http://www.javadoc.io/doc/org.redisson/redisson/3.3.0) | [Changelog](https://github.com/redisson/redisson/blob/master/CHANGELOG.md) | [Code examples](https://github.com/redisson/redisson-examples) | [Support chat](https://gitter.im/mrniko/redisson) Based on high-performance async and lock-free Java Redis client and [Netty](http://netty.io) framework. Redis 2.8+ compatible. @@ -11,8 +12,6 @@ Redis 2.8+ compatible. __NOTE__: Both version lines have same features except `CompletionStage` interface added in 3.x.x -[Documentation](https://github.com/redisson/redisson/wiki) | [Javadocs](http://www.javadoc.io/doc/org.redisson/redisson/3.3.0) | [Changelog](https://github.com/redisson/redisson/blob/master/CHANGELOG.md) | [Code examples](https://github.com/redisson/redisson-examples) | [Support chat](https://gitter.im/mrniko/redisson) - Features ================================ From e9e9e2e3edb326b8acf3d9c92bf18231c45625b8 Mon Sep 17 00:00:00 2001 From: Nikita Date: Sat, 4 Mar 2017 12:54:56 +0300 Subject: [PATCH 27/28] [maven-release-plugin] prepare release redisson-2.8.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/pom.xml | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 960251c48..44bb0f89b 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.redisson redisson-parent - 2.8.1-SNAPSHOT + 2.8.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.8.1 diff --git a/redisson-all/pom.xml b/redisson-all/pom.xml index f2b1e9fa2..7cffe9e34 100644 --- a/redisson-all/pom.xml +++ b/redisson-all/pom.xml @@ -4,7 +4,7 @@ org.redisson redisson-parent - 2.8.1-SNAPSHOT + 2.8.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.8.1 diff --git a/redisson-tomcat/pom.xml b/redisson-tomcat/pom.xml index 93169d2af..d3707b722 100644 --- a/redisson-tomcat/pom.xml +++ b/redisson-tomcat/pom.xml @@ -4,7 +4,7 @@ org.redisson redisson-parent - 2.8.1-SNAPSHOT + 2.8.1 ../ diff --git a/redisson-tomcat/redisson-tomcat-6/pom.xml b/redisson-tomcat/redisson-tomcat-6/pom.xml index 3e87203a9..0afb7899b 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.8.1-SNAPSHOT + 2.8.1 ../ diff --git a/redisson-tomcat/redisson-tomcat-7/pom.xml b/redisson-tomcat/redisson-tomcat-7/pom.xml index e6b67b474..9119807d6 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.8.1-SNAPSHOT + 2.8.1 ../ diff --git a/redisson-tomcat/redisson-tomcat-8/pom.xml b/redisson-tomcat/redisson-tomcat-8/pom.xml index 448561403..404e3be7e 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.8.1-SNAPSHOT + 2.8.1 ../ diff --git a/redisson/pom.xml b/redisson/pom.xml index 884652062..849806636 100644 --- a/redisson/pom.xml +++ b/redisson/pom.xml @@ -4,7 +4,7 @@ org.redisson redisson-parent - 2.8.1-SNAPSHOT + 2.8.1 ../ From d182cd7421d67942fc86415f9bbb81c8a674bdc8 Mon Sep 17 00:00:00 2001 From: Nikita Date: Sat, 4 Mar 2017 12:55:05 +0300 Subject: [PATCH 28/28] [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/pom.xml | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 44bb0f89b..d819cfc88 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.redisson redisson-parent - 2.8.1 + 2.8.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.8.1 + HEAD diff --git a/redisson-all/pom.xml b/redisson-all/pom.xml index 7cffe9e34..9d40c05a9 100644 --- a/redisson-all/pom.xml +++ b/redisson-all/pom.xml @@ -4,7 +4,7 @@ org.redisson redisson-parent - 2.8.1 + 2.8.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.8.1 + redisson-parent-0.9.0 diff --git a/redisson-tomcat/pom.xml b/redisson-tomcat/pom.xml index d3707b722..32d8f3c10 100644 --- a/redisson-tomcat/pom.xml +++ b/redisson-tomcat/pom.xml @@ -4,7 +4,7 @@ org.redisson redisson-parent - 2.8.1 + 2.8.2-SNAPSHOT ../ diff --git a/redisson-tomcat/redisson-tomcat-6/pom.xml b/redisson-tomcat/redisson-tomcat-6/pom.xml index 0afb7899b..3a77822e7 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.8.1 + 2.8.2-SNAPSHOT ../ diff --git a/redisson-tomcat/redisson-tomcat-7/pom.xml b/redisson-tomcat/redisson-tomcat-7/pom.xml index 9119807d6..e5bb47f02 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.8.1 + 2.8.2-SNAPSHOT ../ diff --git a/redisson-tomcat/redisson-tomcat-8/pom.xml b/redisson-tomcat/redisson-tomcat-8/pom.xml index 404e3be7e..dd91cca2c 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.8.1 + 2.8.2-SNAPSHOT ../ diff --git a/redisson/pom.xml b/redisson/pom.xml index 849806636..58a826900 100644 --- a/redisson/pom.xml +++ b/redisson/pom.xml @@ -4,7 +4,7 @@ org.redisson redisson-parent - 2.8.1 + 2.8.2-SNAPSHOT ../