use of com.hazelcast.client.impl.clientside.ClusterDiscoveryService in project hazelcast by hazelcast.
the class ClientClusterDiscoveryServiceTest method test_continueFromWhereItleftOff.
@Test
public void test_continueFromWhereItleftOff() {
ArrayList<CandidateClusterContext> arrayList = new ArrayList<>();
int numberOfCandidates = 10;
for (int i = 0; i < numberOfCandidates; i++) {
arrayList.add(createContext(i));
}
ClusterDiscoveryService discoveryService = new ClusterDiscoveryService(arrayList, 1, lifecycleService);
getNextCluster(discoveryService);
assertEquals(arrayList.get(2), getNextCluster(discoveryService));
assertEquals(arrayList.get(3), getNextCluster(discoveryService));
}
use of com.hazelcast.client.impl.clientside.ClusterDiscoveryService in project hazelcast by hazelcast.
the class ClientClusterDiscoveryServiceTest method test_no_iteration_when_try_count_is_zero.
@Test
public void test_no_iteration_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);
MutableInteger count = new MutableInteger();
for (int i = 0; i < 3; i++) {
discoveryService.tryNextCluster((o, o2) -> {
count.value++;
return false;
});
}
assertEquals(0, count.value);
}
use of com.hazelcast.client.impl.clientside.ClusterDiscoveryService in project hazelcast by hazelcast.
the class ClientClusterDiscoveryServiceTest method testSingleCandidateBehavior.
@Test
public void testSingleCandidateBehavior() {
CandidateClusterContext context = createContext(1);
ArrayList<CandidateClusterContext> arrayList = new ArrayList<>();
arrayList.add(context);
ClusterDiscoveryService discoveryService = new ClusterDiscoveryService(arrayList, 1, lifecycleService);
assertNotNull(discoveryService.current());
for (int i = 1; i < 3; i++) {
assertNotNull(discoveryService.current());
assertEquals(context, getNextCluster(discoveryService));
}
}
use of com.hazelcast.client.impl.clientside.ClusterDiscoveryService in project hazelcast by hazelcast.
the class ClientClusterDiscoveryServiceTest method test_oneIteration.
@Test
public void test_oneIteration() {
ArrayList<CandidateClusterContext> arrayList = new ArrayList<>();
int numberOfCandidates = 10;
for (int i = 0; i < numberOfCandidates; i++) {
arrayList.add(createContext(i));
}
ClusterDiscoveryService discoveryService = new ClusterDiscoveryService(arrayList, 1, lifecycleService);
MutableInteger count = new MutableInteger();
discoveryService.tryNextCluster((o, o2) -> {
count.value++;
return false;
});
assertEquals(numberOfCandidates, count.value);
}
Aggregations