use of com.hazelcast.client.impl.clientside.ClusterDiscoveryService in project hazelcast by hazelcast.
the class ClientClusterDiscoveryServiceTest method test_current_and_next_clusters_are_same_when_single_candidate_with_multiple_tries.
@Test
public void test_current_and_next_clusters_are_same_when_single_candidate_with_multiple_tries() {
CandidateClusterContext context = createContext(1);
ArrayList<CandidateClusterContext> arrayList = new ArrayList<>();
arrayList.add(context);
ClusterDiscoveryService discoveryService = new ClusterDiscoveryService(arrayList, 7, lifecycleService);
Set<CandidateClusterContext> scannedClusters = new HashSet<>();
discoveryService.tryNextCluster((current, next) -> {
scannedClusters.add(current);
scannedClusters.add(next);
return false;
});
assertEquals(1, scannedClusters.size());
assertTrue(scannedClusters.contains(context));
}
use of com.hazelcast.client.impl.clientside.ClusterDiscoveryService in project hazelcast by hazelcast.
the class ClientClusterDiscoveryServiceTest method test_n_iterations.
@Test
public void test_n_iterations() {
ArrayList<CandidateClusterContext> arrayList = new ArrayList<>();
int n = 15;
for (int i = 0; i < 10; i++) {
arrayList.add(createContext(i));
}
ClusterDiscoveryService discoveryService = new ClusterDiscoveryService(arrayList, n, lifecycleService);
MutableInteger count = new MutableInteger();
discoveryService.tryNextCluster((o, o2) -> {
count.value++;
return false;
});
assertEquals(10 * n, count.value);
}
use of com.hazelcast.client.impl.clientside.ClusterDiscoveryService in project hazelcast by hazelcast.
the class ClientClusterDiscoveryServiceTest method test_current_candidate_does_not_change_when_try_count_is_zero.
@Test
public void test_current_candidate_does_not_change_when_try_count_is_zero() {
ArrayList<CandidateClusterContext> arrayList = new ArrayList<>();
int numberOfCandidates = 10;
for (int i = 0; i < numberOfCandidates; i++) {
arrayList.add(createContext(i));
}
ClusterDiscoveryService discoveryService = new ClusterDiscoveryService(arrayList, 0, lifecycleService);
Set<CandidateClusterContext> candidates = new HashSet<>();
for (int i = 0; i < 3; i++) {
candidates.add(discoveryService.current());
}
assertTrue(candidates.toString(), candidates.contains(arrayList.get(0)));
}
use of com.hazelcast.client.impl.clientside.ClusterDiscoveryService in project hazelcast by hazelcast.
the class ClientClusterDiscoveryServiceTest method testCurrentAndNextReturnsCorrect.
@Test
public void testCurrentAndNextReturnsCorrect() {
ArrayList<CandidateClusterContext> arrayList = new ArrayList<>();
CandidateClusterContext first = createContext(1);
arrayList.add(first);
CandidateClusterContext second = createContext(2);
arrayList.add(second);
ClusterDiscoveryService discoveryService = new ClusterDiscoveryService(arrayList, 10, lifecycleService);
assertEquals(first, discoveryService.current());
assertEquals(second, getNextCluster(discoveryService));
assertEquals(second, discoveryService.current());
assertEquals(first, getNextCluster(discoveryService));
assertEquals(first, discoveryService.current());
}
use of com.hazelcast.client.impl.clientside.ClusterDiscoveryService in project hazelcast by hazelcast.
the class ClientClusterDiscoveryServiceTest method test_current_and_next_clusters_are_same_when_single_candidate.
@Test
public void test_current_and_next_clusters_are_same_when_single_candidate() {
CandidateClusterContext context = createContext(1);
ArrayList<CandidateClusterContext> arrayList = new ArrayList<>();
arrayList.add(context);
ClusterDiscoveryService discoveryService = new ClusterDiscoveryService(arrayList, 1, lifecycleService);
Set<CandidateClusterContext> scannedClusters = new HashSet<>();
discoveryService.tryNextCluster((current, next) -> {
scannedClusters.add(current);
scannedClusters.add(next);
return false;
});
assertEquals(1, scannedClusters.size());
assertTrue(scannedClusters.contains(context));
}
Aggregations