Skip to content

Commit

Permalink
Ensure random member selectors select from full set of members.
Browse files Browse the repository at this point in the history
  • Loading branch information
kuujo committed Jan 21, 2015
1 parent 0f565e4 commit 8bcd211
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Expand Up @@ -33,7 +33,7 @@ public class AsyncMapTest extends ConcurrentTestCase {
public void testAsyncMapPutGet() throws Throwable {
TestCluster<AsyncMap<String, String>> cluster = TestCluster.of((uri, config) -> AsyncMap.create("test", uri, config, new AsyncMapConfig().withLog(new BufferedLog())));
cluster.open().thenRun(this::resume);
await(5000);
await(15000);
AsyncMap<String, String> map = cluster.activeResources().iterator().next();
map.put("foo", "Hello world!").thenRun(() -> {
map.get("foo").thenAccept(result -> {
Expand Down
Expand Up @@ -98,7 +98,7 @@ private void sync() {
Random random = new Random();
List<ReplicaInfo> randomMembers = new ArrayList<>(3);
for (int i = 0; i < Math.min(activeMembers.size(), 3); i++) {
randomMembers.add(activeMembers.get(random.nextInt(Math.min(activeMembers.size(), 2))));
randomMembers.add(activeMembers.get(random.nextInt(Math.min(activeMembers.size(), 3))));
}

// Increment the local member version in the vector clock.
Expand Down
Expand Up @@ -243,7 +243,7 @@ private Collection<CoordinatedMember> getGossipMembers() {
// Create a random list of three active members.
Collection<CoordinatedMember> randomMembers = new HashSet<>(3);
for (int i = 0; i < Math.min(activeMembers.size(), 3); i++) {
randomMembers.add(activeMembers.get(random.nextInt(Math.min(activeMembers.size(), 2))));
randomMembers.add(activeMembers.get(random.nextInt(Math.min(activeMembers.size(), 3))));
}
return randomMembers;
}
Expand Down

0 comments on commit 8bcd211

Please sign in to comment.