Code formatted according to checkstyle rules

pull/1907/head
Nikita Koksharov 6 years ago
parent 864233e40c
commit d3b6066fdc

@ -360,29 +360,6 @@
</execution>
</executions>
<configuration>
<includes>
**/org/redisson/api/**/*.java,
**/org/redisson/cache/**/*.java,
**/org/redisson/client/**/*.java,
**/org/redisson/cluster/**/*.java,
**/org/redisson/codec/**/*.java,
**/org/redisson/command/**/*.java,
**/org/redisson/config/**/*.java,
**/org/redisson/connection/**/*.java,
**/org/redisson/eviction/**/*.java,
**/org/redisson/executor/**/*.java,
**/org/redisson/jcache/**/*.java,
**/org/redisson/liveobject/**/*.java,
**/org/redisson/mapreduce/**/*.java,
**/org/redisson/misc/**/*.java,
**/org/redisson/pubsub/**/*.java,
**/org/redisson/reactive/**/*.java,
**/org/redisson/remote/**/*.java,
**/org/redisson/rx/**/*.java,
**/org/redisson/spring/**/*.java,
**/org/redisson/transaction/**/*.java,
</includes>
<consoleOutput>true</consoleOutput>
<enableRSS>false</enableRSS>
<configLocation>/checkstyle.xml</configLocation>

@ -15,9 +15,6 @@
*/
package org.redisson;
import java.util.ArrayList;
import java.util.List;
import org.redisson.api.listener.MessageListener;
import org.redisson.client.RedisPubSubListener;
import org.redisson.client.protocol.pubsub.PubSubType;
@ -46,6 +43,7 @@ public class PubSubMessageListener<V> implements RedisPubSubListener<Object> {
}
@Override
@SuppressWarnings("AvoidInlineConditionals")
public int hashCode() {
final int prime = 31;
int result = 1;
@ -78,7 +76,7 @@ public class PubSubMessageListener<V> implements RedisPubSubListener<Object> {
public void onMessage(CharSequence channel, Object message) {
// could be subscribed to multiple channels
if (name.equals(channel.toString()) && type.isInstance(message)) {
listener.onMessage(channel, (V)message);
listener.onMessage(channel, (V) message);
}
}
@ -86,7 +84,7 @@ public class PubSubMessageListener<V> implements RedisPubSubListener<Object> {
public void onPatternMessage(CharSequence pattern, CharSequence channel, Object message) {
// could be subscribed to multiple channels
if (name.equals(pattern.toString()) && type.isInstance(message)) {
listener.onMessage(channel, (V)message);
listener.onMessage(channel, (V) message);
}
}

@ -43,6 +43,7 @@ public class PubSubPatternMessageListener<V> implements RedisPubSubListener<V> {
}
@Override
@SuppressWarnings("AvoidInlineConditionals")
public int hashCode() {
final int prime = 31;
int result = 1;

@ -40,6 +40,7 @@ public class PubSubPatternStatusListener implements RedisPubSubListener<Object>
}
@Override
@SuppressWarnings("AvoidInlineConditionals")
public int hashCode() {
final int prime = 31;
int result = 1;

@ -40,6 +40,7 @@ public class PubSubStatusListener implements RedisPubSubListener<Object> {
}
@Override
@SuppressWarnings("AvoidInlineConditionals")
public int hashCode() {
final int prime = 31;
int result = 1;

@ -113,7 +113,7 @@ public class RedisNodes<N extends Node> implements NodesGroup<N> {
@Override
public boolean pingAll() {
List<RedisClientEntry> clients = new ArrayList<RedisClientEntry>((Collection<RedisClientEntry>)getNodes());
List<RedisClientEntry> clients = new ArrayList<>((Collection<RedisClientEntry>) getNodes());
Map<RedisConnection, RFuture<String>> result = new ConcurrentHashMap<>(clients.size());
CountDownLatch latch = new CountDownLatch(clients.size());
for (RedisClientEntry entry : clients) {

@ -42,7 +42,7 @@ public abstract class RedissonBaseAdder<T extends Number> extends RedissonExpira
private final RPromise<Void> result;
private ResetListener(RPromise<Void> result) {
ResetListener(RPromise<Void> result) {
this.result = result;
}
@ -72,7 +72,7 @@ public abstract class RedissonBaseAdder<T extends Number> extends RedissonExpira
private final RPromise<T> result;
private SumListener(RPromise<T> result) {
SumListener(RPromise<T> result) {
this.result = result;
}

@ -28,8 +28,8 @@ import java.util.Map.Entry;
public abstract class RedissonBaseMapIterator<V> extends BaseIterator<V, Map.Entry<Object, Object>> {
@SuppressWarnings("unchecked")
protected V getValue(final Map.Entry<Object, Object> entry) {
return (V)new AbstractMap.SimpleEntry(entry.getKey(), entry.getValue()) {
protected V getValue(Map.Entry<Object, Object> entry) {
return (V) new AbstractMap.SimpleEntry(entry.getKey(), entry.getValue()) {
@Override
public Object setValue(Object value) {

@ -44,7 +44,7 @@ public class RedissonBinaryStream extends RedissonBucket<byte[]> implements RBin
@Override
public void write(int b) throws IOException {
writeBytes(new byte[] {(byte)b});
writeBytes(new byte[] {(byte) b});
}
private void writeBytes(byte[] bytes) {
@ -104,7 +104,7 @@ public class RedissonBinaryStream extends RedissonBucket<byte[]> implements RBin
@Override
public int available() throws IOException {
return (int)(size() - index);
return (int) (size() - index);
}
@Override
@ -134,7 +134,7 @@ public class RedissonBinaryStream extends RedissonBucket<byte[]> implements RBin
throw new IndexOutOfBoundsException();
}
return (Integer)get(commandExecutor.evalReadAsync(getName(), codec, new RedisCommand<Integer>("EVAL", new Decoder<Integer>() {
return (Integer) get(commandExecutor.evalReadAsync(getName(), codec, new RedisCommand<Integer>("EVAL", new Decoder<Integer>() {
@Override
public Integer decode(ByteBuf buf, State state) {
if (buf.readableBytes() == 0) {

@ -83,7 +83,16 @@ public class RedissonBitSet extends RedissonExpirable implements RBitSet {
@Override
public RFuture<Boolean> setAsync(long bitIndex, boolean value) {
return commandExecutor.writeAsync(getName(), LongCodec.INSTANCE, RedisCommands.SETBIT, getName(), bitIndex, value ? 1 : 0);
int val = toInt(value);
return commandExecutor.writeAsync(getName(), LongCodec.INSTANCE, RedisCommands.SETBIT, getName(), bitIndex, val);
}
protected int toInt(boolean value) {
int val = 0;
if (value) {
val = 1;
}
return val;
}
@Override
@ -199,9 +208,10 @@ public class RedissonBitSet extends RedissonExpirable implements RBitSet {
@Override
public RFuture<Void> setAsync(long fromIndex, long toIndex, boolean value) {
int val = toInt(value);
CommandBatchService executorService = new CommandBatchService(commandExecutor.getConnectionManager());
for (long i = fromIndex; i < toIndex; i++) {
executorService.writeAsync(getName(), LongCodec.INSTANCE, RedisCommands.SETBIT_VOID, getName(), i, value ? 1 : 0);
executorService.writeAsync(getName(), LongCodec.INSTANCE, RedisCommands.SETBIT_VOID, getName(), i, val);
}
return executorService.executeAsyncVoid();
}

@ -15,9 +15,7 @@
*/
package org.redisson;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.redisson.api.RBlockingDeque;

@ -274,7 +274,7 @@ public class RedissonBoundedBlockingQueue<V> extends RedissonQueue<V> implements
}
String channelName = RedissonSemaphore.getChannelName(getSemaphoreName());
return commandExecutor.evalWriteAsync(getName(), codec, new RedisCommand<Object>("EVAL", new ListDrainToDecoder((Collection<Object>)c)),
return commandExecutor.evalWriteAsync(getName(), codec, new RedisCommand<Object>("EVAL", new ListDrainToDecoder((Collection<Object>) c)),
"local vals = redis.call('lrange', KEYS[1], 0, -1); " +
"redis.call('del', KEYS[1]); " +
"if #vals > 0 then "
@ -302,7 +302,7 @@ public class RedissonBoundedBlockingQueue<V> extends RedissonQueue<V> implements
String channelName = RedissonSemaphore.getChannelName(getSemaphoreName());
return commandExecutor.evalWriteAsync(getName(), codec, new RedisCommand<Object>("EVAL", new ListDrainToDecoder((Collection<Object>)c)),
return commandExecutor.evalWriteAsync(getName(), codec, new RedisCommand<Object>("EVAL", new ListDrainToDecoder((Collection<Object>) c)),
"local elemNum = math.min(ARGV[1], redis.call('llen', KEYS[1])) - 1;" +
"local vals = redis.call('lrange', KEYS[1], 0, elemNum); " +
"redis.call('ltrim', KEYS[1], elemNum + 1, -1); " +

@ -37,8 +37,8 @@ import org.redisson.pubsub.CountDownLatchPubSub;
*/
public class RedissonCountDownLatch extends RedissonObject implements RCountDownLatch {
public static final Long zeroCountMessage = 0L;
public static final Long newCountMessage = 1L;
public static final Long ZERO_COUNT_MESSAGE = 0L;
public static final Long NEW_COUNT_MESSAGE = 1L;
private static final CountDownLatchPubSub PUBSUB = new CountDownLatchPubSub();
@ -76,7 +76,7 @@ public class RedissonCountDownLatch extends RedissonObject implements RCountDown
}
try {
remainTime -= (System.currentTimeMillis() - current);
remainTime -= System.currentTimeMillis() - current;
if (remainTime <= 0) {
return false;
}
@ -92,7 +92,7 @@ public class RedissonCountDownLatch extends RedissonObject implements RCountDown
entry.getLatch().await(remainTime, TimeUnit.MILLISECONDS);
}
remainTime -= (System.currentTimeMillis() - current);
remainTime -= System.currentTimeMillis() - current;
}
return true;
@ -124,7 +124,7 @@ public class RedissonCountDownLatch extends RedissonObject implements RCountDown
"local v = redis.call('decr', KEYS[1]);" +
"if v <= 0 then redis.call('del', KEYS[1]) end;" +
"if v == 0 then redis.call('publish', KEYS[2], ARGV[1]) end;",
Arrays.<Object>asList(getName(), getChannelName()), zeroCountMessage);
Arrays.<Object>asList(getName(), getChannelName()), ZERO_COUNT_MESSAGE);
}
private String getEntryName() {
@ -160,7 +160,7 @@ public class RedissonCountDownLatch extends RedissonObject implements RCountDown
+ "else "
+ "return 0 "
+ "end",
Arrays.<Object>asList(getName(), getChannelName()), newCountMessage, count);
Arrays.<Object>asList(getName(), getChannelName()), NEW_COUNT_MESSAGE, count);
}
@Override
@ -172,7 +172,7 @@ public class RedissonCountDownLatch extends RedissonObject implements RCountDown
+ "else "
+ "return 0 "
+ "end",
Arrays.<Object>asList(getName(), getChannelName()), newCountMessage);
Arrays.<Object>asList(getName(), getChannelName()), NEW_COUNT_MESSAGE);
}
}

@ -106,8 +106,7 @@ public class RedissonDelayedQueue<V> extends RedissonExpirable implements RDelay
+ "local v = redis.call('zrange', KEYS[2], 0, 0); "
+ "if v[1] == value then "
+ "redis.call('publish', KEYS[4], ARGV[1]); "
+ "end;"
,
+ "end;",
Arrays.<Object>asList(getName(), timeoutSetName, queueName, channelName),
timeout, randomId, encode(e));
}
@ -166,7 +165,7 @@ public class RedissonDelayedQueue<V> extends RedissonExpirable implements RDelay
}
V getValue(int index) {
return (V)get(commandExecutor.evalReadAsync(getName(), codec, RedisCommands.EVAL_OBJECT,
return (V) get(commandExecutor.evalReadAsync(getName(), codec, RedisCommands.EVAL_OBJECT,
"local v = redis.call('lindex', KEYS[1], ARGV[1]); "
+ "if v ~= false then "
+ "local randomId, value = struct.unpack('dLc0', v);"

@ -42,7 +42,6 @@ import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiConsumer;
import org.redisson.api.CronSchedule;
import org.redisson.api.ExecutorOptions;
@ -102,7 +101,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
private static final Logger LOGGER = LoggerFactory.getLogger(RedissonExecutorService.class);
private static RemoteInvocationOptions RESULT_OPTIONS = RemoteInvocationOptions.defaults().noAck().expectResultWithin(1, TimeUnit.HOURS);
private static final RemoteInvocationOptions RESULT_OPTIONS = RemoteInvocationOptions.defaults().noAck().expectResultWithin(1, TimeUnit.HOURS);
public static final int SHUTDOWN_STATE = 1;
public static final int TERMINATED_STATE = 2;
@ -166,8 +165,8 @@ public class RedissonExecutorService implements RScheduledExecutorService {
}
remoteService = new RedissonExecutorRemoteService(codec, redisson, name, connectionManager.getCommandExecutor(), executorId, responses);
requestQueueName = ((RedissonRemoteService)remoteService).getRequestQueueName(RemoteExecutorService.class);
responseQueueName = ((RedissonRemoteService)remoteService).getResponseQueueName(executorId);
requestQueueName = ((RedissonRemoteService) remoteService).getRequestQueueName(RemoteExecutorService.class);
responseQueueName = ((RedissonRemoteService) remoteService).getResponseQueueName(executorId);
String objectName = requestQueueName;
tasksCounterName = objectName + ":counter";
tasksName = objectName + ":tasks";
@ -323,7 +322,8 @@ public class RedissonExecutorService implements RScheduledExecutorService {
check(task);
ClassBody classBody = getClassBody(task);
byte[] state = encode(task);
RemotePromise<Void> promise = (RemotePromise<Void>)asyncServiceWithoutResult.executeRunnable(new TaskParameters(classBody.getClazzName(), classBody.getClazz(), classBody.getLambda(), state));
RemotePromise<Void> promise = (RemotePromise<Void>) asyncServiceWithoutResult.executeRunnable(
new TaskParameters(classBody.getClazzName(), classBody.getClazz(), classBody.getLambda(), state));
syncExecute(promise);
}
@ -586,7 +586,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
check(task);
ClassBody classBody = getClassBody(task);
byte[] state = encode(task);
RemotePromise<?> promise = (RemotePromise<?>)asyncService.executeCallable(new TaskParameters(classBody.getClazzName(), classBody.getClazz(), classBody.getLambda(), state));
RemotePromise<?> promise = (RemotePromise<?>) asyncService.executeCallable(new TaskParameters(classBody.getClazzName(), classBody.getClazz(), classBody.getLambda(), state));
RedissonExecutorFuture<?> executorFuture = new RedissonExecutorFuture(promise);
result.add(executorFuture);
}
@ -612,7 +612,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
check(task);
ClassBody classBody = getClassBody(task);
byte[] state = encode(task);
RemotePromise<?> promise = (RemotePromise<?>)asyncService.executeCallable(new TaskParameters(classBody.getClazzName(), classBody.getClazz(), classBody.getLambda(), state));
RemotePromise<?> promise = (RemotePromise<?>) asyncService.executeCallable(new TaskParameters(classBody.getClazzName(), classBody.getClazz(), classBody.getLambda(), state));
RedissonExecutorFuture<?> executorFuture = new RedissonExecutorFuture(promise);
result.add(executorFuture);
}
@ -620,7 +620,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
executorRemoteService.executeAddAsync().onComplete((res, e) -> {
if (e != null) {
for (RExecutorFuture<?> executorFuture : result) {
((RPromise<Void>)executorFuture).tryFailure(e);
((RPromise<Void>) executorFuture).tryFailure(e);
}
return;
}
@ -629,7 +629,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
if (!bool) {
RejectedExecutionException ex = new RejectedExecutionException("Task rejected. ExecutorService is in shutdown state");
for (RExecutorFuture<?> executorFuture : result) {
((RPromise<Void>)executorFuture).tryFailure(ex);
((RPromise<Void>) executorFuture).tryFailure(ex);
}
break;
}
@ -702,7 +702,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
check(task);
ClassBody classBody = getClassBody(task);
byte[] state = encode(task);
RemotePromise<Void> promise = (RemotePromise<Void>)asyncService.executeRunnable(new TaskParameters(classBody.getClazzName(), classBody.getClazz(), classBody.getLambda(), state));
RemotePromise<Void> promise = (RemotePromise<Void>) asyncService.executeRunnable(new TaskParameters(classBody.getClazzName(), classBody.getClazz(), classBody.getLambda(), state));
RedissonExecutorFuture<Void> executorFuture = new RedissonExecutorFuture<Void>(promise);
result.add(executorFuture);
}
@ -728,7 +728,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
check(task);
ClassBody classBody = getClassBody(task);
byte[] state = encode(task);
RemotePromise<Void> promise = (RemotePromise<Void>)asyncService.executeRunnable(new TaskParameters(classBody.getClazzName(), classBody.getClazz(), classBody.getLambda(), state));
RemotePromise<Void> promise = (RemotePromise<Void>) asyncService.executeRunnable(new TaskParameters(classBody.getClazzName(), classBody.getClazz(), classBody.getLambda(), state));
RedissonExecutorFuture<Void> executorFuture = new RedissonExecutorFuture<Void>(promise);
result.add(executorFuture);
}
@ -736,7 +736,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
executorRemoteService.executeAddAsync().onComplete((res, e) -> {
if (e != null) {
for (RExecutorFuture<?> executorFuture : result) {
((RPromise<Void>)executorFuture).tryFailure(e);
((RPromise<Void>) executorFuture).tryFailure(e);
}
return;
}
@ -745,7 +745,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
if (!bool) {
RejectedExecutionException ex = new RejectedExecutionException("Task rejected. ExecutorService is in shutdown state");
for (RExecutorFuture<?> executorFuture : result) {
((RPromise<Void>)executorFuture).tryFailure(ex);
((RPromise<Void>) executorFuture).tryFailure(ex);
}
break;
}
@ -795,7 +795,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
@Override
public RScheduledFuture<?> schedule(Runnable task, long delay, TimeUnit unit) {
RedissonScheduledFuture<?> future = (RedissonScheduledFuture<?>) scheduleAsync(task, delay, unit);
RemotePromise<?> rp = (RemotePromise<?>)future.getInnerPromise();
RemotePromise<?> rp = (RemotePromise<?>) future.getInnerPromise();
syncExecute(rp);
storeReference(future, rp.getRequestId());
return future;
@ -846,7 +846,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
@Override
public <V> RScheduledFuture<V> schedule(Callable<V> task, long delay, TimeUnit unit) {
RedissonScheduledFuture<V> future = (RedissonScheduledFuture<V>) scheduleAsync(task, delay, unit);
RemotePromise<?> rp = (RemotePromise<?>)future.getInnerPromise();
RemotePromise<?> rp = (RemotePromise<?>) future.getInnerPromise();
syncExecute(rp);
storeReference(future, rp.getRequestId());
return future;
@ -866,7 +866,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
@Override
public RScheduledFuture<?> scheduleAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit) {
RedissonScheduledFuture<?> future = (RedissonScheduledFuture<?>) scheduleAtFixedRateAsync(task, initialDelay, period, unit);
RemotePromise<?> rp = (RemotePromise<?>)future.getInnerPromise();
RemotePromise<?> rp = (RemotePromise<?>) future.getInnerPromise();
syncExecute(rp);
storeReference(future, rp.getRequestId());
return future;
@ -894,7 +894,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
@Override
public RScheduledFuture<?> schedule(Runnable task, CronSchedule cronSchedule) {
RedissonScheduledFuture<?> future = (RedissonScheduledFuture<?>) scheduleAsync(task, cronSchedule);
RemotePromise<?> rp = (RemotePromise<?>)future.getInnerPromise();
RemotePromise<?> rp = (RemotePromise<?>) future.getInnerPromise();
syncExecute(rp);
storeReference(future, rp.getRequestId());
return future;
@ -934,7 +934,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
@Override
public RScheduledFuture<?> scheduleWithFixedDelay(Runnable task, long initialDelay, long delay, TimeUnit unit) {
RedissonScheduledFuture<?> future = (RedissonScheduledFuture<?>) scheduleWithFixedDelayAsync(task, initialDelay, delay, unit);
RemotePromise<?> rp = (RemotePromise<?>)future.getInnerPromise();
RemotePromise<?> rp = (RemotePromise<?>) future.getInnerPromise();
syncExecute(rp);
storeReference(future, rp.getRequestId());
return future;
@ -997,8 +997,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
}
@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks)
throws InterruptedException, ExecutionException {
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
try {
return invokeAny(tasks, -1, null);
} catch (TimeoutException cannotHappen) {
@ -1008,8 +1007,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks,
long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
if (tasks == null) {
throw new NullPointerException();
}
@ -1039,7 +1037,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
RExecutorBatchFuture future = submit(tasks.toArray(new Callable[tasks.size()]));
future.await();
List<?> futures = future.getTaskFutures();
return (List<Future<T>>)futures;
return (List<Future<T>>) futures;
}
@Override
@ -1052,7 +1050,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
RExecutorBatchFuture future = submit(tasks.toArray(new Callable[tasks.size()]));
future.await(timeout, unit);
List<?> futures = future.getTaskFutures();
return (List<Future<T>>)futures;
return (List<Future<T>>) futures;
}
}

@ -53,24 +53,31 @@ import org.redisson.connection.decoder.MapGetAllDecoder;
*/
public class RedissonGeo<V> extends RedissonScoredSortedSet<V> implements RGeo<V> {
private static final MultiDecoder<Map<Object, Object>> postitionDecoder = new ListMultiDecoder(new CodecDecoder(), new GeoPositionDecoder(), new ObjectListReplayDecoder(ListMultiDecoder.RESET), new GeoMapReplayDecoder());
private static final MultiDecoder<Map<Object, Object>> distanceDecoder = new ListMultiDecoder(new GeoDistanceDecoder(), new GeoMapReplayDecoder());
private static final RedisCommand<Map<Object, Object>> GEORADIUS_RO_DISTANCE = new RedisCommand<Map<Object, Object>>("GEORADIUS_RO", distanceDecoder);
private static final RedisCommand<Map<Object, Object>> GEORADIUS_RO_POS = new RedisCommand<Map<Object, Object>>("GEORADIUS_RO", postitionDecoder);
private static final RedisCommand<Map<Object, Object>> GEORADIUSBYMEMBER_RO_DISTANCE = new RedisCommand<Map<Object, Object>>("GEORADIUSBYMEMBER_RO", distanceDecoder);
private static final RedisCommand<Map<Object, Object>> GEORADIUSBYMEMBER_RO_POS = new RedisCommand<Map<Object, Object>>("GEORADIUSBYMEMBER_RO", postitionDecoder);
private static final MultiDecoder<Map<Object, Object>> POSTITION_DECODER = new ListMultiDecoder(new CodecDecoder(),
new GeoPositionDecoder(), new ObjectListReplayDecoder(ListMultiDecoder.RESET), new GeoMapReplayDecoder());
private static final MultiDecoder<Map<Object, Object>> DISTANCE_DECODER = new ListMultiDecoder(
new GeoDistanceDecoder(), new GeoMapReplayDecoder());
private static final RedisCommand<Map<Object, Object>> GEORADIUS_RO_DISTANCE = new RedisCommand<Map<Object, Object>>(
"GEORADIUS_RO", DISTANCE_DECODER);
private static final RedisCommand<Map<Object, Object>> GEORADIUS_RO_POS = new RedisCommand<Map<Object, Object>>(
"GEORADIUS_RO", POSTITION_DECODER);
private static final RedisCommand<Map<Object, Object>> GEORADIUSBYMEMBER_RO_DISTANCE = new RedisCommand<Map<Object, Object>>(
"GEORADIUSBYMEMBER_RO", DISTANCE_DECODER);
private static final RedisCommand<Map<Object, Object>> GEORADIUSBYMEMBER_RO_POS = new RedisCommand<Map<Object, Object>>(
"GEORADIUSBYMEMBER_RO", POSTITION_DECODER);
public RedissonGeo(CommandAsyncExecutor connectionManager, String name, RedissonClient redisson) {
super(connectionManager, name, redisson);
}
public RedissonGeo(Codec codec, CommandAsyncExecutor connectionManager, String name, RedissonClient redisson) {
super(codec, connectionManager, name, redisson);
}
@Override
public RFuture<Long> addAsync(double longitude, double latitude, V member) {
return commandExecutor.writeAsync(getName(), codec, RedisCommands.GEOADD, getName(), convert(longitude), convert(latitude), encode(member));
return commandExecutor.writeAsync(getName(), codec, RedisCommands.GEOADD, getName(), convert(longitude),
convert(latitude), encode(member));
}
private String convert(double longitude) {
@ -103,17 +110,18 @@ public class RedissonGeo<V> extends RedissonScoredSortedSet<V> implements RGeo<V
public Double dist(V firstMember, V secondMember, GeoUnit geoUnit) {
return get(distAsync(firstMember, secondMember, geoUnit));
}
@Override
public RFuture<Double> distAsync(V firstMember, V secondMember, GeoUnit geoUnit) {
return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, RedisCommands.GEODIST, getName(), encode(firstMember), encode(secondMember), geoUnit);
return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, RedisCommands.GEODIST, getName(),
encode(firstMember), encode(secondMember), geoUnit);
}
@Override
public Map<V, String> hash(V... members) {
return get(hashAsync(members));
}
@Override
public RFuture<Map<V, String>> hashAsync(V... members) {
List<Object> params = new ArrayList<Object>(members.length + 1);
@ -121,15 +129,16 @@ public class RedissonGeo<V> extends RedissonScoredSortedSet<V> implements RGeo<V
for (Object member : members) {
params.add(encode(member));
}
RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEOHASH", new MapGetAllDecoder((List<Object>)Arrays.asList(members), 0));
RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEOHASH",
new MapGetAllDecoder((List<Object>) Arrays.asList(members), 0));
return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, command, params.toArray());
}
@Override
public Map<V, GeoPosition> pos(V... members) {
return get(posAsync(members));
}
@Override
public RFuture<Map<V, GeoPosition>> posAsync(V... members) {
List<Object> params = new ArrayList<Object>(members.length + 1);
@ -137,322 +146,370 @@ public class RedissonGeo<V> extends RedissonScoredSortedSet<V> implements RGeo<V
for (Object member : members) {
params.add(encode(member));
}
MultiDecoder<Map<Object, Object>> decoder = new ListMultiDecoder(0, new GeoPositionDecoder(),
// new ObjectListReplayDecoder(ListMultiDecoder.RESET),
new GeoPositionMapDecoder((List<Object>)Arrays.asList(members)));
MultiDecoder<Map<Object, Object>> decoder = new ListMultiDecoder(0, new GeoPositionDecoder(),
// new ObjectListReplayDecoder(ListMultiDecoder.RESET),
new GeoPositionMapDecoder((List<Object>) Arrays.asList(members)));
RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEOPOS", decoder);
return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, command, params.toArray());
}
@Override
public List<V> radius(double longitude, double latitude, double radius, GeoUnit geoUnit) {
return get(radiusAsync(longitude, latitude, radius, geoUnit));
}
@Override
public RFuture<List<V>> radiusAsync(double longitude, double latitude, double radius, GeoUnit geoUnit) {
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUS_RO, getName(), convert(longitude), convert(latitude), radius, geoUnit);
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUS_RO, getName(), convert(longitude),
convert(latitude), radius, geoUnit);
}
@Override
public List<V> radius(double longitude, double latitude, double radius, GeoUnit geoUnit, int count) {
return get(radiusAsync(longitude, latitude, radius, geoUnit, count));
}
@Override
public RFuture<List<V>> radiusAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, int count) {
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUS_RO, getName(), convert(longitude), convert(latitude),
radius, geoUnit, "COUNT", count);
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUS_RO, getName(), convert(longitude),
convert(latitude), radius, geoUnit, "COUNT", count);
}
@Override
public List<V> radius(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
return get(radiusAsync(longitude, latitude, radius, geoUnit, geoOrder));
}
@Override
public RFuture<List<V>> radiusAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUS_RO, getName(), convert(longitude), convert(latitude),
radius, geoUnit, geoOrder);
public RFuture<List<V>> radiusAsync(double longitude, double latitude, double radius, GeoUnit geoUnit,
GeoOrder geoOrder) {
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUS_RO, getName(), convert(longitude),
convert(latitude), radius, geoUnit, geoOrder);
}
@Override
public List<V> radius(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
public List<V> radius(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder,
int count) {
return get(radiusAsync(longitude, latitude, radius, geoUnit, geoOrder, count));
}
@Override
public RFuture<List<V>> radiusAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUS_RO, getName(), convert(longitude), convert(latitude),
radius, geoUnit, "COUNT", count, geoOrder);
public RFuture<List<V>> radiusAsync(double longitude, double latitude, double radius, GeoUnit geoUnit,
GeoOrder geoOrder, int count) {
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUS_RO, getName(), convert(longitude),
convert(latitude), radius, geoUnit, "COUNT", count, geoOrder);
}
@Override
public Map<V, Double> radiusWithDistance(double longitude, double latitude, double radius, GeoUnit geoUnit) {
return get(radiusWithDistanceAsync(longitude, latitude, radius, geoUnit));
}
@Override
public RFuture<Map<V, Double>> radiusWithDistanceAsync(double longitude, double latitude, double radius, GeoUnit geoUnit) {
return commandExecutor.readAsync(getName(), codec, GEORADIUS_RO_DISTANCE, getName(), convert(longitude), convert(latitude),
radius, geoUnit, "WITHDIST");
public RFuture<Map<V, Double>> radiusWithDistanceAsync(double longitude, double latitude, double radius,
GeoUnit geoUnit) {
return commandExecutor.readAsync(getName(), codec, GEORADIUS_RO_DISTANCE, getName(), convert(longitude),
convert(latitude), radius, geoUnit, "WITHDIST");
}
@Override
public Map<V, Double> radiusWithDistance(double longitude, double latitude, double radius, GeoUnit geoUnit, int count) {
public Map<V, Double> radiusWithDistance(double longitude, double latitude, double radius, GeoUnit geoUnit,
int count) {
return get(radiusWithDistanceAsync(longitude, latitude, radius, geoUnit, count));
}
@Override
public RFuture<Map<V, Double>> radiusWithDistanceAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, int count) {
return commandExecutor.readAsync(getName(), codec, GEORADIUS_RO_DISTANCE, getName(), convert(longitude), convert(latitude),
radius, geoUnit, "WITHDIST", "COUNT", count);
public RFuture<Map<V, Double>> radiusWithDistanceAsync(double longitude, double latitude, double radius,
GeoUnit geoUnit, int count) {
return commandExecutor.readAsync(getName(), codec, GEORADIUS_RO_DISTANCE, getName(), convert(longitude),
convert(latitude), radius, geoUnit, "WITHDIST", "COUNT", count);
}
@Override
public Map<V, Double> radiusWithDistance(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
public Map<V, Double> radiusWithDistance(double longitude, double latitude, double radius, GeoUnit geoUnit,
GeoOrder geoOrder) {
return get(radiusWithDistanceAsync(longitude, latitude, radius, geoUnit, geoOrder));
}
@Override
public RFuture<Map<V, Double>> radiusWithDistanceAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
return commandExecutor.readAsync(getName(), codec, GEORADIUS_RO_DISTANCE, getName(), convert(longitude), convert(latitude),
radius, geoUnit, "WITHDIST", geoOrder);
public RFuture<Map<V, Double>> radiusWithDistanceAsync(double longitude, double latitude, double radius,
GeoUnit geoUnit, GeoOrder geoOrder) {
return commandExecutor.readAsync(getName(), codec, GEORADIUS_RO_DISTANCE, getName(), convert(longitude),
convert(latitude), radius, geoUnit, "WITHDIST", geoOrder);
}
@Override
public Map<V, Double> radiusWithDistance(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
public Map<V, Double> radiusWithDistance(double longitude, double latitude, double radius, GeoUnit geoUnit,
GeoOrder geoOrder, int count) {
return get(radiusWithDistanceAsync(longitude, latitude, radius, geoUnit, geoOrder, count));
}
@Override
public RFuture<Map<V, Double>> radiusWithDistanceAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return commandExecutor.readAsync(getName(), codec, GEORADIUS_RO_DISTANCE, getName(), convert(longitude), convert(latitude),
radius, geoUnit, "WITHDIST", "COUNT", count, geoOrder);
public RFuture<Map<V, Double>> radiusWithDistanceAsync(double longitude, double latitude, double radius,
GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return commandExecutor.readAsync(getName(), codec, GEORADIUS_RO_DISTANCE, getName(), convert(longitude),
convert(latitude), radius, geoUnit, "WITHDIST", "COUNT", count, geoOrder);
}
@Override
public Map<V, GeoPosition> radiusWithPosition(double longitude, double latitude, double radius, GeoUnit geoUnit) {
return get(radiusWithPositionAsync(longitude, latitude, radius, geoUnit));
}
@Override
public RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(double longitude, double latitude, double radius, GeoUnit geoUnit) {
return commandExecutor.readAsync(getName(), codec, GEORADIUS_RO_POS, getName(), convert(longitude), convert(latitude), radius, geoUnit, "WITHCOORD");
public RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(double longitude, double latitude, double radius,
GeoUnit geoUnit) {
return commandExecutor.readAsync(getName(), codec, GEORADIUS_RO_POS, getName(), convert(longitude),
convert(latitude), radius, geoUnit, "WITHCOORD");
}
@Override
public Map<V, GeoPosition> radiusWithPosition(double longitude, double latitude, double radius, GeoUnit geoUnit, int count) {
public Map<V, GeoPosition> radiusWithPosition(double longitude, double latitude, double radius, GeoUnit geoUnit,
int count) {
return get(radiusWithPositionAsync(longitude, latitude, radius, geoUnit, count));
}
@Override
public RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, int count) {
return commandExecutor.readAsync(getName(), codec, GEORADIUS_RO_POS, getName(), convert(longitude), convert(latitude),
radius, geoUnit, "WITHCOORD", "COUNT", count);
public RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(double longitude, double latitude, double radius,
GeoUnit geoUnit, int count) {
return commandExecutor.readAsync(getName(), codec, GEORADIUS_RO_POS, getName(), convert(longitude),
convert(latitude), radius, geoUnit, "WITHCOORD", "COUNT", count);
}
@Override
public Map<V, GeoPosition> radiusWithPosition(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
public Map<V, GeoPosition> radiusWithPosition(double longitude, double latitude, double radius, GeoUnit geoUnit,
GeoOrder geoOrder) {
return get(radiusWithPositionAsync(longitude, latitude, radius, geoUnit, geoOrder));
}
@Override
public RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
return commandExecutor.readAsync(getName(), codec, GEORADIUS_RO_POS, getName(), convert(longitude), convert(latitude),
radius, geoUnit, "WITHCOORD", geoOrder);
public RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(double longitude, double latitude, double radius,
GeoUnit geoUnit, GeoOrder geoOrder) {
return commandExecutor.readAsync(getName(), codec, GEORADIUS_RO_POS, getName(), convert(longitude),
convert(latitude), radius, geoUnit, "WITHCOORD", geoOrder);
}
@Override
public Map<V, GeoPosition> radiusWithPosition(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
public Map<V, GeoPosition> radiusWithPosition(double longitude, double latitude, double radius, GeoUnit geoUnit,
GeoOrder geoOrder, int count) {
return get(radiusWithPositionAsync(longitude, latitude, radius, geoUnit, geoOrder, count));
}
@Override
public RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return commandExecutor.readAsync(getName(), codec, GEORADIUS_RO_POS, getName(), convert(longitude), convert(latitude),
radius, geoUnit, "WITHCOORD", "COUNT", count, geoOrder);
public RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(double longitude, double latitude, double radius,
GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return commandExecutor.readAsync(getName(), codec, GEORADIUS_RO_POS, getName(), convert(longitude),
convert(latitude), radius, geoUnit, "WITHCOORD", "COUNT", count, geoOrder);
}
@Override
public List<V> radius(V member, double radius, GeoUnit geoUnit) {
return get(radiusAsync(member, radius, geoUnit));
}
@Override
public RFuture<List<V>> radiusAsync(V member, double radius, GeoUnit geoUnit) {
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_RO, getName(), encode(member), radius, geoUnit);
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_RO, getName(),
encode(member), radius, geoUnit);
}
@Override
public List<V> radius(V member, double radius, GeoUnit geoUnit, int count) {
return get(radiusAsync(member, radius, geoUnit, count));
}
@Override
public RFuture<List<V>> radiusAsync(V member, double radius, GeoUnit geoUnit, int count) {
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_RO, getName(), encode(member), radius, geoUnit, "COUNT", count);
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_RO, getName(),
encode(member), radius, geoUnit, "COUNT", count);
}
@Override
public List<V> radius(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
return get(radiusAsync(member, radius, geoUnit, geoOrder));
}
@Override
public RFuture<List<V>> radiusAsync(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_RO, getName(), encode(member), radius, geoUnit, geoOrder);
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_RO, getName(),
encode(member), radius, geoUnit, geoOrder);
}
@Override
public List<V> radius(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return get(radiusAsync(member, radius, geoUnit, geoOrder, count));
}
@Override
public RFuture<List<V>> radiusAsync(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_RO, getName(), encode(member), radius, geoUnit, "COUNT", count, geoOrder);
return commandExecutor.readAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_RO, getName(),
encode(member), radius, geoUnit, "COUNT", count, geoOrder);
}
@Override
public Map<V, Double> radiusWithDistance(V member, double radius, GeoUnit geoUnit) {
return get(radiusWithDistanceAsync(member, radius, geoUnit));
}
@Override
public RFuture<Map<V, Double>> radiusWithDistanceAsync(V member, double radius, GeoUnit geoUnit) {
return commandExecutor.readAsync(getName(), codec, GEORADIUSBYMEMBER_RO_DISTANCE, getName(), encode(member), radius, geoUnit, "WITHDIST");
return commandExecutor.readAsync(getName(), codec, GEORADIUSBYMEMBER_RO_DISTANCE, getName(), encode(member),
radius, geoUnit, "WITHDIST");
}
@Override
public Map<V, Double> radiusWithDistance(V member, double radius, GeoUnit geoUnit, int count) {
return get(radiusWithDistanceAsync(member, radius, geoUnit, count));
}
@Override
public RFuture<Map<V, Double>> radiusWithDistanceAsync(V member, double radius, GeoUnit geoUnit, int count) {
return commandExecutor.readAsync(getName(), codec, GEORADIUSBYMEMBER_RO_DISTANCE, getName(), encode(member), radius, geoUnit, "WITHDIST", "COUNT", count);
return commandExecutor.readAsync(getName(), codec, GEORADIUSBYMEMBER_RO_DISTANCE, getName(), encode(member),
radius, geoUnit, "WITHDIST", "COUNT", count);
}
@Override
public Map<V, Double> radiusWithDistance(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
return get(radiusWithDistanceAsync(member, radius, geoUnit, geoOrder));
}
@Override
public RFuture<Map<V, Double>> radiusWithDistanceAsync(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
return commandExecutor.readAsync(getName(), codec, GEORADIUSBYMEMBER_RO_DISTANCE, getName(), encode(member), radius, geoUnit, "WITHDIST", geoOrder);
public RFuture<Map<V, Double>> radiusWithDistanceAsync(V member, double radius, GeoUnit geoUnit,
GeoOrder geoOrder) {
return commandExecutor.readAsync(getName(), codec, GEORADIUSBYMEMBER_RO_DISTANCE, getName(), encode(member),
radius, geoUnit, "WITHDIST", geoOrder);
}
@Override
public Map<V, Double> radiusWithDistance(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return get(radiusWithDistanceAsync(member, radius, geoUnit, geoOrder, count));
}
@Override
public RFuture<Map<V, Double>> radiusWithDistanceAsync(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return commandExecutor.readAsync(getName(), codec, GEORADIUSBYMEMBER_RO_DISTANCE, getName(), encode(member), radius, geoUnit, "WITHDIST", "COUNT", count, geoOrder);
public RFuture<Map<V, Double>> radiusWithDistanceAsync(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder,
int count) {
return commandExecutor.readAsync(getName(), codec, GEORADIUSBYMEMBER_RO_DISTANCE, getName(), encode(member),
radius, geoUnit, "WITHDIST", "COUNT", count, geoOrder);
}
@Override
public Map<V, GeoPosition> radiusWithPosition(V member, double radius, GeoUnit geoUnit) {
return get(radiusWithPositionAsync(member, radius, geoUnit));
}
@Override
public RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(V member, double radius, GeoUnit geoUnit) {
return commandExecutor.readAsync(getName(), codec, GEORADIUSBYMEMBER_RO_POS, getName(), encode(member), radius, geoUnit, "WITHCOORD");
return commandExecutor.readAsync(getName(), codec, GEORADIUSBYMEMBER_RO_POS, getName(), encode(member), radius,
geoUnit, "WITHCOORD");
}
@Override
public Map<V, GeoPosition> radiusWithPosition(V member, double radius, GeoUnit geoUnit, int count) {
return get(radiusWithPositionAsync(member, radius, geoUnit, count));
}
@Override
public RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(V member, double radius, GeoUnit geoUnit, int count) {
return commandExecutor.readAsync(getName(), codec, GEORADIUSBYMEMBER_RO_POS, getName(), encode(member), radius, geoUnit, "WITHCOORD", "COUNT", count);
return commandExecutor.readAsync(getName(), codec, GEORADIUSBYMEMBER_RO_POS, getName(), encode(member), radius,
geoUnit, "WITHCOORD", "COUNT", count);
}
@Override
public Map<V, GeoPosition> radiusWithPosition(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
return get(radiusWithPositionAsync(member, radius, geoUnit, geoOrder));
}
@Override
public RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder) {
return commandExecutor.readAsync(getName(), codec, GEORADIUSBYMEMBER_RO_POS, getName(), encode(member), radius, geoUnit, "WITHCOORD", geoOrder);
public RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(V member, double radius, GeoUnit geoUnit,
GeoOrder geoOrder) {
return commandExecutor.readAsync(getName(), codec, GEORADIUSBYMEMBER_RO_POS, getName(), encode(member), radius,
geoUnit, "WITHCOORD", geoOrder);
}
@Override
public Map<V, GeoPosition> radiusWithPosition(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
public Map<V, GeoPosition> radiusWithPosition(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder,
int count) {
return get(radiusWithPositionAsync(member, radius, geoUnit, geoOrder, count));
}
@Override
public RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return commandExecutor.readAsync(getName(), codec, GEORADIUSBYMEMBER_RO_POS, getName(), encode(member), radius, geoUnit, "WITHCOORD", "COUNT", count, geoOrder);
public RFuture<Map<V, GeoPosition>> radiusWithPositionAsync(V member, double radius, GeoUnit geoUnit,
GeoOrder geoOrder, int count) {
return commandExecutor.readAsync(getName(), codec, GEORADIUSBYMEMBER_RO_POS, getName(), encode(member), radius,
geoUnit, "WITHCOORD", "COUNT", count, geoOrder);
}
@Override
public long radiusStoreTo(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit) {
return get(radiusStoreToAsync(destName, longitude, latitude, radius, geoUnit));
}
@Override
public long radiusStoreTo(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit) {
return get(radiusStoreToAsync(destName, longitude, latitude, radius, geoUnit));
}
@Override
public RFuture<Long> radiusStoreToAsync(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit) {
return commandExecutor.writeAsync(getName(), LongCodec.INSTANCE, RedisCommands.GEORADIUS_STORE, getName(), convert(longitude), convert(latitude), radius, geoUnit, "STORE", destName);
}
@Override
public RFuture<Long> radiusStoreToAsync(String destName, double longitude, double latitude, double radius,
GeoUnit geoUnit) {
return commandExecutor.writeAsync(getName(), LongCodec.INSTANCE, RedisCommands.GEORADIUS_STORE, getName(),
convert(longitude), convert(latitude), radius, geoUnit, "STORE", destName);
}
@Override
public long radiusStoreTo(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit, int count) {
return get(radiusStoreToAsync(destName, longitude, latitude, radius, geoUnit, count));
}
@Override
public long radiusStoreTo(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit,
int count) {
return get(radiusStoreToAsync(destName, longitude, latitude, radius, geoUnit, count));
}
@Override
public RFuture<Long> radiusStoreToAsync(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit, int count) {
return commandExecutor.writeAsync(getName(), LongCodec.INSTANCE, RedisCommands.GEORADIUS_STORE, getName(), convert(longitude), convert(latitude), radius, geoUnit, "COUNT", count, "STORE", destName);
}
@Override
public RFuture<Long> radiusStoreToAsync(String destName, double longitude, double latitude, double radius,
GeoUnit geoUnit, int count) {
return commandExecutor.writeAsync(getName(), LongCodec.INSTANCE, RedisCommands.GEORADIUS_STORE, getName(),
convert(longitude), convert(latitude), radius, geoUnit, "COUNT", count, "STORE", destName);
}
@Override
public long radiusStoreTo(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return get(radiusStoreToAsync(destName, longitude, latitude, radius, geoUnit, geoOrder, count));
}
@Override
public long radiusStoreTo(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit,
GeoOrder geoOrder, int count) {
return get(radiusStoreToAsync(destName, longitude, latitude, radius, geoUnit, geoOrder, count));
}
@Override
public RFuture<Long> radiusStoreToAsync(String destName, double longitude, double latitude, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return commandExecutor.writeAsync(getName(), LongCodec.INSTANCE, RedisCommands.GEORADIUS_STORE, getName(), convert(longitude), convert(latitude), radius, geoUnit, geoOrder, "COUNT", count, "STORE", destName);
}
@Override
public RFuture<Long> radiusStoreToAsync(String destName, double longitude, double latitude, double radius,
GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return commandExecutor.writeAsync(getName(), LongCodec.INSTANCE, RedisCommands.GEORADIUS_STORE, getName(),
convert(longitude), convert(latitude), radius, geoUnit, geoOrder, "COUNT", count, "STORE", destName);
}
@Override
public long radiusStoreTo(String destName, V member, double radius, GeoUnit geoUnit) {
return get(radiusStoreToAsync(destName, member, radius, geoUnit));
}
@Override
public long radiusStoreTo(String destName, V member, double radius, GeoUnit geoUnit) {
return get(radiusStoreToAsync(destName, member, radius, geoUnit));
}
@Override
public RFuture<Long> radiusStoreToAsync(String destName, V member, double radius, GeoUnit geoUnit) {
return commandExecutor.writeAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_STORE, getName(), encode(member), radius, geoUnit, "STORE", destName);
}
@Override
public RFuture<Long> radiusStoreToAsync(String destName, V member, double radius, GeoUnit geoUnit) {
return commandExecutor.writeAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_STORE, getName(),
encode(member), radius, geoUnit, "STORE", destName);
}
@Override
public long radiusStoreTo(String destName, V member, double radius, GeoUnit geoUnit, int count) {
return get(radiusStoreToAsync(destName, member, radius, geoUnit, count));
}
@Override
public long radiusStoreTo(String destName, V member, double radius, GeoUnit geoUnit, int count) {
return get(radiusStoreToAsync(destName, member, radius, geoUnit, count));
}
@Override
public RFuture<Long> radiusStoreToAsync(String destName, V member, double radius, GeoUnit geoUnit, int count) {
return commandExecutor.writeAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_STORE, getName(), encode(member), radius, geoUnit, "COUNT", count, "STORE", destName);
}
@Override
public RFuture<Long> radiusStoreToAsync(String destName, V member, double radius, GeoUnit geoUnit, int count) {
return commandExecutor.writeAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_STORE, getName(),
encode(member), radius, geoUnit, "COUNT", count, "STORE", destName);
}
@Override
public long radiusStoreTo(String destName, V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
@Override
public long radiusStoreTo(String destName, V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return get(radiusStoreToAsync(destName, member, radius, geoUnit, geoOrder, count));
}
}
@Override
public RFuture<Long> radiusStoreToAsync(String destName, V member, double radius, GeoUnit geoUnit, GeoOrder geoOrder, int count) {
return commandExecutor.writeAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_STORE, getName(), encode(member), radius, geoUnit, geoOrder, "COUNT", count, "STORE", destName);
}
@Override
public RFuture<Long> radiusStoreToAsync(String destName, V member, double radius, GeoUnit geoUnit,
GeoOrder geoOrder, int count) {
return commandExecutor.writeAsync(getName(), codec, RedisCommands.GEORADIUSBYMEMBER_STORE, getName(),
encode(member), radius, geoUnit, geoOrder, "COUNT", count, "STORE", destName);
}
}

@ -71,7 +71,7 @@ public class RedissonKeys implements RKeys {
public RFuture<RType> getTypeAsync(String key) {
return commandExecutor.readAsync(key, RedisCommands.TYPE, key);
}
@Override
public int getSlot(String key) {
return commandExecutor.get(getSlotAsync(key));
@ -86,7 +86,7 @@ public class RedissonKeys implements RKeys {
public Iterable<String> getKeysByPattern(String pattern) {
return getKeysByPattern(pattern, 10);
}
@Override
public Iterable<String> getKeysByPattern(String pattern, int count) {
List<Iterable<String>> iterables = new ArrayList<Iterable<String>>();
@ -102,22 +102,24 @@ public class RedissonKeys implements RKeys {
return new CompositeIterable<String>(iterables);
}
@Override
public Iterable<String> getKeys() {
return getKeysByPattern(null);
}
@Override
public Iterable<String> getKeys(int count) {
return getKeysByPattern(null, count);
}
public RFuture<ListScanResult<Object>> scanIteratorAsync(RedisClient client, MasterSlaveEntry entry, long startPos, String pattern, int count) {
public RFuture<ListScanResult<Object>> scanIteratorAsync(RedisClient client, MasterSlaveEntry entry, long startPos,
String pattern, int count) {
if (pattern == null) {
return commandExecutor.readAsync(client, entry, StringCodec.INSTANCE, RedisCommands.SCAN, startPos, "COUNT", count);
return commandExecutor.readAsync(client, entry, StringCodec.INSTANCE, RedisCommands.SCAN, startPos, "COUNT",
count);
}
return commandExecutor.readAsync(client, entry, StringCodec.INSTANCE, RedisCommands.SCAN, startPos, "MATCH", pattern, "COUNT", count);
return commandExecutor.readAsync(client, entry, StringCodec.INSTANCE, RedisCommands.SCAN, startPos, "MATCH",
pattern, "COUNT", count);
}
private Iterator<String> createKeysIterator(MasterSlaveEntry entry, String pattern, int count) {
@ -125,14 +127,15 @@ public class RedissonKeys implements RKeys {
@Override
protected ListScanResult<Object> iterator(RedisClient client, long nextIterPos) {
return commandExecutor.get(RedissonKeys.this.scanIteratorAsync(client, entry, nextIterPos, pattern, count));
return commandExecutor
.get(RedissonKeys.this.scanIteratorAsync(client, entry, nextIterPos, pattern, count));
}
@Override
protected void remove(Object value) {
RedissonKeys.this.delete((String)value);
RedissonKeys.this.delete((String) value);
}
};
}
@ -140,11 +143,12 @@ public class RedissonKeys implements RKeys {
public long touch(String... names) {
return commandExecutor.get(touchAsync(names));
}
@Override
public RFuture<Long> touchAsync(String... names) {
return commandExecutor.writeAllAsync(RedisCommands.TOUCH_LONG, new SlotCallback<Long, Long>() {
AtomicLong results = new AtomicLong();
@Override
public void onSlotResult(Long result) {
results.addAndGet(result);
@ -156,16 +160,17 @@ public class RedissonKeys implements RKeys {
}
}, names);
}
@Override
public long countExists(String... names) {
return commandExecutor.get(countExistsAsync(names));
}
@Override
public RFuture<Long> countExistsAsync(String... names) {
return commandExecutor.readAllAsync(RedisCommands.EXISTS_LONG, new SlotCallback<Long, Long>() {
AtomicLong results = new AtomicLong();
@Override
public void onSlotResult(Long result) {
results.addAndGet(result);
@ -178,7 +183,6 @@ public class RedissonKeys implements RKeys {
}, names);
}
@Override
public String randomKey() {
return commandExecutor.get(randomKeyAsync());
@ -218,7 +222,7 @@ public class RedissonKeys implements RKeys {
} else {
failed.set(e);
}
checkExecution(result, failed, count, executed);
};
@ -233,18 +237,18 @@ public class RedissonKeys implements RKeys {
while (keysIterator.hasNext()) {
String key = keysIterator.next();
keys.add(key);
if (keys.size() % batchSize == 0) {
count += delete(keys.toArray(new String[keys.size()]));
keys.clear();
}
}
if (!keys.isEmpty()) {
count += delete(keys.toArray(new String[keys.size()]));
keys.clear();
}
RFuture<Long> future = RedissonPromise.newSucceededFuture(count);
future.onComplete(listener);
} catch (Exception e) {
@ -262,7 +266,7 @@ public class RedissonKeys implements RKeys {
public long delete(String... keys) {
return commandExecutor.get(deleteAsync(keys));
}
@Override
public long delete(RObject... objects) {
return commandExecutor.get(deleteAsync(objects));
@ -274,10 +278,10 @@ public class RedissonKeys implements RKeys {
for (RObject obj : objects) {
keys.add(obj.getName());
}
return deleteAsync(keys.toArray(new String[keys.size()]));
}
@Override
public long unlink(String... keys) {
return commandExecutor.get(deleteAsync(keys));
@ -292,7 +296,7 @@ public class RedissonKeys implements RKeys {
public RFuture<Long> deleteAsync(String... keys) {
return executeAsync(RedisCommands.DEL, keys);
}
private RFuture<Long> executeAsync(RedisStrictCommand<Long> command, String... keys) {
if (!commandExecutor.getConnectionManager().isClusterMode()) {
return commandExecutor.writeAsync(null, command, keys);
@ -324,7 +328,7 @@ public class RedissonKeys implements RKeys {
} else {
failed.set(u);
}
checkExecution(result, failed, count, executed);
};
@ -351,6 +355,7 @@ public class RedissonKeys implements RKeys {
public RFuture<Long> countAsync() {
return commandExecutor.readAllAsync(RedisCommands.DBSIZE, new SlotCallback<Long, Long>() {
AtomicLong results = new AtomicLong();
@Override
public void onSlotResult(Long result) {
results.addAndGet(result);
@ -383,7 +388,6 @@ public class RedissonKeys implements RKeys {
return commandExecutor.writeAllAsync(RedisCommands.FLUSHALL_ASYNC);
}
@Override
public void flushdb() {
commandExecutor.get(flushdbAsync());
@ -404,12 +408,14 @@ public class RedissonKeys implements RKeys {
return commandExecutor.writeAllAsync(RedisCommands.FLUSHALL);
}
private void checkExecution(RPromise<Long> result, AtomicReference<Throwable> failed,
AtomicLong count, AtomicLong executed) {
private void checkExecution(RPromise<Long> result, AtomicReference<Throwable> failed, AtomicLong count,
AtomicLong executed) {
if (executed.decrementAndGet() == 0) {
if (failed.get() != null) {
if (count.get() > 0) {
RedisException ex = new RedisException("" + count.get() + " keys has been deleted. But one or more nodes has an error", failed.get());
RedisException ex = new RedisException(
"" + count.get() + " keys has been deleted. But one or more nodes has an error",
failed.get());
result.tryFailure(ex);
} else {
result.tryFailure(failed.get());
@ -477,7 +483,8 @@ public class RedissonKeys implements RKeys {
@Override
public RFuture<Boolean> expireAsync(String name, long timeToLive, TimeUnit timeUnit) {
return commandExecutor.writeAsync(name, StringCodec.INSTANCE, RedisCommands.PEXPIRE, name, timeUnit.toMillis(timeToLive));
return commandExecutor.writeAsync(name, StringCodec.INSTANCE, RedisCommands.PEXPIRE, name,
timeUnit.toMillis(timeToLive));
}
@Override
@ -499,7 +506,7 @@ public class RedissonKeys implements RKeys {
public RFuture<Void> copyAsync(String name, String host, int port, int database, long timeout) {
return commandExecutor.writeAsync(name, RedisCommands.MIGRATE, host, port, name, database, timeout, "COPY");
}
@Override
public boolean move(String name, int database) {
return commandExecutor.get(moveAsync(name, database));
@ -534,5 +541,5 @@ public class RedissonKeys implements RKeys {
public Stream<String> getKeysStream(int count) {
return toStream(getKeys(count).iterator());
}
}

@ -343,7 +343,7 @@ public class RedissonList<V> extends RedissonExpirable implements RList<V> {
return get(setAsync(index, element));
} catch (RedisException e) {
if (e.getCause() instanceof IndexOutOfBoundsException) {
throw (IndexOutOfBoundsException)e.getCause();
throw (IndexOutOfBoundsException) e.getCause();
}
throw e;
}
@ -613,6 +613,8 @@ public class RedissonList<V> extends RedissonExpirable implements RList<V> {
return new RedissonSubList<V>(codec, commandExecutor, getName(), fromIndex, toIndex);
}
@Override
@SuppressWarnings("AvoidInlineConditionals")
public String toString() {
Iterator<V> it = iterator();
if (! it.hasNext())
@ -630,6 +632,7 @@ public class RedissonList<V> extends RedissonExpirable implements RList<V> {
}
@Override
@SuppressWarnings("AvoidInlineConditionals")
public boolean equals(Object o) {
if (o == this)
return true;
@ -648,6 +651,7 @@ public class RedissonList<V> extends RedissonExpirable implements RList<V> {
}
@Override
@SuppressWarnings("AvoidInlineConditionals")
public int hashCode() {
int hashCode = 1;
for (V e : this) {
@ -718,7 +722,7 @@ public class RedissonList<V> extends RedissonExpirable implements RList<V> {
@Override
public <T> Collection<T> readSort(String byPattern, List<String> getPatterns, SortOrder order) {
return (Collection<T>)get(readSortAsync(byPattern, getPatterns, order));
return (Collection<T>) get(readSortAsync(byPattern, getPatterns, order));
}
@Override
@ -728,7 +732,7 @@ public class RedissonList<V> extends RedissonExpirable implements RList<V> {
@Override
public <T> Collection<T> readSort(String byPattern, List<String> getPatterns, SortOrder order, int offset, int count) {
return (Collection<T>)get(readSortAsync(byPattern, getPatterns, order, offset, count));
return (Collection<T>) get(readSortAsync(byPattern, getPatterns, order, offset, count));
}
@Override
@ -778,7 +782,7 @@ public class RedissonList<V> extends RedissonExpirable implements RList<V> {
@Override
public <T> Collection<T> readSortAlpha(String byPattern, List<String> getPatterns, SortOrder order) {
return (Collection<T>)get(readSortAlphaAsync(byPattern, getPatterns, order));
return (Collection<T>) get(readSortAlphaAsync(byPattern, getPatterns, order));
}
@Override
@ -788,7 +792,7 @@ public class RedissonList<V> extends RedissonExpirable implements RList<V> {
@Override
public <T> Collection<T> readSortAlpha(String byPattern, List<String> getPatterns, SortOrder order, int offset, int count) {
return (Collection<T>)get(readSortAlphaAsync(byPattern, getPatterns, order, offset, count));
return (Collection<T>) get(readSortAlphaAsync(byPattern, getPatterns, order, offset, count));
}
@Override

@ -656,6 +656,7 @@ public class RedissonListMultimapValues<V> extends RedissonExpirable implements
}
@Override
@SuppressWarnings("AvoidInlineConditionals")
public String toString() {
Iterator<V> it = iterator();
if (! it.hasNext())
@ -673,6 +674,7 @@ public class RedissonListMultimapValues<V> extends RedissonExpirable implements
}
@Override
@SuppressWarnings("AvoidInlineConditionals")
public boolean equals(Object o) {
if (o == this)
return true;
@ -691,6 +693,7 @@ public class RedissonListMultimapValues<V> extends RedissonExpirable implements
}
@Override
@SuppressWarnings("AvoidInlineConditionals")
public int hashCode() {
int hashCode = 1;
for (V e : this) {

@ -90,7 +90,7 @@ import net.bytebuddy.matcher.ElementMatchers;
public class RedissonLiveObjectService implements RLiveObjectService {
private static final ConcurrentMap<Class<? extends Resolver>, Resolver<?, ?, ?>> providerCache = PlatformDependent.newConcurrentHashMap();
private static final ConcurrentMap<Class<? extends Resolver>, Resolver<?, ?, ?>> PROVIDER_CACHE = PlatformDependent.newConcurrentHashMap();
private final ConcurrentMap<Class<?>, Class<?>> classCache;
private final RedissonClient redisson;
private final CommandAsyncExecutor commandExecutor;
@ -126,14 +126,14 @@ public class RedissonLiveObjectService implements RLiveObjectService {
}
private Resolver<?, ?, ?> getResolver(Class<?> cls, Class<? extends Resolver> resolverClass, Annotation anno) {
if (!providerCache.containsKey(resolverClass)) {
if (!PROVIDER_CACHE.containsKey(resolverClass)) {
try {
providerCache.putIfAbsent(resolverClass, resolverClass.newInstance());
PROVIDER_CACHE.putIfAbsent(resolverClass, resolverClass.newInstance());
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
return providerCache.get(resolverClass);
return PROVIDER_CACHE.get(resolverClass);
}
public <T> T createLiveObject(Class<T> entityClass, Object id) {
@ -143,7 +143,10 @@ public class RedissonLiveObjectService implements RLiveObjectService {
@Override
public <T> T get(Class<T> entityClass, Object id) {
T proxied = createLiveObject(entityClass, id);
return asLiveObject(proxied).isExists() ? proxied : null;
if (asLiveObject(proxied).isExists()) {
return proxied;
}
return null;
}
Set<Object> traverseAnd(ANDCondition condition, NamingScheme namingScheme, Class<?> entityClass) {
@ -306,45 +309,42 @@ public class RedissonLiveObjectService implements RLiveObjectService {
if (rObject != null) {
commandExecutor.getObjectBuilder().store(rObject, field.getName(), liveMap);
if (rObject instanceof SortedSet) {
((RSortedSet)rObject).trySetComparator(((SortedSet)object).comparator());
((RSortedSet) rObject).trySetComparator(((SortedSet) object).comparator());
}
if (rObject instanceof Collection) {
for (Object obj : (Collection<Object>)object) {
for (Object obj : (Collection<Object>) object) {
if (obj != null && ClassUtils.isAnnotationPresent(obj.getClass(), REntity.class)) {
Object persisted = alreadyPersisted.get(obj);
if (persisted == null) {
if (checkCascade(detachedObject, type, field.getName())) {
persisted = persist(obj, alreadyPersisted, type);
}
if (persisted == null
&& checkCascade(detachedObject, type, field.getName())) {
persisted = persist(obj, alreadyPersisted, type);
}
obj = persisted;
}
((Collection)rObject).add(obj);
((Collection) rObject).add(obj);
}
} else if (rObject instanceof Map) {
Map<Object, Object> rMap = (Map<Object, Object>) rObject;
Map<?, ?> map = (Map<?, ?>)rObject;
Map<?, ?> map = (Map<?, ?>) rObject;
for (Entry<?, ?> entry : map.entrySet()) {
Object key = entry.getKey();
Object value = entry.getValue();
if (key != null && ClassUtils.isAnnotationPresent(key.getClass(), REntity.class)) {
Object persisted = alreadyPersisted.get(key);
if (persisted == null) {
if (checkCascade(detachedObject, type, field.getName())) {
persisted = persist(key, alreadyPersisted, type);
}
if (persisted == null
&& checkCascade(detachedObject, type, field.getName())) {
persisted = persist(key, alreadyPersisted, type);
}
key = persisted;
}
if (value != null && ClassUtils.isAnnotationPresent(value.getClass(), REntity.class)) {
Object persisted = alreadyPersisted.get(value);
if (persisted == null) {
if (checkCascade(detachedObject, type, field.getName())) {
persisted = persist(value, alreadyPersisted, type);
}
if (persisted == null
&& checkCascade(detachedObject, type, field.getName())) {
persisted = persist(value, alreadyPersisted, type);
}
value = persisted;
}
@ -407,132 +407,128 @@ public class RedissonLiveObjectService implements RLiveObjectService {
@SuppressWarnings("unchecked")
private <T> T detach(T attachedObject, Map<String, Object> alreadyDetached) {
validateAttached(attachedObject);
try {
T detached = instantiateDetachedObject((Class<T>) attachedObject.getClass().getSuperclass(), asLiveObject(attachedObject).getLiveObjectId());
BeanCopy.beans(attachedObject, detached).declared(true, true).copy();
alreadyDetached.put(getMap(attachedObject).getName(), detached);
T detached = instantiateDetachedObject((Class<T>) attachedObject.getClass().getSuperclass(), asLiveObject(attachedObject).getLiveObjectId());
BeanCopy.beans(attachedObject, detached).declared(true, true).copy();
alreadyDetached.put(getMap(attachedObject).getName(), detached);
for (Entry<String, Object> obj : getMap(attachedObject).entrySet()) {
if (!checkCascade(attachedObject, RCascadeType.DETACH, obj.getKey())) {
continue;
}
for (Entry<String, Object> obj : getMap(attachedObject).entrySet()) {
if (!checkCascade(attachedObject, RCascadeType.DETACH, obj.getKey())) {
continue;
if (obj.getValue() instanceof RSortedSet) {
SortedSet<Object> redissonSet = (SortedSet<Object>) obj.getValue();
Set<Object> set = new TreeSet<Object>(redissonSet.comparator());
for (Object object : redissonSet) {
if (isLiveObject(object)) {
Object detachedObject = alreadyDetached.get(getMap(object).getName());
if (detachedObject == null) {
detachedObject = detach(object, alreadyDetached);
}
object = detachedObject;
}
set.add(object);
}
if (obj.getValue() instanceof RSortedSet) {
SortedSet<Object> redissonSet = (SortedSet<Object>) obj.getValue();
Set<Object> set = new TreeSet<Object>(redissonSet.comparator());
for (Object object : redissonSet) {
if (isLiveObject(object)) {
Object detachedObject = alreadyDetached.get(getMap(object).getName());
if (detachedObject == null) {
detachedObject = detach(object, alreadyDetached);
}
object = detachedObject;
ClassUtils.setField(detached, obj.getKey(), set);
} else if (obj.getValue() instanceof RDeque) {
Collection<Object> redissonDeque = (Collection<Object>) obj.getValue();
Deque<Object> deque = new LinkedList<Object>();
for (Object object : redissonDeque) {
if (isLiveObject(object)) {
Object detachedObject = alreadyDetached.get(getMap(object).getName());
if (detachedObject == null) {
detachedObject = detach(object, alreadyDetached);
}
set.add(object);
object = detachedObject;
}
ClassUtils.setField(detached, obj.getKey(), set);
} else if (obj.getValue() instanceof RDeque) {
Collection<Object> redissonDeque = (Collection<Object>) obj.getValue();
Deque<Object> deque = new LinkedList<Object>();
for (Object object : redissonDeque) {
if (isLiveObject(object)) {
Object detachedObject = alreadyDetached.get(getMap(object).getName());
if (detachedObject == null) {
detachedObject = detach(object, alreadyDetached);
}
object = detachedObject;
deque.add(object);
}
ClassUtils.setField(detached, obj.getKey(), deque);
} else if (obj.getValue() instanceof RQueue) {
Collection<Object> redissonQueue = (Collection<Object>) obj.getValue();
Queue<Object> queue = new LinkedList<Object>();
for (Object object : redissonQueue) {
if (isLiveObject(object)) {
Object detachedObject = alreadyDetached.get(getMap(object).getName());
if (detachedObject == null) {
detachedObject = detach(object, alreadyDetached);
}
deque.add(object);
object = detachedObject;
}
ClassUtils.setField(detached, obj.getKey(), deque);
} else if (obj.getValue() instanceof RQueue) {
Collection<Object> redissonQueue = (Collection<Object>) obj.getValue();
Queue<Object> queue = new LinkedList<Object>();
for (Object object : redissonQueue) {
if (isLiveObject(object)) {
Object detachedObject = alreadyDetached.get(getMap(object).getName());
if (detachedObject == null) {
detachedObject = detach(object, alreadyDetached);
}
object = detachedObject;
queue.add(object);
}
ClassUtils.setField(detached, obj.getKey(), queue);
} else if (obj.getValue() instanceof RSet) {
Set<Object> set = new HashSet<Object>();
Collection<Object> redissonSet = (Collection<Object>) obj.getValue();
for (Object object : redissonSet) {
if (isLiveObject(object)) {
Object detachedObject = alreadyDetached.get(getMap(object).getName());
if (detachedObject == null) {
detachedObject = detach(object, alreadyDetached);
}
queue.add(object);
object = detachedObject;
}
ClassUtils.setField(detached, obj.getKey(), queue);
} else if (obj.getValue() instanceof RSet) {
Set<Object> set = new HashSet<Object>();
Collection<Object> redissonSet = (Collection<Object>) obj.getValue();
for (Object object : redissonSet) {
if (isLiveObject(object)) {
Object detachedObject = alreadyDetached.get(getMap(object).getName());
if (detachedObject == null) {
detachedObject = detach(object, alreadyDetached);
}
object = detachedObject;
set.add(object);
}
ClassUtils.setField(detached, obj.getKey(), set);
} else if (obj.getValue() instanceof RList) {
List<Object> list = new ArrayList<Object>();
Collection<Object> redissonList = (Collection<Object>) obj.getValue();
for (Object object : redissonList) {
if (isLiveObject(object)) {
Object detachedObject = alreadyDetached.get(getMap(object).getName());
if (detachedObject == null) {
detachedObject = detach(object, alreadyDetached);
}
set.add(object);
object = detachedObject;
}
list.add(object);
}
ClassUtils.setField(detached, obj.getKey(), list);
} else if (isLiveObject(obj.getValue())) {
Object detachedObject = alreadyDetached.get(getMap(obj.getValue()).getName());
if (detachedObject == null) {
detachedObject = detach(obj.getValue(), alreadyDetached);
}
ClassUtils.setField(detached, obj.getKey(), detachedObject);
} else if (obj.getValue() instanceof RMap) {
Map<Object, Object> map = new LinkedHashMap<Object, Object>();
Map<Object, Object> redissonMap = (Map<Object, Object>) obj.getValue();
for (Entry<Object, Object> entry : redissonMap.entrySet()) {
Object key = entry.getKey();
Object value = entry.getValue();
ClassUtils.setField(detached, obj.getKey(), set);
} else if (obj.getValue() instanceof RList) {
List<Object> list = new ArrayList<Object>();
Collection<Object> redissonList = (Collection<Object>) obj.getValue();
for (Object object : redissonList) {
if (isLiveObject(object)) {
Object detachedObject = alreadyDetached.get(getMap(object).getName());
if (detachedObject == null) {
detachedObject = detach(object, alreadyDetached);
}
object = detachedObject;
if (isLiveObject(key)) {
Object detachedObject = alreadyDetached.get(getMap(key).getName());
if (detachedObject == null) {
detachedObject = detach(key, alreadyDetached);
}
list.add(object);
}
ClassUtils.setField(detached, obj.getKey(), list);
} else if (isLiveObject(obj.getValue())) {
Object detachedObject = alreadyDetached.get(getMap(obj.getValue()).getName());
if (detachedObject == null) {
detachedObject = detach(obj.getValue(), alreadyDetached);
key = detachedObject;
}
ClassUtils.setField(detached, obj.getKey(), detachedObject);
} else if (obj.getValue() instanceof RMap) {
Map<Object, Object> map = new LinkedHashMap<Object, Object>();
Map<Object, Object> redissonMap = (Map<Object, Object>) obj.getValue();
for (Entry<Object, Object> entry : redissonMap.entrySet()) {
Object key = entry.getKey();
Object value = entry.getValue();
if (isLiveObject(key)) {
Object detachedObject = alreadyDetached.get(getMap(key).getName());
if (detachedObject == null) {
detachedObject = detach(key, alreadyDetached);
}
key = detachedObject;
}
if (isLiveObject(value)) {
Object detachedObject = alreadyDetached.get(getMap(value).getName());
if (detachedObject == null) {
detachedObject = detach(value, alreadyDetached);
}
value = detachedObject;
if (isLiveObject(value)) {
Object detachedObject = alreadyDetached.get(getMap(value).getName());
if (detachedObject == null) {
detachedObject = detach(value, alreadyDetached);
}
map.put(key, value);
value = detachedObject;
}
ClassUtils.setField(detached, obj.getKey(), map);
} else {
validateAnnotation(detached, obj.getKey());
map.put(key, value);
}
ClassUtils.setField(detached, obj.getKey(), map);
} else {
validateAnnotation(detached, obj.getKey());
}
return detached;
} catch (Exception ex) {
throw ex instanceof RuntimeException ? (RuntimeException) ex : new RuntimeException(ex);
}
return detached;
}
@Override
@ -550,29 +546,29 @@ public class RedissonLiveObjectService implements RLiveObjectService {
}
if (obj.getValue() instanceof RSortedSet) {
deleteCollection(deleted, (Iterable<?>)obj.getValue());
((RObject)obj.getValue()).delete();
deleteCollection(deleted, (Iterable<?>) obj.getValue());
((RObject) obj.getValue()).delete();
} else if (obj.getValue() instanceof RDeque) {
deleteCollection(deleted, (Iterable<?>)obj.getValue());
((RObject)obj.getValue()).delete();
deleteCollection(deleted, (Iterable<?>) obj.getValue());
((RObject) obj.getValue()).delete();
} else if (obj.getValue() instanceof RQueue) {
deleteCollection(deleted, (Iterable<?>)obj.getValue());
((RObject)obj.getValue()).delete();
deleteCollection(deleted, (Iterable<?>) obj.getValue());
((RObject) obj.getValue()).delete();
} else if (obj.getValue() instanceof RSet) {
deleteCollection(deleted, (Iterable<?>)obj.getValue());
((RObject)obj.getValue()).delete();
deleteCollection(deleted, (Iterable<?>) obj.getValue());
((RObject) obj.getValue()).delete();
} else if (obj.getValue() instanceof RList) {
deleteCollection(deleted, (Iterable<?>)obj.getValue());
((RObject)obj.getValue()).delete();
deleteCollection(deleted, (Iterable<?>) obj.getValue());
((RObject) obj.getValue()).delete();
} else if (isLiveObject(obj.getValue())) {
if (deleted.add(getMap(obj.getValue()).getName())) {
delete(obj.getValue(), deleted);
}
} else if (obj.getValue() instanceof RMap) {
RMap<Object, Object> map = (RMap<Object, Object>)obj.getValue();
RMap<Object, Object> map = (RMap<Object, Object>) obj.getValue();
deleteCollection(deleted, map.keySet());
deleteCollection(deleted, map.values());
((RObject)obj.getValue()).delete();
((RObject) obj.getValue()).delete();
} else {
validateAnnotation(attachedObject, obj.getKey());
}
@ -632,7 +628,11 @@ public class RedissonLiveObjectService implements RLiveObjectService {
@Override
public void unregisterClass(Class<?> cls) {
classCache.remove(cls.isAssignableFrom(RLiveObject.class) ? cls.getSuperclass() : cls);
if (cls.isAssignableFrom(RLiveObject.class)) {
classCache.remove(cls.getSuperclass());
} else {
classCache.remove(cls);
}
}
@Override

@ -81,6 +81,7 @@ public class RedissonLocalCachedMap<K, V> extends RedissonMap<K, V> implements R
public static final String DISABLED_KEYS_SUFFIX = "disabled-keys";
public static final String DISABLED_ACK_SUFFIX = ":topic";
@SuppressWarnings("EqualsHashCode")
public static class CacheValue implements Serializable {
private final Object key;
@ -99,7 +100,7 @@ public class RedissonLocalCachedMap<K, V> extends RedissonMap<K, V> implements R
public Object getValue() {
return value;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
@ -240,16 +241,16 @@ public class RedissonLocalCachedMap<K, V> extends RedissonMap<K, V> implements R
}
@Override
public RFuture<V> getAsync(final Object key) {
public RFuture<V> getAsync(Object key) {
checkKey(key);
final CacheKey cacheKey = toCacheKey(key);
CacheKey cacheKey = toCacheKey(key);
CacheValue cacheValue = cache.get(cacheKey);
if (cacheValue != null && cacheValue.getValue() != null) {
return RedissonPromise.newSucceededFuture((V)cacheValue.getValue());
return RedissonPromise.newSucceededFuture((V) cacheValue.getValue());
}
RFuture<V> future = super.getAsync((K)key);
RFuture<V> future = super.getAsync((K) key);
future.onComplete((value, e) -> {
if (e != null) {
return;
@ -543,19 +544,19 @@ public class RedissonLocalCachedMap<K, V> extends RedissonMap<K, V> implements R
return RedissonPromise.newSucceededFuture(Collections.<K, V>emptyMap());
}
final Map<K, V> result = new HashMap<K, V>();
Map<K, V> result = new HashMap<K, V>();
Set<K> mapKeys = new HashSet<K>(keys);
for (Iterator<K> iterator = mapKeys.iterator(); iterator.hasNext();) {
K key = iterator.next();
final CacheKey cacheKey = toCacheKey(key);
CacheKey cacheKey = toCacheKey(key);
CacheValue value = cache.get(cacheKey);
if (value != null) {
result.put(key, (V)value.getValue());
result.put(key, (V) value.getValue());
iterator.remove();
}
}
final RPromise<Map<K, V>> promise = new RedissonPromise<Map<K, V>>();
RPromise<Map<K, V>> promise = new RedissonPromise<Map<K, V>>();
RFuture<Map<K, V>> future = super.getAllAsync(mapKeys);
future.onComplete((map, e) -> {
if (e != null) {
@ -580,7 +581,7 @@ public class RedissonLocalCachedMap<K, V> extends RedissonMap<K, V> implements R
}
@Override
protected RFuture<Void> putAllOperationAsync(final Map<? extends K, ? extends V> map) {
protected RFuture<Void> putAllOperationAsync(Map<? extends K, ? extends V> map) {
List<Object> params = new ArrayList<Object>(map.size()*3);
params.add(invalidateEntryOnChange);
params.add(map.size()*2);
@ -624,7 +625,7 @@ public class RedissonLocalCachedMap<K, V> extends RedissonMap<K, V> implements R
params.add(msgEncoded);
}
final RPromise<Void> result = new RedissonPromise<Void>();
RPromise<Void> result = new RedissonPromise<Void>();
RFuture<Void> future = commandExecutor.evalWriteAsync(getName(), codec, RedisCommands.EVAL_VOID,
"for i=3, tonumber(ARGV[2]) + 2, 5000 do "
+ "redis.call('hmset', KEYS[1], unpack(ARGV, i, math.min(i+4999, tonumber(ARGV[2]) + 2))); "
@ -654,7 +655,7 @@ public class RedissonLocalCachedMap<K, V> extends RedissonMap<K, V> implements R
}
@Override
protected RFuture<V> addAndGetOperationAsync(final K key, Number value) {
protected RFuture<V> addAndGetOperationAsync(K key, Number value) {
ByteBuf keyState = encodeMapKey(key);
CacheKey cacheKey = toCacheKey(keyState);
ByteBuf msg = encode(new LocalCachedMapInvalidate(instanceId, cacheKey.getKeyHash()));
@ -682,7 +683,7 @@ public class RedissonLocalCachedMap<K, V> extends RedissonMap<K, V> implements R
}
@Override
public RFuture<Boolean> fastPutIfAbsentAsync(final K key, final V value) {
public RFuture<Boolean> fastPutIfAbsentAsync(K key, V value) {
RFuture<Boolean> future = super.fastPutIfAbsentAsync(key, value);
future.onComplete((res, e) -> {
if (e != null) {
@ -699,14 +700,14 @@ public class RedissonLocalCachedMap<K, V> extends RedissonMap<K, V> implements R
@Override
public RFuture<Collection<V>> readAllValuesAsync() {
final List<V> result = new ArrayList<V>();
final List<Object> mapKeys = new ArrayList<Object>();
List<V> result = new ArrayList<V>();
List<Object> mapKeys = new ArrayList<Object>();
for (CacheValue value : cache.values()) {
mapKeys.add(encodeMapKey(value.getKey()));
result.add((V) value.getValue());
}
final RPromise<Collection<V>> promise = new RedissonPromise<Collection<V>>();
RPromise<Collection<V>> promise = new RedissonPromise<Collection<V>>();
RFuture<Collection<V>> future = commandExecutor.evalReadAsync(getName(), codec, ALL_KEYS,
"local entries = redis.call('hgetall', KEYS[1]); "
+ "local result = {};"
@ -742,14 +743,14 @@ public class RedissonLocalCachedMap<K, V> extends RedissonMap<K, V> implements R
@Override
public RFuture<Map<K, V>> readAllMapAsync() {
final Map<K, V> result = new HashMap<K, V>();
Map<K, V> result = new HashMap<K, V>();
List<Object> mapKeys = new ArrayList<Object>();
for (CacheValue value : cache.values()) {
mapKeys.add(encodeMapKey(value.getKey()));
result.put((K)value.getKey(), (V)value.getValue());
result.put((K) value.getKey(), (V) value.getValue());
}
final RPromise<Map<K, V>> promise = new RedissonPromise<Map<K, V>>();
RPromise<Map<K, V>> promise = new RedissonPromise<Map<K, V>>();
RFuture<Map<K, V>> future = readAll(ALL_MAP, mapKeys, result);
future.onComplete((res, e) -> {
@ -775,7 +776,7 @@ public class RedissonLocalCachedMap<K, V> extends RedissonMap<K, V> implements R
// add anything found into the cache. This does not guarantee to find
// entries added during the warmUp, but statistically the cache will have
// few misses after this process
for(Entry<K,V> entry : super.entrySet()) {
for (Entry<K, V> entry : super.entrySet()) {
CacheKey cacheKey = toCacheKey(entry.getKey());
cachePut(cacheKey, entry.getKey(), entry.getValue());
}
@ -793,14 +794,14 @@ public class RedissonLocalCachedMap<K, V> extends RedissonMap<K, V> implements R
@Override
public RFuture<Set<Entry<K, V>>> readAllEntrySetAsync() {
final Set<Entry<K, V>> result = new HashSet<Entry<K, V>>();
Set<Entry<K, V>> result = new HashSet<Entry<K, V>>();
List<Object> mapKeys = new ArrayList<Object>();
for (CacheValue value : cache.values()) {
mapKeys.add(encodeMapKey(value.getKey()));
result.add(new AbstractMap.SimpleEntry<K, V>((K)value.getKey(), (V)value.getValue()));
result.add(new AbstractMap.SimpleEntry<K, V>((K) value.getKey(), (V) value.getValue()));
}
final RPromise<Set<Entry<K, V>>> promise = new RedissonPromise<Set<Entry<K, V>>>();
RPromise<Set<Entry<K, V>>> promise = new RedissonPromise<Set<Entry<K, V>>>();
RFuture<Set<Entry<K, V>>> future = readAll(ALL_ENTRIES, mapKeys, result);
future.onComplete((res, e) -> {
@ -844,7 +845,7 @@ public class RedissonLocalCachedMap<K, V> extends RedissonMap<K, V> implements R
}
@Override
public RFuture<Boolean> fastReplaceAsync(final K key, final V value) {
public RFuture<Boolean> fastReplaceAsync(K key, V value) {
RFuture<Boolean> future = super.fastReplaceAsync(key, value);
future.onComplete((res, e) -> {
if (e != null) {
@ -916,7 +917,7 @@ public class RedissonLocalCachedMap<K, V> extends RedissonMap<K, V> implements R
}
@Override
public RFuture<V> replaceAsync(final K key, final V value) {
public RFuture<V> replaceAsync(K key, V value) {
RFuture<V> future = super.replaceAsync(key, value);
future.onComplete((res, e) -> {
if (e != null) {
@ -959,8 +960,8 @@ public class RedissonLocalCachedMap<K, V> extends RedissonMap<K, V> implements R
}
@Override
public RFuture<Boolean> replaceAsync(final K key, V oldValue, final V newValue) {
final CacheKey cacheKey = toCacheKey(key);
public RFuture<Boolean> replaceAsync(K key, V oldValue, V newValue) {
CacheKey cacheKey = toCacheKey(key);
RFuture<Boolean> future = super.replaceAsync(key, oldValue, newValue);
future.onComplete((res, e) -> {
@ -1003,7 +1004,7 @@ public class RedissonLocalCachedMap<K, V> extends RedissonMap<K, V> implements R
@Override
public RFuture<Boolean> removeAsync(Object key, Object value) {
final CacheKey cacheKey = toCacheKey(key);
CacheKey cacheKey = toCacheKey(key);
RFuture<Boolean> future = super.removeAsync(key, value);
future.onComplete((res, e) -> {
@ -1020,7 +1021,7 @@ public class RedissonLocalCachedMap<K, V> extends RedissonMap<K, V> implements R
@Override
public RFuture<V> putIfAbsentAsync(final K key, final V value) {
public RFuture<V> putIfAbsentAsync(K key, V value) {
RFuture<V> future = super.putIfAbsentAsync(key, value);
future.onComplete((res, e) -> {
if (e != null) {

@ -80,7 +80,7 @@ public class RedissonLock extends RedissonExpirable implements RLock {
private static final Logger log = LoggerFactory.getLogger(RedissonLock.class);
private static final ConcurrentMap<String, ExpirationEntry> expirationRenewalMap = PlatformDependent.newConcurrentHashMap();
private static final ConcurrentMap<String, ExpirationEntry> EXPIRATION_RENEWAL_MAP = PlatformDependent.newConcurrentHashMap();
protected long internalLockLeaseTime;
final UUID id;
@ -213,7 +213,7 @@ public class RedissonLock extends RedissonExpirable implements RLock {
}
private void scheduleExpirationRenewal(long threadId) {
if (expirationRenewalMap.containsKey(getEntryName())) {
if (EXPIRATION_RENEWAL_MAP.containsKey(getEntryName())) {
return;
}
@ -223,7 +223,7 @@ public class RedissonLock extends RedissonExpirable implements RLock {
RFuture<Boolean> future = renewExpirationAsync(threadId);
future.onComplete((res, e) -> {
expirationRenewalMap.remove(getEntryName());
EXPIRATION_RENEWAL_MAP.remove(getEntryName());
if (e != null) {
log.error("Can't update lock " + getName() + " expiration", e);
return;
@ -238,7 +238,7 @@ public class RedissonLock extends RedissonExpirable implements RLock {
}, internalLockLeaseTime / 3, TimeUnit.MILLISECONDS);
if (expirationRenewalMap.putIfAbsent(getEntryName(), new ExpirationEntry(threadId, task)) != null) {
if (EXPIRATION_RENEWAL_MAP.putIfAbsent(getEntryName(), new ExpirationEntry(threadId, task)) != null) {
task.cancel();
}
}
@ -255,9 +255,9 @@ public class RedissonLock extends RedissonExpirable implements RLock {
}
void cancelExpirationRenewal(Long threadId) {
ExpirationEntry task = expirationRenewalMap.get(getEntryName());
ExpirationEntry task = EXPIRATION_RENEWAL_MAP.get(getEntryName());
if (task != null && (threadId == null || task.getThreadId() == threadId)) {
expirationRenewalMap.remove(getEntryName());
EXPIRATION_RENEWAL_MAP.remove(getEntryName());
task.getTimeout().cancel();
}
}
@ -299,7 +299,7 @@ public class RedissonLock extends RedissonExpirable implements RLock {
return true;
}
time -= (System.currentTimeMillis() - current);
time -= System.currentTimeMillis() - current;
if (time <= 0) {
acquireFailed(threadId);
return false;
@ -320,7 +320,7 @@ public class RedissonLock extends RedissonExpirable implements RLock {
}
try {
time -= (System.currentTimeMillis() - current);
time -= System.currentTimeMillis() - current;
if (time <= 0) {
acquireFailed(threadId);
return false;
@ -334,7 +334,7 @@ public class RedissonLock extends RedissonExpirable implements RLock {
return true;
}
time -= (System.currentTimeMillis() - currentTime);
time -= System.currentTimeMillis() - currentTime;
if (time <= 0) {
acquireFailed(threadId);
return false;
@ -348,7 +348,7 @@ public class RedissonLock extends RedissonExpirable implements RLock {
getEntry(threadId).getLatch().tryAcquire(time, TimeUnit.MILLISECONDS);
}
time -= (System.currentTimeMillis() - currentTime);
time -= System.currentTimeMillis() - currentTime;
if (time <= 0) {
acquireFailed(threadId);
return false;
@ -383,7 +383,7 @@ public class RedissonLock extends RedissonExpirable implements RLock {
get(unlockAsync(Thread.currentThread().getId()));
} catch (RedisException e) {
if (e.getCause() instanceof IllegalMonitorStateException) {
throw (IllegalMonitorStateException)e.getCause();
throw (IllegalMonitorStateException) e.getCause();
} else {
throw e;
}
@ -796,4 +796,3 @@ public class RedissonLock extends RedissonExpirable implements RLock {
}
;

@ -111,13 +111,13 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public RPermitExpirableSemaphore getPermitExpirableSemaphore(K key) {
String lockName = getLockName(key, "permitexpirablesemaphore");
return new RedissonPermitExpirableSemaphore(commandExecutor, lockName, ((Redisson)redisson).getSemaphorePubSub());
return new RedissonPermitExpirableSemaphore(commandExecutor, lockName, ((Redisson) redisson).getSemaphorePubSub());
}
@Override
public RSemaphore getSemaphore(K key) {
String lockName = getLockName(key, "semaphore");
return new RedissonSemaphore(commandExecutor, lockName, ((Redisson)redisson).getSemaphorePubSub());
return new RedissonSemaphore(commandExecutor, lockName, ((Redisson) redisson).getSemaphorePubSub());
}
@Override
@ -270,7 +270,7 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public V get(Object key) {
return get(getAsync((K)key));
return get(getAsync((K) key));
}
@Override
@ -280,7 +280,7 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public V remove(Object key) {
return get(removeAsync((K)key));
return get(removeAsync((K) key));
}
@Override
@ -297,7 +297,7 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
public RFuture<Void> putAllAsync(Map<? extends K, ? extends V> map, int batchSize) {
Map<K, V> batch = new HashMap<K, V>();
AtomicInteger counter = new AtomicInteger();
Iterator<Entry<K, V>> iter = ((Map<K, V>)map).entrySet().iterator();
Iterator<Entry<K, V>> iter = ((Map<K, V>) map).entrySet().iterator();
RPromise<Void> promise = new RedissonPromise<Void>();
putAllAsync(batch, iter, counter, batchSize, promise);
@ -828,7 +828,7 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public RFuture<Void> loadAllAsync(Set<? extends K> keys, boolean replaceExistingValues, int parallelism) {
return loadAllAsync((Iterable<K>)keys, replaceExistingValues, parallelism, null);
return loadAllAsync((Iterable<K>) keys, replaceExistingValues, parallelism, null);
}
private RFuture<Void> loadAllAsync(Iterable<? extends K> keys, boolean replaceExistingValues, int parallelism, Map<K, V> loadedEntires) {
@ -1062,7 +1062,7 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
}
if (options.getWriteMode() == WriteMode.WRITE_BEHIND) {
result.trySuccess((long)deletedKeys.size());
result.trySuccess((long) deletedKeys.size());
MapWriterTask<List<Long>> listener = new MapWriterTask<List<Long>>() {
@Override
@ -1076,7 +1076,7 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public void run() {
options.getWriter().deleteAll(deletedKeys);
result.trySuccess((long)deletedKeys.size());
result.trySuccess((long) deletedKeys.size());
}
});
}
@ -1172,14 +1172,14 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
if (!(o instanceof Map))
return false;
Map<?,?> m = (Map<?,?>) o;
Map<?, ?> m = (Map<?, ?>) o;
if (m.size() != size())
return false;
try {
Iterator<Entry<K,V>> i = entrySet().iterator();
Iterator<Entry<K, V>> i = entrySet().iterator();
while (i.hasNext()) {
Entry<K,V> e = i.next();
Entry<K, V> e = i.next();
K key = e.getKey();
V value = e.getValue();
if (value == null) {
@ -1202,9 +1202,10 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public int hashCode() {
int h = 0;
Iterator<Entry<K,V>> i = entrySet().iterator();
while (i.hasNext())
Iterator<Entry<K, V>> i = entrySet().iterator();
while (i.hasNext()) {
h += i.next().hashCode();
}
return h;
}
@ -1217,12 +1218,12 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
};
}
class KeySet extends AbstractSet<K> {
final class KeySet extends AbstractSet<K> {
private final String pattern;
private final int count;
public KeySet(String pattern, int count) {
KeySet(String pattern, int count) {
this.pattern = pattern;
this.count = count;
}
@ -1239,7 +1240,7 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public boolean remove(Object o) {
return RedissonMap.this.fastRemove((K)o) == 1;
return RedissonMap.this.fastRemove((K) o) == 1;
}
@Override
@ -1275,7 +1276,7 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
private final String keyPattern;
private final int count;
public Values(String keyPattern, int count) {
Values(String keyPattern, int count) {
this.keyPattern = keyPattern;
this.count = count;
}
@ -1310,7 +1311,7 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
}
protected Iterator<Map.Entry<K,V>> entryIterator(String pattern, int count) {
protected Iterator<Map.Entry<K, V>> entryIterator(String pattern, int count) {
return new RedissonMapIterator<Map.Entry<K, V>>(RedissonMap.this, pattern, count);
}
@ -1389,32 +1390,35 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
});
}
final class EntrySet extends AbstractSet<Map.Entry<K,V>> {
final class EntrySet extends AbstractSet<Map.Entry<K, V>> {
private final String keyPattern;
private final int count;
public EntrySet(String keyPattern, int count) {
EntrySet(String keyPattern, int count) {
this.keyPattern = keyPattern;
this.count = count;
}
public final Iterator<Map.Entry<K,V>> iterator() {
@Override
public Iterator<Map.Entry<K, V>> iterator() {
return entryIterator(keyPattern, count);
}
public final boolean contains(Object o) {
@Override
public boolean contains(Object o) {
if (!(o instanceof Map.Entry))
return false;
Map.Entry<?,?> e = (Map.Entry<?,?>) o;
Map.Entry<?, ?> e = (Map.Entry<?, ?>) o;
Object key = e.getKey();
V value = get(key);
return value != null && value.equals(e);
}
public final boolean remove(Object o) {
@Override
public boolean remove(Object o) {
if (o instanceof Map.Entry) {
Map.Entry<?,?> e = (Map.Entry<?,?>) o;
Map.Entry<?, ?> e = (Map.Entry<?, ?>) o;
Object key = e.getKey();
Object value = e.getValue();
return RedissonMap.this.remove(key, value);
@ -1422,7 +1426,8 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
return false;
}
public final int size() {
@Override
public int size() {
if (keyPattern != null) {
int size = 0;
for (Entry val : this) {
@ -1434,7 +1439,8 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
return RedissonMap.this.size();
}
public final void clear() {
@Override
public void clear() {
RedissonMap.this.clear();
}

@ -1254,9 +1254,9 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
}
params.add(count);
RedisCommand<MapCacheScanResult<Object, Object>> EVAL_HSCAN = new RedisCommand<MapCacheScanResult<Object, Object>>("EVAL",
RedisCommand<MapCacheScanResult<Object, Object>> command = new RedisCommand<MapCacheScanResult<Object, Object>>("EVAL",
new ListMultiDecoder(new LongMultiDecoder(), new ObjectMapDecoder(codec), new ObjectListDecoder(codec), new MapCacheScanResultReplayDecoder()), ValueType.MAP);
RFuture<MapCacheScanResult<Object, Object>> f = commandExecutor.evalReadAsync(client, name, codec, EVAL_HSCAN,
RFuture<MapCacheScanResult<Object, Object>> f = commandExecutor.evalReadAsync(client, name, codec, command,
"local result = {}; "
+ "local idleKeys = {}; "
+ "local res; "
@ -1329,7 +1329,7 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
}
});
return (RFuture<MapScanResult<Object, Object>>)(Object)f;
return (RFuture<MapScanResult<Object, Object>>) (Object) f;
}
@Override
@ -1477,21 +1477,21 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
}
@Override
public boolean fastPutIfAbsent(K key, V value, long ttl, TimeUnit ttlUnit) {
return fastPutIfAbsent(key, value, ttl, ttlUnit, 0, null);
}
public boolean fastPutIfAbsent(K key, V value, long ttl, TimeUnit ttlUnit) {
return fastPutIfAbsent(key, value, ttl, ttlUnit, 0, null);
}
@Override
public boolean fastPutIfAbsent(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit) {
return get(fastPutIfAbsentAsync(key, value, ttl, ttlUnit, maxIdleTime, maxIdleUnit));
return get(fastPutIfAbsentAsync(key, value, ttl, ttlUnit, maxIdleTime, maxIdleUnit));
}
@Override
public RFuture<Boolean> fastPutIfAbsentAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit) {
public RFuture<Boolean> fastPutIfAbsentAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit) {
checkKey(key);
checkValue(value);
if (ttl < 0) {
if (ttl < 0) {
throw new IllegalArgumentException("ttl can't be negative");
}
if (maxIdleTime < 0) {
@ -1902,7 +1902,7 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
}
if (isWindows == null) {
RFuture<Map<String, String>> serverFuture = commandExecutor.readAsync((String)null, StringCodec.INSTANCE, RedisCommands.INFO_SERVER);
RFuture<Map<String, String>> serverFuture = commandExecutor.readAsync((String) null, StringCodec.INSTANCE, RedisCommands.INFO_SERVER);
serverFuture.syncUninterruptibly();
String os = serverFuture.getNow().get("os");
isWindows = os.contains("Windows");
@ -1913,7 +1913,7 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
return topic.addListener(List.class, new MessageListener<List<Object>>() {
@Override
public void onMessage(CharSequence channel, List<Object> msg) {
EntryEvent<K, V> event = new EntryEvent<K, V>(RedissonMapCache.this, EntryEvent.Type.REMOVED, (K)msg.get(0), (V)msg.get(1), null);
EntryEvent<K, V> event = new EntryEvent<K, V>(RedissonMapCache.this, EntryEvent.Type.REMOVED, (K) msg.get(0), (V) msg.get(1), null);
((EntryRemovedListener<K, V>) listener).onRemoved(event);
}
});
@ -1924,7 +1924,7 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
return topic.addListener(List.class, new MessageListener<List<Object>>() {
@Override
public void onMessage(CharSequence channel, List<Object> msg) {
EntryEvent<K, V> event = new EntryEvent<K, V>(RedissonMapCache.this, EntryEvent.Type.CREATED, (K)msg.get(0), (V)msg.get(1), null);
EntryEvent<K, V> event = new EntryEvent<K, V>(RedissonMapCache.this, EntryEvent.Type.CREATED, (K) msg.get(0), (V) msg.get(1), null);
((EntryCreatedListener<K, V>) listener).onCreated(event);
}
});
@ -1935,7 +1935,7 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
return topic.addListener(List.class, new MessageListener<List<Object>>() {
@Override
public void onMessage(CharSequence channel, List<Object> msg) {
EntryEvent<K, V> event = new EntryEvent<K, V>(RedissonMapCache.this, EntryEvent.Type.UPDATED, (K)msg.get(0), (V)msg.get(1), (V)msg.get(2));
EntryEvent<K, V> event = new EntryEvent<K, V>(RedissonMapCache.this, EntryEvent.Type.UPDATED, (K) msg.get(0), (V) msg.get(1), (V) msg.get(2));
((EntryUpdatedListener<K, V>) listener).onUpdated(event);
}
});
@ -1946,7 +1946,7 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
return topic.addListener(List.class, new MessageListener<List<Object>>() {
@Override
public void onMessage(CharSequence channel, List<Object> msg) {
EntryEvent<K, V> event = new EntryEvent<K, V>(RedissonMapCache.this, EntryEvent.Type.EXPIRED, (K)msg.get(0), (V)msg.get(1), null);
EntryEvent<K, V> event = new EntryEvent<K, V>(RedissonMapCache.this, EntryEvent.Type.EXPIRED, (K) msg.get(0), (V) msg.get(1), null);
((EntryExpiredListener<K, V>) listener).onExpired(event);
}
});

@ -41,6 +41,7 @@ import io.netty.util.internal.ThreadLocalRandom;
* @author Nikita Koksharov
*
*/
@SuppressWarnings("ParameterNumber")
public class RedissonMultiLock implements Lock {
final List<RLock> locks = new ArrayList<RLock>();
@ -260,7 +261,7 @@ public class RedissonMultiLock implements Lock {
}
if (remainTime != -1) {
remainTime -= (System.currentTimeMillis() - time);
remainTime -= System.currentTimeMillis() - time;
time = System.currentTimeMillis();
if (remainTime <= 0) {
unlockInner(acquiredLocks);
@ -300,7 +301,7 @@ public class RedissonMultiLock implements Lock {
} else {
long awaitTime = Math.min(lockWaitTime, remainTime.get());
lock.tryLockAsync(awaitTime, newLeaseTime, TimeUnit.MILLISECONDS, threadId)
.onComplete(new TransferListener<Boolean>(lockAcquiredFuture));;
.onComplete(new TransferListener<Boolean>(lockAcquiredFuture));
}
lockAcquiredFuture.onComplete((res, e) -> {
@ -383,7 +384,7 @@ public class RedissonMultiLock implements Lock {
AtomicLong remainTime, AtomicLong time, AtomicInteger failedLocksLimit, TimeUnit unit, long threadId) {
if (remainTime.get() != -1) {
remainTime.addAndGet(-(System.currentTimeMillis() - time.get()));
time.set(System.currentTimeMillis());;
time.set(System.currentTimeMillis());
if (remainTime.get() <= 0) {
unlockInnerAsync(acquiredLocks, threadId).onComplete((res, e) -> {
if (e != null) {

@ -55,8 +55,7 @@ abstract class RedissonMultiMapIterator<K, V, M> implements Iterator<M> {
final CommandAsyncExecutor commandExecutor;
final Codec codec;
public RedissonMultiMapIterator(RedissonMultimap<K, V> map, CommandAsyncExecutor commandExecutor, Codec codec) {
RedissonMultiMapIterator(RedissonMultimap<K, V> map, CommandAsyncExecutor commandExecutor, Codec codec) {
this.map = map;
this.commandExecutor = commandExecutor;
this.codec = codec;
@ -116,7 +115,7 @@ abstract class RedissonMultiMapIterator<K, V, M> implements Iterator<M> {
@SuppressWarnings("unchecked")
M getValue(V entry) {
return (M)new AbstractMap.SimpleEntry<K, V>(currentKey, entry) {
return (M) new AbstractMap.SimpleEntry<K, V>(currentKey, entry) {
@Override
public V setValue(V value) {

@ -69,13 +69,13 @@ public abstract class RedissonMultimap<K, V> extends RedissonExpirable implement
@Override
public RLock getLock(K key) {
String lockName = getLockName(key);
return new RedissonLock((CommandExecutor)commandExecutor, lockName);
return new RedissonLock((CommandExecutor) commandExecutor, lockName);
}
@Override
public RReadWriteLock getReadWriteLock(K key) {
String lockName = getLockName(key);
return new RedissonReadWriteLock((CommandExecutor)commandExecutor, lockName);
return new RedissonReadWriteLock((CommandExecutor) commandExecutor, lockName);
}
private String getLockName(Object key) {
@ -107,7 +107,7 @@ public abstract class RedissonMultimap<K, V> extends RedissonExpirable implement
@Override
public int keySize() {
return get(keySizeAsync());
return get(keySizeAsync());
}
@Override
@ -296,7 +296,7 @@ public abstract class RedissonMultimap<K, V> extends RedissonExpirable implement
@Override
public RFuture<Integer> keySizeAsync() {
return commandExecutor.readAsync(getName(), LongCodec.INSTANCE, RedisCommands.HLEN, getName());
return commandExecutor.readAsync(getName(), LongCodec.INSTANCE, RedisCommands.HLEN, getName());
}
@ -328,7 +328,7 @@ public abstract class RedissonMultimap<K, V> extends RedissonExpirable implement
@Override
public boolean remove(Object o) {
return RedissonMultimap.this.fastRemove((K)o) == 1;
return RedissonMultimap.this.fastRemove((K) o) == 1;
}
@Override
@ -367,22 +367,25 @@ public abstract class RedissonMultimap<K, V> extends RedissonExpirable implement
}
final class EntrySet extends AbstractSet<Map.Entry<K,V>> {
final class EntrySet extends AbstractSet<Map.Entry<K, V>> {
public final Iterator<Map.Entry<K,V>> iterator() {
@Override
public Iterator<Map.Entry<K, V>> iterator() {
return entryIterator();
}
public final boolean contains(Object o) {
@Override
public boolean contains(Object o) {
if (!(o instanceof Map.Entry))
return false;
Map.Entry<?,?> e = (Map.Entry<?,?>) o;
Map.Entry<?, ?> e = (Map.Entry<?, ?>) o;
return containsEntry(e.getKey(), e.getValue());
}
public final boolean remove(Object o) {
@Override
public boolean remove(Object o) {
if (o instanceof Map.Entry) {
Map.Entry<?,?> e = (Map.Entry<?,?>) o;
Map.Entry<?, ?> e = (Map.Entry<?, ?>) o;
Object key = e.getKey();
Object value = e.getValue();
return RedissonMultimap.this.remove(key, value);
@ -390,11 +393,13 @@ public abstract class RedissonMultimap<K, V> extends RedissonExpirable implement
return false;
}
public final int size() {
@Override
public int size() {
return RedissonMultimap.this.size();
}
public final void clear() {
@Override
public void clear() {
RedissonMultimap.this.clear();
}

@ -60,12 +60,12 @@ public class RedissonMultimapCache<K> {
+ "return 0; "
+ "end",
Arrays.<Object>asList(object.getName(), timeoutSetName),
ttlTimeout, ((RedissonObject)object).encodeMapKey(key));
ttlTimeout, ((RedissonObject) object).encodeMapKey(key));
}
public RFuture<Long> sizeInMemoryAsync() {
List<Object> keys = Arrays.<Object>asList(object.getName(), timeoutSetName);
return ((RedissonObject)object).sizeInMemoryAsync(keys);
return ((RedissonObject) object).sizeInMemoryAsync(keys);
}
public RFuture<Boolean> deleteAsync() {

@ -33,14 +33,13 @@ import org.slf4j.LoggerFactory;
import io.netty.buffer.ByteBufUtil;
import io.netty.util.internal.PlatformDependent;
import io.netty.util.internal.ThreadLocalRandom;
/**
*
* @author Nikita Koksharov
*
*/
public class RedissonNode {
public final class RedissonNode {
private static final Logger log = LoggerFactory.getLogger(RedissonNode.class);
@ -156,10 +155,10 @@ public class RedissonNode {
}
private void retrieveAddresses() {
ConnectionManager connectionManager = ((Redisson)redisson).getConnectionManager();
ConnectionManager connectionManager = ((Redisson) redisson).getConnectionManager();
for (MasterSlaveEntry entry : connectionManager.getEntrySet()) {
RFuture<RedisConnection> readFuture = entry.connectionReadOp(null);
if (readFuture.awaitUninterruptibly((long)connectionManager.getConfig().getConnectTimeout())
if (readFuture.awaitUninterruptibly((long) connectionManager.getConfig().getConnectTimeout())
&& readFuture.isSuccess()) {
RedisConnection connection = readFuture.getNow();
entry.releaseRead(connection);
@ -168,7 +167,7 @@ public class RedissonNode {
return;
}
RFuture<RedisConnection> writeFuture = entry.connectionWriteOp(null);
if (writeFuture.awaitUninterruptibly((long)connectionManager.getConfig().getConnectTimeout())
if (writeFuture.awaitUninterruptibly((long) connectionManager.getConfig().getConnectTimeout())
&& writeFuture.isSuccess()) {
RedisConnection connection = writeFuture.getNow();
entry.releaseWrite(connection);

@ -113,7 +113,7 @@ public abstract class RedissonObject implements RObject {
}
public final RFuture<Long> sizeInMemoryAsync(List<Object> keys) {
return commandExecutor.evalWriteAsync((String)keys.get(0), StringCodec.INSTANCE, RedisCommands.EVAL_LONG,
return commandExecutor.evalWriteAsync((String) keys.get(0), StringCodec.INSTANCE, RedisCommands.EVAL_LONG,
"local total = 0;"
+ "for j = 1, #KEYS, 1 do "
+ "local size = redis.call('memory', 'usage', KEYS[j]); "

@ -422,7 +422,7 @@ public class RedissonPermitExpirableSemaphore extends RedissonExpirable implemen
return permitId;
}
time -= (System.currentTimeMillis() - current);
time -= System.currentTimeMillis() - current;
if (time <= 0) {
return null;
}
@ -434,7 +434,7 @@ public class RedissonPermitExpirableSemaphore extends RedissonExpirable implemen
}
try {
time -= (System.currentTimeMillis() - current);
time -= System.currentTimeMillis() - current;
if (time <= 0) {
return null;
}
@ -453,7 +453,7 @@ public class RedissonPermitExpirableSemaphore extends RedissonExpirable implemen
nearestTimeout = null;
}
time -= (System.currentTimeMillis() - current);
time -= System.currentTimeMillis() - current;
if (time <= 0) {
return null;
}

@ -165,7 +165,7 @@ public class RedissonPriorityQueue<V> extends RedissonList<V> implements RPriori
@Override
public boolean contains(Object o) {
return binarySearch((V)o, codec).getIndex() >= 0;
return binarySearch((V) o, codec).getIndex() >= 0;
}
@Override
@ -222,7 +222,7 @@ public class RedissonPriorityQueue<V> extends RedissonList<V> implements RPriori
return false;
}
remove((int)res.getIndex());
remove((int) res.getIndex());
return true;
} finally {
lock.unlock();
@ -411,6 +411,8 @@ public class RedissonPriorityQueue<V> extends RedissonList<V> implements RPriori
return indexRes;
}
@Override
@SuppressWarnings("AvoidInlineConditionals")
public String toString() {
Iterator<V> it = iterator();
if (! it.hasNext())

@ -23,6 +23,7 @@ import org.redisson.api.RFuture;
import org.redisson.api.RRateLimiter;
import org.redisson.api.RateIntervalUnit;
import org.redisson.api.RateType;
import org.redisson.client.codec.IntegerCodec;
import org.redisson.client.codec.LongCodec;
import org.redisson.client.protocol.RedisCommand;
import org.redisson.client.protocol.RedisCommands;

@ -208,7 +208,7 @@ public class RedissonReactive implements RedissonReactiveClient {
List<RBucketReactive<V>> buckets = new ArrayList<RBucketReactive<V>>();
for (Object key : keys) {
if(key != null) {
if (key != null) {
buckets.add(this.<V>getBucket(key.toString()));
}
}
@ -342,7 +342,7 @@ public class RedissonReactive implements RedissonReactiveClient {
@Override
public <V> RQueueReactive<V> getQueue(String name, Codec codec) {
return ReactiveProxyBuilder.create(commandExecutor, new RedissonQueue<V>(codec, commandExecutor, name, null),
new RedissonListReactive<V>(codec,commandExecutor, name), RQueueReactive.class);
new RedissonListReactive<V>(codec, commandExecutor, name), RQueueReactive.class);
}
@Override

@ -58,25 +58,27 @@ import org.redisson.misc.BiHashMap;
*/
public class RedissonReference implements Serializable {
private static final BiHashMap<String, String> reactiveMap = new BiHashMap<String, String>();
private static final long serialVersionUID = -2378564460151709127L;
private static final BiHashMap<String, String> REACTIVE_MAP = new BiHashMap<String, String>();
static {
reactiveMap.put(RAtomicLongReactive.class.getName(), RAtomicLong.class.getName());
reactiveMap.put(RBitSetReactive.class.getName(), RBitSet.class.getName());
reactiveMap.put(RBlockingQueueReactive.class.getName(), RBlockingQueue.class.getName());
reactiveMap.put(RBucketReactive.class.getName(), RBucket.class.getName());
reactiveMap.put(RDequeReactive.class.getName(), RDeque.class.getName());
reactiveMap.put(RHyperLogLogReactive.class.getName(), RHyperLogLog.class.getName());
reactiveMap.put(RLexSortedSetReactive.class.getName(), RLexSortedSet.class.getName());
reactiveMap.put(RListReactive.class.getName(), RList.class.getName());
reactiveMap.put(RMapCacheReactive.class.getName(), RMapCache.class.getName());
reactiveMap.put(RMapReactive.class.getName(), RMap.class.getName());
reactiveMap.put(RQueueReactive.class.getName(), RQueue.class.getName());
reactiveMap.put(RScoredSortedSetReactive.class.getName(), RScoredSortedSet.class.getName());
reactiveMap.put(RSetCacheReactive.class.getName(), RSetCache.class.getName());
reactiveMap.put(RSetReactive.class.getName(), RSet.class.getName());
reactiveMap.makeImmutable();
REACTIVE_MAP.put(RAtomicLongReactive.class.getName(), RAtomicLong.class.getName());
REACTIVE_MAP.put(RBitSetReactive.class.getName(), RBitSet.class.getName());
REACTIVE_MAP.put(RBlockingQueueReactive.class.getName(), RBlockingQueue.class.getName());
REACTIVE_MAP.put(RBucketReactive.class.getName(), RBucket.class.getName());
REACTIVE_MAP.put(RDequeReactive.class.getName(), RDeque.class.getName());
REACTIVE_MAP.put(RHyperLogLogReactive.class.getName(), RHyperLogLog.class.getName());
REACTIVE_MAP.put(RLexSortedSetReactive.class.getName(), RLexSortedSet.class.getName());
REACTIVE_MAP.put(RListReactive.class.getName(), RList.class.getName());
REACTIVE_MAP.put(RMapCacheReactive.class.getName(), RMapCache.class.getName());
REACTIVE_MAP.put(RMapReactive.class.getName(), RMap.class.getName());
REACTIVE_MAP.put(RQueueReactive.class.getName(), RQueue.class.getName());
REACTIVE_MAP.put(RScoredSortedSetReactive.class.getName(), RScoredSortedSet.class.getName());
REACTIVE_MAP.put(RSetCacheReactive.class.getName(), RSetCache.class.getName());
REACTIVE_MAP.put(RSetReactive.class.getName(), RSet.class.getName());
REACTIVE_MAP.makeImmutable();
}
public static void warmUp() {}
@ -96,11 +98,15 @@ public class RedissonReference implements Serializable {
if (!ClassUtils.isAnnotationPresent(type, REntity.class) && !RObject.class.isAssignableFrom(type) && !RObjectReactive.class.isAssignableFrom(type)) {
throw new IllegalArgumentException("Class reference has to be a type of either RObject or RLiveObject or RObjectReactive");
}
this.type = RObjectReactive.class.isAssignableFrom(type)
? reactiveMap.get(type.getName())
: type.getName();
if (RObjectReactive.class.isAssignableFrom(type)) {
this.type = REACTIVE_MAP.get(type.getName());
} else {
this.type = type.getName();
}
this.keyName = keyName;
this.codec = codec != null ? codec.getClass().getName() : null;
if (codec != null) {
this.codec = codec.getClass().getName();
}
}
/**
@ -122,8 +128,8 @@ public class RedissonReference implements Serializable {
* ClassNotFoundException - if the class cannot be located
*/
public Class<?> getReactiveType() throws Exception {
if (reactiveMap.containsValue(type)) {
return Class.forName(reactiveMap.reverseGet(type));//live object is not supported in reactive client
if (REACTIVE_MAP.containsValue(type)) {
return Class.forName(REACTIVE_MAP.reverseGet(type)); //live object is not supported in reactive client
}
throw new ClassNotFoundException("There is no Reactive compatible type for " + type);
}
@ -179,9 +185,10 @@ public class RedissonReference implements Serializable {
* ClassNotFoundException - if the class cannot be located
*/
public Class<? extends Codec> getCodecType() throws Exception {
return (Class<? extends Codec>) (codec == null
? null
: Class.forName(codec));
if (codec != null) {
return (Class<? extends Codec>) Class.forName(codec);
}
return null;
}
/**

@ -312,7 +312,7 @@ public class RedissonRx implements RedissonRxClient {
@Override
public <V> RQueueRx<V> getQueue(String name, Codec codec) {
return RxProxyBuilder.create(commandExecutor, new RedissonQueue<V>(codec, commandExecutor, name, null),
new RedissonListRx<V>(new RedissonList<V>(codec,commandExecutor, name, null)), RQueueRx.class);
new RedissonListRx<V>(new RedissonList<V>(codec, commandExecutor, name, null)), RQueueRx.class);
}
@Override

@ -319,7 +319,11 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
element.append("(");
}
if (Double.isInfinite(score)) {
element.append(score > 0 ? "+inf" : "-inf");
if (score > 0) {
element.append("+inf");
} else {
element.append("-inf");
}
} else {
element.append(BigDecimal.valueOf(score).toPlainString());
}
@ -421,7 +425,7 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
@Override
protected void remove(Object value) {
RedissonScoredSortedSet.this.remove((V)value);
RedissonScoredSortedSet.this.remove((V) value);
}
};
@ -493,7 +497,7 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
List<Object> params = new ArrayList<Object>(c.size()*2);
for (Object object : c) {
params.add(0);
params.add(encode((V)object));
params.add(encode((V) object));
}
return commandExecutor.evalWriteAsync(getName(), codec, RedisCommands.EVAL_BOOLEAN,
@ -863,7 +867,7 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
@Override
public <T> Collection<T> readSort(String byPattern, List<String> getPatterns, SortOrder order) {
return (Collection<T>)get(readSortAsync(byPattern, getPatterns, order));
return (Collection<T>) get(readSortAsync(byPattern, getPatterns, order));
}
@Override
@ -873,7 +877,7 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
@Override
public <T> Collection<T> readSort(String byPattern, List<String> getPatterns, SortOrder order, int offset, int count) {
return (Collection<T>)get(readSortAsync(byPattern, getPatterns, order, offset, count));
return (Collection<T>) get(readSortAsync(byPattern, getPatterns, order, offset, count));
}
@Override
@ -903,12 +907,12 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
@Override
public <T> Collection<T> readSortAlpha(String byPattern, List<String> getPatterns, SortOrder order) {
return (Collection<T>)get(readSortAlphaAsync(byPattern, getPatterns, order));
return (Collection<T>) get(readSortAlphaAsync(byPattern, getPatterns, order));
}
@Override
public <T> Collection<T> readSortAlpha(String byPattern, List<String> getPatterns, SortOrder order, int offset, int count) {
return (Collection<T>)get(readSortAlphaAsync(byPattern, getPatterns, order, offset, count));
return (Collection<T>) get(readSortAlphaAsync(byPattern, getPatterns, order, offset, count));
}
@Override

@ -29,7 +29,6 @@ import org.redisson.client.codec.StringCodec;
import org.redisson.client.protocol.RedisCommand;
import org.redisson.client.protocol.RedisCommands;
import org.redisson.command.CommandAsyncExecutor;
import org.redisson.liveobject.core.RedissonObjectBuilder;
import io.netty.buffer.ByteBuf;
@ -198,7 +197,7 @@ public class RedissonScript implements RScript {
public List<Boolean> onFinish() {
return new ArrayList<Boolean>(result);
}
}, (Object[])shaDigests);
}, (Object[]) shaDigests);
}
public List<Boolean> scriptExists(String key, String... shaDigests) {
@ -292,13 +291,13 @@ public class RedissonScript implements RScript {
@Override
public <R> R evalSha(String key, Mode mode, String shaDigest, ReturnType returnType, List<Object> keys,
Object... values) {
return commandExecutor.get((RFuture<R>)evalShaAsync(key, mode, shaDigest, returnType, keys, values));
return commandExecutor.get((RFuture<R>) evalShaAsync(key, mode, shaDigest, returnType, keys, values));
}
@Override
public <R> R eval(String key, Mode mode, String luaScript, ReturnType returnType, List<Object> keys,
Object... values) {
return commandExecutor.get((RFuture<R>)evalAsync(key, mode, luaScript, returnType, keys, values));
return commandExecutor.get((RFuture<R>) evalAsync(key, mode, luaScript, returnType, keys, values));
}
}

@ -287,7 +287,7 @@ public class RedissonSemaphore extends RedissonExpirable implements RSemaphore {
return true;
}
time -= (System.currentTimeMillis() - current);
time -= System.currentTimeMillis() - current;
if (time <= 0) {
return false;
}
@ -299,7 +299,7 @@ public class RedissonSemaphore extends RedissonExpirable implements RSemaphore {
}
try {
time -= (System.currentTimeMillis() - current);
time -= System.currentTimeMillis() - current;
if (time <= 0) {
return false;
}
@ -310,7 +310,7 @@ public class RedissonSemaphore extends RedissonExpirable implements RSemaphore {
return true;
}
time -= (System.currentTimeMillis() - current);
time -= System.currentTimeMillis() - current;
if (time <= 0) {
return false;
}
@ -320,7 +320,7 @@ public class RedissonSemaphore extends RedissonExpirable implements RSemaphore {
getEntry().getLatch().tryAcquire(permits, time, TimeUnit.MILLISECONDS);
time -= (System.currentTimeMillis() - current);
time -= System.currentTimeMillis() - current;
if (time <= 0) {
return false;
}

@ -122,7 +122,7 @@ public class RedissonSet<V> extends RedissonExpirable implements RSet<V>, ScanIt
@Override
protected void remove(Object value) {
RedissonSet.this.remove((V)value);
RedissonSet.this.remove((V) value);
}
};
@ -212,7 +212,7 @@ public class RedissonSet<V> extends RedissonExpirable implements RSet<V>, ScanIt
@Override
public boolean remove(Object value) {
return get(removeAsync((V)value));
return get(removeAsync((V) value));
}
@Override
@ -388,6 +388,7 @@ public class RedissonSet<V> extends RedissonExpirable implements RSet<V>, ScanIt
}
@Override
@SuppressWarnings("AvoidInlineConditionals")
public String toString() {
Iterator<V> it = iterator();
if (! it.hasNext())
@ -446,7 +447,7 @@ public class RedissonSet<V> extends RedissonExpirable implements RSet<V>, ScanIt
@Override
public <T> Collection<T> readSort(String byPattern, List<String> getPatterns, SortOrder order) {
return (Collection<T>)get(readSortAsync(byPattern, getPatterns, order));
return (Collection<T>) get(readSortAsync(byPattern, getPatterns, order));
}
@Override
@ -456,7 +457,7 @@ public class RedissonSet<V> extends RedissonExpirable implements RSet<V>, ScanIt
@Override
public <T> Collection<T> readSort(String byPattern, List<String> getPatterns, SortOrder order, int offset, int count) {
return (Collection<T>)get(readSortAsync(byPattern, getPatterns, order, offset, count));
return (Collection<T>) get(readSortAsync(byPattern, getPatterns, order, offset, count));
}
@Override
@ -486,12 +487,12 @@ public class RedissonSet<V> extends RedissonExpirable implements RSet<V>, ScanIt
@Override
public <T> Collection<T> readSortAlpha(String byPattern, List<String> getPatterns, SortOrder order) {
return (Collection<T>)get(readSortAlphaAsync(byPattern, getPatterns, order));
return (Collection<T>) get(readSortAlphaAsync(byPattern, getPatterns, order));
}
@Override
public <T> Collection<T> readSortAlpha(String byPattern, List<String> getPatterns, SortOrder order, int offset, int count) {
return (Collection<T>)get(readSortAlphaAsync(byPattern, getPatterns, order, offset, count));
return (Collection<T>) get(readSortAlphaAsync(byPattern, getPatterns, order, offset, count));
}
@Override
@ -619,13 +620,13 @@ public class RedissonSet<V> extends RedissonExpirable implements RSet<V>, ScanIt
@Override
public RPermitExpirableSemaphore getPermitExpirableSemaphore(V value) {
String lockName = getLockName(value, "permitexpirablesemaphore");
return new RedissonPermitExpirableSemaphore(commandExecutor, lockName, ((Redisson)redisson).getSemaphorePubSub());
return new RedissonPermitExpirableSemaphore(commandExecutor, lockName, ((Redisson) redisson).getSemaphorePubSub());
}
@Override
public RSemaphore getSemaphore(V value) {
String lockName = getLockName(value, "semaphore");
return new RedissonSemaphore(commandExecutor, lockName, ((Redisson)redisson).getSemaphorePubSub());
return new RedissonSemaphore(commandExecutor, lockName, ((Redisson) redisson).getSemaphorePubSub());
}
@Override

@ -184,7 +184,7 @@ public class RedissonSetCache<V> extends RedissonExpirable implements RSetCache<
@Override
protected void remove(Object value) {
RedissonSetCache.this.remove((V)value);
RedissonSetCache.this.remove((V) value);
}
};
@ -265,7 +265,7 @@ public class RedissonSetCache<V> extends RedissonExpirable implements RSetCache<
@Override
public boolean remove(Object value) {
return get(removeAsync((V)value));
return get(removeAsync((V) value));
}
@Override
@ -336,7 +336,7 @@ public class RedissonSetCache<V> extends RedissonExpirable implements RSetCache<
List<Object> params = new ArrayList<Object>(c.size()*2);
for (Object object : c) {
params.add(score);
params.add(encode((V)object));
params.add(encode((V) object));
}
return commandExecutor.evalWriteAsync(getName(), codec, RedisCommands.EVAL_BOOLEAN,
@ -383,13 +383,13 @@ public class RedissonSetCache<V> extends RedissonExpirable implements RSetCache<
@Override
public RPermitExpirableSemaphore getPermitExpirableSemaphore(V value) {
String lockName = getLockName(value, "permitexpirablesemaphore");
return new RedissonPermitExpirableSemaphore(commandExecutor, lockName, ((Redisson)redisson).getSemaphorePubSub());
return new RedissonPermitExpirableSemaphore(commandExecutor, lockName, ((Redisson) redisson).getSemaphorePubSub());
}
@Override
public RSemaphore getSemaphore(V value) {
String lockName = getLockName(value, "semaphore");
return new RedissonSemaphore(commandExecutor, lockName, ((Redisson)redisson).getSemaphorePubSub());
return new RedissonSemaphore(commandExecutor, lockName, ((Redisson) redisson).getSemaphorePubSub());
}
@Override

@ -230,7 +230,7 @@ public class RedissonSetMultimapValues<V> extends RedissonExpirable implements R
@Override
protected void remove(Object value) {
RedissonSetMultimapValues.this.remove((V)value);
RedissonSetMultimapValues.this.remove((V) value);
}
};
@ -342,7 +342,7 @@ public class RedissonSetMultimapValues<V> extends RedissonExpirable implements R
@Override
public boolean remove(Object value) {
return get(removeAsync((V)value));
return get(removeAsync((V) value));
}
@Override

@ -194,7 +194,7 @@ public class RedissonSortedSet<V> extends RedissonObject implements RSortedSet<V
@Override
public boolean contains(final Object o) {
return binarySearch((V)o, codec).getIndex() >= 0;
return binarySearch((V) o, codec).getIndex() >= 0;
}
@Override
@ -298,7 +298,7 @@ public class RedissonSortedSet<V> extends RedissonObject implements RSortedSet<V
return false;
}
list.remove((int)res.getIndex());
list.remove((int) res.getIndex());
return true;
} finally {
lock.unlock();
@ -447,6 +447,7 @@ public class RedissonSortedSet<V> extends RedissonObject implements RSortedSet<V
return indexRes;
}
@SuppressWarnings("AvoidInlineConditionals")
public String toString() {
Iterator<V> it = iterator();
if (! it.hasNext())

@ -232,7 +232,7 @@ public class RedissonStream<K, V> extends RedissonExpirable implements RStream<K
}
@Override
public RFuture<Map<String, Map<StreamMessageId, Map<K, V>>>> readGroupAsync(String groupName, String consumerName,StreamMessageId id, Map<String, StreamMessageId> keyToId) {
public RFuture<Map<String, Map<StreamMessageId, Map<K, V>>>> readGroupAsync(String groupName, String consumerName, StreamMessageId id, Map<String, StreamMessageId> keyToId) {
return readGroupAsync(groupName, consumerName, 0, id, keyToId);
}

@ -486,6 +486,7 @@ public class RedissonSubList<V> extends RedissonList<V> implements RList<V> {
get(trimAsync(fromIndex, toIndex));
}
@SuppressWarnings("AvoidInlineConditionals")
public String toString() {
Iterator<V> it = iterator();
if (! it.hasNext())
@ -503,6 +504,7 @@ public class RedissonSubList<V> extends RedissonList<V> implements RList<V> {
}
@Override
@SuppressWarnings("AvoidInlineConditionals")
public boolean equals(Object o) {
if (o == this)
return true;
@ -521,6 +523,7 @@ public class RedissonSubList<V> extends RedissonList<V> implements RList<V> {
}
@Override
@SuppressWarnings("AvoidInlineConditionals")
public int hashCode() {
int hashCode = 1;
for (V e : this) {

@ -38,7 +38,7 @@ class RedissonSubSortedSet<V> implements SortedSet<V> {
private V headValue;
private V tailValue;
public RedissonSubSortedSet(RedissonSortedSet<V> redissonSortedSet, ConnectionManager connectionManager, V headValue, V tailValue) {
RedissonSubSortedSet(RedissonSortedSet<V> redissonSortedSet, ConnectionManager connectionManager, V headValue, V tailValue) {
super();
this.headValue = headValue;
this.tailValue = tailValue;
@ -317,6 +317,8 @@ class RedissonSubSortedSet<V> implements SortedSet<V> {
// }
}
@SuppressWarnings("AvoidInlineConditionals")
@Override
public String toString() {
Iterator<V> it = iterator();
if (! it.hasNext())

@ -104,14 +104,14 @@ public class RedissonTopic implements RTopic {
@Override
public <M> int addListener(Class<M> type, MessageListener<? extends M> listener) {
PubSubMessageListener<M> pubSubListener = new PubSubMessageListener<M>(type, (MessageListener<M>)listener, name);
PubSubMessageListener<M> pubSubListener = new PubSubMessageListener<M>(type, (MessageListener<M>) listener, name);
return addListener(pubSubListener);
}
@Override
public RFuture<Integer> addListenerAsync(StatusListener listener) {
PubSubStatusListener pubSubListener = new PubSubStatusListener(listener, name);
return addListenerAsync((RedisPubSubListener<?>)pubSubListener);
return addListenerAsync((RedisPubSubListener<?>) pubSubListener);
}
@Override

@ -37,7 +37,7 @@ public class Version {
continue;
}
String name = attrs.getValue("Bundle-Name");
if (name != null && name.equals("Redisson")) {
if ("Redisson".equals(name)) {
log.info("Redisson " + attrs.getValue("Bundle-Version"));
break;
}

@ -656,6 +656,7 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
if (cfg.getEventLoopGroup() == null) {
group.shutdownGracefully(quietPeriod, timeout, unit).syncUninterruptibly();
}
}
@Override

@ -33,10 +33,10 @@ public class CountDownLatchPubSub extends PublishSubscribe<RedissonCountDownLatc
@Override
protected void onMessage(RedissonCountDownLatchEntry value, Long message) {
if (message.equals(RedissonCountDownLatch.zeroCountMessage)) {
if (message.equals(RedissonCountDownLatch.ZERO_COUNT_MESSAGE)) {
value.getLatch().open();
}
if (message.equals(RedissonCountDownLatch.newCountMessage)) {
if (message.equals(RedissonCountDownLatch.NEW_COUNT_MESSAGE)) {
value.getLatch().close();
}
}

@ -6,7 +6,7 @@
<suppressions>
<suppress checks="FileLength"
files="JCache.java"/>
files="JCache.java|RedissonMapCache.java"/>
<suppress checks="NestedTryDepth"
files="JCache.java"
lines="785-845"/>

Loading…
Cancel
Save