Skip to content

Commit

Permalink
Polishing #2358
Browse files Browse the repository at this point in the history
Add since tags.
  • Loading branch information
mp911de committed Apr 18, 2023
1 parent 10f096b commit 99934ba
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 18 deletions.
7 changes: 1 addition & 6 deletions src/main/java/io/lettuce/core/RedisCommandBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -575,12 +575,7 @@ Command<K, V, String> clusterDelSlotsRange(Range<Integer>... ranges) {
}

Command<K, V, String> clusterFailover(boolean force) {

CommandArgs<K, V> args = new CommandArgs<>(codec).add(FAILOVER);
if (force) {
args.add(FORCE);
}
return createCommand(CLUSTER, new StatusOutput<>(codec), args);
return clusterFailover(force, false);
}

Command<K, V, String> clusterFailover(boolean force, boolean takeOver) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,10 @@ public interface RedisClusterAsyncCommands<K, V> extends BaseRedisAsyncCommands<
* Failover a cluster node. Turns the currently connected node into a master and the master into its replica.
*
* @param force do not coordinate with master if {@code true}
* @param takeOver do not coordinate with the rest of the cluster if {@code true}
* force will take precedence over takeOver if both are set.
* @param takeOver do not coordinate with the rest of the cluster if {@code true} force will take precedence over takeOver
* if both are set.
* @return String simple-string-reply
* @since 6.2.3
*/
RedisFuture<String> clusterFailover(boolean force, boolean takeOver);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
import java.time.Duration;
import java.util.List;

import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import io.lettuce.core.Range;
import io.lettuce.core.api.reactive.*;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
* A complete reactive and thread-safe cluster Redis API with 400+ Methods.
Expand Down Expand Up @@ -150,6 +150,7 @@ public interface RedisClusterReactiveCommands<K, V> extends BaseRedisReactiveCom
* @param force do not coordinate with master if {@code true}
* @param takeOver do not coordinate with the rest of the cluster if {@code true}
* @return String simple-string-reply
* @since 6.2.3
*/
Mono<String> clusterFailover(boolean force, boolean takeOver);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,10 @@ public interface RedisClusterCommands<K, V> extends BaseRedisCommands<K, V>, Red
* Failover a cluster node. Turns the currently connected node into a master and the master into its replica.
*
* @param force do not coordinate with master if {@code true}
* @param takeOver do not coordinate with the rest of the cluster if {@code true}
* force will take precedence over takeOver if both are set.
* @param takeOver do not coordinate with the rest of the cluster if {@code true} force will take precedence over takeOver
* if both are set.
* @return String simple-string-reply
* @since 6.2.3
*/
String clusterFailover(boolean force, boolean takeOver);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@
*/
package io.lettuce.core.cluster;

import static io.lettuce.core.ScriptOutputType.STATUS;
import static org.assertj.core.api.Assertions.assertThat;
import static io.lettuce.core.ScriptOutputType.*;
import static org.assertj.core.api.Assertions.*;
import static org.assertj.core.api.Fail.fail;

import java.time.Duration;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Vector;

import javax.inject.Inject;

Expand Down Expand Up @@ -56,6 +61,10 @@ class NodeSelectionSyncIntegrationTests extends TestSupport {

this.clusterClient = clusterClient;
this.commands = connection.sync();
try {
connection.sync().scriptKill();
} catch (Exception e) {
}
connection.sync().flushall();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ public void testClusterFailover() {

assertThat(redis5Node.is(RedisClusterNode.NodeFlag.REPLICA)).isTrue();
assertThat(redis6Node.is(RedisClusterNode.NodeFlag.UPSTREAM)).isTrue();

}

@Test
public void testClusterFailoverWithTakeOver() {

Expand All @@ -156,7 +156,6 @@ public void testClusterFailoverWithTakeOver() {

assertThat(redis5Node.is(RedisClusterNode.NodeFlag.REPLICA)).isTrue();
assertThat(redis6Node.is(RedisClusterNode.NodeFlag.UPSTREAM)).isTrue();

}

@Test
Expand Down Expand Up @@ -194,7 +193,6 @@ public void testClusterConnectionStability() {
}

connection.getStatefulConnection().close();

}

}

0 comments on commit 99934ba

Please sign in to comment.