refactoring

pull/5884/head
Nikita Koksharov 10 months ago
parent e3bb1aa390
commit 3fb2b97edd

@ -1169,7 +1169,7 @@ public final class Redisson implements RedissonClient {
@Override @Override
public ClusterNodesGroup getClusterNodesGroup() { public ClusterNodesGroup getClusterNodesGroup() {
if (!connectionManager.isClusterMode()) { if (!config.isClusterConfig()) {
throw new IllegalStateException("Redisson is not in cluster mode!"); throw new IllegalStateException("Redisson is not in cluster mode!");
} }
return new RedisClusterNodes(connectionManager, connectionManager.getServiceManager(), commandExecutor); return new RedisClusterNodes(connectionManager, connectionManager.getServiceManager(), commandExecutor);

@ -238,7 +238,7 @@ public class RedissonKeys implements RKeys {
if (commandExecutor instanceof CommandBatchService if (commandExecutor instanceof CommandBatchService
|| commandExecutor instanceof CommandReactiveBatchService || commandExecutor instanceof CommandReactiveBatchService
|| commandExecutor instanceof CommandRxBatchService) { || commandExecutor instanceof CommandRxBatchService) {
if (getConnectionManager().isClusterMode()) { if (commandExecutor.getServiceManager().getCfg().isClusterConfig()) {
throw new IllegalStateException("This method doesn't work in batch for Redis cluster mode. For Redis cluster execute it as non-batch method"); throw new IllegalStateException("This method doesn't work in batch for Redis cluster mode. For Redis cluster execute it as non-batch method");
} }

@ -956,7 +956,7 @@ public class RedissonReactive implements RedissonReactiveClient {
@Override @Override
public NodesGroup<ClusterNode> getClusterNodesGroup() { public NodesGroup<ClusterNode> getClusterNodesGroup() {
if (!connectionManager.isClusterMode()) { if (!getConfig().isClusterConfig()) {
throw new IllegalStateException("Redisson not in cluster mode!"); throw new IllegalStateException("Redisson not in cluster mode!");
} }
return new RedisNodes<>(connectionManager, connectionManager.getServiceManager(), commandExecutor); return new RedisNodes<>(connectionManager, connectionManager.getServiceManager(), commandExecutor);

@ -959,7 +959,7 @@ public class RedissonRx implements RedissonRxClient {
@Override @Override
public NodesGroup<ClusterNode> getClusterNodesGroup() { public NodesGroup<ClusterNode> getClusterNodesGroup() {
if (!connectionManager.isClusterMode()) { if (!getConfig().isClusterConfig()) {
throw new IllegalStateException("Redisson not in cluster mode!"); throw new IllegalStateException("Redisson not in cluster mode!");
} }
return new RedisNodes<ClusterNode>(connectionManager, connectionManager.getServiceManager(), commandExecutor); return new RedisNodes<ClusterNode>(connectionManager, connectionManager.getServiceManager(), commandExecutor);

@ -972,10 +972,5 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager {
return lastClusterNode; return lastClusterNode;
} }
@Override
public boolean isClusterMode() {
return true;
}
} }

@ -659,7 +659,7 @@ public class CommandAsyncService implements CommandAsyncExecutor {
} }
private <T, R> RFuture<R> evalBatchedAsync(boolean readOnly, Codec codec, RedisCommand<T> command, String script, List<Object> keys, SlotCallback<T, R> callback) { private <T, R> RFuture<R> evalBatchedAsync(boolean readOnly, Codec codec, RedisCommand<T> command, String script, List<Object> keys, SlotCallback<T, R> callback) {
if (!connectionManager.isClusterMode()) { if (!getServiceManager().getCfg().isClusterConfig()) {
Object[] keysArray = callback.createKeys(null, keys); Object[] keysArray = callback.createKeys(null, keys);
Object[] paramsArray = callback.createParams(Collections.emptyList()); Object[] paramsArray = callback.createParams(Collections.emptyList());
if (readOnly) { if (readOnly) {
@ -740,7 +740,7 @@ public class CommandAsyncService implements CommandAsyncExecutor {
} }
private <T, R> RFuture<R> executeBatchedAsync(boolean readOnly, Codec codec, RedisCommand<T> command, SlotCallback<T, R> callback, Object[] keys) { private <T, R> RFuture<R> executeBatchedAsync(boolean readOnly, Codec codec, RedisCommand<T> command, SlotCallback<T, R> callback, Object[] keys) {
if (!connectionManager.isClusterMode()) { if (!getServiceManager().getCfg().isClusterConfig()) {
Object[] params = callback.createParams(Arrays.asList(keys)); Object[] params = callback.createParams(Arrays.asList(keys));
if (readOnly) { if (readOnly) {
return readAsync((String) null, codec, command, params); return readAsync((String) null, codec, command, params);
@ -881,7 +881,7 @@ public class CommandAsyncService implements CommandAsyncExecutor {
@Override @Override
public <V> RFuture<V> pollFromAnyAsync(String name, Codec codec, RedisCommand<?> command, long secondsTimeout, String... queueNames) { public <V> RFuture<V> pollFromAnyAsync(String name, Codec codec, RedisCommand<?> command, long secondsTimeout, String... queueNames) {
List<String> mappedNames = Arrays.stream(queueNames).map(m -> connectionManager.getServiceManager().getConfig().getNameMapper().map(m)).collect(Collectors.toList()); List<String> mappedNames = Arrays.stream(queueNames).map(m -> connectionManager.getServiceManager().getConfig().getNameMapper().map(m)).collect(Collectors.toList());
if (connectionManager.isClusterMode() && queueNames.length > 0) { if (getServiceManager().getCfg().isClusterConfig() && queueNames.length > 0) {
AtomicReference<Iterator<String>> ref = new AtomicReference<>(); AtomicReference<Iterator<String>> ref = new AtomicReference<>();
List<String> names = new ArrayList<>(); List<String> names = new ArrayList<>();
names.add(name); names.add(name);

@ -40,8 +40,6 @@ public interface ConnectionManager {
RedisURI getLastClusterNode(); RedisURI getLastClusterNode();
boolean isClusterMode();
int calcSlot(String key); int calcSlot(String key);
int calcSlot(ByteBuf key); int calcSlot(ByteBuf key);

@ -139,11 +139,6 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
}); });
} }
@Override
public boolean isClusterMode() {
return false;
}
@Override @Override
public Collection<MasterSlaveEntry> getEntrySet() { public Collection<MasterSlaveEntry> getEntrySet() {
lazyConnect(); lazyConnect();

@ -212,7 +212,7 @@ public class AccessorInterceptor {
set.removeAsync(((RLiveObject) me).getLiveObjectId()); set.removeAsync(((RLiveObject) me).getLiveObjectId());
} else { } else {
if (ClassUtils.isAnnotationPresent(field.getType(), REntity.class) if (ClassUtils.isAnnotationPresent(field.getType(), REntity.class)
|| commandExecutor.getConnectionManager().isClusterMode()) { || commandExecutor.getServiceManager().getCfg().isClusterConfig()) {
CompletableFuture<Object> f; CompletableFuture<Object> f;
if (commandExecutor instanceof CommandBatchService) { if (commandExecutor instanceof CommandBatchService) {
f = liveMap.removeAsync(field.getName()).toCompletableFuture(); f = liveMap.removeAsync(field.getName()).toCompletableFuture();

Loading…
Cancel
Save