Skip to content
This repository has been archived by the owner on Jun 11, 2023. It is now read-only.

Commit

Permalink
Polishing redis#1359
Browse files Browse the repository at this point in the history
Add author and since tags. Simplify test.

Original pull request: redis#1360.
  • Loading branch information
mp911de committed Jul 29, 2020
1 parent 6982a6f commit a731e82
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
* @param <K> Key type.
* @param <V> Value type.
* @author Mark Paluch
* @author Jon Chambers
* @since 3.3
*/
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
* @param <K> Key type.
* @param <V> Value type.
* @author Mark Paluch
* @author Jon Chambers
* @since 4.0
*/
public class RedisAdvancedClusterReactiveCommandsImpl<K, V> extends AbstractRedisReactiveCommands<K, V>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* Advanced asynchronous and thread-safe Redis Cluster API.
*
* @author Mark Paluch
* @author Jon Chambers
* @since 4.0
*/
public interface RedisAdvancedClusterAsyncCommands<K, V> extends RedisClusterAsyncCommands<K, V> {
Expand Down Expand Up @@ -250,6 +251,7 @@ default AsyncNodeSelection<K, V> all() {
*
* @return String simple-string-reply
* @see RedisServerAsyncCommands#flushallAsync()
* @since 6.0
*/
RedisFuture<String> flushallAsync();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* Advanced reactive and thread-safe Redis Cluster API.
*
* @author Mark Paluch
* @author Jon Chambers
* @since 5.0
*/
public interface RedisAdvancedClusterReactiveCommands<K, V> extends RedisClusterReactiveCommands<K, V> {
Expand Down Expand Up @@ -145,6 +146,7 @@ public interface RedisAdvancedClusterReactiveCommands<K, V> extends RedisCluster
*
* @return String simple-string-reply
* @see RedisServerReactiveCommands#flushallAsync()
* @since 6.0
*/
Mono<String> flushallAsync();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
import io.lettuce.core.cluster.api.NodeSelectionSupport;
import io.lettuce.core.cluster.api.StatefulRedisClusterConnection;
import io.lettuce.core.cluster.models.partitions.RedisClusterNode;
import io.lettuce.core.cluster.pubsub.api.async.PubSubAsyncNodeSelection;
import io.lettuce.core.output.KeyStreamingChannel;

/**
* Advanced synchronous and thread-safe Redis Cluster API.
*
* @author Mark Paluch
* @author Jon Chambers
* @since 4.0
*/
public interface RedisAdvancedClusterCommands<K, V> extends RedisClusterCommands<K, V> {
Expand Down Expand Up @@ -249,6 +249,7 @@ default NodeSelection<K, V> all() {
*
* @return String simple-string-reply
* @see RedisServerCommands#flushallAsync()
* @since 6.0
*/
String flushallAsync();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import java.time.Instant;
import java.util.*;
import java.util.stream.Collectors;

Expand All @@ -43,18 +42,15 @@
import io.lettuce.core.cluster.models.partitions.Partitions;
import io.lettuce.core.cluster.models.partitions.RedisClusterNode;
import io.lettuce.core.codec.Base16;
import io.lettuce.core.internal.LettuceStrings;
import io.lettuce.test.TestFutures;
import io.lettuce.test.KeysAndValues;
import io.lettuce.test.LettuceExtension;
import io.lettuce.test.ListStreamingAdapter;
import io.lettuce.test.*;
import io.lettuce.test.condition.EnabledOnCommand;
import io.lettuce.test.settings.TestSettings;

/**
* Integration tests for {@link StatefulRedisClusterConnection}.
*
*
* @author Mark Paluch
* @author Jon Chambers
*/
@SuppressWarnings("rawtypes")
@ExtendWith(LettuceExtension.class)
Expand Down Expand Up @@ -341,21 +337,17 @@ void flushall() {
}

@Test
void flushallAsync() throws InterruptedException {
void flushallAsync() {

writeKeysToTwoNodes();

assertThat(sync.flushallAsync()).isEqualTo("OK");

// This is hacky, but by its nature FLUSHALL ASYNC doesn't give us a mechanism to know when it's done
boolean bothKeysCleared = false;
final Instant deadline = Instant.now().plusSeconds(1);

while (!bothKeysCleared && Instant.now().isBefore(deadline)) {
bothKeysCleared = sync.get(KEY_ON_NODE_1) == null && sync.get(KEY_ON_NODE_2) == null;
}
Wait.untilTrue(() -> sync.get(KEY_ON_NODE_1) == null).waitOrTimeout();
Wait.untilTrue(() -> sync.get(KEY_ON_NODE_2) == null).waitOrTimeout();

assertThat(bothKeysCleared).isTrue();
assertThat(sync.get(KEY_ON_NODE_1)).isNull();
assertThat(sync.get(KEY_ON_NODE_2)).isNull();
}

@Test
Expand Down

0 comments on commit a731e82

Please sign in to comment.