use of com.hazelcast.cluster.Cluster in project hazelcast by hazelcast.
the class PromoteLiteMemberTest method promotion_shouldFail_whenMastershipClaimInProgress_duringPromotion.
@Test
public void promotion_shouldFail_whenMastershipClaimInProgress_duringPromotion() {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
HazelcastInstance hz1 = factory.newHazelcastInstance(new Config());
HazelcastInstance hz2 = factory.newHazelcastInstance(new Config().setLiteMember(true));
// artificially set mastership claim flag
ClusterServiceImpl clusterService = getNode(hz1).getClusterService();
clusterService.getClusterJoinManager().setMastershipClaimInProgress();
Cluster cluster = hz2.getCluster();
exception.expect(IllegalStateException.class);
cluster.promoteLocalLiteMember();
}
use of com.hazelcast.cluster.Cluster in project hazelcast by hazelcast.
the class AbstractClockTest method assertClusterSizeAlways.
protected static void assertClusterSizeAlways(final int expected, HazelcastInstance hz) {
final Cluster cluster = hz.getCluster();
assertTrueAllTheTime(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals("Cluster should be stable when system clock changes!", expected, cluster.getMembers().size());
}
}, JUMP_AFTER_SECONDS * 2);
}
use of com.hazelcast.cluster.Cluster in project hazelcast by hazelcast.
the class ClientRandomLBTest method testRandomLB_withMembers.
@Test
public void testRandomLB_withMembers() {
RandomLB randomLB = new RandomLB();
HazelcastInstance server = factory.newHazelcastInstance();
Cluster cluster = server.getCluster();
ClientConfig clientConfig = new ClientConfig();
clientConfig.setLoadBalancer(randomLB);
randomLB.init(cluster, clientConfig);
Member member = cluster.getLocalMember();
assertEquals(member, randomLB.next());
assertEquals(member, randomLB.nextDataMember());
}
use of com.hazelcast.cluster.Cluster in project hazelcast by hazelcast.
the class ClientRandomLBTest method testRandomLB_withLiteMembers.
@Test
public void testRandomLB_withLiteMembers() {
RandomLB randomLB = new RandomLB();
HazelcastInstance server = factory.newHazelcastInstance(new Config().setLiteMember(true));
Cluster cluster = server.getCluster();
ClientConfig clientConfig = new ClientConfig();
clientConfig.setLoadBalancer(randomLB);
randomLB.init(cluster, clientConfig);
Member member = cluster.getLocalMember();
assertEquals(member, randomLB.next());
assertNull(randomLB.nextDataMember());
}
use of com.hazelcast.cluster.Cluster in project hazelcast by hazelcast.
the class ClientRoundRobinLBTest method testRoundRobinLB_withLiteMembers.
@Test
public void testRoundRobinLB_withLiteMembers() {
RoundRobinLB roundRobinLB = new RoundRobinLB();
HazelcastInstance server = factory.newHazelcastInstance(new Config().setLiteMember(true));
Cluster cluster = server.getCluster();
ClientConfig clientConfig = new ClientConfig();
clientConfig.setLoadBalancer(roundRobinLB);
roundRobinLB.init(cluster, clientConfig);
Member member = cluster.getLocalMember();
assertEquals(member, roundRobinLB.next());
assertNull(roundRobinLB.nextDataMember());
}
Aggregations