Search in sources :

Example 1 with RoundRobinLB

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

the class TestClientApplicationContext method testClient.

@Test
public void testClient() {
    assertNotNull(client);
    assertNotNull(client2);
    assertNotNull(client3);
    ClientConfig config = client.getClientConfig();
    assertEquals("13", config.getProperty("hazelcast.client.retry.count"));
    assertEquals(3, config.getNetworkConfig().getConnectionAttemptLimit());
    assertEquals(1000, config.getNetworkConfig().getConnectionTimeout());
    assertEquals(3000, config.getNetworkConfig().getConnectionAttemptPeriod());
    ClientConfig config2 = client2.getClientConfig();
    assertEquals(credentials, config2.getSecurityConfig().getCredentials());
    client.getMap("default").put("Q", "q");
    client2.getMap("default").put("X", "x");
    IMap<Object, Object> map = instance.getMap("default");
    assertEquals("q", map.get("Q"));
    assertEquals("x", map.get("X"));
    ClientConfig config3 = client3.getClientConfig();
    SerializationConfig serConf = config3.getSerializationConfig();
    assertEquals(ByteOrder.BIG_ENDIAN, serConf.getByteOrder());
    assertEquals(false, serConf.isAllowUnsafe());
    assertEquals(false, serConf.isCheckClassDefErrors());
    assertEquals(false, serConf.isEnableCompression());
    assertEquals(false, serConf.isEnableSharedObject());
    assertEquals(false, serConf.isUseNativeByteOrder());
    assertEquals(10, serConf.getPortableVersion());
    Map<Integer, String> map1 = serConf.getDataSerializableFactoryClasses();
    assertNotNull(map1);
    assertTrue(map1.containsKey(1));
    assertEquals("com.hazelcast.spring.serialization.DummyDataSerializableFactory", map1.get(1));
    Map<Integer, String> portableFactoryClasses = serConf.getPortableFactoryClasses();
    assertNotNull(portableFactoryClasses);
    assertTrue(portableFactoryClasses.containsKey(2));
    assertEquals("com.hazelcast.spring.serialization.DummyPortableFactory", portableFactoryClasses.get(2));
    Collection<SerializerConfig> serializerConfigs = serConf.getSerializerConfigs();
    assertNotNull(serializerConfigs);
    SerializerConfig serializerConfig = serializerConfigs.iterator().next();
    assertNotNull(serializerConfig);
    assertEquals("com.hazelcast.nio.serialization.CustomSerializationTest$FooXmlSerializer", serializerConfig.getClassName());
    assertEquals("com.hazelcast.nio.serialization.CustomSerializationTest$Foo", serializerConfig.getTypeClassName());
    List<ProxyFactoryConfig> proxyFactoryConfigs = config3.getProxyFactoryConfigs();
    assertNotNull(proxyFactoryConfigs);
    ProxyFactoryConfig proxyFactoryConfig = proxyFactoryConfigs.get(0);
    assertNotNull(proxyFactoryConfig);
    assertEquals("com.hazelcast.spring.DummyProxyFactory", proxyFactoryConfig.getClassName());
    assertEquals("MyService", proxyFactoryConfig.getService());
    LoadBalancer loadBalancer = config3.getLoadBalancer();
    assertNotNull(loadBalancer);
    assertTrue(loadBalancer instanceof RoundRobinLB);
    NearCacheConfig nearCacheConfig = config3.getNearCacheConfig("default");
    assertNotNull(nearCacheConfig);
    assertEquals(1, nearCacheConfig.getTimeToLiveSeconds());
    assertEquals(70, nearCacheConfig.getMaxIdleSeconds());
    assertEquals(EvictionPolicy.LRU, nearCacheConfig.getEvictionConfig().getEvictionPolicy());
    assertEquals(4000, nearCacheConfig.getEvictionConfig().getSize());
    assertEquals(true, nearCacheConfig.isInvalidateOnChange());
    assertEquals(CACHE_ON_UPDATE, nearCacheConfig.getLocalUpdatePolicy());
}
Also used : SerializationConfig(com.hazelcast.config.SerializationConfig) LoadBalancer(com.hazelcast.client.LoadBalancer) NearCacheConfig(com.hazelcast.config.NearCacheConfig) RoundRobinLB(com.hazelcast.client.util.RoundRobinLB) SerializerConfig(com.hazelcast.config.SerializerConfig) ProxyFactoryConfig(com.hazelcast.client.config.ProxyFactoryConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with RoundRobinLB

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

the class ClientRoundRobinLBTest method testRoundRobinLB_withMembers.

@Test
public void testRoundRobinLB_withMembers() {
    RoundRobinLB roundRobinLB = new RoundRobinLB();
    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory();
    final HazelcastInstance server = factory.newHazelcastInstance();
    Cluster cluster = server.getCluster();
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setLoadBalancer(roundRobinLB);
    roundRobinLB.init(cluster, clientConfig);
    Member member = cluster.getLocalMember();
    Member nextMember = roundRobinLB.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) RoundRobinLB(com.hazelcast.client.util.RoundRobinLB) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 3 with RoundRobinLB

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

the class ClientRoundRobinLBTest method testRoundRobinLB_withoutMembers.

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

Aggregations

RoundRobinLB (com.hazelcast.client.util.RoundRobinLB)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 Test (org.junit.Test)3 ClientConfig (com.hazelcast.client.config.ClientConfig)2 Member (com.hazelcast.core.Member)2 ParallelTest (com.hazelcast.test.annotation.ParallelTest)2 LoadBalancer (com.hazelcast.client.LoadBalancer)1 ProxyFactoryConfig (com.hazelcast.client.config.ProxyFactoryConfig)1 NearCacheConfig (com.hazelcast.config.NearCacheConfig)1 SerializationConfig (com.hazelcast.config.SerializationConfig)1 SerializerConfig (com.hazelcast.config.SerializerConfig)1 Cluster (com.hazelcast.core.Cluster)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)1