From 27209e88f21a650d0d30c43aef6b724b51f02df4 Mon Sep 17 00:00:00 2001 From: Nikita Date: Fri, 9 Sep 2016 19:49:37 +0300 Subject: [PATCH 01/15] CompletableFuture & CompletionStage integration. #500 --- .../main/java/org/redisson/api/RFuture.java | 19 +- .../org/redisson/misc/PromiseDelegator.java | 222 +++++++++++++++--- .../org/redisson/misc/RedissonPromise.java | 130 ++++++---- .../java/org/redisson/RedisClientTest.java | 8 +- .../java/org/redisson/RedissonMapTest.java | 11 +- 5 files changed, 308 insertions(+), 82 deletions(-) diff --git a/redisson/src/main/java/org/redisson/api/RFuture.java b/redisson/src/main/java/org/redisson/api/RFuture.java index bc0a1c0f6..613ef004e 100644 --- a/redisson/src/main/java/org/redisson/api/RFuture.java +++ b/redisson/src/main/java/org/redisson/api/RFuture.java @@ -15,6 +15,7 @@ */ package org.redisson.api; +import java.util.concurrent.CompletionStage; import java.util.concurrent.TimeUnit; import io.netty.util.concurrent.FutureListener; @@ -26,7 +27,7 @@ import io.netty.util.concurrent.FutureListener; * * @param */ -public interface RFuture extends java.util.concurrent.Future { +public interface RFuture extends java.util.concurrent.Future, CompletionStage { /** * Returns {@code true} if and only if the I/O operation was completed @@ -52,6 +53,22 @@ public interface RFuture extends java.util.concurrent.Future { */ V getNow(); + /** + * Returns the result value when complete, or throws an + * (unchecked) exception if completed exceptionally. To better + * conform with the use of common functional forms, if a + * computation involved in the completion of this + * CompletableFuture threw an exception, this method throws an + * (unchecked) {@link CompletionException} with the underlying + * exception as its cause. + * + * @return the result value + * @throws CancellationException if the computation was cancelled + * @throws CompletionException if this future completed + * exceptionally or a completion computation threw an exception + */ + V join(); + /** * Waits for this future to be completed within the * specified time limit. diff --git a/redisson/src/main/java/org/redisson/misc/PromiseDelegator.java b/redisson/src/main/java/org/redisson/misc/PromiseDelegator.java index 92efb057f..b18e6a256 100644 --- a/redisson/src/main/java/org/redisson/misc/PromiseDelegator.java +++ b/redisson/src/main/java/org/redisson/misc/PromiseDelegator.java @@ -15,9 +15,16 @@ */ package org.redisson.misc; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; import java.util.concurrent.ExecutionException; +import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import java.util.function.BiConsumer; +import java.util.function.BiFunction; +import java.util.function.Consumer; +import java.util.function.Function; import io.netty.util.concurrent.FutureListener; @@ -34,120 +41,261 @@ public class PromiseDelegator implements RPromise { return promise; } - @Override + public T join() { + return promise.join(); + } + public boolean isSuccess() { return promise.isSuccess(); } - @Override public boolean trySuccess(T result) { return promise.trySuccess(result); } - @Override public Throwable cause() { return promise.cause(); } - @Override + public T getNow() { + return promise.getNow(); + } + public boolean tryFailure(Throwable cause) { return promise.tryFailure(cause); } - @Override + public boolean await(long timeout, TimeUnit unit) throws InterruptedException { + return promise.await(timeout, unit); + } + public boolean setUncancellable() { return promise.setUncancellable(); } - @Override + public boolean await(long timeoutMillis) throws InterruptedException { + return promise.await(timeoutMillis); + } + public RPromise addListener(FutureListener listener) { return promise.addListener(listener); } - @Override public RPromise addListeners(FutureListener... listeners) { return promise.addListeners(listeners); } - @Override public RPromise removeListener(FutureListener listener) { return promise.removeListener(listener); } - @Override public RPromise removeListeners(FutureListener... listeners) { return promise.removeListeners(listeners); } - @Override public RPromise await() throws InterruptedException { return promise.await(); } - @Override + public boolean cancel(boolean mayInterruptIfRunning) { + return promise.cancel(mayInterruptIfRunning); + } + public RPromise awaitUninterruptibly() { return promise.awaitUninterruptibly(); } - @Override public RPromise sync() throws InterruptedException { return promise.sync(); } - @Override public RPromise syncUninterruptibly() { return promise.syncUninterruptibly(); } - @Override - public boolean await(long timeout, TimeUnit unit) throws InterruptedException { - return promise.await(timeout, unit); - } - - @Override public boolean isCancelled() { return promise.isCancelled(); } - @Override public boolean isDone() { return promise.isDone(); } - @Override - public boolean await(long timeoutMillis) throws InterruptedException { - return promise.await(timeoutMillis); - } - - @Override public T get() throws InterruptedException, ExecutionException { return promise.get(); } - @Override public boolean awaitUninterruptibly(long timeout, TimeUnit unit) { return promise.awaitUninterruptibly(timeout, unit); } - @Override public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return promise.get(timeout, unit); } - @Override + public CompletionStage thenApply(Function fn) { + return promise.thenApply(fn); + } + public boolean awaitUninterruptibly(long timeoutMillis) { return promise.awaitUninterruptibly(timeoutMillis); } - @Override - public T getNow() { - return promise.getNow(); + public CompletionStage thenApplyAsync(Function fn) { + return promise.thenApplyAsync(fn); } - @Override - public boolean cancel(boolean mayInterruptIfRunning) { - return promise.cancel(mayInterruptIfRunning); + public CompletionStage thenApplyAsync(Function fn, Executor executor) { + return promise.thenApplyAsync(fn, executor); } - - + + public CompletionStage thenAccept(Consumer action) { + return promise.thenAccept(action); + } + + public CompletionStage thenAcceptAsync(Consumer action) { + return promise.thenAcceptAsync(action); + } + + public CompletionStage thenAcceptAsync(Consumer action, Executor executor) { + return promise.thenAcceptAsync(action, executor); + } + + public CompletionStage thenRun(Runnable action) { + return promise.thenRun(action); + } + + public CompletionStage thenRunAsync(Runnable action) { + return promise.thenRunAsync(action); + } + + public CompletionStage thenRunAsync(Runnable action, Executor executor) { + return promise.thenRunAsync(action, executor); + } + + public CompletionStage thenCombine(CompletionStage other, + BiFunction fn) { + return promise.thenCombine(other, fn); + } + + public CompletionStage thenCombineAsync(CompletionStage other, + BiFunction fn) { + return promise.thenCombineAsync(other, fn); + } + + public CompletionStage thenCombineAsync(CompletionStage other, + BiFunction fn, Executor executor) { + return promise.thenCombineAsync(other, fn, executor); + } + + public CompletionStage thenAcceptBoth(CompletionStage other, + BiConsumer action) { + return promise.thenAcceptBoth(other, action); + } + + public CompletionStage thenAcceptBothAsync(CompletionStage other, + BiConsumer action) { + return promise.thenAcceptBothAsync(other, action); + } + + public CompletionStage thenAcceptBothAsync(CompletionStage other, + BiConsumer action, Executor executor) { + return promise.thenAcceptBothAsync(other, action, executor); + } + + public CompletionStage runAfterBoth(CompletionStage other, Runnable action) { + return promise.runAfterBoth(other, action); + } + + public CompletionStage runAfterBothAsync(CompletionStage other, Runnable action) { + return promise.runAfterBothAsync(other, action); + } + + public CompletionStage runAfterBothAsync(CompletionStage other, Runnable action, Executor executor) { + return promise.runAfterBothAsync(other, action, executor); + } + + public CompletionStage applyToEither(CompletionStage other, Function fn) { + return promise.applyToEither(other, fn); + } + + public CompletionStage applyToEitherAsync(CompletionStage other, Function fn) { + return promise.applyToEitherAsync(other, fn); + } + + public CompletionStage applyToEitherAsync(CompletionStage other, Function fn, + Executor executor) { + return promise.applyToEitherAsync(other, fn, executor); + } + + public CompletionStage acceptEither(CompletionStage other, Consumer action) { + return promise.acceptEither(other, action); + } + + public CompletionStage acceptEitherAsync(CompletionStage other, Consumer action) { + return promise.acceptEitherAsync(other, action); + } + + public CompletionStage acceptEitherAsync(CompletionStage other, Consumer action, + Executor executor) { + return promise.acceptEitherAsync(other, action, executor); + } + + public CompletionStage runAfterEither(CompletionStage other, Runnable action) { + return promise.runAfterEither(other, action); + } + + public CompletionStage runAfterEitherAsync(CompletionStage other, Runnable action) { + return promise.runAfterEitherAsync(other, action); + } + + public CompletionStage runAfterEitherAsync(CompletionStage other, Runnable action, Executor executor) { + return promise.runAfterEitherAsync(other, action, executor); + } + + public CompletionStage thenCompose(Function> fn) { + return promise.thenCompose(fn); + } + + public CompletionStage thenComposeAsync(Function> fn) { + return promise.thenComposeAsync(fn); + } + + public CompletionStage thenComposeAsync(Function> fn, + Executor executor) { + return promise.thenComposeAsync(fn, executor); + } + + public CompletionStage exceptionally(Function fn) { + return promise.exceptionally(fn); + } + + public CompletionStage whenComplete(BiConsumer action) { + return promise.whenComplete(action); + } + + public CompletionStage whenCompleteAsync(BiConsumer action) { + return promise.whenCompleteAsync(action); + } + + public CompletionStage whenCompleteAsync(BiConsumer action, Executor executor) { + return promise.whenCompleteAsync(action, executor); + } + + public CompletionStage handle(BiFunction fn) { + return promise.handle(fn); + } + + public CompletionStage handleAsync(BiFunction fn) { + return promise.handleAsync(fn); + } + + public CompletionStage handleAsync(BiFunction fn, Executor executor) { + return promise.handleAsync(fn, executor); + } + + public CompletableFuture toCompletableFuture() { + return promise.toCompletableFuture(); + } + } diff --git a/redisson/src/main/java/org/redisson/misc/RedissonPromise.java b/redisson/src/main/java/org/redisson/misc/RedissonPromise.java index ecc76eee3..3ecbb4f48 100644 --- a/redisson/src/main/java/org/redisson/misc/RedissonPromise.java +++ b/redisson/src/main/java/org/redisson/misc/RedissonPromise.java @@ -15,15 +15,20 @@ */ package org.redisson.misc; +import java.util.concurrent.CancellationException; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicInteger; import org.redisson.api.RFuture; import io.netty.util.concurrent.FutureListener; import io.netty.util.concurrent.ImmediateEventExecutor; import io.netty.util.concurrent.Promise; +import io.netty.util.internal.PlatformDependent; /** * @@ -31,9 +36,16 @@ import io.netty.util.concurrent.Promise; * * @param */ -public class RedissonPromise implements RPromise { +public class RedissonPromise extends CompletableFuture implements RPromise { + private volatile boolean uncancellable; + + private final int SUCCESS = 1; + private final int FAILED = 2; + private final int CANCELED = 3; + private final Promise promise = ImmediateEventExecutor.INSTANCE.newPromise(); + private final AtomicInteger status = new AtomicInteger(); public RedissonPromise() { } @@ -49,7 +61,6 @@ public class RedissonPromise implements RPromise { future.trySuccess(result); return future; } - public Promise getInnerPromise() { return promise; @@ -57,27 +68,45 @@ public class RedissonPromise implements RPromise { @Override public boolean isSuccess() { - return promise.isSuccess(); + return isDone() && !isCompletedExceptionally(); } @Override - public boolean trySuccess(T result) { - return promise.trySuccess(result); + public synchronized boolean trySuccess(T result) { + if (status.compareAndSet(0, SUCCESS)) { + complete(result); + promise.trySuccess(result); + return true; + } + return false; } @Override public Throwable cause() { - return promise.cause(); + try { + getNow(null); + } catch (CompletionException e) { + return e.getCause(); + } + return null; } @Override - public boolean tryFailure(Throwable cause) { - return promise.tryFailure(cause); + public synchronized boolean tryFailure(Throwable cause) { + if (status.compareAndSet(0, FAILED)) { + completeExceptionally(cause); + promise.tryFailure(cause); + return true; + } + return false; } @Override public boolean setUncancellable() { - return promise.setUncancellable(); + if (!isDone()) { + uncancellable = true; + } + return uncancellable; } @Override @@ -106,76 +135,97 @@ public class RedissonPromise implements RPromise { @Override public RPromise await() throws InterruptedException { - promise.await(); + try { + get(); + } catch (ExecutionException | CancellationException e) { + // skip + } return this; } @Override public RPromise awaitUninterruptibly() { - promise.awaitUninterruptibly(); + try { + return await(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } return this; } @Override public RPromise sync() throws InterruptedException { - promise.sync(); + try { + get(); + } catch (ExecutionException e) { + if (e.getCause() instanceof CancellationException) { + throw (CancellationException)e.getCause(); + } + PlatformDependent.throwException(e.getCause()); + } return this; } @Override public RPromise syncUninterruptibly() { - promise.syncUninterruptibly(); + try { + join(); + } catch (CompletionException e) { + PlatformDependent.throwException(e.getCause()); + } return this; } @Override public boolean await(long timeout, TimeUnit unit) throws InterruptedException { - return promise.await(timeout, unit); - } - - @Override - public boolean isCancelled() { - return promise.isCancelled(); - } - - @Override - public boolean isDone() { - return promise.isDone(); + try { + get(timeout, unit); + } catch (ExecutionException e) { + if (e.getCause() instanceof CancellationException) { + throw (CancellationException)e.getCause(); + } + throw new CompletionException(e.getCause()); + } catch (TimeoutException e) { + return false; + } + return isDone(); } @Override public boolean await(long timeoutMillis) throws InterruptedException { - return promise.await(timeoutMillis); - } - - @Override - public T get() throws InterruptedException, ExecutionException { - return promise.get(); + return await(timeoutMillis, TimeUnit.MILLISECONDS); } @Override public boolean awaitUninterruptibly(long timeout, TimeUnit unit) { - return promise.awaitUninterruptibly(timeout, unit); - } - - @Override - public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { - return promise.get(timeout, unit); + try { + return await(timeout, unit); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + return false; + } } @Override public boolean awaitUninterruptibly(long timeoutMillis) { - return promise.awaitUninterruptibly(timeoutMillis); + return awaitUninterruptibly(timeoutMillis, TimeUnit.MILLISECONDS); } @Override public T getNow() { - return promise.getNow(); + return getNow(null); } @Override - public boolean cancel(boolean mayInterruptIfRunning) { - return promise.cancel(mayInterruptIfRunning); + public synchronized boolean cancel(boolean mayInterruptIfRunning) { + if (uncancellable) { + return false; + } + if (status.compareAndSet(0, CANCELED)) { + promise.cancel(mayInterruptIfRunning); + return super.cancel(mayInterruptIfRunning); + } + return false; } } diff --git a/redisson/src/test/java/org/redisson/RedisClientTest.java b/redisson/src/test/java/org/redisson/RedisClientTest.java index 98da18393..aad94f6d0 100644 --- a/redisson/src/test/java/org/redisson/RedisClientTest.java +++ b/redisson/src/test/java/org/redisson/RedisClientTest.java @@ -33,7 +33,6 @@ import org.redisson.misc.RPromise; import org.redisson.misc.RedissonPromise; import io.netty.util.concurrent.FutureListener; -import io.netty.util.concurrent.ImmediateEventExecutor; public class RedisClientTest { @@ -69,12 +68,17 @@ public class RedisClientTest { public void testConnectAsync() throws InterruptedException { RedisClient c = new RedisClient("localhost", 6379); RFuture f = c.connectAsync(); - final CountDownLatch l = new CountDownLatch(1); + final CountDownLatch l = new CountDownLatch(2); f.addListener((FutureListener) future -> { RedisConnection conn = future.get(); assertThat(conn.sync(RedisCommands.PING)).isEqualTo("PONG"); l.countDown(); }); + f.handle((conn, ex) -> { + assertThat(conn.sync(RedisCommands.PING)).isEqualTo("PONG"); + l.countDown(); + return null; + }); assertThat(l.await(10, TimeUnit.SECONDS)).isTrue(); } diff --git a/redisson/src/test/java/org/redisson/RedissonMapTest.java b/redisson/src/test/java/org/redisson/RedissonMapTest.java index c57434c73..4d78ba571 100644 --- a/redisson/src/test/java/org/redisson/RedissonMapTest.java +++ b/redisson/src/test/java/org/redisson/RedissonMapTest.java @@ -12,6 +12,7 @@ import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import org.junit.Assert; @@ -627,8 +628,14 @@ public class RedissonMapTest extends BaseTest { map.put(4, 6); map.put(7, 8); - assertThat(map.fastRemoveAsync(1, 3, 7).get()).isEqualTo(3); - Thread.sleep(1); + CountDownLatch l = new CountDownLatch(1); + RFuture future = map.fastRemoveAsync(1, 3, 7); + future.handle((r, ex) -> { + assertThat(r).isEqualTo(3); + l.countDown(); + return this; + }); + assertThat(future.get()).isEqualTo(3); assertThat(map.size()).isEqualTo(1); } From 702a38d968d571be71f8b0f7602592b7a895b2dc Mon Sep 17 00:00:00 2001 From: Nikita Date: Fri, 9 Sep 2016 20:05:18 +0300 Subject: [PATCH 02/15] Revert "CompletableFuture & CompletionStage integration. #500" This reverts commit 27209e88f21a650d0d30c43aef6b724b51f02df4. --- .../main/java/org/redisson/api/RFuture.java | 19 +- .../org/redisson/misc/PromiseDelegator.java | 222 +++--------------- .../org/redisson/misc/RedissonPromise.java | 130 ++++------ .../java/org/redisson/RedisClientTest.java | 8 +- .../java/org/redisson/RedissonMapTest.java | 11 +- 5 files changed, 82 insertions(+), 308 deletions(-) diff --git a/redisson/src/main/java/org/redisson/api/RFuture.java b/redisson/src/main/java/org/redisson/api/RFuture.java index 613ef004e..bc0a1c0f6 100644 --- a/redisson/src/main/java/org/redisson/api/RFuture.java +++ b/redisson/src/main/java/org/redisson/api/RFuture.java @@ -15,7 +15,6 @@ */ package org.redisson.api; -import java.util.concurrent.CompletionStage; import java.util.concurrent.TimeUnit; import io.netty.util.concurrent.FutureListener; @@ -27,7 +26,7 @@ import io.netty.util.concurrent.FutureListener; * * @param */ -public interface RFuture extends java.util.concurrent.Future, CompletionStage { +public interface RFuture extends java.util.concurrent.Future { /** * Returns {@code true} if and only if the I/O operation was completed @@ -53,22 +52,6 @@ public interface RFuture extends java.util.concurrent.Future, CompletionSt */ V getNow(); - /** - * Returns the result value when complete, or throws an - * (unchecked) exception if completed exceptionally. To better - * conform with the use of common functional forms, if a - * computation involved in the completion of this - * CompletableFuture threw an exception, this method throws an - * (unchecked) {@link CompletionException} with the underlying - * exception as its cause. - * - * @return the result value - * @throws CancellationException if the computation was cancelled - * @throws CompletionException if this future completed - * exceptionally or a completion computation threw an exception - */ - V join(); - /** * Waits for this future to be completed within the * specified time limit. diff --git a/redisson/src/main/java/org/redisson/misc/PromiseDelegator.java b/redisson/src/main/java/org/redisson/misc/PromiseDelegator.java index b18e6a256..92efb057f 100644 --- a/redisson/src/main/java/org/redisson/misc/PromiseDelegator.java +++ b/redisson/src/main/java/org/redisson/misc/PromiseDelegator.java @@ -15,16 +15,9 @@ */ package org.redisson.misc; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionStage; import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import java.util.function.BiConsumer; -import java.util.function.BiFunction; -import java.util.function.Consumer; -import java.util.function.Function; import io.netty.util.concurrent.FutureListener; @@ -41,261 +34,120 @@ public class PromiseDelegator implements RPromise { return promise; } - public T join() { - return promise.join(); - } - + @Override public boolean isSuccess() { return promise.isSuccess(); } + @Override public boolean trySuccess(T result) { return promise.trySuccess(result); } + @Override public Throwable cause() { return promise.cause(); } - public T getNow() { - return promise.getNow(); - } - + @Override public boolean tryFailure(Throwable cause) { return promise.tryFailure(cause); } - public boolean await(long timeout, TimeUnit unit) throws InterruptedException { - return promise.await(timeout, unit); - } - + @Override public boolean setUncancellable() { return promise.setUncancellable(); } - public boolean await(long timeoutMillis) throws InterruptedException { - return promise.await(timeoutMillis); - } - + @Override public RPromise addListener(FutureListener listener) { return promise.addListener(listener); } + @Override public RPromise addListeners(FutureListener... listeners) { return promise.addListeners(listeners); } + @Override public RPromise removeListener(FutureListener listener) { return promise.removeListener(listener); } + @Override public RPromise removeListeners(FutureListener... listeners) { return promise.removeListeners(listeners); } + @Override public RPromise await() throws InterruptedException { return promise.await(); } - public boolean cancel(boolean mayInterruptIfRunning) { - return promise.cancel(mayInterruptIfRunning); - } - + @Override public RPromise awaitUninterruptibly() { return promise.awaitUninterruptibly(); } + @Override public RPromise sync() throws InterruptedException { return promise.sync(); } + @Override public RPromise syncUninterruptibly() { return promise.syncUninterruptibly(); } + @Override + public boolean await(long timeout, TimeUnit unit) throws InterruptedException { + return promise.await(timeout, unit); + } + + @Override public boolean isCancelled() { return promise.isCancelled(); } + @Override public boolean isDone() { return promise.isDone(); } + @Override + public boolean await(long timeoutMillis) throws InterruptedException { + return promise.await(timeoutMillis); + } + + @Override public T get() throws InterruptedException, ExecutionException { return promise.get(); } + @Override public boolean awaitUninterruptibly(long timeout, TimeUnit unit) { return promise.awaitUninterruptibly(timeout, unit); } + @Override public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return promise.get(timeout, unit); } - public CompletionStage thenApply(Function fn) { - return promise.thenApply(fn); - } - + @Override public boolean awaitUninterruptibly(long timeoutMillis) { return promise.awaitUninterruptibly(timeoutMillis); } - public CompletionStage thenApplyAsync(Function fn) { - return promise.thenApplyAsync(fn); - } - - public CompletionStage thenApplyAsync(Function fn, Executor executor) { - return promise.thenApplyAsync(fn, executor); - } - - public CompletionStage thenAccept(Consumer action) { - return promise.thenAccept(action); - } - - public CompletionStage thenAcceptAsync(Consumer action) { - return promise.thenAcceptAsync(action); - } - - public CompletionStage thenAcceptAsync(Consumer action, Executor executor) { - return promise.thenAcceptAsync(action, executor); - } - - public CompletionStage thenRun(Runnable action) { - return promise.thenRun(action); - } - - public CompletionStage thenRunAsync(Runnable action) { - return promise.thenRunAsync(action); - } - - public CompletionStage thenRunAsync(Runnable action, Executor executor) { - return promise.thenRunAsync(action, executor); - } - - public CompletionStage thenCombine(CompletionStage other, - BiFunction fn) { - return promise.thenCombine(other, fn); - } - - public CompletionStage thenCombineAsync(CompletionStage other, - BiFunction fn) { - return promise.thenCombineAsync(other, fn); - } - - public CompletionStage thenCombineAsync(CompletionStage other, - BiFunction fn, Executor executor) { - return promise.thenCombineAsync(other, fn, executor); - } - - public CompletionStage thenAcceptBoth(CompletionStage other, - BiConsumer action) { - return promise.thenAcceptBoth(other, action); - } - - public CompletionStage thenAcceptBothAsync(CompletionStage other, - BiConsumer action) { - return promise.thenAcceptBothAsync(other, action); - } - - public CompletionStage thenAcceptBothAsync(CompletionStage other, - BiConsumer action, Executor executor) { - return promise.thenAcceptBothAsync(other, action, executor); - } - - public CompletionStage runAfterBoth(CompletionStage other, Runnable action) { - return promise.runAfterBoth(other, action); - } - - public CompletionStage runAfterBothAsync(CompletionStage other, Runnable action) { - return promise.runAfterBothAsync(other, action); - } - - public CompletionStage runAfterBothAsync(CompletionStage other, Runnable action, Executor executor) { - return promise.runAfterBothAsync(other, action, executor); - } - - public CompletionStage applyToEither(CompletionStage other, Function fn) { - return promise.applyToEither(other, fn); - } - - public CompletionStage applyToEitherAsync(CompletionStage other, Function fn) { - return promise.applyToEitherAsync(other, fn); - } - - public CompletionStage applyToEitherAsync(CompletionStage other, Function fn, - Executor executor) { - return promise.applyToEitherAsync(other, fn, executor); - } - - public CompletionStage acceptEither(CompletionStage other, Consumer action) { - return promise.acceptEither(other, action); - } - - public CompletionStage acceptEitherAsync(CompletionStage other, Consumer action) { - return promise.acceptEitherAsync(other, action); - } - - public CompletionStage acceptEitherAsync(CompletionStage other, Consumer action, - Executor executor) { - return promise.acceptEitherAsync(other, action, executor); - } - - public CompletionStage runAfterEither(CompletionStage other, Runnable action) { - return promise.runAfterEither(other, action); - } - - public CompletionStage runAfterEitherAsync(CompletionStage other, Runnable action) { - return promise.runAfterEitherAsync(other, action); - } - - public CompletionStage runAfterEitherAsync(CompletionStage other, Runnable action, Executor executor) { - return promise.runAfterEitherAsync(other, action, executor); - } - - public CompletionStage thenCompose(Function> fn) { - return promise.thenCompose(fn); - } - - public CompletionStage thenComposeAsync(Function> fn) { - return promise.thenComposeAsync(fn); - } - - public CompletionStage thenComposeAsync(Function> fn, - Executor executor) { - return promise.thenComposeAsync(fn, executor); - } - - public CompletionStage exceptionally(Function fn) { - return promise.exceptionally(fn); - } - - public CompletionStage whenComplete(BiConsumer action) { - return promise.whenComplete(action); - } - - public CompletionStage whenCompleteAsync(BiConsumer action) { - return promise.whenCompleteAsync(action); - } - - public CompletionStage whenCompleteAsync(BiConsumer action, Executor executor) { - return promise.whenCompleteAsync(action, executor); - } - - public CompletionStage handle(BiFunction fn) { - return promise.handle(fn); - } - - public CompletionStage handleAsync(BiFunction fn) { - return promise.handleAsync(fn); - } - - public CompletionStage handleAsync(BiFunction fn, Executor executor) { - return promise.handleAsync(fn, executor); + @Override + public T getNow() { + return promise.getNow(); } - public CompletableFuture toCompletableFuture() { - return promise.toCompletableFuture(); + @Override + public boolean cancel(boolean mayInterruptIfRunning) { + return promise.cancel(mayInterruptIfRunning); } - + + } diff --git a/redisson/src/main/java/org/redisson/misc/RedissonPromise.java b/redisson/src/main/java/org/redisson/misc/RedissonPromise.java index 3ecbb4f48..ecc76eee3 100644 --- a/redisson/src/main/java/org/redisson/misc/RedissonPromise.java +++ b/redisson/src/main/java/org/redisson/misc/RedissonPromise.java @@ -15,20 +15,15 @@ */ package org.redisson.misc; -import java.util.concurrent.CancellationException; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionException; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicInteger; import org.redisson.api.RFuture; import io.netty.util.concurrent.FutureListener; import io.netty.util.concurrent.ImmediateEventExecutor; import io.netty.util.concurrent.Promise; -import io.netty.util.internal.PlatformDependent; /** * @@ -36,16 +31,9 @@ import io.netty.util.internal.PlatformDependent; * * @param */ -public class RedissonPromise extends CompletableFuture implements RPromise { +public class RedissonPromise implements RPromise { - private volatile boolean uncancellable; - - private final int SUCCESS = 1; - private final int FAILED = 2; - private final int CANCELED = 3; - private final Promise promise = ImmediateEventExecutor.INSTANCE.newPromise(); - private final AtomicInteger status = new AtomicInteger(); public RedissonPromise() { } @@ -61,6 +49,7 @@ public class RedissonPromise extends CompletableFuture implements RPromise future.trySuccess(result); return future; } + public Promise getInnerPromise() { return promise; @@ -68,45 +57,27 @@ public class RedissonPromise extends CompletableFuture implements RPromise @Override public boolean isSuccess() { - return isDone() && !isCompletedExceptionally(); + return promise.isSuccess(); } @Override - public synchronized boolean trySuccess(T result) { - if (status.compareAndSet(0, SUCCESS)) { - complete(result); - promise.trySuccess(result); - return true; - } - return false; + public boolean trySuccess(T result) { + return promise.trySuccess(result); } @Override public Throwable cause() { - try { - getNow(null); - } catch (CompletionException e) { - return e.getCause(); - } - return null; + return promise.cause(); } @Override - public synchronized boolean tryFailure(Throwable cause) { - if (status.compareAndSet(0, FAILED)) { - completeExceptionally(cause); - promise.tryFailure(cause); - return true; - } - return false; + public boolean tryFailure(Throwable cause) { + return promise.tryFailure(cause); } @Override public boolean setUncancellable() { - if (!isDone()) { - uncancellable = true; - } - return uncancellable; + return promise.setUncancellable(); } @Override @@ -135,97 +106,76 @@ public class RedissonPromise extends CompletableFuture implements RPromise @Override public RPromise await() throws InterruptedException { - try { - get(); - } catch (ExecutionException | CancellationException e) { - // skip - } + promise.await(); return this; } @Override public RPromise awaitUninterruptibly() { - try { - return await(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } + promise.awaitUninterruptibly(); return this; } @Override public RPromise sync() throws InterruptedException { - try { - get(); - } catch (ExecutionException e) { - if (e.getCause() instanceof CancellationException) { - throw (CancellationException)e.getCause(); - } - PlatformDependent.throwException(e.getCause()); - } + promise.sync(); return this; } @Override public RPromise syncUninterruptibly() { - try { - join(); - } catch (CompletionException e) { - PlatformDependent.throwException(e.getCause()); - } + promise.syncUninterruptibly(); return this; } @Override public boolean await(long timeout, TimeUnit unit) throws InterruptedException { - try { - get(timeout, unit); - } catch (ExecutionException e) { - if (e.getCause() instanceof CancellationException) { - throw (CancellationException)e.getCause(); - } - throw new CompletionException(e.getCause()); - } catch (TimeoutException e) { - return false; - } - return isDone(); + return promise.await(timeout, unit); + } + + @Override + public boolean isCancelled() { + return promise.isCancelled(); + } + + @Override + public boolean isDone() { + return promise.isDone(); } @Override public boolean await(long timeoutMillis) throws InterruptedException { - return await(timeoutMillis, TimeUnit.MILLISECONDS); + return promise.await(timeoutMillis); + } + + @Override + public T get() throws InterruptedException, ExecutionException { + return promise.get(); } @Override public boolean awaitUninterruptibly(long timeout, TimeUnit unit) { - try { - return await(timeout, unit); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - return false; - } + return promise.awaitUninterruptibly(timeout, unit); + } + + @Override + public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { + return promise.get(timeout, unit); } @Override public boolean awaitUninterruptibly(long timeoutMillis) { - return awaitUninterruptibly(timeoutMillis, TimeUnit.MILLISECONDS); + return promise.awaitUninterruptibly(timeoutMillis); } @Override public T getNow() { - return getNow(null); + return promise.getNow(); } @Override - public synchronized boolean cancel(boolean mayInterruptIfRunning) { - if (uncancellable) { - return false; - } - if (status.compareAndSet(0, CANCELED)) { - promise.cancel(mayInterruptIfRunning); - return super.cancel(mayInterruptIfRunning); - } - return false; + public boolean cancel(boolean mayInterruptIfRunning) { + return promise.cancel(mayInterruptIfRunning); } } diff --git a/redisson/src/test/java/org/redisson/RedisClientTest.java b/redisson/src/test/java/org/redisson/RedisClientTest.java index aad94f6d0..98da18393 100644 --- a/redisson/src/test/java/org/redisson/RedisClientTest.java +++ b/redisson/src/test/java/org/redisson/RedisClientTest.java @@ -33,6 +33,7 @@ import org.redisson.misc.RPromise; import org.redisson.misc.RedissonPromise; import io.netty.util.concurrent.FutureListener; +import io.netty.util.concurrent.ImmediateEventExecutor; public class RedisClientTest { @@ -68,17 +69,12 @@ public class RedisClientTest { public void testConnectAsync() throws InterruptedException { RedisClient c = new RedisClient("localhost", 6379); RFuture f = c.connectAsync(); - final CountDownLatch l = new CountDownLatch(2); + final CountDownLatch l = new CountDownLatch(1); f.addListener((FutureListener) future -> { RedisConnection conn = future.get(); assertThat(conn.sync(RedisCommands.PING)).isEqualTo("PONG"); l.countDown(); }); - f.handle((conn, ex) -> { - assertThat(conn.sync(RedisCommands.PING)).isEqualTo("PONG"); - l.countDown(); - return null; - }); assertThat(l.await(10, TimeUnit.SECONDS)).isTrue(); } diff --git a/redisson/src/test/java/org/redisson/RedissonMapTest.java b/redisson/src/test/java/org/redisson/RedissonMapTest.java index 4d78ba571..c57434c73 100644 --- a/redisson/src/test/java/org/redisson/RedissonMapTest.java +++ b/redisson/src/test/java/org/redisson/RedissonMapTest.java @@ -12,7 +12,6 @@ import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import org.junit.Assert; @@ -628,14 +627,8 @@ public class RedissonMapTest extends BaseTest { map.put(4, 6); map.put(7, 8); - CountDownLatch l = new CountDownLatch(1); - RFuture future = map.fastRemoveAsync(1, 3, 7); - future.handle((r, ex) -> { - assertThat(r).isEqualTo(3); - l.countDown(); - return this; - }); - assertThat(future.get()).isEqualTo(3); + assertThat(map.fastRemoveAsync(1, 3, 7).get()).isEqualTo(3); + Thread.sleep(1); assertThat(map.size()).isEqualTo(1); } From c1326cc5b718282a84f2f760399ba0ea9eef2fd1 Mon Sep 17 00:00:00 2001 From: Nikita Date: Mon, 12 Sep 2016 13:08:07 +0300 Subject: [PATCH 03/15] javadoc parser compatibility fixed --- .../java/org/redisson/RedissonFairLock.java | 2 +- .../main/java/org/redisson/RedissonLock.java | 2 +- .../java/org/redisson/RedissonSemaphore.java | 2 +- .../redisson/api/LocalCachedMapOptions.java | 40 +- .../src/main/java/org/redisson/api/Node.java | 6 +- .../java/org/redisson/api/NodesGroup.java | 13 +- .../main/java/org/redisson/api/RBatch.java | 175 +++++--- .../java/org/redisson/api/RBatchReactive.java | 104 +++-- .../java/org/redisson/api/RBlockingDeque.java | 6 +- .../org/redisson/api/RBlockingDequeAsync.java | 6 +- .../java/org/redisson/api/RBlockingQueue.java | 1 + .../org/redisson/api/RBlockingQueueAsync.java | 6 +- .../redisson/api/RBlockingQueueReactive.java | 2 +- .../java/org/redisson/api/RBloomFilter.java | 8 +- .../api/RBoundedBlockingQueueAsync.java | 1 - .../main/java/org/redisson/api/RBuckets.java | 19 +- .../org/redisson/api/RCollectionAsync.java | 2 +- .../redisson/api/RCountDownLatchAsync.java | 8 +- .../org/redisson/api/RExecutorService.java | 3 +- .../redisson/api/RExecutorServiceAsync.java | 9 +- .../main/java/org/redisson/api/RFuture.java | 35 +- .../src/main/java/org/redisson/api/RGeo.java | 83 ++-- .../main/java/org/redisson/api/RGeoAsync.java | 83 ++-- .../src/main/java/org/redisson/api/RKeys.java | 20 +- .../java/org/redisson/api/RKeysAsync.java | 4 +- .../main/java/org/redisson/api/RMapCache.java | 26 +- .../java/org/redisson/api/RMapCacheAsync.java | 22 +- .../main/java/org/redisson/api/RObject.java | 15 +- .../java/org/redisson/api/RObjectAsync.java | 12 +- .../org/redisson/api/RObjectReactive.java | 12 +- .../java/org/redisson/api/RRemoteService.java | 28 +- .../org/redisson/api/RScoredSortedSet.java | 2 +- .../redisson/api/RScoredSortedSetAsync.java | 2 +- .../org/redisson/api/RSemaphoreAsync.java | 2 +- .../java/org/redisson/api/RedissonClient.java | 425 ++++++++++-------- .../redisson/api/RedissonNodeInitializer.java | 2 +- .../redisson/api/RedissonReactiveClient.java | 204 +++++---- .../redisson/api/RemoteInvocationOptions.java | 6 +- .../redisson/api/annotation/RRemoteAsync.java | 6 +- .../config/BaseMasterSlaveServersConfig.java | 24 +- .../main/java/org/redisson/config/Config.java | 6 +- .../org/redisson/misc/ReclosableLatch.java | 2 +- .../RemoteServiceAckTimeoutException.java | 2 +- .../redisson/spring/cache/CacheConfig.java | 2 +- .../cache/RedissonSpringCacheManager.java | 10 +- 45 files changed, 821 insertions(+), 629 deletions(-) diff --git a/redisson/src/main/java/org/redisson/RedissonFairLock.java b/redisson/src/main/java/org/redisson/RedissonFairLock.java index 14e23e2b7..73dd905fe 100644 --- a/redisson/src/main/java/org/redisson/RedissonFairLock.java +++ b/redisson/src/main/java/org/redisson/RedissonFairLock.java @@ -32,7 +32,7 @@ import org.redisson.pubsub.LockPubSub; * Distributed implementation of {@link java.util.concurrent.locks.Lock} * Implements reentrant lock.
* Lock will be removed automatically if client disconnects. - *

+ *

* Implements a fair locking so it guarantees an acquire order by threads. * * @author Nikita Koksharov diff --git a/redisson/src/main/java/org/redisson/RedissonLock.java b/redisson/src/main/java/org/redisson/RedissonLock.java index 1f600951f..d1a7e7baa 100644 --- a/redisson/src/main/java/org/redisson/RedissonLock.java +++ b/redisson/src/main/java/org/redisson/RedissonLock.java @@ -46,7 +46,7 @@ import io.netty.util.internal.PlatformDependent; * Distributed implementation of {@link java.util.concurrent.locks.Lock} * Implements reentrant lock.
* Lock will be removed automatically if client disconnects. - *

+ *

* Implements a non-fair locking so doesn't guarantees an acquire order. * * @author Nikita Koksharov diff --git a/redisson/src/main/java/org/redisson/RedissonSemaphore.java b/redisson/src/main/java/org/redisson/RedissonSemaphore.java index 15579f404..bef6d3636 100644 --- a/redisson/src/main/java/org/redisson/RedissonSemaphore.java +++ b/redisson/src/main/java/org/redisson/RedissonSemaphore.java @@ -38,7 +38,7 @@ import io.netty.util.concurrent.FutureListener; /** * Distributed and concurrent implementation of {@link java.util.concurrent.Semaphore}. - *

+ *

* Works in non-fair mode. Therefore order of acquiring is unpredictable. * * @author Nikita Koksharov diff --git a/redisson/src/main/java/org/redisson/api/LocalCachedMapOptions.java b/redisson/src/main/java/org/redisson/api/LocalCachedMapOptions.java index 62d76a4a1..8e3f72e26 100644 --- a/redisson/src/main/java/org/redisson/api/LocalCachedMapOptions.java +++ b/redisson/src/main/java/org/redisson/api/LocalCachedMapOptions.java @@ -46,7 +46,7 @@ public class LocalCachedMapOptions { /** * Creates a new instance of LocalCachedMapOptions with default options. - *

+ *

* This is equivalent to: *

      *     new LocalCachedMapOptions()
@@ -54,6 +54,9 @@ public class LocalCachedMapOptions {
      *      .evictionPolicy(EvictionPolicy.NONE)
      *      .invalidateEntryOnChange(true);
      * 
+ * + * @return LocalCachedMapOptions instance + * */ public static LocalCachedMapOptions defaults() { return new LocalCachedMapOptions() @@ -85,8 +88,8 @@ public class LocalCachedMapOptions { /** * Sets cache size. If size is 0 then cache is unbounded. * - * @param cacheSize - * @return + * @param cacheSize - size of cache + * @return LocalCachedMapOptions instance */ public LocalCachedMapOptions cacheSize(int cacheSize) { this.cacheSize = cacheSize; @@ -99,7 +102,7 @@ public class LocalCachedMapOptions { * @param value - if true then invalidation message which removes corresponding entry from cache * will be sent to all other RLocalCachedMap instances on each entry update/remove operation. * if false then invalidation message won't be sent - * @return + * @return LocalCachedMapOptions instance */ public LocalCachedMapOptions invalidateEntryOnChange(boolean value) { this.invalidateEntryOnChange = value; @@ -113,7 +116,7 @@ public class LocalCachedMapOptions { *

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

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

NONE - doesn't use eviction policy, but timeToLive and maxIdleTime params are still working. - * @return + * @return LocalCachedMapOptions instance */ public LocalCachedMapOptions evictionPolicy(EvictionPolicy evictionPolicy) { if (evictionPolicy == null) { @@ -125,10 +128,10 @@ public class LocalCachedMapOptions { /** * Sets time to live in milliseconds for each map entry in cache. - * If value equals to 0 then timeout is not applied + * If value equals to 0 then timeout is not applied * - * @param timeToLiveInMillis - * @return + * @param timeToLiveInMillis - time to live in milliseconds + * @return LocalCachedMapOptions instance */ public LocalCachedMapOptions timeToLive(long timeToLiveInMillis) { this.timeToLiveInMillis = timeToLiveInMillis; @@ -137,11 +140,11 @@ public class LocalCachedMapOptions { /** * Sets time to live for each map entry in cache. - * If value equals to 0 then timeout is not applied + * If value equals to 0 then timeout is not applied * - * @param timeToLive - * @param timeUnit - * @return + * @param timeToLive - time to live + * @param timeUnit - time unit + * @return LocalCachedMapOptions instance */ public LocalCachedMapOptions timeToLive(long timeToLive, TimeUnit timeUnit) { return timeToLive(timeUnit.toMillis(timeToLive)); @@ -149,10 +152,10 @@ public class LocalCachedMapOptions { /** * Sets max idle time in milliseconds for each map entry in cache. - * If value equals to 0 then timeout is not applied + * If value equals to 0 then timeout is not applied * - * @param maxIdleInMillis - * @return + * @param maxIdleInMillis - time to live in milliseconds + * @return LocalCachedMapOptions instance */ public LocalCachedMapOptions maxIdle(long maxIdleInMillis) { this.maxIdleInMillis = maxIdleInMillis; @@ -161,10 +164,11 @@ public class LocalCachedMapOptions { /** * Sets max idle time for each map entry in cache. - * If value equals to 0 then timeout is not applied + * If value equals to 0 then timeout is not applied * - * @param maxIdleInMillis - * @return + * @param maxIdle - max idle time + * @param timeUnit - time unit + * @return LocalCachedMapOptions instance */ public LocalCachedMapOptions maxIdle(long maxIdle, TimeUnit timeUnit) { return timeToLive(timeUnit.toMillis(maxIdle)); diff --git a/redisson/src/main/java/org/redisson/api/Node.java b/redisson/src/main/java/org/redisson/api/Node.java index 208e00197..0f1ed2541 100644 --- a/redisson/src/main/java/org/redisson/api/Node.java +++ b/redisson/src/main/java/org/redisson/api/Node.java @@ -28,16 +28,14 @@ public interface Node { /** * Returns node type * - * @see {@link NodeType} - * - * @return + * @return node type */ NodeType getType(); /** * Get Redis node address * - * @return + * @return node address */ InetSocketAddress getAddr(); diff --git a/redisson/src/main/java/org/redisson/api/NodesGroup.java b/redisson/src/main/java/org/redisson/api/NodesGroup.java index 7a73d741e..4b9c0cf98 100644 --- a/redisson/src/main/java/org/redisson/api/NodesGroup.java +++ b/redisson/src/main/java/org/redisson/api/NodesGroup.java @@ -30,24 +30,23 @@ public interface NodesGroup { * Adds connection listener which will be triggered * when Redisson has just been connected to or disconnected from redis server * - * @param connectionListener + * @param connectionListener - connection listener + * @return id of listener */ int addConnectionListener(ConnectionListener connectionListener); /** * Removes connection listener by id * - * @param listenerId + * @param listenerId - id of connection listener */ void removeConnectionListener(int listenerId); /** * Get all nodes by type * - * @see {@link NodeType} - * - * @param type - * @return + * @param type - type of node + * @return collection of nodes */ Collection getNodes(NodeType type); @@ -55,7 +54,7 @@ public interface NodesGroup { * All Redis nodes used by Redisson. * This collection may change during master change, cluster topology update and etc. * - * @return + * @return collection of nodes */ Collection getNodes(); diff --git a/redisson/src/main/java/org/redisson/api/RBatch.java b/redisson/src/main/java/org/redisson/api/RBatch.java index 94d693379..32868333c 100644 --- a/redisson/src/main/java/org/redisson/api/RBatch.java +++ b/redisson/src/main/java/org/redisson/api/RBatch.java @@ -22,11 +22,11 @@ import org.redisson.client.codec.Codec; /** * Interface for using pipeline feature. - *

+ *

* All method invocations on objects * from this interface are batched to separate queue and could be executed later * with execute() or executeAsync() methods. - *

+ *

* Please be ware, atomicity is not guaranteed. * * @@ -38,8 +38,9 @@ public interface RBatch { /** * Returns geospatial items holder instance by name. * - * @param name - * @return + * @param type of object + * @param name - name of object + * @return Geo object */ RGeoAsync getGeo(String name); @@ -47,27 +48,32 @@ public interface RBatch { * Returns geospatial items holder instance by name * using provided codec for geospatial members. * - * @param name - * @param geospatial member codec - * @return + * @param type of value + * @param name - name of object + * @param codec - codec for value + * @return Geo object */ RGeoAsync getGeo(String name, Codec codec); /** * Returns Set based MultiMap instance by name. * - * @param name - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @return Multimap object */ RMultimapAsync getSetMultimap(String name); /** * Returns Set based MultiMap instance by name * using provided codec for both map keys and values. - * - * @param name - * @param codec - * @return + * + * @param type of key + * @param type of value + * @param name - name of object + * @param codec - provided codec + * @return Multimap object */ RMultimapAsync getSetMultimap(String name, Codec codec); @@ -77,8 +83,10 @@ public interface RBatch { * *

If eviction is not required then it's better to use regular map {@link #getSetMultimap(String)}.

* - * @param name - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @return SetMultimapCache object */ RMultimapCacheAsync getSetMultimapCache(String name); @@ -89,8 +97,11 @@ public interface RBatch { * *

If eviction is not required then it's better to use regular map {@link #getSetMultimap(String, Codec)}.

* - * @param name - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @param codec - provided codec + * @return SetMultimapCache object */ RMultimapCacheAsync getSetMultimapCache(String name, Codec codec); @@ -101,9 +112,9 @@ public interface RBatch { * *

If eviction is not required then it's better to use regular map {@link #getSet(String, Codec)}.

* - * @param name - * @param codec - * @return + * @param type of value + * @param name - name of object + * @return SetCache object */ RSetCacheAsync getSetCache(String name); @@ -115,9 +126,10 @@ public interface RBatch { * *

If eviction is not required then it's better to use regular map {@link #getSet(String, Codec)}.

* - * @param name - * @param codec - * @return + * @param type of value + * @param name - name of object + * @param codec - codec for values + * @return SetCache object */ RSetCacheAsync getSetCache(String name, Codec codec); @@ -128,9 +140,11 @@ public interface RBatch { * *

If eviction is not required then it's better to use regular map {@link #getMap(String, Codec)}.

* - * @param name - * @param codec - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @param codec - codec for keys and values + * @return MapCache object */ RMapCacheAsync getMapCache(String name, Codec codec); @@ -140,16 +154,19 @@ public interface RBatch { * *

If eviction is not required then it's better to use regular map {@link #getMap(String)}.

* - * @param name - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @return MapCache object */ RMapCacheAsync getMapCache(String name); /** * Returns object holder by name * - * @param name of object - * @return + * @param type of object + * @param name - name of object + * @return Bucket object */ RBucketAsync getBucket(String name); @@ -158,8 +175,9 @@ public interface RBatch { /** * Returns HyperLogLog object * - * @param name of object - * @return + * @param type of object + * @param name - name of object + * @return HyperLogLog object */ RHyperLogLogAsync getHyperLogLog(String name); @@ -168,8 +186,9 @@ public interface RBatch { /** * Returns list instance by name. * - * @param name of list - * @return + * @param type of object + * @param name - name of object + * @return List object */ RListAsync getList(String name); @@ -178,8 +197,10 @@ public interface RBatch { /** * Returns List based MultiMap instance by name. * - * @param name - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @return ListMultimap object */ RMultimapAsync getListMultimap(String name); @@ -187,9 +208,11 @@ public interface RBatch { * Returns List based MultiMap instance by name * using provided codec for both map keys and values. * - * @param name - * @param codec - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @param codec - codec for keys and values + * @return ListMultimap object */ RMultimapAsync getListMultimap(String name, Codec codec); @@ -199,8 +222,10 @@ public interface RBatch { * *

If eviction is not required then it's better to use regular map {@link #getSetMultimap(String)}.

* - * @param name - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @return ListMultimapCache object */ RMultimapAsync getListMultimapCache(String name); @@ -211,16 +236,21 @@ public interface RBatch { * *

If eviction is not required then it's better to use regular map {@link #getSetMultimap(String, Codec)}.

* - * @param name - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @param codec - codec for keys and values + * @return ListMultimapCache object */ RMultimapAsync getListMultimapCache(String name, Codec codec); /** * Returns map instance by name. * - * @param name of map - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @return Map object */ RMapAsync getMap(String name); @@ -229,8 +259,9 @@ public interface RBatch { /** * Returns set instance by name. * - * @param name of set - * @return + * @param type of value + * @param name - name of object + * @return Set object */ RSetAsync getSet(String name); @@ -239,8 +270,9 @@ public interface RBatch { /** * Returns topic instance by name. * - * @param name of topic - * @return + * @param type of message + * @param name - name of object + * @return Topic object */ RTopicAsync getTopic(String name); @@ -249,8 +281,9 @@ public interface RBatch { /** * Returns queue instance by name. * - * @param name of queue - * @return + * @param type of value + * @param name - name of object + * @return Queue object */ RQueueAsync getQueue(String name); @@ -259,8 +292,9 @@ public interface RBatch { /** * Returns blocking queue instance by name. * - * @param name of queue - * @return + * @param type of value + * @param name - name of object + * @return BlockingQueue object */ RBlockingQueueAsync getBlockingQueue(String name); @@ -269,8 +303,9 @@ public interface RBatch { /** * Returns deque instance by name. * - * @param name of deque - * @return + * @param type of value + * @param name - name of object + * @return Deque object */ RDequeAsync getDeque(String name); @@ -278,9 +313,10 @@ public interface RBatch { /** * Returns blocking deque instance by name. - * - * @param name of queue - * @return + * + * @param type of value + * @param name - name of object + * @return BlockingDeque object */ RBlockingDequeAsync getBlockingDeque(String name); @@ -289,24 +325,25 @@ public interface RBatch { /** * Returns atomicLong instance by name. * - * @param name - * @return + * @param name - name of object + * @return AtomicLong object */ RAtomicLongAsync getAtomicLong(String name); /** * Returns atomicDouble instance by name. * - * @param name - * @return + * @param name - name of object + * @return AtomicDouble object */ RAtomicDoubleAsync getAtomicDouble(String name); /** * Returns Redis Sorted Set instance by name - * - * @param name - * @return + * + * @param type of value + * @param name - name of object + * @return ScoredSortedSet object */ RScoredSortedSetAsync getScoredSortedSet(String name); @@ -317,8 +354,8 @@ public interface RBatch { * All elements are inserted with the same score during addition, * in order to force lexicographical ordering * - * @param name - * @return + * @param name - name of object + * @return LexSortedSet object */ RLexSortedSetAsync getLexSortedSet(String name); @@ -327,7 +364,7 @@ public interface RBatch { /** * Returns script operations object * - * @return + * @return Script object */ RScriptAsync getScript(); @@ -335,7 +372,7 @@ public interface RBatch { * Returns keys operations. * Each of Redis/Redisson object associated with own key * - * @return + * @return Keys object */ RKeysAsync getKeys(); diff --git a/redisson/src/main/java/org/redisson/api/RBatchReactive.java b/redisson/src/main/java/org/redisson/api/RBatchReactive.java index 2cd0e3594..89843ae47 100644 --- a/redisson/src/main/java/org/redisson/api/RBatchReactive.java +++ b/redisson/src/main/java/org/redisson/api/RBatchReactive.java @@ -40,9 +40,9 @@ public interface RBatchReactive { * *

If eviction is not required then it's better to use regular map {@link #getSet(String, Codec)}.

* - * @param name - * @param codec - * @return + * @param type of value + * @param name - name of object + * @return SetCache object */ RSetCacheReactive getSetCache(String name); @@ -54,9 +54,10 @@ public interface RBatchReactive { * *

If eviction is not required then it's better to use regular map {@link #getSet(String, Codec)}.

* - * @param name - * @param codec - * @return + * @param type of value + * @param name - name of object + * @param codec - codec for values + * @return SetCache object */ RSetCacheReactive getSetCache(String name, Codec codec); @@ -67,9 +68,11 @@ public interface RBatchReactive { * *

If eviction is not required then it's better to use regular map {@link #getMap(String, Codec)}.

* - * @param name - * @param codec - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @param codec - codec for keys and values + * @return MapCache object */ RMapCacheReactive getMapCache(String name, Codec codec); @@ -79,26 +82,30 @@ public interface RBatchReactive { * *

If eviction is not required then it's better to use regular map {@link #getMap(String)}.

* - * @param name - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @return MapCache object */ RMapCacheReactive getMapCache(String name); /** * Returns object holder by name * - * @param name of object - * @return + * @param type of value + * @param name - name of object + * @return Bucket object */ RBucketReactive getBucket(String name); RBucketReactive getBucket(String name, Codec codec); /** - * Returns HyperLogLog object + * Returns HyperLogLog object by name * - * @param name of object - * @return + * @param type of value + * @param name - name of object + * @return HyperLogLog object */ RHyperLogLogReactive getHyperLogLog(String name); @@ -107,8 +114,9 @@ public interface RBatchReactive { /** * Returns list instance by name. * - * @param name of list - * @return + * @param type of value + * @param name - name of object + * @return List object */ RListReactive getList(String name); @@ -117,8 +125,10 @@ public interface RBatchReactive { /** * Returns map instance by name. * - * @param name of map - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @return Map object */ RMapReactive getMap(String name); @@ -126,9 +136,10 @@ public interface RBatchReactive { /** * Returns set instance by name. - * - * @param name of set - * @return + * + * @param type of value + * @param name - name of object + * @return Set object */ RSetReactive getSet(String name); @@ -137,8 +148,9 @@ public interface RBatchReactive { /** * Returns topic instance by name. * - * @param name of topic - * @return + * @param type of message + * @param name - name of object + * @return Topic object */ RTopicReactive getTopic(String name); @@ -147,8 +159,9 @@ public interface RBatchReactive { /** * Returns queue instance by name. * - * @param name of queue - * @return + * @param type of value + * @param name - name of object + * @return Queue object */ RQueueReactive getQueue(String name); @@ -156,9 +169,10 @@ public interface RBatchReactive { /** * Returns blocking queue instance by name. - * - * @param name of queue - * @return + * + * @param type of value + * @param name - name of object + * @return BlockingQueue object */ RBlockingQueueReactive getBlockingQueue(String name); @@ -166,9 +180,10 @@ public interface RBatchReactive { /** * Returns deque instance by name. - * - * @param name of deque - * @return + * + * @param type of value + * @param name - name of object + * @return Deque object */ RDequeReactive getDequeReactive(String name); @@ -176,17 +191,18 @@ public interface RBatchReactive { /** * Returns "atomic long" instance by name. - * - * @param name of the "atomic long" - * @return + * + * @param name - name of object + * @return AtomicLong object */ RAtomicLongReactive getAtomicLongReactive(String name); /** * Returns Redis Sorted Set instance by name - * - * @param name - * @return + * + * @param type of value + * @param name - name of object + * @return ScoredSortedSet object */ RScoredSortedSetReactive getScoredSortedSet(String name); @@ -197,8 +213,8 @@ public interface RBatchReactive { * All elements are inserted with the same score during addition, * in order to force lexicographical ordering * - * @param name - * @return + * @param name - name of object + * @return LexSortedSet object */ RLexSortedSetReactive getLexSortedSet(String name); @@ -206,14 +222,14 @@ public interface RBatchReactive { * Returns bitSet instance by name. * * @param name of bitSet - * @return + * @return BitSet object */ RBitSetReactive getBitSet(String name); /** * Returns script operations object * - * @return + * @return Script object */ RScriptReactive getScript(); @@ -221,7 +237,7 @@ public interface RBatchReactive { * Returns keys operations. * Each of Redis/Redisson object associated with own key * - * @return + * @return Keys object */ RKeysReactive getKeys(); diff --git a/redisson/src/main/java/org/redisson/api/RBlockingDeque.java b/redisson/src/main/java/org/redisson/api/RBlockingDeque.java index c6390333e..194ea02f2 100644 --- a/redisson/src/main/java/org/redisson/api/RBlockingDeque.java +++ b/redisson/src/main/java/org/redisson/api/RBlockingDeque.java @@ -30,7 +30,8 @@ public interface RBlockingDeque extends BlockingDeque, RBlockingQueue, * Retrieves and removes first available head element of any queue, * waiting up to the specified wait time if necessary for an element to become available * in any of defined queues including queue own. - * + * + * @param queueNames - names of queue * @param timeout how long to wait before giving up, in units of * {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the @@ -45,7 +46,8 @@ public interface RBlockingDeque extends BlockingDeque, RBlockingQueue, * Retrieves and removes first available tail element of any queue, * waiting up to the specified wait time if necessary for an element to become available * in any of defined queues including queue own. - * + * + * @param queueNames - names of queue * @param timeout how long to wait before giving up, in units of * {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the diff --git a/redisson/src/main/java/org/redisson/api/RBlockingDequeAsync.java b/redisson/src/main/java/org/redisson/api/RBlockingDequeAsync.java index e2929d548..e405da925 100644 --- a/redisson/src/main/java/org/redisson/api/RBlockingDequeAsync.java +++ b/redisson/src/main/java/org/redisson/api/RBlockingDequeAsync.java @@ -31,13 +31,13 @@ public interface RBlockingDequeAsync extends RDequeAsync, RBlockingQueueAs * waiting up to the specified wait time if necessary for an element to become available * in any of defined queues including queue own. * + * @param queueNames - names of queue * @param timeout how long to wait before giving up, in units of * {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the * {@code timeout} parameter * @return the head of this queue, or {@code null} if the * specified waiting time elapses before an element is available - * @throws InterruptedException if interrupted while waiting */ RFuture pollFirstFromAnyAsync(long timeout, TimeUnit unit, String ... queueNames); @@ -45,14 +45,14 @@ public interface RBlockingDequeAsync extends RDequeAsync, RBlockingQueueAs * Retrieves and removes first available tail element of any queue in async mode, * waiting up to the specified wait time if necessary for an element to become available * in any of defined queues including queue own. - * + * + * @param queueNames - names of queue * @param timeout how long to wait before giving up, in units of * {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the * {@code timeout} parameter * @return the head of this queue, or {@code null} if the * specified waiting time elapses before an element is available - * @throws InterruptedException if interrupted while waiting */ RFuture pollLastFromAnyAsync(long timeout, TimeUnit unit, String ... queueNames); diff --git a/redisson/src/main/java/org/redisson/api/RBlockingQueue.java b/redisson/src/main/java/org/redisson/api/RBlockingQueue.java index 3b8726744..b39c79c5d 100644 --- a/redisson/src/main/java/org/redisson/api/RBlockingQueue.java +++ b/redisson/src/main/java/org/redisson/api/RBlockingQueue.java @@ -31,6 +31,7 @@ public interface RBlockingQueue extends BlockingQueue, RQueue, RBlockin * waiting up to the specified wait time if necessary for an element to become available * in any of defined queues including queue own. * + * @param queueNames - names of queue * @param timeout how long to wait before giving up, in units of * {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the diff --git a/redisson/src/main/java/org/redisson/api/RBlockingQueueAsync.java b/redisson/src/main/java/org/redisson/api/RBlockingQueueAsync.java index 932d503f7..d52047bce 100644 --- a/redisson/src/main/java/org/redisson/api/RBlockingQueueAsync.java +++ b/redisson/src/main/java/org/redisson/api/RBlockingQueueAsync.java @@ -32,13 +32,13 @@ public interface RBlockingQueueAsync extends RQueueAsync { * waiting up to the specified wait time if necessary for an element to become available * in any of defined queues including queue own. * + * @param queueNames - names of queue * @param timeout how long to wait before giving up, in units of * {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the * {@code timeout} parameter * @return Future object with the head of this queue, or {@code null} if the * specified waiting time elapses before an element is available - * @throws InterruptedException if interrupted while waiting */ RFuture pollFromAnyAsync(long timeout, TimeUnit unit, String ... queueNames); @@ -104,7 +104,6 @@ public interface RBlockingQueueAsync extends RQueueAsync { * {@code timeout} parameter * @return the head of this queue, or {@code null} if the * specified waiting time elapses before an element is available - * @throws InterruptedException if interrupted while waiting */ RFuture pollAsync(long timeout, TimeUnit unit); @@ -113,7 +112,6 @@ public interface RBlockingQueueAsync extends RQueueAsync { * until an element becomes available. * * @return the head of this queue - * @throws InterruptedException if interrupted while waiting */ RFuture takeAsync(); @@ -122,12 +120,12 @@ public interface RBlockingQueueAsync extends RQueueAsync { * for space to become available. * * @param e the element to add - * @throws InterruptedException if interrupted while waiting * @throws ClassCastException if the class of the specified element * prevents it from being added to this queue * @throws NullPointerException if the specified element is null * @throws IllegalArgumentException if some property of the specified * element prevents it from being added to this queue + * @return void */ RFuture putAsync(V e); diff --git a/redisson/src/main/java/org/redisson/api/RBlockingQueueReactive.java b/redisson/src/main/java/org/redisson/api/RBlockingQueueReactive.java index 61f7a2757..e3a8f1747 100644 --- a/redisson/src/main/java/org/redisson/api/RBlockingQueueReactive.java +++ b/redisson/src/main/java/org/redisson/api/RBlockingQueueReactive.java @@ -34,13 +34,13 @@ public interface RBlockingQueueReactive extends RQueueReactive { * waiting up to the specified wait time if necessary for an element to become available * in any of defined queues including queue own. * + * @param queueNames - names of queue * @param timeout how long to wait before giving up, in units of * {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the * {@code timeout} parameter * @return Publisher object with the head of this queue, or {@code null} if the * specified waiting time elapses before an element is available - * @throws InterruptedException if interrupted while waiting */ Publisher pollFromAny(long timeout, TimeUnit unit, String ... queueNames); diff --git a/redisson/src/main/java/org/redisson/api/RBloomFilter.java b/redisson/src/main/java/org/redisson/api/RBloomFilter.java index 455c3ff13..b1bd46c5c 100644 --- a/redisson/src/main/java/org/redisson/api/RBloomFilter.java +++ b/redisson/src/main/java/org/redisson/api/RBloomFilter.java @@ -22,7 +22,7 @@ package org.redisson.api; * * @author Nikita Koksharov * - * @param + * @param - type of object */ public interface RBloomFilter extends RExpirable { @@ -35,8 +35,8 @@ public interface RBloomFilter extends RExpirable { * calculated from expectedInsertions and falseProbability * Stores config to Redis server. * - * @param expectedInsertions - * @param falseProbability + * @param expectedInsertions - expected amount of insertions + * @param falseProbability - expected false probability * @return true if Bloom filter initialized * false if Bloom filter already has been initialized */ @@ -53,7 +53,7 @@ public interface RBloomFilter extends RExpirable { /** * Calculates probabilistic number of elements already added to Bloom filter. * - * @return + * @return probabilistic number of elements */ int count(); diff --git a/redisson/src/main/java/org/redisson/api/RBoundedBlockingQueueAsync.java b/redisson/src/main/java/org/redisson/api/RBoundedBlockingQueueAsync.java index bbf4294e2..7d9fa9194 100644 --- a/redisson/src/main/java/org/redisson/api/RBoundedBlockingQueueAsync.java +++ b/redisson/src/main/java/org/redisson/api/RBoundedBlockingQueueAsync.java @@ -46,7 +46,6 @@ public interface RBoundedBlockingQueueAsync extends RBlockingQueueAsync { * {@code timeout} parameter * @return {@code true} if successful, or {@code false} if * the specified waiting time elapses before space is available - * @throws InterruptedException if interrupted while waiting * @throws ClassCastException if the class of the specified element * prevents it from being added to this queue * @throws NullPointerException if the specified element is null diff --git a/redisson/src/main/java/org/redisson/api/RBuckets.java b/redisson/src/main/java/org/redisson/api/RBuckets.java index 88d0e6d84..bda58ea38 100644 --- a/redisson/src/main/java/org/redisson/api/RBuckets.java +++ b/redisson/src/main/java/org/redisson/api/RBuckets.java @@ -30,18 +30,20 @@ public interface RBuckets { * h[^e]llo matches hallo, hbllo, ... but not hello * h[a-b]llo matches hallo and hbllo *

Use \ to escape special characters if you want to match them verbatim. - * - * @param pattern - * @return + * + * @param type of value + * @param pattern - pattern of key + * @return List of bucket objects */ List> find(String pattern); /** * Returns Redis object mapped by key. Result Map is not contains * key-value entry for null values. - * - * @param keys - * @return + * + * @param type of value + * @param keys - keys + * @return Map with name of bucket as key and bucket as value */ Map get(String ... keys); @@ -50,14 +52,15 @@ public interface RBuckets { * If at least one of them is already exist then * don't set none of them. * - * @param buckets + * @param buckets - map of buckets + * @return true if object has been set overwise false */ boolean trySet(Map buckets); /** * Saves objects mapped by Redis key. * - * @param buckets + * @param buckets - map of buckets */ void set(Map buckets); diff --git a/redisson/src/main/java/org/redisson/api/RCollectionAsync.java b/redisson/src/main/java/org/redisson/api/RCollectionAsync.java index 213bc83bb..cf458b079 100644 --- a/redisson/src/main/java/org/redisson/api/RCollectionAsync.java +++ b/redisson/src/main/java/org/redisson/api/RCollectionAsync.java @@ -81,7 +81,7 @@ public interface RCollectionAsync extends RExpirableAsync { /** * Returns the number of elements in this collection. * - * @return + * @return size of collection */ RFuture sizeAsync(); diff --git a/redisson/src/main/java/org/redisson/api/RCountDownLatchAsync.java b/redisson/src/main/java/org/redisson/api/RCountDownLatchAsync.java index 116ba10e6..a9c2c3cd7 100644 --- a/redisson/src/main/java/org/redisson/api/RCountDownLatchAsync.java +++ b/redisson/src/main/java/org/redisson/api/RCountDownLatchAsync.java @@ -19,7 +19,7 @@ package org.redisson.api; * Distributed alternative to the {@link java.util.concurrent.CountDownLatch} * * It has an advantage over {@link java.util.concurrent.CountDownLatch} -- - * count can be set via {@link #trySetCount} method. + * count can be set via {@link #trySetCountAsync} method. * * @author Nikita Koksharov * @@ -35,6 +35,8 @@ public interface RCountDownLatchAsync extends RObjectAsync { * thread scheduling purposes. * *

If the current count equals zero then nothing happens. + * + * @return void */ RFuture countDownAsync(); @@ -51,8 +53,8 @@ public interface RCountDownLatchAsync extends RObjectAsync { * Sets new count value only if previous count already has reached zero * or is not set at all. * - * @param count - number of times {@link #countDown} must be invoked - * before threads can pass through {@link #await} + * @param count - number of times countDown must be invoked + * before threads can pass through await * @return true if new count setted * false if previous count has not reached zero */ diff --git a/redisson/src/main/java/org/redisson/api/RExecutorService.java b/redisson/src/main/java/org/redisson/api/RExecutorService.java index 664eabe79..a64cefe8e 100644 --- a/redisson/src/main/java/org/redisson/api/RExecutorService.java +++ b/redisson/src/main/java/org/redisson/api/RExecutorService.java @@ -28,7 +28,7 @@ public interface RExecutorService extends ExecutorService, RExecutorServiceAsync /** * Returns executor name * - * @return + * @return name of service */ String getName(); @@ -43,6 +43,7 @@ public interface RExecutorService extends ExecutorService, RExecutorServiceAsync * Register workers using custom executor to execute each task * * @param workers - workers amount + * @param executor - executor instance */ void registerWorkers(int workers, ExecutorService executor); diff --git a/redisson/src/main/java/org/redisson/api/RExecutorServiceAsync.java b/redisson/src/main/java/org/redisson/api/RExecutorServiceAsync.java index f5d99692a..e8e66c365 100644 --- a/redisson/src/main/java/org/redisson/api/RExecutorServiceAsync.java +++ b/redisson/src/main/java/org/redisson/api/RExecutorServiceAsync.java @@ -35,16 +35,17 @@ public interface RExecutorServiceAsync { /** * Submit task for execution in async mode with listeners support * - * @param task - * @return + * @param type of return value + * @param task - task to execute + * @return Future object */ RFuture submitAsync(Callable task); /** * Submit task for execution in async mode with listeners support * - * @param task - * @return + * @param task - task to execute + * @return Future object */ RFuture submitAsync(Runnable task); diff --git a/redisson/src/main/java/org/redisson/api/RFuture.java b/redisson/src/main/java/org/redisson/api/RFuture.java index bc0a1c0f6..56c925e05 100644 --- a/redisson/src/main/java/org/redisson/api/RFuture.java +++ b/redisson/src/main/java/org/redisson/api/RFuture.java @@ -24,13 +24,15 @@ import io.netty.util.concurrent.FutureListener; * * @author Nikita Koksharov * - * @param + * @param type of value */ public interface RFuture extends java.util.concurrent.Future { /** * Returns {@code true} if and only if the I/O operation was completed * successfully. + * + * @return {@code true} if future was completed successfully */ boolean isSuccess(); @@ -49,6 +51,8 @@ public interface RFuture extends java.util.concurrent.Future { * * As it is possible that a {@code null} value is used to mark the future as successful you also need to check * if the future is really done with {@link #isDone()} and not relay on the returned {@code null} value. + * + * @return object */ V getNow(); @@ -56,6 +60,8 @@ public interface RFuture extends java.util.concurrent.Future { * Waits for this future to be completed within the * specified time limit. * + * @param timeout - wait timeout + * @param unit - time unit * @return {@code true} if and only if the future was completed within * the specified time limit * @@ -68,6 +74,7 @@ public interface RFuture extends java.util.concurrent.Future { * Waits for this future to be completed within the * specified time limit. * + * @param timeoutMillis - timeout value * @return {@code true} if and only if the future was completed within * the specified time limit * @@ -81,6 +88,9 @@ public interface RFuture extends java.util.concurrent.Future { * specified listener is notified when this future is * {@linkplain #isDone() done}. If this future is already * completed, the specified listener is notified immediately. + * + * @param listener - listener for future object + * @return Future object */ RFuture addListener(FutureListener listener); @@ -89,6 +99,9 @@ public interface RFuture extends java.util.concurrent.Future { * specified listeners are notified when this future is * {@linkplain #isDone() done}. If this future is already * completed, the specified listeners are notified immediately. + * + * @param listeners - listeners for future object + * @return Future object */ RFuture addListeners(FutureListener... listeners); @@ -98,6 +111,9 @@ public interface RFuture extends java.util.concurrent.Future { * future is {@linkplain #isDone() done}. If the specified * listener is not associated with this future, this method * does nothing and returns silently. + * + * @param listener - listener for future object + * @return Future object */ RFuture removeListener(FutureListener listener); @@ -107,18 +123,27 @@ public interface RFuture extends java.util.concurrent.Future { * future is {@linkplain #isDone() done}. If the specified * listeners are not associated with this future, this method * does nothing and returns silently. + * + * @param listeners - listeners for future object + * @return Future object */ RFuture removeListeners(FutureListener... listeners); /** * Waits for this future until it is done, and rethrows the cause of the failure if this future * failed. + * + * @throws InterruptedException + * if the current thread was interrupted + * @return Future object */ RFuture sync() throws InterruptedException; /** * Waits for this future until it is done, and rethrows the cause of the failure if this future * failed. + * + * @return Future object */ RFuture syncUninterruptibly(); @@ -127,6 +152,7 @@ public interface RFuture extends java.util.concurrent.Future { * * @throws InterruptedException * if the current thread was interrupted + * @return Future object */ RFuture await() throws InterruptedException; @@ -134,6 +160,8 @@ public interface RFuture extends java.util.concurrent.Future { * Waits for this future to be completed without * interruption. This method catches an {@link InterruptedException} and * discards it silently. + * + * @return Future object */ RFuture awaitUninterruptibly(); @@ -142,6 +170,8 @@ public interface RFuture extends java.util.concurrent.Future { * specified time limit without interruption. This method catches an * {@link InterruptedException} and discards it silently. * + * @param timeout - timeout value + * @param unit - timeout unit value * @return {@code true} if and only if the future was completed within * the specified time limit */ @@ -151,7 +181,8 @@ public interface RFuture extends java.util.concurrent.Future { * Waits for this future to be completed within the * specified time limit without interruption. This method catches an * {@link InterruptedException} and discards it silently. - * + * + * @param timeoutMillis - timeout value * @return {@code true} if and only if the future was completed within * the specified time limit */ diff --git a/redisson/src/main/java/org/redisson/api/RGeo.java b/redisson/src/main/java/org/redisson/api/RGeo.java index 03de38d09..9d55b3ceb 100644 --- a/redisson/src/main/java/org/redisson/api/RGeo.java +++ b/redisson/src/main/java/org/redisson/api/RGeo.java @@ -23,14 +23,16 @@ import java.util.Map; * * @author Nikita Koksharov * - * @param + * @param type of value */ public interface RGeo extends RExpirable, RGeoAsync { /** * Adds geospatial member. * - * @param entries + * @param longitude - longitude of object + * @param latitude - latitude of object + * @param member - object itself * @return number of elements added to the sorted set, * not including elements already existing for which * the score was updated @@ -40,7 +42,7 @@ public interface RGeo extends RExpirable, RGeoAsync { /** * Adds geospatial members. * - * @param entries + * @param entries - objects * @return number of elements added to the sorted set, * not including elements already existing for which * the score was updated @@ -50,28 +52,26 @@ public interface RGeo extends RExpirable, RGeoAsync { /** * Returns distance between members in GeoUnit units. * - * @see {@link GeoUnit} - * - * @param firstMember - * @param secondMember - * @param geoUnit - * @return + * @param firstMember - first object + * @param secondMember - second object + * @param geoUnit - geo unit + * @return distance */ Double dist(V firstMember, V secondMember, GeoUnit geoUnit); /** * Returns 11 characters Geohash string mapped by defined member. * - * @param members - * @return + * @param members - objects + * @return hash mapped by object */ Map hash(V... members); /** * Returns geo-position mapped by defined member. * - * @param members - * @return + * @param members - objects + * @return geo position mapped by object */ Map pos(V... members); @@ -81,11 +81,11 @@ public interface RGeo extends RExpirable, RGeoAsync { * and the maximum distance from the center (the radius) * in GeoUnit units. * - * @param longitude - * @param latitude - * @param radius - * @param geoUnit - * @return + * @param longitude - longitude of object + * @param latitude - latitude of object + * @param radius - radius in geo units + * @param geoUnit - geo unit + * @return list of objects */ List radius(double longitude, double latitude, double radius, GeoUnit geoUnit); @@ -96,11 +96,11 @@ public interface RGeo extends RExpirable, RGeoAsync { * and the maximum distance from the center (the radius) * in GeoUnit units. * - * @param longitude - * @param latitude - * @param radius - * @param geoUnit - * @return + * @param longitude - longitude of object + * @param latitude - latitude of object + * @param radius - radius in geo units + * @param geoUnit - geo unit + * @return distance mapped by object */ Map radiusWithDistance(double longitude, double latitude, double radius, GeoUnit geoUnit); @@ -111,11 +111,11 @@ public interface RGeo extends RExpirable, RGeoAsync { * and the maximum distance from the center (the radius) * in GeoUnit units. * - * @param longitude - * @param latitude - * @param radius - * @param geoUnit - * @return + * @param longitude - longitude of object + * @param latitude - latitude of object + * @param radius - radius in geo units + * @param geoUnit - geo unit + * @return geo position mapped by object */ Map radiusWithPosition(double longitude, double latitude, double radius, GeoUnit geoUnit); @@ -125,11 +125,10 @@ public interface RGeo extends RExpirable, RGeoAsync { * and the maximum distance from the defined member location (the radius) * in GeoUnit units. * - * @param longitude - * @param latitude - * @param radius - * @param geoUnit - * @return + * @param member - object + * @param radius - radius in geo units + * @param geoUnit - geo unit + * @return list of objects */ List radius(V member, double radius, GeoUnit geoUnit); @@ -140,11 +139,10 @@ public interface RGeo extends RExpirable, RGeoAsync { * and the maximum distance from the defined member location (the radius) * in GeoUnit units. * - * @param longitude - * @param latitude - * @param radius - * @param geoUnit - * @return + * @param member - object + * @param radius - radius in geo units + * @param geoUnit - geo unit + * @return distance mapped by object */ Map radiusWithDistance(V member, double radius, GeoUnit geoUnit); @@ -155,11 +153,10 @@ public interface RGeo extends RExpirable, RGeoAsync { * and the maximum distance from the defined member location (the radius) * in GeoUnit units. * - * @param longitude - * @param latitude - * @param radius - * @param geoUnit - * @return + * @param member - object + * @param radius - radius in geo units + * @param geoUnit - geo unit + * @return geo position mapped by object */ Map radiusWithPosition(V member, double radius, GeoUnit geoUnit); diff --git a/redisson/src/main/java/org/redisson/api/RGeoAsync.java b/redisson/src/main/java/org/redisson/api/RGeoAsync.java index e0a5483d9..a1e379fbe 100644 --- a/redisson/src/main/java/org/redisson/api/RGeoAsync.java +++ b/redisson/src/main/java/org/redisson/api/RGeoAsync.java @@ -22,14 +22,16 @@ import java.util.Map; * * @author Nikita Koksharov * - * @param + * @param type of value */ public interface RGeoAsync extends RExpirableAsync { /** * Adds geospatial member. * - * @param entries + * @param longitude - longitude of object + * @param latitude - latitude of object + * @param member - object itself * @return number of elements added to the sorted set, * not including elements already existing for which * the score was updated @@ -39,7 +41,7 @@ public interface RGeoAsync extends RExpirableAsync { /** * Adds geospatial members. * - * @param entries + * @param entries - objects * @return number of elements added to the sorted set, * not including elements already existing for which * the score was updated @@ -49,28 +51,26 @@ public interface RGeoAsync extends RExpirableAsync { /** * Returns distance between members in GeoUnit units. * - * @see {@link GeoUnit} - * - * @param firstMember - * @param secondMember - * @param geoUnit - * @return + * @param firstMember - first object + * @param secondMember - second object + * @param geoUnit - geo unit + * @return distance */ RFuture distAsync(V firstMember, V secondMember, GeoUnit geoUnit); /** * Returns 11 characters Geohash string mapped by defined member. * - * @param members - * @return + * @param members - objects + * @return hash mapped by object */ RFuture> hashAsync(V... members); /** * Returns geo-position mapped by defined member. * - * @param members - * @return + * @param members - objects + * @return geo position mapped by object */ RFuture> posAsync(V... members); @@ -80,11 +80,11 @@ public interface RGeoAsync extends RExpirableAsync { * and the maximum distance from the center (the radius) * in GeoUnit units. * - * @param longitude - * @param latitude - * @param radius - * @param geoUnit - * @return + * @param longitude - longitude of object + * @param latitude - latitude of object + * @param radius - radius in geo units + * @param geoUnit - geo unit + * @return list of objects */ RFuture> radiusAsync(double longitude, double latitude, double radius, GeoUnit geoUnit); @@ -95,11 +95,11 @@ public interface RGeoAsync extends RExpirableAsync { * and the maximum distance from the center (the radius) * in GeoUnit units. * - * @param longitude - * @param latitude - * @param radius - * @param geoUnit - * @return + * @param longitude - longitude of object + * @param latitude - latitude of object + * @param radius - radius in geo units + * @param geoUnit - geo unit + * @return distance mapped by object */ RFuture> radiusWithDistanceAsync(double longitude, double latitude, double radius, GeoUnit geoUnit); @@ -110,11 +110,11 @@ public interface RGeoAsync extends RExpirableAsync { * and the maximum distance from the center (the radius) * in GeoUnit units. * - * @param longitude - * @param latitude - * @param radius - * @param geoUnit - * @return + * @param longitude - longitude of object + * @param latitude - latitude of object + * @param radius - radius in geo units + * @param geoUnit - geo unit + * @return geo position mapped by object */ RFuture> radiusWithPositionAsync(double longitude, double latitude, double radius, GeoUnit geoUnit); @@ -124,11 +124,10 @@ public interface RGeoAsync extends RExpirableAsync { * and the maximum distance from the defined member location (the radius) * in GeoUnit units. * - * @param longitude - * @param latitude - * @param radius - * @param geoUnit - * @return + * @param member - object + * @param radius - radius in geo units + * @param geoUnit - geo unit + * @return list of objects */ RFuture> radiusAsync(V member, double radius, GeoUnit geoUnit); @@ -139,11 +138,10 @@ public interface RGeoAsync extends RExpirableAsync { * and the maximum distance from the defined member location (the radius) * in GeoUnit units. * - * @param longitude - * @param latitude - * @param radius - * @param geoUnit - * @return + * @param member - object + * @param radius - radius in geo units + * @param geoUnit - geo unit + * @return distance mapped by object */ RFuture> radiusWithDistanceAsync(V member, double radius, GeoUnit geoUnit); @@ -154,11 +152,10 @@ public interface RGeoAsync extends RExpirableAsync { * and the maximum distance from the defined member location (the radius) * in GeoUnit units. * - * @param longitude - * @param latitude - * @param radius - * @param geoUnit - * @return + * @param member - object + * @param radius - radius in geo units + * @param geoUnit - geo unit + * @return geo position mapped by object */ RFuture> radiusWithPositionAsync(V member, double radius, GeoUnit geoUnit); diff --git a/redisson/src/main/java/org/redisson/api/RKeys.java b/redisson/src/main/java/org/redisson/api/RKeys.java index ca5dd518d..f904a0ef9 100644 --- a/redisson/src/main/java/org/redisson/api/RKeys.java +++ b/redisson/src/main/java/org/redisson/api/RKeys.java @@ -40,13 +40,13 @@ public interface RKeys extends RKeysAsync { * Get all keys by pattern using iterator. * Keys traversed with SCAN operation. Each SCAN operation loads * up to 10 keys per request. - *

+ *

* Supported glob-style patterns: - *

+ *

* h?llo subscribes to hello, hallo and hxllo - *

+ *

* h*llo subscribes to hllo and heeeello - *

+ *

* h[ae]llo subscribes to hello and hallo, but not hillo * * @param pattern - match pattern @@ -58,13 +58,13 @@ public interface RKeys extends RKeysAsync { * Get all keys by pattern using iterator. * Keys traversed with SCAN operation. Each SCAN operation loads * up to count keys per request. - *

+ *

* Supported glob-style patterns: - *

+ *

* h?llo subscribes to hello, hallo and hxllo - *

+ *

* h*llo subscribes to hllo and heeeello - *

+ *

* h[ae]llo subscribes to hello and hallo, but not hillo * * @param pattern - match pattern @@ -102,9 +102,9 @@ public interface RKeys extends RKeysAsync { /** * Delete multiple objects by a key pattern. - *

+ *

* Method executes in NON atomic way in cluster mode due to lua script limitations. - *

+ *

* Supported glob-style patterns: * h?llo subscribes to hello, hallo and hxllo * h*llo subscribes to hllo and heeeello diff --git a/redisson/src/main/java/org/redisson/api/RKeysAsync.java b/redisson/src/main/java/org/redisson/api/RKeysAsync.java index 903029adf..f0cb30b94 100644 --- a/redisson/src/main/java/org/redisson/api/RKeysAsync.java +++ b/redisson/src/main/java/org/redisson/api/RKeysAsync.java @@ -58,9 +58,9 @@ public interface RKeysAsync { /** * Delete multiple objects by a key pattern. - *

+ *

* Method executes in NON atomic way in cluster mode due to lua script limitations. - *

+ *

* Supported glob-style patterns: * h?llo subscribes to hello, hallo and hxllo * h*llo subscribes to hllo and heeeello diff --git a/redisson/src/main/java/org/redisson/api/RMapCache.java b/redisson/src/main/java/org/redisson/api/RMapCache.java index 8731a26fa..0f2652fde 100644 --- a/redisson/src/main/java/org/redisson/api/RMapCache.java +++ b/redisson/src/main/java/org/redisson/api/RMapCache.java @@ -41,10 +41,10 @@ public interface RMapCache extends RMap, RMapCacheAsync { /** * If the specified key is not already associated * with a value, associate it with the given value. - *

+ *

* Stores value mapped by key with specified time to live. * Entry expires after specified time to live. - *

+ *

* If the map previously contained a mapping for * the key, the old value is replaced by the specified value. * @@ -60,10 +60,10 @@ public interface RMapCache extends RMap, RMapCacheAsync { /** * If the specified key is not already associated * with a value, associate it with the given value. - *

+ *

* Stores value mapped by key with specified time to live and max idle time. * Entry expires when specified time to live or max idle time has expired. - *

+ *

* If the map previously contained a mapping for * the key, the old value is replaced by the specified value. * @@ -75,7 +75,7 @@ public interface RMapCache extends RMap, RMapCacheAsync { * @param maxIdleTime - max idle time for key\value entry. * If 0 then max idle time doesn't affect entry expiration. * @param maxIdleUnit - *

+ *

* if maxIdleTime and ttl params are equal to 0 * then entry stores infinitely. * @@ -86,7 +86,7 @@ public interface RMapCache extends RMap, RMapCacheAsync { /** * Stores value mapped by key with specified time to live. * Entry expires after specified time to live. - *

+ *

* If the map previously contained a mapping for * the key, the old value is replaced by the specified value. * @@ -102,7 +102,7 @@ public interface RMapCache extends RMap, RMapCacheAsync { /** * Stores value mapped by key with specified time to live and max idle time. * Entry expires when specified time to live or max idle time has expired. - *

+ *

* If the map previously contained a mapping for * the key, the old value is replaced by the specified value. * @@ -114,7 +114,7 @@ public interface RMapCache extends RMap, RMapCacheAsync { * @param maxIdleTime - max idle time for key\value entry. * If 0 then max idle time doesn't affect entry expiration. * @param maxIdleUnit - *

+ *

* if maxIdleTime and ttl params are equal to 0 * then entry stores infinitely. * @@ -125,10 +125,10 @@ public interface RMapCache extends RMap, RMapCacheAsync { /** * Stores value mapped by key with specified time to live. * Entry expires after specified time to live. - *

+ *

* If the map previously contained a mapping for * the key, the old value is replaced by the specified value. - *

+ *

* Works faster than usual {@link #put(Object, Object, long, TimeUnit)} * as it not returns previous value. * @@ -144,10 +144,10 @@ public interface RMapCache extends RMap, RMapCacheAsync { /** * Stores value mapped by key with specified time to live and max idle time. * Entry expires when specified time to live or max idle time has expired. - *

+ *

* If the map previously contained a mapping for * the key, the old value is replaced by the specified value. - *

+ *

* Works faster than usual {@link #put(Object, Object, long, TimeUnit, long, TimeUnit)} * as it not returns previous value. * @@ -159,7 +159,7 @@ public interface RMapCache extends RMap, RMapCacheAsync { * @param maxIdleTime - max idle time for key\value entry. * If 0 then max idle time doesn't affect entry expiration. * @param maxIdleUnit - *

+ *

* if maxIdleTime and ttl params are equal to 0 * then entry stores infinitely. diff --git a/redisson/src/main/java/org/redisson/api/RMapCacheAsync.java b/redisson/src/main/java/org/redisson/api/RMapCacheAsync.java index 85bcb9850..8397c96e5 100644 --- a/redisson/src/main/java/org/redisson/api/RMapCacheAsync.java +++ b/redisson/src/main/java/org/redisson/api/RMapCacheAsync.java @@ -41,7 +41,7 @@ public interface RMapCacheAsync extends RMapAsync { /** * If the specified key is not already associated * with a value, associate it with the given value. - *

+ *

* Stores value mapped by key with specified time to live. * Entry expires after specified time to live. * If the map previously contained a mapping for @@ -59,10 +59,10 @@ public interface RMapCacheAsync extends RMapAsync { /** * If the specified key is not already associated * with a value, associate it with the given value. - *

+ *

* Stores value mapped by key with specified time to live and max idle time. * Entry expires when specified time to live or max idle time has expired. - *

+ *

* If the map previously contained a mapping for * the key, the old value is replaced by the specified value. * @@ -74,7 +74,7 @@ public interface RMapCacheAsync extends RMapAsync { * @param maxIdleTime - max idle time for key\value entry. * If 0 then max idle time doesn't affect entry expiration. * @param maxIdleUnit - *

+ *

* if maxIdleTime and ttl params are equal to 0 * then entry stores infinitely. * @@ -100,7 +100,7 @@ public interface RMapCacheAsync extends RMapAsync { /** * Stores value mapped by key with specified time to live and max idle time. * Entry expires when specified time to live or max idle time has expired. - *

+ *

* If the map previously contained a mapping for * the key, the old value is replaced by the specified value. * @@ -112,7 +112,7 @@ public interface RMapCacheAsync extends RMapAsync { * @param maxIdleTime - max idle time for key\value entry. * If 0 then max idle time doesn't affect entry expiration. * @param maxIdleUnit - *

+ *

* if maxIdleTime and ttl params are equal to 0 * then entry stores infinitely. * @@ -123,10 +123,10 @@ public interface RMapCacheAsync extends RMapAsync { /** * Stores value mapped by key with specified time to live. * Entry expires after specified time to live. - *

+ *

* If the map previously contained a mapping for * the key, the old value is replaced by the specified value. - *

+ *

* Works faster than usual {@link #put(Object, Object, long, TimeUnit)} * as it not returns previous value. * @@ -142,10 +142,10 @@ public interface RMapCacheAsync extends RMapAsync { /** * Stores value mapped by key with specified time to live and max idle time. * Entry expires when specified time to live or max idle time has expired. - *

+ *

* If the map previously contained a mapping for * the key, the old value is replaced by the specified value. - *

+ *

* Works faster than usual {@link #put(Object, Object, long, TimeUnit, long, TimeUnit)} * as it not returns previous value. * @@ -157,7 +157,7 @@ public interface RMapCacheAsync extends RMapAsync { * @param maxIdleTime - max idle time for key\value entry. * If 0 then max idle time doesn't affect entry expiration. * @param maxIdleUnit - *

+ *

* if maxIdleTime and ttl params are equal to 0 * then entry stores infinitely. diff --git a/redisson/src/main/java/org/redisson/api/RObject.java b/redisson/src/main/java/org/redisson/api/RObject.java index 5a25b7f7a..ca93b1b13 100644 --- a/redisson/src/main/java/org/redisson/api/RObject.java +++ b/redisson/src/main/java/org/redisson/api/RObject.java @@ -31,14 +31,13 @@ public interface RObject extends RObjectAsync { * @param host - destination host * @param port - destination port * @param database - destination database - * @return */ void migrate(String host, int port, int database); /** * Move object to another database * - * @param database + * @param database - Redis database number * @return true if key was moved else false */ boolean move(int database); @@ -46,19 +45,21 @@ public interface RObject extends RObjectAsync { /** * Returns name of object * - * @return name + * @return name - name of object */ String getName(); /** * Deletes the object + * + * @return true if it was exist and deleted else false */ boolean delete(); /** * Rename current object key to newName * - * @param newName + * @param newName - new name of object */ void rename(String newName); @@ -66,8 +67,8 @@ public interface RObject extends RObjectAsync { * Rename current object key to newName * only if new key is not exists * - * @param newName - * @return + * @param newName - new name of object + * @return true if object has been renamed successfully and false otherwise */ boolean renamenx(String newName); @@ -81,7 +82,7 @@ public interface RObject extends RObjectAsync { /** * Returns the underlying Codec used by this RObject * - * @return + * @return Codec of object */ Codec getCodec(); } diff --git a/redisson/src/main/java/org/redisson/api/RObjectAsync.java b/redisson/src/main/java/org/redisson/api/RObjectAsync.java index 900e31fac..2747eb892 100644 --- a/redisson/src/main/java/org/redisson/api/RObjectAsync.java +++ b/redisson/src/main/java/org/redisson/api/RObjectAsync.java @@ -30,14 +30,14 @@ public interface RObjectAsync { * @param host - destination host * @param port - destination port * @param database - destination database - * @return + * @return void */ RFuture migrateAsync(String host, int port, int database); /** * Move object to another database in async mode * - * @param database + * @param database - number of Redis database * @return true if key was moved false if not */ RFuture moveAsync(int database); @@ -53,8 +53,8 @@ public interface RObjectAsync { * Rename current object key to newName * in async mode * - * @param newName - * @return + * @param newName - new name of object + * @return void */ RFuture renameAsync(String newName); @@ -62,8 +62,8 @@ public interface RObjectAsync { * Rename current object key to newName * in async mode only if new key is not exists * - * @param newName - * @return + * @param newName - new name of object + * @return true if object has been renamed successfully and false otherwise */ RFuture renamenxAsync(String newName); diff --git a/redisson/src/main/java/org/redisson/api/RObjectReactive.java b/redisson/src/main/java/org/redisson/api/RObjectReactive.java index 87f0e0f3f..175d49441 100644 --- a/redisson/src/main/java/org/redisson/api/RObjectReactive.java +++ b/redisson/src/main/java/org/redisson/api/RObjectReactive.java @@ -36,14 +36,14 @@ public interface RObjectReactive { * @param host - destination host * @param port - destination port * @param database - destination database - * @return + * @return void */ Publisher migrate(String host, int port, int database); /** * Move object to another database in mode * - * @param database + * @param database - number of Redis database * @return true if key was moved false if not */ Publisher move(int database); @@ -59,8 +59,8 @@ public interface RObjectReactive { * Rename current object key to newName * in mode * - * @param newName - * @return + * @param newName - new name of object + * @return void */ Publisher rename(String newName); @@ -68,8 +68,8 @@ public interface RObjectReactive { * Rename current object key to newName * in mode only if new key is not exists * - * @param newName - * @return + * @param newName - new name of object + * @return true if object has been renamed successfully and false otherwise */ Publisher renamenx(String newName); diff --git a/redisson/src/main/java/org/redisson/api/RRemoteService.java b/redisson/src/main/java/org/redisson/api/RRemoteService.java index 188cc9eef..7c06da6d6 100644 --- a/redisson/src/main/java/org/redisson/api/RRemoteService.java +++ b/redisson/src/main/java/org/redisson/api/RRemoteService.java @@ -20,36 +20,36 @@ import java.util.concurrent.TimeUnit; /** * Allows to execute object methods remotely between Redisson instances (Server side and Client side instances in terms of remote invocation). - *

+ *

* 1. Server side instance (worker instance). Register object with RRemoteService instance. - *

+ *

* * RRemoteService remoteService = redisson.getRemoteService();
*
* // register remote service before any remote invocation
* remoteService.register(SomeServiceInterface.class, someServiceImpl); *
- *

+ *

* 2. Client side instance. Invokes method remotely. - *

+ *

* * RRemoteService remoteService = redisson.getRemoteService();
* SomeServiceInterface service = remoteService.get(SomeServiceInterface.class);
*
* String result = service.doSomeStuff(1L, "secondParam", new AnyParam()); *
- *

- *

+ *

+ *

* There are two timeouts during execution: - *

+ *

* Acknowledge (Ack) timeout.Client side instance waits for acknowledge message from Server side instance. - *

+ *

* If acknowledge has not been received by Client side instance then RemoteServiceAckTimeoutException will be thrown. * And next invocation attempt can be made. - *

+ *

* If acknowledge has not been received Client side instance but Server side instance has received invocation message already. * In this case invocation will be skipped, due to ack timeout checking by Server side instance. - *

+ *

* Execution timeout. Client side instance received acknowledge message. If it hasn't received any result or error * from server side during execution timeout then RemoteServiceTimeoutException will be thrown. * @@ -88,7 +88,7 @@ public interface RRemoteService { /** * Get remote service object for remote invocations. - *

+ *

* This method is a shortcut for *

      *     get(remoteInterface, RemoteInvocationOptions.defaults())
@@ -105,7 +105,7 @@ public interface RRemoteService {
     /**
      * Get remote service object for remote invocations 
      * with specified invocation timeout.
-     * 

+ *

* This method is a shortcut for *

      *     get(remoteInterface, RemoteInvocationOptions.defaults()
@@ -125,7 +125,7 @@ public interface RRemoteService {
     /**
      * Get remote service object for remote invocations
      * with specified invocation and ack timeouts
-     * 

+ *

* This method is a shortcut for *

      *     get(remoteInterface, RemoteInvocationOptions.defaults()
@@ -148,7 +148,7 @@ public interface RRemoteService {
     /**
      * Get remote service object for remote invocations
      * with the specified options
-     * 

+ *

* Note that when using the noResult() option, * it is expected that the invoked method returns void, * or else IllegalArgumentException will be thrown. diff --git a/redisson/src/main/java/org/redisson/api/RScoredSortedSet.java b/redisson/src/main/java/org/redisson/api/RScoredSortedSet.java index 871b90253..ec2d0df92 100644 --- a/redisson/src/main/java/org/redisson/api/RScoredSortedSet.java +++ b/redisson/src/main/java/org/redisson/api/RScoredSortedSet.java @@ -65,7 +65,7 @@ public interface RScoredSortedSet extends RScoredSortedSetAsync, Iterable< /** * Adds element to this set only if has not been added before. - *

+ *

* Works only with Redis 3.0.2 and higher. * * @param score diff --git a/redisson/src/main/java/org/redisson/api/RScoredSortedSetAsync.java b/redisson/src/main/java/org/redisson/api/RScoredSortedSetAsync.java index 11fb7dad0..990cb45be 100644 --- a/redisson/src/main/java/org/redisson/api/RScoredSortedSetAsync.java +++ b/redisson/src/main/java/org/redisson/api/RScoredSortedSetAsync.java @@ -53,7 +53,7 @@ public interface RScoredSortedSetAsync extends RExpirableAsync { /** * Adds element to this set only if has not been added before. - *

+ *

* Works only with Redis 3.0.2 and higher. * * @param score diff --git a/redisson/src/main/java/org/redisson/api/RSemaphoreAsync.java b/redisson/src/main/java/org/redisson/api/RSemaphoreAsync.java index 40f44cb3d..49c9af4ed 100644 --- a/redisson/src/main/java/org/redisson/api/RSemaphoreAsync.java +++ b/redisson/src/main/java/org/redisson/api/RSemaphoreAsync.java @@ -19,7 +19,7 @@ import java.util.concurrent.TimeUnit; /** * Distributed and concurrent implementation of {@link java.util.concurrent.Semaphore}. - *

+ *

* Works in non-fair mode. Therefore order of acquiring is unpredictable. * * @author Nikita Koksharov diff --git a/redisson/src/main/java/org/redisson/api/RedissonClient.java b/redisson/src/main/java/org/redisson/api/RedissonClient.java index d0782c528..a4c7c269b 100755 --- a/redisson/src/main/java/org/redisson/api/RedissonClient.java +++ b/redisson/src/main/java/org/redisson/api/RedissonClient.java @@ -34,18 +34,20 @@ public interface RedissonClient { /** * Returns geospatial items holder instance by name. * - * @param name - * @return + * @param type of value + * @param name - name of object + * @return Geo object */ RGeo getGeo(String name); /** * Returns geospatial items holder instance by name * using provided codec for geospatial members. - * - * @param name - * @param geospatial member codec - * @return + * + * @param type of value + * @param name - name of object + * @param codec - codec for value + * @return Geo object */ RGeo getGeo(String name, Codec codec); @@ -54,10 +56,10 @@ public interface RedissonClient { * Supports value eviction with a given TTL value. * *

If eviction is not required then it's better to use regular map {@link #getSet(String, Codec)}.

- * - * @param name - * @param codec - * @return + * + * @param type of value + * @param name - name of object + * @return SetCache object */ RSetCache getSetCache(String name); @@ -66,10 +68,11 @@ public interface RedissonClient { * Supports value eviction with a given TTL value. * *

If eviction is not required then it's better to use regular map {@link #getSet(String, Codec)}.

- * - * @param name - * @param codec - * @return + * + * @param type of value + * @param name - name of object + * @param codec - codec for values + * @return SetCache object */ RSetCache getSetCache(String name, Codec codec); @@ -80,9 +83,11 @@ public interface RedissonClient { * *

If eviction is not required then it's better to use regular map {@link #getMap(String, Codec)}.

* - * @param name - * @param codec - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @param codec - codec for keys and values + * @return MapCache object */ RMapCache getMapCache(String name, Codec codec); @@ -92,16 +97,19 @@ public interface RedissonClient { * *

If eviction is not required then it's better to use regular map {@link #getMap(String)}.

* - * @param name - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @return MapCache object */ RMapCache getMapCache(String name); /** * Returns object holder instance by name. * - * @param name of object - * @return + * @param type of value + * @param name - name of object + * @return Bucket object */ RBucket getBucket(String name); @@ -109,16 +117,17 @@ public interface RedissonClient { * Returns object holder instance by name * using provided codec for object. * - * @param name of object - * @param object codec - * @return + * @param type of value + * @param name - name of object + * @param codec - codec for values + * @return Bucket object */ RBucket getBucket(String name, Codec codec); /** * Returns interface for mass operations with Bucket objects. * - * @return + * @return Buckets */ RBuckets getBuckets(); @@ -126,51 +135,58 @@ public interface RedissonClient { * Returns interface for mass operations with Bucket objects * using provided codec for object. * - * @return + * @param codec - codec for bucket objects + * @return Buckets */ RBuckets getBuckets(Codec codec); /** * Returns HyperLogLog instance by name. * - * @param name of object - * @return + * @param type of value + * @param name - name of object + * @return HyperLogLog object */ RHyperLogLog getHyperLogLog(String name); /** * Returns HyperLogLog instance by name * using provided codec for hll objects. - * - * @param name of object - * @param object codec - * @return + * + * @param type of value + * @param name - name of object + * @param codec - codec for values + * @return HyperLogLog object */ RHyperLogLog getHyperLogLog(String name, Codec codec); /** * Returns list instance by name. * - * @param name of object - * @return + * @param type of value + * @param name - name of object + * @return List object */ RList getList(String name); /** * Returns list instance by name * using provided codec for list objects. - * - * @param name of object - * @param list object codec - * @return + * + * @param type of value + * @param name - name of object + * @param codec - codec for values + * @return List object */ RList getList(String name, Codec codec); /** * Returns List based Multimap instance by name. - * - * @param name - * @return + * + * @param type of key + * @param type of value + * @param name - name of object + * @return ListMultimap object */ RListMultimap getListMultimap(String name); @@ -178,9 +194,11 @@ public interface RedissonClient { * Returns List based Multimap instance by name * using provided codec for both map keys and values. * - * @param name - * @param codec - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @param codec - codec for keys and values + * @return ListMultimap object */ RListMultimap getListMultimap(String name, Codec codec); @@ -190,8 +208,10 @@ public interface RedissonClient { * *

If eviction is not required then it's better to use regular map {@link #getSetMultimap(String)}.

* - * @param name - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @return ListMultimapCache object */ RListMultimapCache getListMultimapCache(String name); @@ -202,8 +222,11 @@ public interface RedissonClient { * *

If eviction is not required then it's better to use regular map {@link #getSetMultimap(String, Codec)}.

* - * @param name - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @param codec - codec for keys and values + * @return ListMultimapCache object */ RListMultimapCache getListMultimapCache(String name, Codec codec); @@ -211,9 +234,11 @@ public interface RedissonClient { * Returns local cached map instance by name. * Configured by parameters of options-object. * - * @param name - * @param options - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @param options - local map options + * @return LocalCachedMap object */ RLocalCachedMap getLocalCachedMap(String name, LocalCachedMapOptions options); @@ -221,18 +246,22 @@ public interface RedissonClient { * Returns local cached map instance by name * using provided codec. Configured by parameters of options-object. * - * @param name - * @param codec - * @param options - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @param codec - codec for keys and values + * @param options - local map options + * @return LocalCachedMap object */ RLocalCachedMap getLocalCachedMap(String name, Codec codec, LocalCachedMapOptions options); /** * Returns map instance by name. * - * @param name of map - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @return Map object */ RMap getMap(String name); @@ -240,17 +269,21 @@ public interface RedissonClient { * Returns map instance by name * using provided codec for both map keys and values. * - * @param name of map - * @param map key and value codec - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @param codec - codec for keys and values + * @return Map object */ RMap getMap(String name, Codec codec); /** * Returns Set based Multimap instance by name. * - * @param name - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @return SetMultimap object */ RSetMultimap getSetMultimap(String name); @@ -258,9 +291,11 @@ public interface RedissonClient { * Returns Set based Multimap instance by name * using provided codec for both map keys and values. * - * @param name - * @param codec - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @param codec - codec for keys and values + * @return SetMultimap object */ RSetMultimap getSetMultimap(String name, Codec codec); @@ -270,8 +305,10 @@ public interface RedissonClient { * *

If eviction is not required then it's better to use regular map {@link #getSetMultimap(String)}.

* - * @param name - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @return SetMultimapCache object */ RSetMultimapCache getSetMultimapCache(String name); @@ -282,16 +319,19 @@ public interface RedissonClient { * *

If eviction is not required then it's better to use regular map {@link #getSetMultimap(String, Codec)}.

* - * @param name - * @return + * @param type of key + * @param type of value + * @param name - name of object + * @param codec - codec for keys and values + * @return SetMultimapCache object */ RSetMultimapCache getSetMultimapCache(String name, Codec codec); /** * Returns semaphore instance by name * - * @param name of semaphore - * @return + * @param name - name of object + * @return Semaphore object */ RSemaphore getSemaphore(String name); @@ -299,63 +339,66 @@ public interface RedissonClient { * Returns semaphore instance by name. * Supports lease time parameter for each acquired permit. * - * @param name - * @return + * @param name - name of object + * @return PermitExpirableSemaphore object */ RPermitExpirableSemaphore getPermitExpirableSemaphore(String name); /** * Returns lock instance by name. - *

+ *

* Implements a non-fair locking so doesn't guarantees an acquire order by threads. * - * @param name of lock - * @return + * @param name - name of object + * @return Lock object */ RLock getLock(String name); /** * Returns lock instance by name. - *

+ *

* Implements a fair locking so it guarantees an acquire order by threads. * - * @param name - * @return + * @param name - name of object + * @return Lock object */ RLock getFairLock(String name); /** * Returns readWriteLock instance by name. * - * @param name - * @return + * @param name - name of object + * @return Lock object */ RReadWriteLock getReadWriteLock(String name); /** * Returns set instance by name. - * - * @param name of set - * @return + * + * @param type of value + * @param name - name of object + * @return Lock object */ RSet getSet(String name); /** * Returns set instance by name * using provided codec for set objects. - * - * @param name of set - * @param set object codec - * @return + * + * @param type of value + * @param name - name of object + * @param codec - codec for values + * @return Set object */ RSet getSet(String name, Codec codec); /** * Returns sorted set instance by name. * This sorted set uses comparator to sort objects. - * - * @param name of sorted set - * @return + * + * @param type of value + * @param name - name of object + * @return SortedSet object */ RSortedSet getSortedSet(String name); @@ -363,19 +406,21 @@ public interface RedissonClient { * Returns sorted set instance by name * using provided codec for sorted set objects. * This sorted set sorts objects using comparator. - * - * @param name of sorted set - * @param sorted set object codec - * @return + * + * @param type of value + * @param name - name of object + * @param codec - codec for values + * @return SortedSet object */ RSortedSet getSortedSet(String name, Codec codec); /** * Returns Redis Sorted Set instance by name. * This sorted set sorts objects by object score. - * - * @param name of scored sorted set - * @return + * + * @param type of value + * @param name - name of object + * @return ScoredSortedSet object */ RScoredSortedSet getScoredSortedSet(String name); @@ -383,10 +428,11 @@ public interface RedissonClient { * Returns Redis Sorted Set instance by name * using provided codec for sorted set objects. * This sorted set sorts objects by object score. - * - * @param name of scored sorted set - * @param scored sorted set object codec - * @return + * + * @param type of value + * @param name - name of object + * @param codec - codec for values + * @return ScoredSortedSet object */ RScoredSortedSet getScoredSortedSet(String name, Codec codec); @@ -394,17 +440,18 @@ public interface RedissonClient { * Returns String based Redis Sorted Set instance by name * All elements are inserted with the same score during addition, * in order to force lexicographical ordering - * - * @param name - * @return + * + * @param name - name of object + * @return LexSortedSet object */ RLexSortedSet getLexSortedSet(String name); /** * Returns topic instance by name. - * - * @param name of topic - * @return + * + * @param type of message + * @param name - name of object + * @return Topic object */ RTopic getTopic(String name); @@ -412,9 +459,10 @@ public interface RedissonClient { * Returns topic instance by name * using provided codec for messages. * - * @param name of topic - * @param message codec - * @return + * @param type of message + * @param name - name of object + * @param codec - codec for message + * @return Topic object */ RTopic getTopic(String name, Codec codec); @@ -425,9 +473,10 @@ public interface RedissonClient { * h?llo subscribes to hello, hallo and hxllo * h*llo subscribes to hllo and heeeello * h[ae]llo subscribes to hello and hallo, but not hillo - * + * + * @param type of message * @param pattern of the topic - * @return + * @return PatterTopic object */ RPatternTopic getPatternTopic(String pattern); @@ -439,18 +488,20 @@ public interface RedissonClient { * h?llo subscribes to hello, hallo and hxllo * h*llo subscribes to hllo and heeeello * h[ae]llo subscribes to hello and hallo, but not hillo - * + * + * @param type of message * @param pattern of the topic - * @param message codec - * @return + * @param codec - codec for message + * @return PatterTopic object */ RPatternTopic getPatternTopic(String pattern, Codec codec); /** * Returns unbounded queue instance by name. * - * @param name of queue - * @return + * @param type of value + * @param name - name of object + * @return Queue object */ RQueue getQueue(String name); @@ -458,121 +509,131 @@ public interface RedissonClient { * Returns unbounded queue instance by name * using provided codec for queue objects. * - * @param name of queue - * @param queue objects codec - * @return + * @param type of value + * @param name - name of object + * @param codec - codec for message + * @return Queue object */ RQueue getQueue(String name, Codec codec); /** * Returns unbounded blocking queue instance by name. - * - * @param name of queue - * @return + * + * @param type of value + * @param name - name of object + * @return BlockingQueue object */ RBlockingQueue getBlockingQueue(String name); /** * Returns unbounded blocking queue instance by name * using provided codec for queue objects. - * - * @param name of queue - * @param queue objects codec - * @return + * + * @param type of value + * @param name - name of queue + * @param codec - queue objects codec + * @return BlockingQueue object */ RBlockingQueue getBlockingQueue(String name, Codec codec); /** * Returns bounded blocking queue instance by name. * + * @param type of value * @param name of queue - * @return + * @return BoundedBlockingQueue object */ RBoundedBlockingQueue getBoundedBlockingQueue(String name); /** * Returns bounded blocking queue instance by name * using provided codec for queue objects. - * - * @param name of queue - * @param queue objects codec - * @return + * + * @param type of value + * @param name - name of queue + * @param codec - codec for values + * @return BoundedBlockingQueue object */ RBoundedBlockingQueue getBoundedBlockingQueue(String name, Codec codec); /** * Returns unbounded deque instance by name. - * - * @param name of deque - * @return + * + * @param type of value + * @param name - name of object + * @return Deque object */ RDeque getDeque(String name); /** * Returns unbounded deque instance by name * using provided codec for deque objects. - * - * @param name of deque - * @param deque objects codec - * @return + * + * @param type of value + * @param name - name of object + * @param codec - codec for values + * @return Deque object */ RDeque getDeque(String name, Codec codec); /** * Returns unbounded blocking deque instance by name. - * - * @param name of deque - * @return + * + * @param type of value + * @param name - name of object + * @return BlockingDeque object */ RBlockingDeque getBlockingDeque(String name); /** * Returns unbounded blocking deque instance by name * using provided codec for deque objects. - * - * @param name of deque - * @param deque objects codec - * @return + * + * @param type of value + * @param name - name of object + * @param codec - deque objects codec + * @return BlockingDeque object */ RBlockingDeque getBlockingDeque(String name, Codec codec); /** * Returns atomicLong instance by name. * - * @param name of atomicLong - * @return + * @param name - name of object + * @return AtomicLong object */ RAtomicLong getAtomicLong(String name); /** * Returns atomicDouble instance by name. * - * @param name of atomicLong - * @return + * @param name - name of object + * @return AtomicDouble object */ RAtomicDouble getAtomicDouble(String name); /** * Returns countDownLatch instance by name. * - * @param name of countDownLatch - * @return + * @param name - name of object + * @return CountDownLatch object */ RCountDownLatch getCountDownLatch(String name); /** * Returns bitSet instance by name. * - * @param name of bitSet - * @return + * @param name - name of object + * @return BitSet object */ RBitSet getBitSet(String name); /** * Returns bloom filter instance by name. - * - * @param name of bloom filter - * @return + * + * @param type of value + * @param name - name of object + * @return BloomFilter object */ RBloomFilter getBloomFilter(String name); @@ -580,22 +641,25 @@ public interface RedissonClient { * Returns bloom filter instance by name * using provided codec for objects. * - * @param name of bloom filter - * @return + * @param type of value + * @param name - name of object + * @param codec - codec for values + * @return BloomFilter object */ RBloomFilter getBloomFilter(String name, Codec codec); /** * Returns script operations object * - * @return + * @return Script object */ RScript getScript(); /** * Returns ScheduledExecutorService by name * - * @return + * @param name - name of object + * @return ScheduledExecutorService object */ RScheduledExecutorService getExecutorService(String name); @@ -603,14 +667,16 @@ public interface RedissonClient { * Returns ScheduledExecutorService by name * using provided codec for task, response and request serialization * - * @return + * @param name - name of object + * @param codec - codec for task, response and request + * @return ScheduledExecutorService object */ RScheduledExecutorService getExecutorService(Codec codec, String name); /** * Returns object for remote operations prefixed with the default name (redisson_remote_service) * - * @return + * @return RemoteService object */ RRemoteService getRemoteSerivce(); @@ -618,15 +684,16 @@ public interface RedissonClient { * Returns object for remote operations prefixed with the default name (redisson_remote_service) * and uses provided codec for method arguments and result. * - * @return + * @param codec - codec for response and request + * @return RemoteService object */ RRemoteService getRemoteSerivce(Codec codec); /** * Returns object for remote operations prefixed with the specified name * - * @param name The name used as the Redis key prefix for the services - * @return + * @param name - the name used as the Redis key prefix for the services + * @return RemoteService object */ RRemoteService getRemoteSerivce(String name); @@ -634,8 +701,9 @@ public interface RedissonClient { * Returns object for remote operations prefixed with the specified name * and uses provided codec for method arguments and result. * - * @param name The name used as the Redis key prefix for the services - * @return + * @param name - the name used as the Redis key prefix for the services + * @param codec - codec for response and request + * @return RemoteService object */ RRemoteService getRemoteSerivce(String name, Codec codec); @@ -645,7 +713,7 @@ public interface RedissonClient { * * See http://redis.io/topics/pipelining * - * @return + * @return Batch object */ RBatch createBatch(); @@ -653,7 +721,7 @@ public interface RedissonClient { * Returns interface with methods for Redis keys. * Each of Redis/Redisson object associated with own key * - * @return + * @return Keys object */ RKeys getKeys(); @@ -661,7 +729,7 @@ public interface RedissonClient { * Returns RedissonAttachedLiveObjectService which can be used to * retrieve live REntity(s) * - * @return + * @return LiveObjectService object */ RLiveObjectService getLiveObjectService(); @@ -698,14 +766,14 @@ public interface RedissonClient { /** * Returns the CodecProvider instance * - * @return CodecProvider + * @return CodecProvider object */ public CodecProvider getCodecProvider(); /** * Returns the ResolverProvider instance * - * @return resolverProvider + * @return ResolverProvider object */ public ResolverProvider getResolverProvider(); @@ -713,21 +781,21 @@ public interface RedissonClient { /** * Get Redis nodes group for server operations * - * @return + * @return NodesGroup object */ NodesGroup getNodesGroup(); /** * Get Redis cluster nodes group for server operations * - * @return + * @return ClusterNodesGroup object */ ClusterNodesGroup getClusterNodesGroup(); /** * Returns {@code true} if this Redisson instance has been shut down. * - * @return + * @return code true} if this Redisson instance has been shut down overwise false */ boolean isShutdown(); @@ -735,7 +803,8 @@ public interface RedissonClient { * Returns {@code true} if this Redisson instance was started to be shutdown * or was shutdown {@link #isShutdown()} already. * - * @return + * @return {@code true} if this Redisson instance was started to be shutdown + * or was shutdown {@link #isShutdown()} already. */ boolean isShuttingDown(); diff --git a/redisson/src/main/java/org/redisson/api/RedissonNodeInitializer.java b/redisson/src/main/java/org/redisson/api/RedissonNodeInitializer.java index 4720be52c..c40097d7a 100644 --- a/redisson/src/main/java/org/redisson/api/RedissonNodeInitializer.java +++ b/redisson/src/main/java/org/redisson/api/RedissonNodeInitializer.java @@ -27,7 +27,7 @@ public interface RedissonNodeInitializer { /** * Invoked during Redisson Node startup * - * @param redissonNode + * @param redissonNode - Redisson Node instance */ void onStartup(RedissonNode redissonNode); diff --git a/redisson/src/main/java/org/redisson/api/RedissonReactiveClient.java b/redisson/src/main/java/org/redisson/api/RedissonReactiveClient.java index 71a72a95f..f8f8abffc 100644 --- a/redisson/src/main/java/org/redisson/api/RedissonReactiveClient.java +++ b/redisson/src/main/java/org/redisson/api/RedissonReactiveClient.java @@ -36,9 +36,9 @@ public interface RedissonReactiveClient { * *

If eviction is not required then it's better to use regular map {@link #getSet(String, Codec)}.

* - * @param name - * @param codec - * @return + * @param type of values + * @param name - name of object + * @return SetCache object */ RSetCacheReactive getSetCache(String name); @@ -48,9 +48,10 @@ public interface RedissonReactiveClient { * *

If eviction is not required then it's better to use regular map {@link #getSet(String, Codec)}.

* - * @param name - * @param codec - * @return + * @param type of values + * @param name - name of object + * @param codec - codec for values + * @return SetCache object */ RSetCacheReactive getSetCache(String name, Codec codec); @@ -61,9 +62,11 @@ public interface RedissonReactiveClient { * *

If eviction is not required then it's better to use regular map {@link #getMap(String, Codec)}.

* - * @param name - * @param codec - * @return + * @param type of keys + * @param type of values + * @param name - name of object + * @param codec - codec for values + * @return MapCache object */ RMapCacheReactive getMapCache(String name, Codec codec); @@ -73,16 +76,19 @@ public interface RedissonReactiveClient { * *

If eviction is not required then it's better to use regular map {@link #getMap(String)}.

* - * @param name - * @return + * @param type of keys + * @param type of values + * @param name - name of object + * @return MapCache object */ RMapCacheReactive getMapCache(String name); /** * Returns object holder instance by name - * - * @param name of object - * @return + * + * @param type of value + * @param name - name of object + * @return Bucket object */ RBucketReactive getBucket(String name); @@ -90,22 +96,28 @@ public interface RedissonReactiveClient { * Returns object holder instance by name * using provided codec for object. * - * @param name of object - * @param object codec - * @return + * @param type of value + * @param name - name of object + * @param codec - codec for value + * @return Bucket object */ RBucketReactive getBucket(String name, Codec codec); /** * Returns a list of object holder instances by a key pattern + * + * @param type of value + * @param pattern - pattern for name of buckets + * @return list of buckets */ List> findBuckets(String pattern); /** * Returns HyperLogLog instance by name. - * - * @param name of object - * @return + * + * @param type of values + * @param name - name of object + * @return HyperLogLog object */ RHyperLogLogReactive getHyperLogLog(String name); @@ -113,17 +125,19 @@ public interface RedissonReactiveClient { * Returns HyperLogLog instance by name * using provided codec for hll objects. * - * @param name of object - * @param object codec - * @return + * @param type of values + * @param name - name of object + * @param codec - codec of values + * @return HyperLogLog object */ RHyperLogLogReactive getHyperLogLog(String name, Codec codec); /** * Returns list instance by name. * - * @param name of object - * @return + * @param type of values + * @param name - name of object + * @return List object */ RListReactive getList(String name); @@ -131,17 +145,20 @@ public interface RedissonReactiveClient { * Returns list instance by name * using provided codec for list objects. * - * @param name of object - * @param list object codec - * @return + * @param type of values + * @param name - name of object + * @param codec - codec for values + * @return List object */ RListReactive getList(String name, Codec codec); /** * Returns map instance by name. * - * @param name of map - * @return + * @param type of keys + * @param type of values + * @param name - name of object + * @return Map object */ RMapReactive getMap(String name); @@ -149,17 +166,20 @@ public interface RedissonReactiveClient { * Returns map instance by name * using provided codec for both map keys and values. * - * @param name of map - * @param map key and value codec - * @return + * @param type of keys + * @param type of values + * @param name - name of object + * @param codec - codec for keys and values + * @return Map object */ RMapReactive getMap(String name, Codec codec); /** * Returns set instance by name. * - * @param name of set - * @return + * @param type of values + * @param name - name of object + * @return Set object */ RSetReactive getSet(String name); @@ -167,18 +187,20 @@ public interface RedissonReactiveClient { * Returns set instance by name * using provided codec for set objects. * - * @param name of set - * @param set object codec - * @return + * @param type of values + * @param name - name of set + * @param codec - codec for values + * @return Set object */ RSetReactive getSet(String name, Codec codec); /** * Returns Redis Sorted Set instance by name. * This sorted set sorts objects by object score. - * + * + * @param type of values * @param name of scored sorted set - * @return + * @return ScoredSortedSet object */ RScoredSortedSetReactive getScoredSortedSet(String name); @@ -186,10 +208,11 @@ public interface RedissonReactiveClient { * Returns Redis Sorted Set instance by name * using provided codec for sorted set objects. * This sorted set sorts objects by object score. - * - * @param name of scored sorted set - * @param scored sorted set object codec - * @return + * + * @param type of values + * @param name - name of scored sorted set + * @param codec - codec for values + * @return ScoredSortedSet object */ RScoredSortedSetReactive getScoredSortedSet(String name, Codec codec); @@ -198,16 +221,17 @@ public interface RedissonReactiveClient { * All elements are inserted with the same score during addition, * in order to force lexicographical ordering * - * @param name - * @return + * @param name - name of object + * @return LexSortedSet object */ RLexSortedSetReactive getLexSortedSet(String name); /** * Returns topic instance by name. * - * @param name of topic - * @return + * @param type of message + * @param name - name of object + * @return Topic object */ RTopicReactive getTopic(String name); @@ -215,9 +239,10 @@ public interface RedissonReactiveClient { * Returns topic instance by name * using provided codec for messages. * - * @param name of topic - * @param message codec - * @return + * @param type of message + * @param name - name of object + * @param codec - codec for message + * @return Topic object */ RTopicReactive getTopic(String name, Codec codec); @@ -229,8 +254,9 @@ public interface RedissonReactiveClient { * h*llo subscribes to hllo and heeeello * h[ae]llo subscribes to hello and hallo, but not hillo * + * @param type of message * @param pattern of the topic - * @return + * @return PatternTopic object */ RPatternTopicReactive getPatternTopic(String pattern); @@ -243,63 +269,70 @@ public interface RedissonReactiveClient { * h*llo subscribes to hllo and heeeello * h[ae]llo subscribes to hello and hallo, but not hillo * + * @param type of message * @param pattern of the topic - * @param message codec - * @return + * @param codec - codec for message + * @return PatternTopic object */ RPatternTopicReactive getPatternTopic(String pattern, Codec codec); /** * Returns queue instance by name. * - * @param name of queue - * @return + * @param type of values + * @param name - name of object + * @return Queue object */ RQueueReactive getQueue(String name); /** * Returns queue instance by name * using provided codec for queue objects. - * - * @param name of queue - * @param queue objects codec - * @return + * + * @param type of values + * @param name - name of object + * @param codec - codec for values + * @return Queue object */ RQueueReactive getQueue(String name, Codec codec); /** * Returns blocking queue instance by name. - * - * @param name of queue - * @return + * + * @param type of values + * @param name - name of object + * @return BlockingQueue object */ RBlockingQueueReactive getBlockingQueue(String name); /** * Returns blocking queue instance by name * using provided codec for queue objects. - * - * @param name of queue - * @param queue objects codec - * @return + * + * @param type of values + * @param name - name of object + * @param codec - code for values + * @return BlockingQueue object */ RBlockingQueueReactive getBlockingQueue(String name, Codec codec); /** * Returns deque instance by name. - * - * @param name of deque - * @return + * + * @param type of values + * @param name - name of object + * @return Deque object */ RDequeReactive getDeque(String name); /** * Returns deque instance by name * using provided codec for deque objects. - * - * @param name of deque - * @param deque objects codec - * @return + * + * @param type of values + * @param name - name of object + * @param codec - coded for values + * @return Deque object */ RDequeReactive getDeque(String name, Codec codec); @@ -307,22 +340,22 @@ public interface RedissonReactiveClient { * Returns "atomic long" instance by name. * * @param name of the "atomic long" - * @return + * @return AtomicLong object */ RAtomicLongReactive getAtomicLong(String name); /** * Returns bitSet instance by name. * - * @param name of bitSet - * @return + * @param name - name of object + * @return BitSet object */ RBitSetReactive getBitSet(String name); /** * Returns script operations object * - * @return + * @return Script object */ RScriptReactive getScript(); @@ -332,7 +365,7 @@ public interface RedissonReactiveClient { * * See http://redis.io/topics/pipelining * - * @return + * @return Batch object */ RBatchReactive createBatch(); @@ -340,7 +373,7 @@ public interface RedissonReactiveClient { * Returns keys operations. * Each of Redis/Redisson object associated with own key * - * @return + * @return Keys object */ RKeysReactive getKeys(); @@ -361,28 +394,28 @@ public interface RedissonReactiveClient { /** * Returns the CodecProvider instance * - * @return CodecProvider + * @return CodecProvider object */ CodecProvider getCodecProvider(); /** * Get Redis nodes group for server operations * - * @return + * @return NodesGroup object */ NodesGroup getNodesGroup(); /** * Get Redis cluster nodes group for server operations * - * @return + * @return NodesGroup object */ NodesGroup getClusterNodesGroup(); /** * Returns {@code true} if this Redisson instance has been shut down. * - * @return + * @return true if this Redisson instance has been shut down otherwise false */ boolean isShutdown(); @@ -390,7 +423,8 @@ public interface RedissonReactiveClient { * Returns {@code true} if this Redisson instance was started to be shutdown * or was shutdown {@link #isShutdown()} already. * - * @return + * @return true if this Redisson instance was started to be shutdown + * or was shutdown {@link #isShutdown()} already otherwise false */ boolean isShuttingDown(); diff --git a/redisson/src/main/java/org/redisson/api/RemoteInvocationOptions.java b/redisson/src/main/java/org/redisson/api/RemoteInvocationOptions.java index 044c5c9ac..09d3f5e39 100644 --- a/redisson/src/main/java/org/redisson/api/RemoteInvocationOptions.java +++ b/redisson/src/main/java/org/redisson/api/RemoteInvocationOptions.java @@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit; * Used to tune how RRemoteService will behave * in regard to the remote invocations acknowledgement * and execution timeout. - *

+ *

* Examples: *

  *     // 1 second ack timeout and 30 seconds execution timeout
@@ -73,13 +73,15 @@ public class RemoteInvocationOptions implements Serializable {
 
     /**
      * Creates a new instance of RemoteInvocationOptions with opinionated defaults.
-     * 

+ *

* This is equivalent to: *

      *     new RemoteInvocationOptions()
      *      .expectAckWithin(1, TimeUnit.SECONDS)
      *      .expectResultWithin(30, TimeUnit.SECONDS)
      * 
+ * + * @return RemoteInvocationOptions object */ public static RemoteInvocationOptions defaults() { return new RemoteInvocationOptions() diff --git a/redisson/src/main/java/org/redisson/api/annotation/RRemoteAsync.java b/redisson/src/main/java/org/redisson/api/annotation/RRemoteAsync.java index 28d7ccfb4..aff41e024 100644 --- a/redisson/src/main/java/org/redisson/api/annotation/RRemoteAsync.java +++ b/redisson/src/main/java/org/redisson/api/annotation/RRemoteAsync.java @@ -23,10 +23,10 @@ import java.lang.annotation.Target; /** * Annotation used to mark interface as asynchronous * client interface for remote service interface. - *

+ *

* All method signatures must match with remote service interface, * but return type must be io.netty.util.concurrent.Future. - *

+ *

* It's not necessary to add all methods from remote service. * Add only those which are needed. * @@ -40,7 +40,7 @@ public @interface RRemoteAsync { /** * Remote interface class used to register * - * @return + * @return class used to register */ Class value(); diff --git a/redisson/src/main/java/org/redisson/config/BaseMasterSlaveServersConfig.java b/redisson/src/main/java/org/redisson/config/BaseMasterSlaveServersConfig.java index 94b9718b7..55e49dc2b 100644 --- a/redisson/src/main/java/org/redisson/config/BaseMasterSlaveServersConfig.java +++ b/redisson/src/main/java/org/redisson/config/BaseMasterSlaveServersConfig.java @@ -74,9 +74,9 @@ public class BaseMasterSlaveServersConfigeach slave node. - *

+ *

* Default is 250 - *

+ *

* @see #setSlaveConnectionMinimumIdleSize(int) * * @param slaveConnectionPoolSize @@ -92,7 +92,7 @@ public class BaseMasterSlaveServersConfig + *

* Default is 250 * * @see #setMasterConnectionMinimumIdleSize(int) @@ -126,9 +126,9 @@ public class BaseMasterSlaveServersConfigeach slave node - *

+ *

* Default is 50 - *

+ *

* @see #setSlaveSubscriptionConnectionMinimumIdleSize(int) * */ @@ -142,9 +142,9 @@ public class BaseMasterSlaveServersConfigeach slave node - *

+ *

* Default is 5 - *

+ *

* @see #setSlaveConnectionPoolSize(int) * */ @@ -158,9 +158,9 @@ public class BaseMasterSlaveServersConfigeach slave node - *

+ *

* Default is 5 - *

+ *

* @see #setMasterConnectionPoolSize(int) * */ @@ -174,9 +174,9 @@ public class BaseMasterSlaveServersConfigeach slave node. - *

+ *

* Default is 1 - *

+ *

* @see #setSlaveSubscriptionConnectionPoolSize(int) * */ @@ -190,7 +190,7 @@ public class BaseMasterSlaveServersConfig + *

* Default is SLAVE * * @param readMode diff --git a/redisson/src/main/java/org/redisson/config/Config.java b/redisson/src/main/java/org/redisson/config/Config.java index 921d41e37..370053ce3 100644 --- a/redisson/src/main/java/org/redisson/config/Config.java +++ b/redisson/src/main/java/org/redisson/config/Config.java @@ -353,9 +353,9 @@ public class Config { /** * Threads amount shared between all redis node clients. - *

+ *

* Default is 0. - *

+ *

* 0 means current_processors_amount * 2 * * @param threads @@ -419,7 +419,7 @@ public class Config { * own threads and each Redisson client creates own EventLoopGroup by default. * So if there are multiple Redisson instances in same JVM * it would be useful to share one EventLoopGroup among them. - *

+ *

* Only {@link io.netty.channel.epoll.EpollEventLoopGroup} or * {@link io.netty.channel.nio.NioEventLoopGroup} can be used. * diff --git a/redisson/src/main/java/org/redisson/misc/ReclosableLatch.java b/redisson/src/main/java/org/redisson/misc/ReclosableLatch.java index 976ffc80f..af911bde2 100644 --- a/redisson/src/main/java/org/redisson/misc/ReclosableLatch.java +++ b/redisson/src/main/java/org/redisson/misc/ReclosableLatch.java @@ -20,7 +20,7 @@ import java.util.concurrent.locks.AbstractQueuedSynchronizer; /** * A thread gate, that uses an {@link java.util.concurrent.locks.AbstractQueuedSynchronizer}. - *

+ *

* This implementation allows you to create a latch with a default state (open or closed), and repeatedly open or close * the latch. * diff --git a/redisson/src/main/java/org/redisson/remote/RemoteServiceAckTimeoutException.java b/redisson/src/main/java/org/redisson/remote/RemoteServiceAckTimeoutException.java index b6149a146..da8699fb4 100644 --- a/redisson/src/main/java/org/redisson/remote/RemoteServiceAckTimeoutException.java +++ b/redisson/src/main/java/org/redisson/remote/RemoteServiceAckTimeoutException.java @@ -18,7 +18,7 @@ package org.redisson.remote; /** * Rises when remote method executor has not answered * within Ack timeout. - *

+ *

* Method invocation has not been started in this case. * So a new invocation attempt can be made. * diff --git a/redisson/src/main/java/org/redisson/spring/cache/CacheConfig.java b/redisson/src/main/java/org/redisson/spring/cache/CacheConfig.java index 89ff64f0f..3f2b199a9 100644 --- a/redisson/src/main/java/org/redisson/spring/cache/CacheConfig.java +++ b/redisson/src/main/java/org/redisson/spring/cache/CacheConfig.java @@ -51,7 +51,7 @@ public class CacheConfig { * @param maxIdleTime - max idle time for key\value entry in milliseconds. * If 0 then max idle time doesn't affect entry expiration. * @param maxIdleUnit - *

+ *

* if maxIdleTime and ttl params are equal to 0 * then entry stores infinitely. */ diff --git a/redisson/src/main/java/org/redisson/spring/cache/RedissonSpringCacheManager.java b/redisson/src/main/java/org/redisson/spring/cache/RedissonSpringCacheManager.java index 26288582e..c127084b0 100644 --- a/redisson/src/main/java/org/redisson/spring/cache/RedissonSpringCacheManager.java +++ b/redisson/src/main/java/org/redisson/spring/cache/RedissonSpringCacheManager.java @@ -69,7 +69,7 @@ public class RedissonSpringCacheManager implements CacheManager, ResourceLoaderA /** * Creates CacheManager supplied by Redisson instance, Codec instance * and Cache config mapped by Cache name. - *

+ *

* Each Cache instance share one Codec instance. * * @param redisson @@ -84,7 +84,7 @@ public class RedissonSpringCacheManager implements CacheManager, ResourceLoaderA /** * Creates CacheManager supplied by Redisson instance * and Cache config mapped by Cache name. - *

+ *

* Loads the config file from the class path, interpreting plain paths as class path resource names * that include the package path (e.g. "mypackage/myresource.txt"). * @@ -98,9 +98,9 @@ public class RedissonSpringCacheManager implements CacheManager, ResourceLoaderA /** * Creates CacheManager supplied by Redisson instance, Codec instance * and Config location path. - *

+ *

* Each Cache instance share one Codec instance. - *

+ *

* Loads the config file from the class path, interpreting plain paths as class path resource names * that include the package path (e.g. "mypackage/myresource.txt"). * @@ -211,5 +211,5 @@ public class RedissonSpringCacheManager implements CacheManager, ResourceLoaderA } } } - + } From 9384e1b61cbc76c5697208ff36f8bf5d91b3a72a Mon Sep 17 00:00:00 2001 From: Nikita Date: Mon, 12 Sep 2016 13:14:50 +0300 Subject: [PATCH 04/15] valuesAmountToClean risen from 100 to 500 --- redisson/src/main/java/org/redisson/EvictionScheduler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redisson/src/main/java/org/redisson/EvictionScheduler.java b/redisson/src/main/java/org/redisson/EvictionScheduler.java index f7a270f04..66ba67897 100644 --- a/redisson/src/main/java/org/redisson/EvictionScheduler.java +++ b/redisson/src/main/java/org/redisson/EvictionScheduler.java @@ -120,7 +120,7 @@ public class EvictionScheduler { private final ConcurrentMap lastExpiredTime = PlatformDependent.newConcurrentHashMap(); private final int expireTaskExecutionDelay = 1000; - private final int valuesAmountToClean = 100; + private final int valuesAmountToClean = 500; public EvictionScheduler(CommandAsyncExecutor executor) { this.executor = executor; From 42bc256cc73279c33e2fb1cfc7910b5ae46109a1 Mon Sep 17 00:00:00 2001 From: Nikita Date: Mon, 12 Sep 2016 14:05:58 +0300 Subject: [PATCH 05/15] javadoc parser compatibility fixed --- .../src/main/java/org/redisson/api/RKeys.java | 24 +++++----- .../java/org/redisson/api/RKeysAsync.java | 20 ++++---- .../java/org/redisson/api/RKeysReactive.java | 27 +++++------ .../java/org/redisson/api/RLexSortedSet.java | 4 +- .../org/redisson/api/RLexSortedSetAsync.java | 4 +- .../src/main/java/org/redisson/api/RList.java | 19 ++++---- .../java/org/redisson/api/RListAsync.java | 21 +++++---- .../main/java/org/redisson/api/RMultimap.java | 46 +++++++++++++++---- .../java/org/redisson/api/RMultimapAsync.java | 27 +++++++++-- 9 files changed, 122 insertions(+), 70 deletions(-) diff --git a/redisson/src/main/java/org/redisson/api/RKeys.java b/redisson/src/main/java/org/redisson/api/RKeys.java index f904a0ef9..627d51001 100644 --- a/redisson/src/main/java/org/redisson/api/RKeys.java +++ b/redisson/src/main/java/org/redisson/api/RKeys.java @@ -22,8 +22,8 @@ public interface RKeys extends RKeysAsync { /** * Get Redis object type by key * - * @param name - * @return + * @param key - name of key + * @return type of key */ RType getType(String key); @@ -31,8 +31,8 @@ public interface RKeys extends RKeysAsync { * Get hash slot identifier for key. * Available for cluster nodes only * - * @param key - * @return + * @param key - name of key + * @return slot number */ int getSlot(String key); @@ -50,7 +50,7 @@ public interface RKeys extends RKeysAsync { * h[ae]llo subscribes to hello and hallo, but not hillo * * @param pattern - match pattern - * @return + * @return Iterable object */ Iterable getKeysByPattern(String pattern); @@ -69,21 +69,21 @@ public interface RKeys extends RKeysAsync { * * @param pattern - match pattern * @param count - keys loaded per request to Redis - * @return + * @return Iterable object */ Iterable getKeysByPattern(String pattern, int count); /** * Get all keys using iterator. Keys traversing with SCAN operation * - * @return + * @return Iterable object */ Iterable getKeys(); /** * Get random key * - * @return + * @return random key */ String randomKey(); @@ -95,8 +95,8 @@ public interface RKeys extends RKeysAsync { * h*llo subscribes to hllo and heeeello * h[ae]llo subscribes to hello and hallo, but not hillo * - * @param pattern - * @return + * @param pattern - match pattern + * @return collection of keys */ Collection findKeysByPattern(String pattern); @@ -110,7 +110,7 @@ public interface RKeys extends RKeysAsync { * h*llo subscribes to hllo and heeeello * h[ae]llo subscribes to hello and hallo, but not hillo * - * @param pattern + * @param pattern - match pattern * @return number of removed keys */ long deleteByPattern(String pattern); @@ -126,7 +126,7 @@ public interface RKeys extends RKeysAsync { /** * Returns the number of keys in the currently-selected database * - * @return + * @return count of keys */ long count(); diff --git a/redisson/src/main/java/org/redisson/api/RKeysAsync.java b/redisson/src/main/java/org/redisson/api/RKeysAsync.java index f0cb30b94..252203a2e 100644 --- a/redisson/src/main/java/org/redisson/api/RKeysAsync.java +++ b/redisson/src/main/java/org/redisson/api/RKeysAsync.java @@ -22,8 +22,8 @@ public interface RKeysAsync { /** * Get Redis object type by key * - * @param name - * @return + * @param key - name of key + * @return type of key */ RFuture getTypeAsync(String key); @@ -31,15 +31,15 @@ public interface RKeysAsync { * Get hash slot identifier for key in async mode. * Available for cluster nodes only * - * @param key - * @return + * @param key - name of key + * @return slot */ RFuture getSlotAsync(String key); /** * Get random key in async mode * - * @return + * @return random key */ RFuture randomKeyAsync(); @@ -51,8 +51,8 @@ public interface RKeysAsync { * h*llo subscribes to hllo and heeeello * h[ae]llo subscribes to hello and hallo, but not hillo * - * @param pattern - * @return + * @param pattern - match pattern + * @return collections of keys */ RFuture> findKeysByPatternAsync(String pattern); @@ -66,7 +66,7 @@ public interface RKeysAsync { * h*llo subscribes to hllo and heeeello * h[ae]llo subscribes to hello and hallo, but not hillo * - * @param pattern + * @param pattern - match pattern * @return number of removed keys */ RFuture deleteByPatternAsync(String pattern); @@ -82,17 +82,19 @@ public interface RKeysAsync { /** * Returns the number of keys in the currently-selected database in async mode * - * @return + * @return number of keys */ RFuture countAsync(); /** * Delete all keys of currently selected database + * @return void */ RFuture flushdbAsync(); /** * Delete all keys of all existing databases + * @return void */ RFuture flushallAsync(); diff --git a/redisson/src/main/java/org/redisson/api/RKeysReactive.java b/redisson/src/main/java/org/redisson/api/RKeysReactive.java index e48c19eba..7982fb719 100644 --- a/redisson/src/main/java/org/redisson/api/RKeysReactive.java +++ b/redisson/src/main/java/org/redisson/api/RKeysReactive.java @@ -26,8 +26,7 @@ public interface RKeysReactive { * * Uses SCAN Redis command. * - * @param pattern - * @return + * @return all keys */ Publisher getKeys(); @@ -41,8 +40,8 @@ public interface RKeysReactive { * h*llo subscribes to hllo and heeeello * h[ae]llo subscribes to hello and hallo, but not hillo * - * @param pattern - * @return + * @param pattern - match pattern + * @return keys */ Publisher getKeysByPattern(String pattern); @@ -52,8 +51,8 @@ public interface RKeysReactive { * * Uses KEYSLOT Redis command. * - * @param key - * @return + * @param key - name of key + * @return slot number */ Publisher getSlot(String key); @@ -67,8 +66,8 @@ public interface RKeysReactive { * h*llo subscribes to hllo and heeeello * h[ae]llo subscribes to hello and hallo, but not hillo * - * @param pattern - * @return + * @param pattern - match pattern + * @return collection of keys */ Publisher> findKeysByPattern(String pattern); @@ -77,7 +76,7 @@ public interface RKeysReactive { * * Uses RANDOM_KEY Redis command. * - * @return + * @return random key */ Publisher randomKey(); @@ -91,8 +90,8 @@ public interface RKeysReactive { * h*llo subscribes to hllo and heeeello * h[ae]llo subscribes to hello and hallo, but not hillo * - * @param pattern - * @return + * @param pattern - match pattern + * @return deleted objects amount */ Publisher deleteByPattern(String pattern); @@ -102,7 +101,7 @@ public interface RKeysReactive { * Uses DEL Redis command. * * @param keys - object names - * @return + * @return deleted objects amount */ Publisher delete(String ... keys); @@ -110,7 +109,8 @@ public interface RKeysReactive { * Delete all the keys of the currently selected database * * Uses FLUSHDB Redis command. - * + * + * @return void */ Publisher flushdb(); @@ -119,6 +119,7 @@ public interface RKeysReactive { * * Uses FLUSHALL Redis command. * + * @return void */ Publisher flushall(); diff --git a/redisson/src/main/java/org/redisson/api/RLexSortedSet.java b/redisson/src/main/java/org/redisson/api/RLexSortedSet.java index c1b8c7940..081e2d582 100644 --- a/redisson/src/main/java/org/redisson/api/RLexSortedSet.java +++ b/redisson/src/main/java/org/redisson/api/RLexSortedSet.java @@ -31,7 +31,7 @@ public interface RLexSortedSet extends RLexSortedSetAsync, Set, RExpirab /** * Returns rank of value, with the scores ordered from high to low. * - * @param o + * @param o - object * @return rank or null if value does not exist */ Integer revRank(String o); @@ -39,7 +39,7 @@ public interface RLexSortedSet extends RLexSortedSetAsync, Set, RExpirab /** * Read all values at once. * - * @return + * @return collection of values */ Collection readAll(); diff --git a/redisson/src/main/java/org/redisson/api/RLexSortedSetAsync.java b/redisson/src/main/java/org/redisson/api/RLexSortedSetAsync.java index 181b28ea2..33a22eee3 100644 --- a/redisson/src/main/java/org/redisson/api/RLexSortedSetAsync.java +++ b/redisson/src/main/java/org/redisson/api/RLexSortedSetAsync.java @@ -30,7 +30,7 @@ public interface RLexSortedSetAsync extends RCollectionAsync { /** * Read all values at once. * - * @return + * @return collection of values */ RFuture> readAllAsync(); @@ -65,7 +65,7 @@ public interface RLexSortedSetAsync extends RCollectionAsync { /** * Returns rank of value, with the scores ordered from high to low. * - * @param o + * @param o - value * @return rank or null if value does not exist */ RFuture revRankAsync(String o); diff --git a/redisson/src/main/java/org/redisson/api/RList.java b/redisson/src/main/java/org/redisson/api/RList.java index 8ba8bc2ec..7aea672e0 100644 --- a/redisson/src/main/java/org/redisson/api/RList.java +++ b/redisson/src/main/java/org/redisson/api/RList.java @@ -30,8 +30,8 @@ public interface RList extends List, RExpirable, RListAsync, RandomAcce /** * Add element after elementToFind * - * @param elementToFind - * @param element + * @param elementToFind - object to find + * @param element - object to add * @return new list size */ Integer addAfter(V elementToFind, V element); @@ -39,8 +39,8 @@ public interface RList extends List, RExpirable, RListAsync, RandomAcce /** * Add element before elementToFind * - * @param elementToFind - * @param element + * @param elementToFind - object to find + * @param element - object to add * @return new list size */ Integer addBefore(V elementToFind, V element); @@ -50,8 +50,8 @@ public interface RList extends List, RExpirable, RListAsync, RandomAcce * Works faster than {@link #set(int, Object)} but * doesn't return previous element. * - * @param index - * @param element + * @param index - index of object + * @param element - object to set */ void fastSet(int index, V element); @@ -60,7 +60,7 @@ public interface RList extends List, RExpirable, RListAsync, RandomAcce /** * Read all elements at once * - * @return + * @return list of values */ List readAll(); @@ -68,9 +68,8 @@ public interface RList extends List, RExpirable, RListAsync, RandomAcce * Trim list and remains elements only in specified range * fromIndex, inclusive, and toIndex, inclusive. * - * @param fromIndex - * @param toIndex - * @return + * @param fromIndex - from index + * @param toIndex - to index */ void trim(int fromIndex, int toIndex); diff --git a/redisson/src/main/java/org/redisson/api/RListAsync.java b/redisson/src/main/java/org/redisson/api/RListAsync.java index df8de1f03..eb0d7d2de 100644 --- a/redisson/src/main/java/org/redisson/api/RListAsync.java +++ b/redisson/src/main/java/org/redisson/api/RListAsync.java @@ -31,8 +31,8 @@ public interface RListAsync extends RCollectionAsync, RandomAccess { /** * Add element after elementToFind * - * @param elementToFind - * @param element + * @param elementToFind - object to find + * @param element - object to add * @return new list size */ RFuture addAfterAsync(V elementToFind, V element); @@ -40,8 +40,8 @@ public interface RListAsync extends RCollectionAsync, RandomAccess { /** * Add element before elementToFind * - * @param elementToFind - * @param element + * @param elementToFind - object to find + * @param element - object to add * @return new list size */ RFuture addBeforeAsync(V elementToFind, V element); @@ -57,8 +57,9 @@ public interface RListAsync extends RCollectionAsync, RandomAccess { * Works faster than {@link #setAsync(int, Object)} but * doesn't return previous element. * - * @param index - * @param element + * @param index - index of object + * @param element - object + * @return void */ RFuture fastSetAsync(int index, V element); @@ -69,7 +70,7 @@ public interface RListAsync extends RCollectionAsync, RandomAccess { /** * Read all elements at once * - * @return + * @return list of values */ RFuture> readAllAsync(); @@ -77,9 +78,9 @@ public interface RListAsync extends RCollectionAsync, RandomAccess { * Trim list and remains elements only in specified range * fromIndex, inclusive, and toIndex, inclusive. * - * @param fromIndex - * @param toIndex - * @return + * @param fromIndex - from index + * @param toIndex - to index + * @return void */ RFuture trimAsync(long fromIndex, long toIndex); diff --git a/redisson/src/main/java/org/redisson/api/RMultimap.java b/redisson/src/main/java/org/redisson/api/RMultimap.java index c751ffbfa..1603c3d28 100644 --- a/redisson/src/main/java/org/redisson/api/RMultimap.java +++ b/redisson/src/main/java/org/redisson/api/RMultimap.java @@ -32,32 +32,42 @@ public interface RMultimap extends RExpirable, RMultimapAsync { /** * Returns the number of key-value pairs in this multimap. * - * @return + * @return size of multimap */ int size(); /** * Check is map empty * - * @return + * @return true if empty */ boolean isEmpty(); /** * Returns {@code true} if this multimap contains at least one key-value pair * with the key {@code key}. + * + * @param key - map key + * @return true if contains a key */ boolean containsKey(Object key); /** * Returns {@code true} if this multimap contains at least one key-value pair * with the value {@code value}. + * + * @param value - map value + * @return true if contains a value */ boolean containsValue(Object value); /** * Returns {@code true} if this multimap contains at least one key-value pair * with the key {@code key} and the value {@code value}. + * + * @param key - map key + * @param value - map value + * @return true if contains an entry */ boolean containsEntry(Object key, Object value); @@ -69,6 +79,8 @@ public interface RMultimap extends RExpirable, RMultimapAsync { * multimap size by 1. Other implementations prohibit duplicates, and storing * a key-value pair that's already in the multimap has no effect. * + * @param key - map key + * @param value - map value * @return {@code true} if the method increased the size of the multimap, or * {@code false} if the multimap already contained the key-value pair and * doesn't allow duplicates @@ -81,6 +93,8 @@ public interface RMultimap extends RExpirable, RMultimapAsync { * pairs in the multimap fit this description, which one is removed is * unspecified. * + * @param key - map key + * @param value - map value * @return {@code true} if the multimap changed */ boolean remove(Object key, Object value); @@ -95,7 +109,9 @@ public interface RMultimap extends RExpirable, RMultimapAsync { * }}

* *

In particular, this is a no-op if {@code values} is empty. - * + * + * @param key - map key + * @param values - map values * @return {@code true} if the multimap changed */ boolean putAll(K key, Iterable values); @@ -107,6 +123,8 @@ public interface RMultimap extends RExpirable, RMultimapAsync { *

If {@code values} is empty, this is equivalent to * {@link #removeAll(Object) removeAll(key)}. * + * @param key - map key + * @param values - map values * @return the collection of replaced values, or an empty collection if no * values were previously associated with the key. The collection * may be modifiable, but updating it will have no effect on the @@ -120,8 +138,9 @@ public interface RMultimap extends RExpirable, RMultimapAsync { *

Once this method returns, {@code key} will not be mapped to any values, * so it will not appear in {@link #keySet()}, {@link #asMap()}, or any other * views. - *

Use {@link #fastRemove()} if values are not needed.

- * + *

Use {@link RMultimap#fastRemove()} if values are not needed.

+ * + * @param key - map key * @return the values that were removed (possibly empty). The returned * collection may be modifiable, but updating it will have no * effect on the multimap. @@ -141,6 +160,9 @@ public interface RMultimap extends RExpirable, RMultimapAsync { * *

Changes to the returned collection will update the underlying multimap, * and vice versa. + * + * @param key - map key + * @return collection of values */ Collection get(K key); @@ -148,8 +170,8 @@ public interface RMultimap extends RExpirable, RMultimapAsync { * Returns all elements at once. Result collection is NOT backed by map, * so changes are not reflected in map. * - * @param key - * @return + * @param key - map key + * @return collection of values */ Collection getAll(K key); @@ -160,11 +182,15 @@ public interface RMultimap extends RExpirable, RMultimapAsync { * *

Changes to the returned set will update the underlying multimap, and * vice versa. However, adding to the returned set is not possible. + * + * @return set of keys */ Set keySet(); /** * Returns the count of distinct keys in this multimap. + * + * @return keys amount */ int keySize(); @@ -176,6 +202,8 @@ public interface RMultimap extends RExpirable, RMultimapAsync { *

Changes to the returned collection will update the underlying multimap, * and vice versa. However, adding to the returned collection is not * possible. + * + * @return collection of values */ Collection values(); @@ -186,6 +214,8 @@ public interface RMultimap extends RExpirable, RMultimapAsync { *

Changes to the returned collection or the entries it contains will * update the underlying multimap, and vice versa. However, adding to * the returned collection is not possible. + * + * @return collection of entries */ Collection> entries(); @@ -195,7 +225,7 @@ public interface RMultimap extends RExpirable, RMultimapAsync { * Works faster than RMultimap.remove but not returning * the value associated with key * - * @param keys + * @param keys - map keys * @return the number of keys that were removed from the hash, not including specified but non existing keys */ long fastRemove(K ... keys); diff --git a/redisson/src/main/java/org/redisson/api/RMultimapAsync.java b/redisson/src/main/java/org/redisson/api/RMultimapAsync.java index 41c466dd7..6b93699e8 100644 --- a/redisson/src/main/java/org/redisson/api/RMultimapAsync.java +++ b/redisson/src/main/java/org/redisson/api/RMultimapAsync.java @@ -30,25 +30,35 @@ public interface RMultimapAsync extends RExpirableAsync { /** * Returns the number of key-value pairs in this multimap. * - * @return + * @return size of multimap */ RFuture sizeAsync(); /** * Returns {@code true} if this multimap contains at least one key-value pair * with the key {@code key}. + * + * @param key - map key + * @return true if contains a key */ RFuture containsKeyAsync(Object key); /** * Returns {@code true} if this multimap contains at least one key-value pair * with the value {@code value}. + * + * @param value - map value + * @return true if contains a value */ RFuture containsValueAsync(Object value); /** * Returns {@code true} if this multimap contains at least one key-value pair * with the key {@code key} and the value {@code value}. + * + * @param key - map key + * @param value - map value + * @return true if contains an entry */ RFuture containsEntryAsync(Object key, Object value); @@ -60,6 +70,8 @@ public interface RMultimapAsync extends RExpirableAsync { * multimap size by 1. Other implementations prohibit duplicates, and storing * a key-value pair that's already in the multimap has no effect. * + * @param key - map key + * @param value - map value * @return {@code true} if the method increased the size of the multimap, or * {@code false} if the multimap already contained the key-value pair and * doesn't allow duplicates @@ -72,6 +84,8 @@ public interface RMultimapAsync extends RExpirableAsync { * pairs in the multimap fit this description, which one is removed is * unspecified. * + * @param key - map key + * @param value - map value * @return {@code true} if the multimap changed */ RFuture removeAsync(Object key, Object value); @@ -89,6 +103,8 @@ public interface RMultimapAsync extends RExpirableAsync { * *

In particular, this is a no-op if {@code values} is empty. * + * @param key - map key + * @param values - map values * @return {@code true} if the multimap changed */ RFuture putAllAsync(K key, Iterable values); @@ -100,6 +116,8 @@ public interface RMultimapAsync extends RExpirableAsync { *

If {@code values} is empty, this is equivalent to * {@link #removeAll(Object) removeAll(key)}. * + * @param key - map key + * @param values - map values * @return the collection of replaced values, or an empty collection if no * values were previously associated with the key. The collection * may be modifiable, but updating it will have no effect on the @@ -114,6 +132,7 @@ public interface RMultimapAsync extends RExpirableAsync { * so it will not appear in {@link #keySet()}, {@link #asMap()}, or any other * views. * + * @param key - map key * @return the values that were removed (possibly empty). The returned * collection may be modifiable, but updating it will have no * effect on the multimap. @@ -126,17 +145,17 @@ public interface RMultimapAsync extends RExpirableAsync { /** * Returns the number of key-value pairs in this multimap. * - * @return + * @return keys amount */ RFuture keySizeAsync(); /** * Removes keys from map by one operation * - * Works faster than removeAll but not returning + * Works faster than RMultimap.remove but not returning * the value associated with key * - * @param keys + * @param keys - map keys * @return the number of keys that were removed from the hash, not including specified but non existing keys */ RFuture fastRemoveAsync(K ... keys); From cbb7e3695f5a607b1c9af9ad066789f56dbdcb76 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Mon, 12 Sep 2016 14:27:22 +0300 Subject: [PATCH 06/15] Update README.md --- README.md | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ca9347815..56d112dd3 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,6 @@ Features * [Distributed collections](https://github.com/mrniko/redisson/wiki/7.-Distributed-collections) * [Distributed locks and synchronizers](https://github.com/mrniko/redisson/wiki/8.-Distributed-locks-and-synchronizers) * [Distributed services](https://github.com/mrniko/redisson/wiki/9.-distributed-services) -* [Scheduler service](https://github.com/mrniko/redisson/wiki/9.-distributed-services/#94-scheduled-executor-service) * [Spring cache](https://github.com/mrniko/redisson/wiki/14.-Integration%20with%20frameworks/#141-spring-cache) integration * [Hibernate](https://github.com/mrniko/redisson/wiki/14.-Integration%20with%20frameworks/#142-hibernate) integration * [Reactive Streams](https://github.com/mrniko/redisson/wiki/3.-operations-execution#32-reactive-way) @@ -58,16 +57,18 @@ Projects using Redisson ================================ [Setronica](http://setronica.com/), [Monits](http://monits.com/), [Brookhaven National Laboratory](http://bnl.gov/), [Netflix Dyno client] (https://github.com/Netflix/dyno), [武林Q传](http://www.nbrpg.com/), [Ocous](http://www.ocous.com/), [Invaluable](http://www.invaluable.com/), [Clover](https://www.clover.com/) , [Apache Karaf Decanter](https://karaf.apache.org/projects.html#decanter), [Atmosphere Framework](http://async-io.org/) -### Articles +Articles +================================ [Java data structures powered by Redis. Introduction to Redisson. PDF](http://redisson.org/Redisson.pdf) [Introducing Redisson Live Objects (Object Hash Mapping)](https://dzone.com/articles/introducing-redisson-live-object-object-hash-mappi) [Java Remote Method Invocation with Redisson](https://dzone.com/articles/java-remote-method-invocation-with-redisson) [Java Multimaps With Redis](https://dzone.com/articles/multimaps-with-redis) -### Maven +Quick start +=============================== -Include the following to your dependency list: +#### Maven org.redisson @@ -75,11 +76,34 @@ Include the following to your dependency list: 2.3.0 -### Gradle +#### Gradle compile 'org.redisson:redisson:2.3.0' + +#### Java + +```java +// 1. Create config object +Config = ... + +// 2. Create Redisson instance +RedissonClient redisson = Redisson.create(config); + +// 3. Get object you need +RMap map = redisson.getMap("myMap"); + +RSet set = redisson.getMap("mySet"); + +RList list = redisson.getMap("myList"); + +RLock lock = redisson.getMap("myLock"); + +// over 30 different objects and services ... + +``` -### Downloads +Downloads +=============================== [Redisson 2.3.0](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson&v=2.3.0&e=jar) [Redisson node 2.3.0](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-all&v=2.3.0&e=jar) From 8975fe9864734344512a972bb3facc17e9ef68c0 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Mon, 12 Sep 2016 14:34:11 +0300 Subject: [PATCH 07/15] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 56d112dd3..716a09de7 100644 --- a/README.md +++ b/README.md @@ -92,11 +92,11 @@ RedissonClient redisson = Redisson.create(config); // 3. Get object you need RMap map = redisson.getMap("myMap"); -RSet set = redisson.getMap("mySet"); +RSet set = redisson.getSet("mySet"); -RList list = redisson.getMap("myList"); +RList list = redisson.getList("myList"); -RLock lock = redisson.getMap("myLock"); +RLock lock = redisson.getLock("myLock"); // over 30 different objects and services ... From 7ea3fec4d196bfdacf781757544329d29604d651 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Mon, 12 Sep 2016 14:34:30 +0300 Subject: [PATCH 08/15] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 716a09de7..6b4aa497d 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ Articles [Java Remote Method Invocation with Redisson](https://dzone.com/articles/java-remote-method-invocation-with-redisson) [Java Multimaps With Redis](https://dzone.com/articles/multimaps-with-redis) -Quick start +Easy to use. Quick start =============================== #### Maven From e4b1a6c017b9e48e42fb2e2dbe8e0b13554437dc Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Mon, 12 Sep 2016 15:01:50 +0300 Subject: [PATCH 09/15] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6b4aa497d..192c0ba59 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,8 @@ Config = ... // 2. Create Redisson instance RedissonClient redisson = Redisson.create(config); +// or +RedissonReactiveClient redisson = Redisson.createReactive(config); // 3. Get object you need RMap map = redisson.getMap("myMap"); From ff7a7a7702fb9c7c94b691fb782c85dc006b22ac Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Mon, 12 Sep 2016 15:02:07 +0300 Subject: [PATCH 10/15] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 192c0ba59..6b4aa497d 100644 --- a/README.md +++ b/README.md @@ -88,8 +88,6 @@ Config = ... // 2. Create Redisson instance RedissonClient redisson = Redisson.create(config); -// or -RedissonReactiveClient redisson = Redisson.createReactive(config); // 3. Get object you need RMap map = redisson.getMap("myMap"); From e76d28a768bd530591beaae863ee993e817ce2be Mon Sep 17 00:00:00 2001 From: Nikita Date: Mon, 12 Sep 2016 15:32:01 +0300 Subject: [PATCH 11/15] Check that RLock still belongs to owner during renewal expiration. #597 --- .../main/java/org/redisson/RedissonLock.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/redisson/src/main/java/org/redisson/RedissonLock.java b/redisson/src/main/java/org/redisson/RedissonLock.java index d1a7e7baa..3a9e09a2e 100644 --- a/redisson/src/main/java/org/redisson/RedissonLock.java +++ b/redisson/src/main/java/org/redisson/RedissonLock.java @@ -148,7 +148,7 @@ public class RedissonLock extends RedissonExpirable implements RLock { return get(tryAcquireAsync(leaseTime, unit, Thread.currentThread().getId())); } - private RFuture tryAcquireOnceAsync(long leaseTime, TimeUnit unit, long threadId) { + private RFuture tryAcquireOnceAsync(long leaseTime, TimeUnit unit, final long threadId) { if (leaseTime != -1) { return tryLockInnerAsync(leaseTime, unit, threadId, RedisCommands.EVAL_NULL_BOOLEAN); } @@ -163,14 +163,14 @@ public class RedissonLock extends RedissonExpirable implements RLock { Boolean ttlRemaining = future.getNow(); // lock acquired if (ttlRemaining) { - scheduleExpirationRenewal(); + scheduleExpirationRenewal(threadId); } } }); return ttlRemainingFuture; } - private RFuture tryAcquireAsync(long leaseTime, TimeUnit unit, long threadId) { + private RFuture tryAcquireAsync(long leaseTime, TimeUnit unit, final long threadId) { if (leaseTime != -1) { return tryLockInnerAsync(leaseTime, unit, threadId, RedisCommands.EVAL_LONG); } @@ -185,7 +185,7 @@ public class RedissonLock extends RedissonExpirable implements RLock { Long ttlRemaining = future.getNow(); // lock acquired if (ttlRemaining == null) { - scheduleExpirationRenewal(); + scheduleExpirationRenewal(threadId); } } }); @@ -197,7 +197,7 @@ public class RedissonLock extends RedissonExpirable implements RLock { return get(tryLockAsync()); } - private void scheduleExpirationRenewal() { + private void scheduleExpirationRenewal(final long threadId) { if (expirationRenewalMap.containsKey(getEntryName())) { return; } @@ -205,7 +205,15 @@ public class RedissonLock extends RedissonExpirable implements RLock { Timeout task = commandExecutor.getConnectionManager().newTimeout(new TimerTask() { @Override public void run(Timeout timeout) throws Exception { - RFuture future = expireAsync(internalLockLeaseTime, TimeUnit.MILLISECONDS); + + RFuture future = commandExecutor.evalWriteAsync(getName(), LongCodec.INSTANCE, RedisCommands.EVAL_BOOLEAN, + "if (redis.call('hexists', KEYS[1], ARGV[2]) == 1) then " + + "redis.call('pexpire', KEYS[1], ARGV[1]); " + + "return 1; " + + "end; " + + "return 0;", + Collections.singletonList(getName()), internalLockLeaseTime, getLockName(threadId)); + future.addListener(new FutureListener() { @Override public void operationComplete(Future future) throws Exception { @@ -217,7 +225,7 @@ public class RedissonLock extends RedissonExpirable implements RLock { if (future.getNow()) { // reschedule itself - scheduleExpirationRenewal(); + scheduleExpirationRenewal(threadId); } } }); From e4909f16d29039025e35ee3df6397023889c45e4 Mon Sep 17 00:00:00 2001 From: Nikita Date: Mon, 12 Sep 2016 15:42:34 +0300 Subject: [PATCH 12/15] TRYAGAIN error handling. #612 --- .../client/RedisTryAgainException.java | 31 +++++++++++++++++++ .../client/handler/CommandDecoder.java | 4 +++ .../redisson/command/CommandAsyncService.java | 14 +++++++++ .../redisson/command/CommandBatchService.java | 12 +++++++ 4 files changed, 61 insertions(+) create mode 100644 redisson/src/main/java/org/redisson/client/RedisTryAgainException.java diff --git a/redisson/src/main/java/org/redisson/client/RedisTryAgainException.java b/redisson/src/main/java/org/redisson/client/RedisTryAgainException.java new file mode 100644 index 000000000..b18219915 --- /dev/null +++ b/redisson/src/main/java/org/redisson/client/RedisTryAgainException.java @@ -0,0 +1,31 @@ +/** + * Copyright 2016 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.client; + +/** + * + * @author Nikita Koksharov + * + */ +public class RedisTryAgainException extends RedisException { + + private static final long serialVersionUID = -2565335188503354660L; + + public RedisTryAgainException(String message) { + super(message); + } + +} diff --git a/redisson/src/main/java/org/redisson/client/handler/CommandDecoder.java b/redisson/src/main/java/org/redisson/client/handler/CommandDecoder.java index 30ac25c3f..cc17c7caf 100644 --- a/redisson/src/main/java/org/redisson/client/handler/CommandDecoder.java +++ b/redisson/src/main/java/org/redisson/client/handler/CommandDecoder.java @@ -29,6 +29,7 @@ import org.redisson.client.RedisMovedException; import org.redisson.client.RedisOutOfMemoryException; import org.redisson.client.RedisPubSubConnection; import org.redisson.client.RedisTimeoutException; +import org.redisson.client.RedisTryAgainException; import org.redisson.client.codec.StringCodec; import org.redisson.client.protocol.CommandData; import org.redisson.client.protocol.CommandsData; @@ -240,6 +241,9 @@ public class CommandDecoder extends ReplayingDecoder { int slot = Integer.valueOf(errorParts[1]); String addr = errorParts[2]; data.tryFailure(new RedisAskException(slot, addr)); + } else if (error.startsWith("TRYAGAIN")) { + data.tryFailure(new RedisTryAgainException(error + + ". channel: " + channel + " data: " + data)); } else if (error.startsWith("LOADING")) { data.tryFailure(new RedisLoadingException(error + ". channel: " + channel + " data: " + data)); diff --git a/redisson/src/main/java/org/redisson/command/CommandAsyncService.java b/redisson/src/main/java/org/redisson/command/CommandAsyncService.java index b2645da50..2dfaecd82 100644 --- a/redisson/src/main/java/org/redisson/command/CommandAsyncService.java +++ b/redisson/src/main/java/org/redisson/command/CommandAsyncService.java @@ -37,6 +37,7 @@ import org.redisson.client.RedisException; import org.redisson.client.RedisLoadingException; import org.redisson.client.RedisMovedException; import org.redisson.client.RedisTimeoutException; +import org.redisson.client.RedisTryAgainException; import org.redisson.client.WriteRedisConnectionException; import org.redisson.client.codec.Codec; import org.redisson.client.protocol.CommandData; @@ -741,6 +742,19 @@ public class CommandAsyncService implements CommandAsyncExecutor { AsyncDetails.release(details); return; } + + if (future.cause() instanceof RedisTryAgainException) { + connectionManager.newTimeout(new TimerTask() { + @Override + public void run(Timeout timeout) throws Exception { + async(details.isReadOnlyMode(), source, details.getCodec(), + details.getCommand(), details.getParams(), details.getMainPromise(), details.getAttempt()); + + } + }, 1, TimeUnit.SECONDS); + AsyncDetails.release(details); + return; + } if (future.isSuccess()) { R res = future.getNow(); diff --git a/redisson/src/main/java/org/redisson/command/CommandBatchService.java b/redisson/src/main/java/org/redisson/command/CommandBatchService.java index 79caa9df4..e4ade39d8 100644 --- a/redisson/src/main/java/org/redisson/command/CommandBatchService.java +++ b/redisson/src/main/java/org/redisson/command/CommandBatchService.java @@ -30,6 +30,7 @@ import org.redisson.client.RedisConnection; import org.redisson.client.RedisLoadingException; import org.redisson.client.RedisMovedException; import org.redisson.client.RedisTimeoutException; +import org.redisson.client.RedisTryAgainException; import org.redisson.client.WriteRedisConnectionException; import org.redisson.client.codec.Codec; import org.redisson.client.codec.StringCodec; @@ -299,6 +300,17 @@ public class CommandBatchService extends CommandReactiveService { execute(entry, source, mainPromise, slots, attempt); return; } + if (future.cause() instanceof RedisTryAgainException) { + entry.clearErrors(); + connectionManager.newTimeout(new TimerTask() { + @Override + public void run(Timeout timeout) throws Exception { + execute(entry, source, mainPromise, slots, attempt); + } + }, 1, TimeUnit.SECONDS); + return; + } + if (future.isSuccess()) { if (slots.decrementAndGet() == 0) { From 90426847ecd880847f2179196079709f3d6341bd Mon Sep 17 00:00:00 2001 From: Nikita Date: Mon, 12 Sep 2016 15:46:17 +0300 Subject: [PATCH 13/15] comments added --- .../src/main/java/org/redisson/client/RedisAskException.java | 5 +++++ .../java/org/redisson/client/RedisConnectionException.java | 5 +++++ .../main/java/org/redisson/client/RedisLoadingException.java | 5 +++++ .../main/java/org/redisson/client/RedisMovedException.java | 5 +++++ .../java/org/redisson/client/RedisNodeNotFoundException.java | 5 +++++ .../java/org/redisson/client/RedisOutOfMemoryException.java | 2 +- .../java/org/redisson/client/RedisRedirectException.java | 5 +++++ .../main/java/org/redisson/client/RedisTimeoutException.java | 5 +++++ .../org/redisson/client/WriteRedisConnectionException.java | 5 +++++ 9 files changed, 41 insertions(+), 1 deletion(-) diff --git a/redisson/src/main/java/org/redisson/client/RedisAskException.java b/redisson/src/main/java/org/redisson/client/RedisAskException.java index 57dbcc91f..b88dd0064 100644 --- a/redisson/src/main/java/org/redisson/client/RedisAskException.java +++ b/redisson/src/main/java/org/redisson/client/RedisAskException.java @@ -15,6 +15,11 @@ */ package org.redisson.client; +/** + * + * @author Nikita Koksharov + * + */ public class RedisAskException extends RedisRedirectException { private static final long serialVersionUID = -6969734163155547631L; diff --git a/redisson/src/main/java/org/redisson/client/RedisConnectionException.java b/redisson/src/main/java/org/redisson/client/RedisConnectionException.java index 651e9543d..07e06dd92 100644 --- a/redisson/src/main/java/org/redisson/client/RedisConnectionException.java +++ b/redisson/src/main/java/org/redisson/client/RedisConnectionException.java @@ -15,6 +15,11 @@ */ package org.redisson.client; +/** + * + * @author Nikita Koksharov + * + */ public class RedisConnectionException extends RedisException { private static final long serialVersionUID = -4756928186967834601L; diff --git a/redisson/src/main/java/org/redisson/client/RedisLoadingException.java b/redisson/src/main/java/org/redisson/client/RedisLoadingException.java index db5e341e7..a0c21321d 100644 --- a/redisson/src/main/java/org/redisson/client/RedisLoadingException.java +++ b/redisson/src/main/java/org/redisson/client/RedisLoadingException.java @@ -15,6 +15,11 @@ */ package org.redisson.client; +/** + * + * @author Nikita Koksharov + * + */ public class RedisLoadingException extends RedisException { private static final long serialVersionUID = -2565335188503354660L; diff --git a/redisson/src/main/java/org/redisson/client/RedisMovedException.java b/redisson/src/main/java/org/redisson/client/RedisMovedException.java index 5fe893f22..2d60fbb87 100644 --- a/redisson/src/main/java/org/redisson/client/RedisMovedException.java +++ b/redisson/src/main/java/org/redisson/client/RedisMovedException.java @@ -15,6 +15,11 @@ */ package org.redisson.client; +/** + * + * @author Nikita Koksharov + * + */ public class RedisMovedException extends RedisRedirectException { private static final long serialVersionUID = -6969734163155547631L; diff --git a/redisson/src/main/java/org/redisson/client/RedisNodeNotFoundException.java b/redisson/src/main/java/org/redisson/client/RedisNodeNotFoundException.java index 7e53541aa..1c9316181 100644 --- a/redisson/src/main/java/org/redisson/client/RedisNodeNotFoundException.java +++ b/redisson/src/main/java/org/redisson/client/RedisNodeNotFoundException.java @@ -15,6 +15,11 @@ */ package org.redisson.client; +/** + * + * @author Nikita Koksharov + * + */ public class RedisNodeNotFoundException extends RedisException { private static final long serialVersionUID = -4756928186967834601L; diff --git a/redisson/src/main/java/org/redisson/client/RedisOutOfMemoryException.java b/redisson/src/main/java/org/redisson/client/RedisOutOfMemoryException.java index 1562c9277..99ae5036f 100644 --- a/redisson/src/main/java/org/redisson/client/RedisOutOfMemoryException.java +++ b/redisson/src/main/java/org/redisson/client/RedisOutOfMemoryException.java @@ -16,7 +16,7 @@ package org.redisson.client; /** - * This error occurs in case then Redis server free memory has been exhausted. + * This error occurs in case when Redis server free memory has been exhausted. * * @author Nikita Koksharov * diff --git a/redisson/src/main/java/org/redisson/client/RedisRedirectException.java b/redisson/src/main/java/org/redisson/client/RedisRedirectException.java index 93633b98a..8042950f8 100644 --- a/redisson/src/main/java/org/redisson/client/RedisRedirectException.java +++ b/redisson/src/main/java/org/redisson/client/RedisRedirectException.java @@ -18,6 +18,11 @@ package org.redisson.client; import java.net.InetSocketAddress; import java.net.URI; +/** + * + * @author Nikita Koksharov + * + */ public class RedisRedirectException extends RedisException { private static final long serialVersionUID = 181505625075250011L; diff --git a/redisson/src/main/java/org/redisson/client/RedisTimeoutException.java b/redisson/src/main/java/org/redisson/client/RedisTimeoutException.java index fe950c59a..9b0bd6080 100644 --- a/redisson/src/main/java/org/redisson/client/RedisTimeoutException.java +++ b/redisson/src/main/java/org/redisson/client/RedisTimeoutException.java @@ -15,6 +15,11 @@ */ package org.redisson.client; +/** + * + * @author Nikita Koksharov + * + */ public class RedisTimeoutException extends RedisException { private static final long serialVersionUID = -8418769175260962404L; diff --git a/redisson/src/main/java/org/redisson/client/WriteRedisConnectionException.java b/redisson/src/main/java/org/redisson/client/WriteRedisConnectionException.java index 8b6b53367..ee9eeb9cf 100644 --- a/redisson/src/main/java/org/redisson/client/WriteRedisConnectionException.java +++ b/redisson/src/main/java/org/redisson/client/WriteRedisConnectionException.java @@ -15,6 +15,11 @@ */ package org.redisson.client; +/** + * + * @author Nikita Koksharov + * + */ public class WriteRedisConnectionException extends RedisException { private static final long serialVersionUID = -4756928186967834601L; From 138be8e3ae72d4cbfb7b3da5cadd966c18c9af1f Mon Sep 17 00:00:00 2001 From: Nikita Date: Mon, 12 Sep 2016 15:46:51 +0300 Subject: [PATCH 14/15] testAutoExpire test fixed --- .../java/org/redisson/RedissonLockTest.java | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/redisson/src/test/java/org/redisson/RedissonLockTest.java b/redisson/src/test/java/org/redisson/RedissonLockTest.java index c07189fed..a885ec503 100644 --- a/redisson/src/test/java/org/redisson/RedissonLockTest.java +++ b/redisson/src/test/java/org/redisson/RedissonLockTest.java @@ -10,6 +10,7 @@ import java.util.concurrent.locks.Lock; import org.junit.Assert; import org.junit.Test; import org.redisson.api.RLock; +import org.redisson.api.RedissonClient; public class RedissonLockTest extends BaseConcurrentTest { @@ -72,15 +73,31 @@ public class RedissonLockTest extends BaseConcurrentTest { @Test public void testAutoExpire() throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); - testSingleInstanceConcurrency(1, r -> { - RLock lock = r.getLock("lock"); - lock.lock(); - latch.countDown(); - }); + + RedissonClient r = createInstance(); + + Thread t = new Thread() { + @Override + public void run() { + RLock lock = r.getLock("lock"); + lock.lock(); + latch.countDown(); + try { + Thread.sleep(15000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }; + + t.start(); Assert.assertTrue(latch.await(1, TimeUnit.SECONDS)); RLock lock = redisson.getLock("lock"); - Thread.sleep(TimeUnit.SECONDS.toMillis(RedissonLock.LOCK_EXPIRATION_INTERVAL_SECONDS + 1)); + t.join(); + r.shutdown(); + Thread.sleep(TimeUnit.SECONDS.toMillis(RedissonLock.LOCK_EXPIRATION_INTERVAL_SECONDS)); Assert.assertFalse("Transient lock has not expired automatically", lock.isLocked()); } From 2bed5e7cfdf35529a880234a7cf8801e5f442111 Mon Sep 17 00:00:00 2001 From: Nikita Date: Mon, 12 Sep 2016 17:36:02 +0300 Subject: [PATCH 15/15] default timeouts risen --- .../java/org/redisson/config/BaseConfig.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/redisson/src/main/java/org/redisson/config/BaseConfig.java b/redisson/src/main/java/org/redisson/config/BaseConfig.java index a7b9f0211..817e93642 100644 --- a/redisson/src/main/java/org/redisson/config/BaseConfig.java +++ b/redisson/src/main/java/org/redisson/config/BaseConfig.java @@ -38,18 +38,18 @@ class BaseConfig> { * Value in milliseconds. * */ - private int connectTimeout = 1000; + private int connectTimeout = 10000; /** * Redis server response timeout. Starts to countdown when Redis command was succesfully sent. * Value in milliseconds. * */ - private int timeout = 1000; + private int timeout = 3000; private int retryAttempts = 3; - private int retryInterval = 1000; + private int retryInterval = 1500; /** * Reconnection attempt timeout to Redis server then @@ -135,6 +135,8 @@ class BaseConfig> { /** * Error will be thrown if Redis command can't be sended to Redis server after retryAttempts. * But if it sent succesfully then timeout will be started. + *

+ * Default is 3 attempts * * @see #timeout * @param retryAttempts @@ -150,6 +152,8 @@ class BaseConfig> { /** * Time interval after which another one attempt to send Redis command will be executed. + *

+ * Default is 1500 milliseconds * * @see retryAttempts * @param retryInterval - time in milliseconds @@ -165,6 +169,8 @@ class BaseConfig> { /** * Redis server response timeout. + *

+ * Default is 3000 milliseconds * * @param timeout in milliseconds */ @@ -208,7 +214,9 @@ class BaseConfig> { /** * Timeout during connecting to any Redis server. - *

+ *

+ * Default is 10000 milliseconds. + * * @param connectTimeout - timeout in milliseconds * @return */ @@ -241,10 +249,10 @@ class BaseConfig> { /** * Reconnection attempt timeout to Redis server when * it has been excluded from internal list of available servers. - *

+ *

* On every such timeout event Redisson tries * to connect to disconnected Redis server. - *

+ *

* Default is 3000 * * @see #failedAttempts @@ -264,7 +272,7 @@ class BaseConfig> { * Redis server will be excluded from the internal list of available nodes * when sequential unsuccessful execution attempts of any Redis command * on this server reaches failedAttempts. - *

+ *

* Default is 3 * */