diff --git a/README.md b/README.md index ca8bf8e00..182b9b6e9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Redisson: Redis based In-Memory Data Grid for Java. ==== -[Quick start](https://github.com/redisson/redisson#quick-start) | [Documentation](https://github.com/redisson/redisson/wiki) | [Javadocs](http://www.javadoc.io/doc/org.redisson/redisson/3.5.7) | [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) | **[PRO version](https://redisson.pro)** +[Quick start](https://github.com/redisson/redisson#quick-start) | [Documentation](https://github.com/redisson/redisson/wiki) | [Javadocs](http://www.javadoc.io/doc/org.redisson/redisson/3.5.7) | [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) | **[Redisson PRO](https://redisson.pro)** Based on high-performance async and lock-free Java Redis client and [Netty](http://netty.io) framework. @@ -53,24 +53,30 @@ Features Used by ================================ +[![Jeppesen](https://redisson.org/assets/logos/client25.png "Jeppesen")](https://www.jeppesen.com/)     +[![AIG](https://redisson.org/assets/logos/client24.png "AIG")](https://www.aig.com/)     +[![Adobe](https://redisson.org/assets/logos/client23.png "Adobe")](https://www.adobe.com/)     [![S&P Global](https://redisson.org/assets/logos/client20.png "S&P Global")](https://www.spglobal.com/)     [![SAP](https://redisson.org/assets/logos/client12.png "SAP")](http://www.sap.com/)     [![EA](https://redisson.org/assets/logos/client1.png "EA")](http://ea.com/)     -[![BROOKHAVEN](https://redisson.org/assets/logos/client6.png "Brookhaven National Laboratory")](http://bnl.gov/)     -[![New Relic Synthetics](https://redisson.org/assets/logos/client3.png "New Relic Synthetics")](http://newrelic.com/synthetics)     +[![BROOKHAVEN](https://redisson.org/assets/logos/client6.png "Brookhaven National Laboratory")](http://bnl.gov/) + +[![New Relic Synthetics](https://redisson.org/assets/logos/client3.png "New Relic Synthetics")](http://newrelic.com/synthetics)     [![Singtel](https://redisson.org/assets/logos/client5.png "New Relic Synthetics")](http://singtel.com/)     -[![Netflix](https://redisson.org/assets/logos/client10.png "Netflix")](https://netflix.com/) +[![Netflix](https://redisson.org/assets/logos/client10.png "Netflix")](https://netflix.com/)     [![Baidu](https://redisson.org/assets/logos/client2.png "Baidu")](http://baidu.com/)     [![Infor](https://redisson.org/assets/logos/client4.png "Infor")](http://www.infor.com/)     -[![Crimson Hexagon](https://redisson.org/assets/logos/client7.png "Crimson Hexagon")](https://www.crimsonhexagon.com/)     +[![Crimson Hexagon](https://redisson.org/assets/logos/client7.png "Crimson Hexagon")](https://www.crimsonhexagon.com/) + [![Datorama](https://redisson.org/assets/logos/client8.png "Datorama")](https://datorama.com/)    [![Invaluable](https://redisson.org/assets/logos/client13.png "Invaluable")](http://www.invaluable.com/)    -[![Ticketmaster](https://redisson.org/assets/logos/client14.png "Ticketmaster")](http://www.ticketmaster.com/) -[![PANDORA](https://redisson.org/assets/logos/client15.png "PANDORA")](http://www.pandora.com/)    +[![Ticketmaster](https://redisson.org/assets/logos/client14.png "Ticketmaster")](http://www.ticketmaster.com/)    [![ContaAzul](https://redisson.org/assets/logos/client18.png "ContaAzul")](https://contaazul.com/)    -[![NAB](https://redisson.org/assets/logos/client11.png "NAB")](https://www.nab.com.au/)    +[![NAB](https://redisson.org/assets/logos/client11.png "NAB")](https://www.nab.com.au/) + [![Alibaba](https://redisson.org/assets/logos/client19.png "Alibaba")](http://www.alibaba-inc.com)    [![Flipkart](https://redisson.org/assets/logos/client21.png "Flipkart")](https://www.flipkart.com/)    +[![BBK](https://redisson.org/assets/logos/client22.png "BBK")](http://www.gdbbk.com/) [![SULAKE](https://redisson.org/assets/logos/client17.png "SULAKE")](http://www.sulake.com/)    diff --git a/redisson-all/pom.xml b/redisson-all/pom.xml index 79b8353b1..d5c93ec96 100644 --- a/redisson-all/pom.xml +++ b/redisson-all/pom.xml @@ -167,7 +167,7 @@ org.springframework.boot spring-boot-actuator - [1.4,) + [1.4,2.0.0) provided diff --git a/redisson/pom.xml b/redisson/pom.xml index 3ebba9a9a..e542fbe45 100644 --- a/redisson/pom.xml +++ b/redisson/pom.xml @@ -271,7 +271,7 @@ org.springframework.boot spring-boot-actuator - [1.4,) + [1.4,2.0.0) provided true diff --git a/redisson/src/main/java/org/redisson/RedissonListMultimapCache.java b/redisson/src/main/java/org/redisson/RedissonListMultimapCache.java index f06233b55..adc06604f 100644 --- a/redisson/src/main/java/org/redisson/RedissonListMultimapCache.java +++ b/redisson/src/main/java/org/redisson/RedissonListMultimapCache.java @@ -42,13 +42,17 @@ public class RedissonListMultimapCache extends RedissonListMultimap RedissonListMultimapCache(EvictionScheduler evictionScheduler, CommandAsyncExecutor connectionManager, String name) { super(connectionManager, name); - evictionScheduler.scheduleCleanMultimap(name, getTimeoutSetName()); + if (evictionScheduler != null) { + evictionScheduler.scheduleCleanMultimap(name, getTimeoutSetName()); + } baseCache = new RedissonMultimapCache(connectionManager, this, getTimeoutSetName(), prefix); } RedissonListMultimapCache(EvictionScheduler evictionScheduler, Codec codec, CommandAsyncExecutor connectionManager, String name) { super(codec, connectionManager, name); - evictionScheduler.scheduleCleanMultimap(name, getTimeoutSetName()); + if (evictionScheduler != null) { + evictionScheduler.scheduleCleanMultimap(name, getTimeoutSetName()); + } baseCache = new RedissonMultimapCache(connectionManager, this, getTimeoutSetName(), prefix); } diff --git a/redisson/src/main/java/org/redisson/RedissonMap.java b/redisson/src/main/java/org/redisson/RedissonMap.java index 825ec0698..89d884458 100644 --- a/redisson/src/main/java/org/redisson/RedissonMap.java +++ b/redisson/src/main/java/org/redisson/RedissonMap.java @@ -237,7 +237,7 @@ public class RedissonMap extends RedissonExpirable implements RMap { return options == null || options.getLoader() == null; } - protected RFuture> getAllOperationAsync(Set keys) { + public RFuture> getAllOperationAsync(Set keys) { List args = new ArrayList(keys.size() + 1); args.add(getName()); encodeMapKeys(args, keys); @@ -624,7 +624,7 @@ public class RedissonMap extends RedissonExpirable implements RMap { Collections.singletonList(getName(key)), encodeMapKey(key), encodeMapValue(value)); } - protected RFuture getOperationAsync(K key) { + public RFuture getOperationAsync(K key) { return commandExecutor.readAsync(getName(key), codec, RedisCommands.HGET, getName(key), encodeMapKey(key)); } @@ -973,7 +973,7 @@ public class RedissonMap extends RedissonExpirable implements RMap { return get(fastRemoveAsync(keys)); } - MapScanResult scanIterator(String name, RedisClient client, long startPos, String pattern) { + public MapScanResult scanIterator(String name, RedisClient client, long startPos, String pattern) { if (pattern == null) { RFuture> f = commandExecutor.readAsync(client, name, new MapScanCodec(codec), RedisCommands.HSCAN, name, startPos); diff --git a/redisson/src/main/java/org/redisson/RedissonMapCache.java b/redisson/src/main/java/org/redisson/RedissonMapCache.java index b5e23bb42..d5816630e 100644 --- a/redisson/src/main/java/org/redisson/RedissonMapCache.java +++ b/redisson/src/main/java/org/redisson/RedissonMapCache.java @@ -210,7 +210,7 @@ public class RedissonMapCache extends RedissonMap implements RMapCac } @Override - protected RFuture> getAllOperationAsync(Set keys) { + public RFuture> getAllOperationAsync(Set keys) { List args = new ArrayList(keys.size() + 1); List plainKeys = new ArrayList(keys.size()); @@ -448,7 +448,7 @@ public class RedissonMapCache extends RedissonMap implements RMapCac } @Override - protected RFuture getOperationAsync(K key) { + public RFuture getOperationAsync(K key) { return commandExecutor.evalWriteAsync(getName(key), codec, RedisCommands.EVAL_MAP_VALUE, "local value = redis.call('hget', KEYS[1], ARGV[2]); " + "if value == false then " @@ -618,7 +618,7 @@ public class RedissonMapCache extends RedissonMap implements RMapCac } @Override - public RFuture addAndGetOperationAsync(K key, Number value) { + protected RFuture addAndGetOperationAsync(K key, Number value) { ByteBuf keyState = encodeMapKey(key); return commandExecutor.evalWriteAsync(getName(key), StringCodec.INSTANCE, new RedisCommand("EVAL", new NumberConvertor(value.getClass())), @@ -1100,7 +1100,7 @@ public class RedissonMapCache extends RedissonMap implements RMapCac @Override - public RFuture removeOperationAsync(K key) { + protected RFuture removeOperationAsync(K key) { return commandExecutor.evalWriteAsync(getName(key), codec, RedisCommands.EVAL_MAP_VALUE, "local value = redis.call('hget', KEYS[1], ARGV[2]); " + "if value == false then " @@ -1198,7 +1198,7 @@ public class RedissonMapCache extends RedissonMap implements RMapCac } @Override - MapScanResult scanIterator(String name, RedisClient client, long startPos, String pattern) { + public MapScanResult scanIterator(String name, RedisClient client, long startPos, String pattern) { return get(scanIteratorAsync(name, client, startPos, pattern)); } @@ -1635,7 +1635,7 @@ public class RedissonMapCache extends RedissonMap implements RMapCac } @Override - public RFuture putAllOperationAsync(Map map) { + protected RFuture putAllOperationAsync(Map map) { List params = new ArrayList(map.size()*2 + 1); params.add(System.currentTimeMillis()); for (java.util.Map.Entry t : map.entrySet()) { diff --git a/redisson/src/main/java/org/redisson/RedissonObject.java b/redisson/src/main/java/org/redisson/RedissonObject.java index 40e0862b1..c999e032e 100644 --- a/redisson/src/main/java/org/redisson/RedissonObject.java +++ b/redisson/src/main/java/org/redisson/RedissonObject.java @@ -56,14 +56,14 @@ public abstract class RedissonObject implements RObject { return commandExecutor.await(future, timeout, timeoutUnit); } - protected static String prefixName(String prefix, String name) { + public static String prefixName(String prefix, String name) { if (name.contains("{")) { return prefix + ":" + name; } return prefix + ":{" + name + "}"; } - protected static String suffixName(String name, String suffix) { + public static String suffixName(String name, String suffix) { if (name.contains("{")) { return name + ":" + suffix; } @@ -194,7 +194,7 @@ public abstract class RedissonObject implements RObject { } } - protected ByteBuf encode(Object value) { + public ByteBuf encode(Object value) { if (commandExecutor.isRedissonReferenceSupportEnabled()) { RedissonReference reference = RedissonObjectFactory.toReference(commandExecutor.getConnectionManager().getCfg(), value); if (reference != null) { @@ -209,7 +209,7 @@ public abstract class RedissonObject implements RObject { } } - protected ByteBuf encodeMapKey(Object value) { + public ByteBuf encodeMapKey(Object value) { if (commandExecutor.isRedissonReferenceSupportEnabled()) { RedissonReference reference = RedissonObjectFactory.toReference(commandExecutor.getConnectionManager().getCfg(), value); if (reference != null) { @@ -224,7 +224,7 @@ public abstract class RedissonObject implements RObject { } } - protected ByteBuf encodeMapValue(Object value) { + public ByteBuf encodeMapValue(Object value) { if (commandExecutor.isRedissonReferenceSupportEnabled()) { RedissonReference reference = RedissonObjectFactory.toReference(commandExecutor.getConnectionManager().getCfg(), value); if (reference != null) { diff --git a/redisson/src/main/java/org/redisson/RedissonSetMultimapCache.java b/redisson/src/main/java/org/redisson/RedissonSetMultimapCache.java index aa7f3d713..40d5f8939 100644 --- a/redisson/src/main/java/org/redisson/RedissonSetMultimapCache.java +++ b/redisson/src/main/java/org/redisson/RedissonSetMultimapCache.java @@ -41,13 +41,17 @@ public class RedissonSetMultimapCache extends RedissonSetMultimap im RedissonSetMultimapCache(EvictionScheduler evictionScheduler, CommandAsyncExecutor connectionManager, String name) { super(connectionManager, name); - evictionScheduler.scheduleCleanMultimap(name, getTimeoutSetName()); + if (evictionScheduler != null) { + evictionScheduler.scheduleCleanMultimap(name, getTimeoutSetName()); + } baseCache = new RedissonMultimapCache(connectionManager, this, getTimeoutSetName(), prefix); } RedissonSetMultimapCache(EvictionScheduler evictionScheduler, Codec codec, CommandAsyncExecutor connectionManager, String name) { super(codec, connectionManager, name); - evictionScheduler.scheduleCleanMultimap(name, getTimeoutSetName()); + if (evictionScheduler != null) { + evictionScheduler.scheduleCleanMultimap(name, getTimeoutSetName()); + } baseCache = new RedissonMultimapCache(connectionManager, this, getTimeoutSetName(), prefix); } diff --git a/redisson/src/main/java/org/redisson/command/CommandAsyncService.java b/redisson/src/main/java/org/redisson/command/CommandAsyncService.java index eab855f5c..3a032dc69 100644 --- a/redisson/src/main/java/org/redisson/command/CommandAsyncService.java +++ b/redisson/src/main/java/org/redisson/command/CommandAsyncService.java @@ -152,6 +152,7 @@ public class CommandAsyncService implements CommandAsyncExecutor { l.await(); } catch (InterruptedException e) { interrupted = true; + break; } } @@ -524,6 +525,12 @@ public class CommandAsyncService implements CommandAsyncExecutor { } if (details.getConnectionFuture().cancel(false)) { + if (details.getException() == null) { + details.setException(new RedisTimeoutException("Unable to get connection! " + + "Node source: " + source + + ", command: " + command + ", command params: " + LogHelper.toString(details.getParams()) + + " after " + connectionManager.getConfig().getRetryAttempts() + " retry attempts")); + } connectionManager.getShutdownLatch().release(); } else { if (details.getConnectionFuture().isSuccess()) { @@ -531,7 +538,10 @@ public class CommandAsyncService implements CommandAsyncExecutor { if (details.getAttempt() == connectionManager.getConfig().getRetryAttempts()) { if (details.getWriteFuture() != null && details.getWriteFuture().cancel(false)) { if (details.getException() == null) { - details.setException(new RedisTimeoutException("Unable to send command: " + command + " with params: " + LogHelper.toString(details.getParams()) + " after " + connectionManager.getConfig().getRetryAttempts() + " retry attempts")); + details.setException(new RedisTimeoutException("Unable to send command! " + + "Node source: " + source + ", connection: " + details.getConnectionFuture().getNow().getChannel() + + ", command: " + command + ", command params: " + LogHelper.toString(details.getParams()) + + " after " + connectionManager.getConfig().getRetryAttempts() + " retry attempts")); } details.getAttemptPromise().tryFailure(details.getException()); } @@ -559,7 +569,9 @@ public class CommandAsyncService implements CommandAsyncExecutor { if (details.getAttempt() == connectionManager.getConfig().getRetryAttempts()) { if (details.getException() == null) { - details.setException(new RedisTimeoutException("Unable to send command: " + command + " with params: " + LogHelper.toString(details.getParams()) + " after " + connectionManager.getConfig().getRetryAttempts() + " retry attempts")); + details.setException(new RedisTimeoutException("Unable to send command! Node source: " + source + + ", command: " + command + ", command params: " + LogHelper.toString(details.getParams()) + + " after " + connectionManager.getConfig().getRetryAttempts() + " retry attempts")); } details.getAttemptPromise().tryFailure(details.getException()); return; @@ -658,11 +670,13 @@ public class CommandAsyncService implements CommandAsyncExecutor { } if (!future.isSuccess()) { - log.trace("Can't write {} to {}", details.getCommand(), connection); details.setException(new WriteRedisConnectionException( - "Can't write command: " + details.getCommand() + ", params: " + LogHelper.toString(details.getParams()) + " to channel: " + future.channel(), future.cause())); + "Unable to send command! Node source: " + details.getSource() + ", connection: " + future.channel() + + ", command: " + details.getCommand() + ", params: " + LogHelper.toString(details.getParams()), future.cause())); if (details.getAttempt() == connectionManager.getConfig().getRetryAttempts()) { - details.getAttemptPromise().tryFailure(details.getException()); + if (!details.getAttemptPromise().tryFailure(details.getException())) { + log.error(details.getException().getMessage()); + } } return; }