Search in sources :

Example 1 with RandomLB

use of com.hazelcast.client.util.RandomLB in project hazelcast by hazelcast.

the class ClientRandomLBTest method testRandomLB_withMembers.

@Test
public void testRandomLB_withMembers() {
    RandomLB randomLB = new RandomLB();
    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory();
    HazelcastInstance server = factory.newHazelcastInstance();
    Cluster cluster = server.getCluster();
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setLoadBalancer(randomLB);
    randomLB.init(cluster, clientConfig);
    Member member = cluster.getLocalMember();
    Member nextMember = randomLB.next();
    assertEquals(member, nextMember);
    factory.terminateAll();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Cluster(com.hazelcast.core.Cluster) ClientConfig(com.hazelcast.client.config.ClientConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) Member(com.hazelcast.core.Member) RandomLB(com.hazelcast.client.util.RandomLB) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with RandomLB

use of com.hazelcast.client.util.RandomLB in project hazelcast by hazelcast.

the class ClientRandomLBTest method testRandomLB_withoutMembers.

@Test
public void testRandomLB_withoutMembers() {
    RandomLB lb = new RandomLB();
    Member m = lb.next();
    assertNull(m);
}
Also used : Member(com.hazelcast.core.Member) RandomLB(com.hazelcast.client.util.RandomLB) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

RandomLB (com.hazelcast.client.util.RandomLB)2 Member (com.hazelcast.core.Member)2 ParallelTest (com.hazelcast.test.annotation.ParallelTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 ClientConfig (com.hazelcast.client.config.ClientConfig)1 Cluster (com.hazelcast.core.Cluster)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)1