diff --git a/src/main/java/io/lettuce/core/RedisCommandBuilder.java b/src/main/java/io/lettuce/core/RedisCommandBuilder.java index e3935fe825..c3c5fd1baa 100644 --- a/src/main/java/io/lettuce/core/RedisCommandBuilder.java +++ b/src/main/java/io/lettuce/core/RedisCommandBuilder.java @@ -579,12 +579,7 @@ Command clusterDelSlotsRange(Range... ranges) { } Command clusterFailover(boolean force) { - - CommandArgs args = new CommandArgs<>(codec).add(FAILOVER); - if (force) { - args.add(FORCE); - } - return createCommand(CLUSTER, new StatusOutput<>(codec), args); + return clusterFailover(force, false); } Command clusterFailover(boolean force, boolean takeOver) { diff --git a/src/main/java/io/lettuce/core/cluster/api/async/RedisClusterAsyncCommands.java b/src/main/java/io/lettuce/core/cluster/api/async/RedisClusterAsyncCommands.java index cb58f5260c..3bec4011ec 100644 --- a/src/main/java/io/lettuce/core/cluster/api/async/RedisClusterAsyncCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/async/RedisClusterAsyncCommands.java @@ -147,9 +147,10 @@ public interface RedisClusterAsyncCommands 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 clusterFailover(boolean force, boolean takeOver); diff --git a/src/main/java/io/lettuce/core/cluster/api/reactive/RedisClusterReactiveCommands.java b/src/main/java/io/lettuce/core/cluster/api/reactive/RedisClusterReactiveCommands.java index eee5bea6f1..4558044d8c 100644 --- a/src/main/java/io/lettuce/core/cluster/api/reactive/RedisClusterReactiveCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/reactive/RedisClusterReactiveCommands.java @@ -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. @@ -150,6 +150,7 @@ public interface RedisClusterReactiveCommands 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 clusterFailover(boolean force, boolean takeOver); diff --git a/src/main/java/io/lettuce/core/cluster/api/sync/RedisClusterCommands.java b/src/main/java/io/lettuce/core/cluster/api/sync/RedisClusterCommands.java index 2a8ca0587a..9dc74c61bd 100644 --- a/src/main/java/io/lettuce/core/cluster/api/sync/RedisClusterCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/sync/RedisClusterCommands.java @@ -145,9 +145,10 @@ public interface RedisClusterCommands extends BaseRedisCommands, 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); diff --git a/src/test/java/io/lettuce/core/cluster/NodeSelectionSyncIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/NodeSelectionSyncIntegrationTests.java index 4e837f4e74..c1783021f7 100644 --- a/src/test/java/io/lettuce/core/cluster/NodeSelectionSyncIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/NodeSelectionSyncIntegrationTests.java @@ -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; @@ -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(); } diff --git a/src/test/java/io/lettuce/core/cluster/RedisClusterStressScenariosTest.java b/src/test/java/io/lettuce/core/cluster/RedisClusterStressScenariosTest.java index 05e8d90367..7100fba8a6 100644 --- a/src/test/java/io/lettuce/core/cluster/RedisClusterStressScenariosTest.java +++ b/src/test/java/io/lettuce/core/cluster/RedisClusterStressScenariosTest.java @@ -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() { @@ -156,7 +156,6 @@ public void testClusterFailoverWithTakeOver() { assertThat(redis5Node.is(RedisClusterNode.NodeFlag.REPLICA)).isTrue(); assertThat(redis6Node.is(RedisClusterNode.NodeFlag.UPSTREAM)).isTrue(); - } @Test @@ -194,7 +193,6 @@ public void testClusterConnectionStability() { } connection.getStatefulConnection().close(); - } }