Search in sources :

Example 11 with Cluster

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();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) Cluster(com.hazelcast.cluster.Cluster) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 12 with Cluster

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);
}
Also used : Cluster(com.hazelcast.cluster.Cluster) AssertTask(com.hazelcast.test.AssertTask)

Example 13 with Cluster

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());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Cluster(com.hazelcast.cluster.Cluster) ClientConfig(com.hazelcast.client.config.ClientConfig) Member(com.hazelcast.cluster.Member) RandomLB(com.hazelcast.client.util.RandomLB) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 14 with Cluster

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());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) ClientConfig(com.hazelcast.client.config.ClientConfig) Cluster(com.hazelcast.cluster.Cluster) ClientConfig(com.hazelcast.client.config.ClientConfig) Member(com.hazelcast.cluster.Member) RandomLB(com.hazelcast.client.util.RandomLB) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 15 with Cluster

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());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) ClientConfig(com.hazelcast.client.config.ClientConfig) Cluster(com.hazelcast.cluster.Cluster) ClientConfig(com.hazelcast.client.config.ClientConfig) Member(com.hazelcast.cluster.Member) RoundRobinLB(com.hazelcast.client.util.RoundRobinLB) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

Cluster (com.hazelcast.cluster.Cluster)24 HazelcastInstance (com.hazelcast.core.HazelcastInstance)13 Member (com.hazelcast.cluster.Member)12 Test (org.junit.Test)12 QuickTest (com.hazelcast.test.annotation.QuickTest)11 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)10 ClientConfig (com.hazelcast.client.config.ClientConfig)5 Config (com.hazelcast.config.Config)5 HazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl)4 MCClusterMetadata (com.hazelcast.client.impl.management.MCClusterMetadata)4 ClientClusterService (com.hazelcast.client.impl.spi.ClientClusterService)4 IPartition (com.hazelcast.internal.partition.IPartition)3 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)3 Partition (com.hazelcast.partition.Partition)3 PartitionService (com.hazelcast.partition.PartitionService)3 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)3 ExecutionException (java.util.concurrent.ExecutionException)3 HazelcastCommandLine.getHazelcastClientInstanceImpl (com.hazelcast.client.console.HazelcastCommandLine.getHazelcastClientInstanceImpl)2 RandomLB (com.hazelcast.client.util.RandomLB)2 RoundRobinLB (com.hazelcast.client.util.RoundRobinLB)2