Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Koksharov committed May 16, 2024
1 parent e3bb1aa commit 3fb2b97
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 20 deletions.
2 changes: 1 addition & 1 deletion redisson/src/main/java/org/redisson/Redisson.java
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ public NodesGroup<Node> getNodesGroup() {

@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);
Expand Down
2 changes: 1 addition & 1 deletion redisson/src/main/java/org/redisson/RedissonKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public RFuture<Long> deleteByPatternAsync(String pattern) {
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");
}

Expand Down
2 changes: 1 addition & 1 deletion redisson/src/main/java/org/redisson/RedissonReactive.java
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ public NodesGroup<Node> getNodesGroup() {

@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);
Expand Down
2 changes: 1 addition & 1 deletion redisson/src/main/java/org/redisson/RedissonRx.java
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ public NodesGroup<Node> getNodesGroup() {

@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -972,10 +972,5 @@ public RedisURI getLastClusterNode() {
return lastClusterNode;
}

@Override
public boolean isClusterMode() {
return true;
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ public <T, R> RFuture<R> evalReadBatchedAsync(Codec codec, RedisCommand<T> comma
}

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) {
Expand Down Expand Up @@ -740,7 +740,7 @@ private <T, R> RFuture<R> evalBatchedAsync(boolean readOnly, Codec codec, RedisC
}

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);
Expand Down Expand Up @@ -881,7 +881,7 @@ public ByteBuf encodeMapValue(Codec codec, Object value) {
@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ public interface ConnectionManager {
PublishSubscribeService getSubscribeService();

RedisURI getLastClusterNode();

boolean isClusterMode();

int calcSlot(String key);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,6 @@ protected final CompletionStage<RedisConnection> connectToNode(NodeType type, Ba
});
}

@Override
public boolean isClusterMode() {
return false;
}

@Override
public Collection<MasterSlaveEntry> getEntrySet() {
lazyConnect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private void removeIndex(RMap<String, Object> liveMap, Object me, Field field) {
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();
Expand Down

0 comments on commit 3fb2b97

Please sign in to comment.