refactoring

pull/4272/head
Nikita Koksharov 3 years ago
parent 31a5dc0977
commit 9bb03cd5c1

@ -23,7 +23,6 @@ import org.redisson.api.BatchResult;
import org.redisson.api.RFuture; import org.redisson.api.RFuture;
import org.redisson.api.RedissonClient; import org.redisson.api.RedissonClient;
import org.redisson.client.RedisClient; import org.redisson.client.RedisClient;
import org.redisson.client.RedisException;
import org.redisson.client.codec.*; import org.redisson.client.codec.*;
import org.redisson.client.protocol.RedisCommand; import org.redisson.client.protocol.RedisCommand;
import org.redisson.client.protocol.RedisCommands; import org.redisson.client.protocol.RedisCommands;
@ -37,8 +36,6 @@ import org.redisson.command.CommandAsyncService;
import org.redisson.command.CommandBatchService; import org.redisson.command.CommandBatchService;
import org.redisson.connection.MasterSlaveEntry; import org.redisson.connection.MasterSlaveEntry;
import org.redisson.misc.CompletableFutureWrapper; import org.redisson.misc.CompletableFutureWrapper;
import org.redisson.misc.RPromise;
import org.redisson.misc.RedissonPromise;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.redis.RedisSystemException; import org.springframework.data.redis.RedisSystemException;
@ -54,10 +51,7 @@ import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiConsumer;
import static org.redisson.client.protocol.RedisCommands.LRANGE; import static org.redisson.client.protocol.RedisCommands.LRANGE;

@ -53,8 +53,6 @@ import org.redisson.command.CommandAsyncService;
import org.redisson.command.CommandBatchService; import org.redisson.command.CommandBatchService;
import org.redisson.connection.MasterSlaveEntry; import org.redisson.connection.MasterSlaveEntry;
import org.redisson.misc.CompletableFutureWrapper; import org.redisson.misc.CompletableFutureWrapper;
import org.redisson.misc.RPromise;
import org.redisson.misc.RedissonPromise;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.redis.RedisSystemException; import org.springframework.data.redis.RedisSystemException;
@ -77,9 +75,6 @@ import org.springframework.data.redis.core.types.RedisClientInfo;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils; import org.springframework.util.ReflectionUtils;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.FutureListener;
/** /**
* Redisson connection * Redisson connection
* *

@ -25,8 +25,6 @@ import java.util.Map.Entry;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiConsumer;
import org.redisson.Redisson; import org.redisson.Redisson;
import org.redisson.SlotCallback; import org.redisson.SlotCallback;
@ -36,7 +34,6 @@ import org.redisson.api.BatchResult;
import org.redisson.api.RFuture; import org.redisson.api.RFuture;
import org.redisson.api.RedissonClient; import org.redisson.api.RedissonClient;
import org.redisson.client.RedisClient; import org.redisson.client.RedisClient;
import org.redisson.client.RedisException;
import org.redisson.client.codec.ByteArrayCodec; import org.redisson.client.codec.ByteArrayCodec;
import org.redisson.client.codec.Codec; import org.redisson.client.codec.Codec;
import org.redisson.client.codec.DoubleCodec; import org.redisson.client.codec.DoubleCodec;
@ -54,8 +51,6 @@ import org.redisson.command.CommandAsyncService;
import org.redisson.command.CommandBatchService; import org.redisson.command.CommandBatchService;
import org.redisson.connection.MasterSlaveEntry; import org.redisson.connection.MasterSlaveEntry;
import org.redisson.misc.CompletableFutureWrapper; import org.redisson.misc.CompletableFutureWrapper;
import org.redisson.misc.RPromise;
import org.redisson.misc.RedissonPromise;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.geo.*; import org.springframework.data.geo.*;
@ -80,9 +75,6 @@ import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.ReflectionUtils; import org.springframework.util.ReflectionUtils;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.FutureListener;
/** /**
* Redisson connection * Redisson connection
* *

@ -17,6 +17,7 @@ package org.redisson.spring.data.connection;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.concurrent.CompletionStage;
import java.util.function.Function; import java.util.function.Function;
import org.reactivestreams.Publisher; import org.reactivestreams.Publisher;
@ -25,8 +26,7 @@ import org.redisson.client.codec.Codec;
import org.redisson.client.codec.StringCodec; import org.redisson.client.codec.StringCodec;
import org.redisson.client.protocol.RedisCommand; import org.redisson.client.protocol.RedisCommand;
import org.redisson.connection.MasterSlaveEntry; import org.redisson.connection.MasterSlaveEntry;
import org.redisson.misc.RPromise; import org.redisson.misc.CompletableFutureWrapper;
import org.redisson.misc.RedissonPromise;
import org.redisson.reactive.CommandReactiveExecutor; import org.redisson.reactive.CommandReactiveExecutor;
import org.springframework.data.redis.RedisSystemException; import org.springframework.data.redis.RedisSystemException;
import org.springframework.data.redis.connection.RedisClusterNode; import org.springframework.data.redis.connection.RedisClusterNode;
@ -56,16 +56,8 @@ abstract class RedissonBaseReactive {
} }
RFuture<String> toStringFuture(RFuture<Void> f) { RFuture<String> toStringFuture(RFuture<Void> f) {
RPromise<String> promise = new RedissonPromise<>(); CompletionStage<String> ff = f.thenApply(r -> "OK");
f.onComplete((res, e) -> { return new CompletableFutureWrapper<>(ff);
if (e != null) {
promise.tryFailure(e);
return;
}
promise.trySuccess("OK");
});
return promise;
} }
<T> Mono<T> execute(RedisClusterNode node, RedisCommand<T> command, Object... params) { <T> Mono<T> execute(RedisClusterNode node, RedisCommand<T> command, Object... params) {

@ -38,8 +38,6 @@ import org.redisson.command.CommandAsyncService;
import org.redisson.command.CommandBatchService; import org.redisson.command.CommandBatchService;
import org.redisson.connection.MasterSlaveEntry; import org.redisson.connection.MasterSlaveEntry;
import org.redisson.misc.CompletableFutureWrapper; import org.redisson.misc.CompletableFutureWrapper;
import org.redisson.misc.RPromise;
import org.redisson.misc.RedissonPromise;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.geo.*; import org.springframework.data.geo.*;

@ -17,6 +17,7 @@ package org.redisson.spring.data.connection;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.concurrent.CompletionStage;
import java.util.function.Function; import java.util.function.Function;
import org.reactivestreams.Publisher; import org.reactivestreams.Publisher;
@ -25,14 +26,11 @@ import org.redisson.client.codec.Codec;
import org.redisson.client.codec.StringCodec; import org.redisson.client.codec.StringCodec;
import org.redisson.client.protocol.RedisCommand; import org.redisson.client.protocol.RedisCommand;
import org.redisson.connection.MasterSlaveEntry; import org.redisson.connection.MasterSlaveEntry;
import org.redisson.misc.RPromise; import org.redisson.misc.CompletableFutureWrapper;
import org.redisson.misc.RedissonPromise;
import org.redisson.reactive.CommandReactiveExecutor; import org.redisson.reactive.CommandReactiveExecutor;
import org.springframework.data.redis.RedisSystemException; import org.springframework.data.redis.RedisSystemException;
import org.springframework.data.redis.connection.RedisClusterNode; import org.springframework.data.redis.connection.RedisClusterNode;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.FutureListener;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@ -58,16 +56,8 @@ abstract class RedissonBaseReactive {
} }
RFuture<String> toStringFuture(RFuture<Void> f) { RFuture<String> toStringFuture(RFuture<Void> f) {
RPromise<String> promise = new RedissonPromise<>(); CompletionStage<String> ff = f.thenApply(r -> "OK");
f.onComplete((res, e) -> { return new CompletableFutureWrapper<>(ff);
if (e != null) {
promise.tryFailure(e);
return;
}
promise.trySuccess("OK");
});
return promise;
} }
<T> Mono<T> execute(RedisClusterNode node, RedisCommand<T> command, Object... params) { <T> Mono<T> execute(RedisClusterNode node, RedisCommand<T> command, Object... params) {

@ -17,6 +17,7 @@ package org.redisson.spring.data.connection;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.concurrent.CompletionStage;
import java.util.function.Function; import java.util.function.Function;
import org.reactivestreams.Publisher; import org.reactivestreams.Publisher;
@ -25,14 +26,11 @@ import org.redisson.client.codec.Codec;
import org.redisson.client.codec.StringCodec; import org.redisson.client.codec.StringCodec;
import org.redisson.client.protocol.RedisCommand; import org.redisson.client.protocol.RedisCommand;
import org.redisson.connection.MasterSlaveEntry; import org.redisson.connection.MasterSlaveEntry;
import org.redisson.misc.RPromise; import org.redisson.misc.CompletableFutureWrapper;
import org.redisson.misc.RedissonPromise;
import org.redisson.reactive.CommandReactiveExecutor; import org.redisson.reactive.CommandReactiveExecutor;
import org.springframework.data.redis.RedisSystemException; import org.springframework.data.redis.RedisSystemException;
import org.springframework.data.redis.connection.RedisClusterNode; import org.springframework.data.redis.connection.RedisClusterNode;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.FutureListener;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@ -58,16 +56,8 @@ abstract class RedissonBaseReactive {
} }
RFuture<String> toStringFuture(RFuture<Void> f) { RFuture<String> toStringFuture(RFuture<Void> f) {
RPromise<String> promise = new RedissonPromise<>(); CompletionStage<String> ff = f.thenApply(r -> "OK");
f.onComplete((res, e) -> { return new CompletableFutureWrapper<>(ff);
if (e != null) {
promise.tryFailure(e);
return;
}
promise.trySuccess("OK");
});
return promise;
} }
<T> Mono<T> execute(RedisClusterNode node, RedisCommand<T> command, Object... params) { <T> Mono<T> execute(RedisClusterNode node, RedisCommand<T> command, Object... params) {

@ -17,6 +17,7 @@ package org.redisson.spring.data.connection;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.concurrent.CompletionStage;
import java.util.function.Function; import java.util.function.Function;
import org.reactivestreams.Publisher; import org.reactivestreams.Publisher;
@ -25,14 +26,11 @@ import org.redisson.client.codec.Codec;
import org.redisson.client.codec.StringCodec; import org.redisson.client.codec.StringCodec;
import org.redisson.client.protocol.RedisCommand; import org.redisson.client.protocol.RedisCommand;
import org.redisson.connection.MasterSlaveEntry; import org.redisson.connection.MasterSlaveEntry;
import org.redisson.misc.RPromise; import org.redisson.misc.CompletableFutureWrapper;
import org.redisson.misc.RedissonPromise;
import org.redisson.reactive.CommandReactiveExecutor; import org.redisson.reactive.CommandReactiveExecutor;
import org.springframework.data.redis.RedisSystemException; import org.springframework.data.redis.RedisSystemException;
import org.springframework.data.redis.connection.RedisClusterNode; import org.springframework.data.redis.connection.RedisClusterNode;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.FutureListener;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@ -58,16 +56,8 @@ abstract class RedissonBaseReactive {
} }
RFuture<String> toStringFuture(RFuture<Void> f) { RFuture<String> toStringFuture(RFuture<Void> f) {
RPromise<String> promise = new RedissonPromise<>(); CompletionStage<String> ff = f.thenApply(r -> "OK");
f.onComplete((res, e) -> { return new CompletableFutureWrapper<>(ff);
if (e != null) {
promise.tryFailure(e);
return;
}
promise.trySuccess("OK");
});
return promise;
} }
<T> Mono<T> execute(RedisClusterNode node, RedisCommand<T> command, Object... params) { <T> Mono<T> execute(RedisClusterNode node, RedisCommand<T> command, Object... params) {

@ -17,6 +17,7 @@ package org.redisson.spring.data.connection;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.concurrent.CompletionStage;
import java.util.function.Function; import java.util.function.Function;
import org.reactivestreams.Publisher; import org.reactivestreams.Publisher;
@ -25,14 +26,11 @@ import org.redisson.client.codec.Codec;
import org.redisson.client.codec.StringCodec; import org.redisson.client.codec.StringCodec;
import org.redisson.client.protocol.RedisCommand; import org.redisson.client.protocol.RedisCommand;
import org.redisson.connection.MasterSlaveEntry; import org.redisson.connection.MasterSlaveEntry;
import org.redisson.misc.RPromise; import org.redisson.misc.CompletableFutureWrapper;
import org.redisson.misc.RedissonPromise;
import org.redisson.reactive.CommandReactiveExecutor; import org.redisson.reactive.CommandReactiveExecutor;
import org.springframework.data.redis.RedisSystemException; import org.springframework.data.redis.RedisSystemException;
import org.springframework.data.redis.connection.RedisClusterNode; import org.springframework.data.redis.connection.RedisClusterNode;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.FutureListener;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@ -58,16 +56,8 @@ abstract class RedissonBaseReactive {
} }
RFuture<String> toStringFuture(RFuture<Void> f) { RFuture<String> toStringFuture(RFuture<Void> f) {
RPromise<String> promise = new RedissonPromise<>(); CompletionStage<String> ff = f.thenApply(r -> "OK");
f.onComplete((res, e) -> { return new CompletableFutureWrapper<>(ff);
if (e != null) {
promise.tryFailure(e);
return;
}
promise.trySuccess("OK");
});
return promise;
} }
<T> Mono<T> execute(RedisClusterNode node, RedisCommand<T> command, Object... params) { <T> Mono<T> execute(RedisClusterNode node, RedisCommand<T> command, Object... params) {

@ -17,6 +17,7 @@ package org.redisson.spring.data.connection;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.concurrent.CompletionStage;
import java.util.function.Function; import java.util.function.Function;
import org.reactivestreams.Publisher; import org.reactivestreams.Publisher;
@ -25,14 +26,11 @@ import org.redisson.client.codec.Codec;
import org.redisson.client.codec.StringCodec; import org.redisson.client.codec.StringCodec;
import org.redisson.client.protocol.RedisCommand; import org.redisson.client.protocol.RedisCommand;
import org.redisson.connection.MasterSlaveEntry; import org.redisson.connection.MasterSlaveEntry;
import org.redisson.misc.RPromise; import org.redisson.misc.CompletableFutureWrapper;
import org.redisson.misc.RedissonPromise;
import org.redisson.reactive.CommandReactiveExecutor; import org.redisson.reactive.CommandReactiveExecutor;
import org.springframework.data.redis.RedisSystemException; import org.springframework.data.redis.RedisSystemException;
import org.springframework.data.redis.connection.RedisClusterNode; import org.springframework.data.redis.connection.RedisClusterNode;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.FutureListener;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@ -58,16 +56,8 @@ abstract class RedissonBaseReactive {
} }
RFuture<String> toStringFuture(RFuture<Void> f) { RFuture<String> toStringFuture(RFuture<Void> f) {
RPromise<String> promise = new RedissonPromise<>(); CompletionStage<String> ff = f.thenApply(r -> "OK");
f.onComplete((res, e) -> { return new CompletableFutureWrapper<>(ff);
if (e != null) {
promise.tryFailure(e);
return;
}
promise.trySuccess("OK");
});
return promise;
} }
<T> Mono<T> execute(RedisClusterNode node, RedisCommand<T> command, Object... params) { <T> Mono<T> execute(RedisClusterNode node, RedisCommand<T> command, Object... params) {

@ -17,6 +17,7 @@ package org.redisson.spring.data.connection;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.concurrent.CompletionStage;
import java.util.function.Function; import java.util.function.Function;
import org.reactivestreams.Publisher; import org.reactivestreams.Publisher;
@ -25,14 +26,11 @@ import org.redisson.client.codec.Codec;
import org.redisson.client.codec.StringCodec; import org.redisson.client.codec.StringCodec;
import org.redisson.client.protocol.RedisCommand; import org.redisson.client.protocol.RedisCommand;
import org.redisson.connection.MasterSlaveEntry; import org.redisson.connection.MasterSlaveEntry;
import org.redisson.misc.RPromise; import org.redisson.misc.CompletableFutureWrapper;
import org.redisson.misc.RedissonPromise;
import org.redisson.reactive.CommandReactiveExecutor; import org.redisson.reactive.CommandReactiveExecutor;
import org.springframework.data.redis.RedisSystemException; import org.springframework.data.redis.RedisSystemException;
import org.springframework.data.redis.connection.RedisClusterNode; import org.springframework.data.redis.connection.RedisClusterNode;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.FutureListener;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@ -58,16 +56,8 @@ abstract class RedissonBaseReactive {
} }
RFuture<String> toStringFuture(RFuture<Void> f) { RFuture<String> toStringFuture(RFuture<Void> f) {
RPromise<String> promise = new RedissonPromise<>(); CompletionStage<String> ff = f.thenApply(r -> "OK");
f.onComplete((res, e) -> { return new CompletableFutureWrapper<>(ff);
if (e != null) {
promise.tryFailure(e);
return;
}
promise.trySuccess("OK");
});
return promise;
} }
<T> Mono<T> execute(RedisClusterNode node, RedisCommand<T> command, Object... params) { <T> Mono<T> execute(RedisClusterNode node, RedisCommand<T> command, Object... params) {

@ -32,6 +32,7 @@ import io.netty.util.concurrent.Promise;
* *
* @param <T> type of object * @param <T> type of object
*/ */
@Deprecated
public class RedissonPromise<T> extends CompletableFuture<T> implements RPromise<T> { public class RedissonPromise<T> extends CompletableFuture<T> implements RPromise<T> {
private static final Field LISTENERS_FIELD; private static final Field LISTENERS_FIELD;

@ -1,7 +1,6 @@
package org.redisson; package org.redisson;
import org.junit.jupiter.api.*; import org.junit.jupiter.api.*;
import org.redisson.api.RFuture;
import org.redisson.client.*; import org.redisson.client.*;
import org.redisson.client.codec.LongCodec; import org.redisson.client.codec.LongCodec;
import org.redisson.client.codec.StringCodec; import org.redisson.client.codec.StringCodec;
@ -9,8 +8,6 @@ import org.redisson.client.protocol.CommandData;
import org.redisson.client.protocol.CommandsData; import org.redisson.client.protocol.CommandsData;
import org.redisson.client.protocol.RedisCommands; import org.redisson.client.protocol.RedisCommands;
import org.redisson.client.protocol.pubsub.PubSubType; import org.redisson.client.protocol.pubsub.PubSubType;
import org.redisson.misc.RPromise;
import org.redisson.misc.RedissonPromise;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;

Loading…
Cancel
Save