refactoring

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

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

@ -238,7 +238,7 @@ public class RedissonKeys implements RKeys {
if (commandExecutor instanceof CommandBatchService
|| commandExecutor instanceof CommandReactiveBatchService
|| 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");
}

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

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

@ -972,10 +972,5 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager {
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) {
if (!connectionManager.isClusterMode()) {
if (!getServiceManager().getCfg().isClusterConfig()) {
Object[] keysArray = callback.createKeys(null, keys);
Object[] paramsArray = callback.createParams(Collections.emptyList());
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) {
if (!connectionManager.isClusterMode()) {
if (!getServiceManager().getCfg().isClusterConfig()) {
Object[] params = callback.createParams(Arrays.asList(keys));
if (readOnly) {
return readAsync((String) null, codec, command, params);
@ -881,7 +881,7 @@ public class CommandAsyncService implements CommandAsyncExecutor {
@Override
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());
if (connectionManager.isClusterMode() && queueNames.length > 0) {
if (getServiceManager().getCfg().isClusterConfig() && queueNames.length > 0) {
AtomicReference<Iterator<String>> ref = new AtomicReference<>();
List<String> names = new ArrayList<>();
names.add(name);

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

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

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

Loading…
Cancel
Save