Search in sources :

Example 36 with HazelcastClientProxy

use of com.hazelcast.client.impl.clientside.HazelcastClientProxy in project hazelcast by hazelcast.

the class ClientMetricsPropertiesTest method testInvalidSystemPropertiesIgnored.

@Test
public void testInvalidSystemPropertiesIgnored() {
    // setting non-defaults
    System.setProperty(ClientProperty.METRICS_ENABLED.getName(), "invalid");
    System.setProperty(ClientProperty.METRICS_JMX_ENABLED.getName(), "invalid");
    System.setProperty(ClientProperty.METRICS_COLLECTION_FREQUENCY.getName(), "invalid");
    HazelcastClientProxy client = createClient();
    ClientConfig config = client.getClientConfig();
    ClientMetricsConfig defaultConfig = new ClientMetricsConfig();
    // booleans result in false values even though they're "invalid"
    // therefore, all boolean config fields are set to false
    ClientMetricsConfig metricsConfig = config.getMetricsConfig();
    assertFalse(metricsConfig.isEnabled());
    assertFalse(metricsConfig.getJmxConfig().isEnabled());
    assertEquals(defaultConfig.getCollectionFrequencySeconds(), metricsConfig.getCollectionFrequencySeconds());
    // verify that the overridden config is used
    ClientMetricsConfig metricsConfigUsed = client.client.getClientStatisticsService().getMetricsConfig();
    assertSame(originalMetricsConfig, metricsConfigUsed);
}
Also used : ClientMetricsConfig(com.hazelcast.client.config.ClientMetricsConfig) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy) ClientConfig(com.hazelcast.client.config.ClientConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 37 with HazelcastClientProxy

use of com.hazelcast.client.impl.clientside.HazelcastClientProxy in project hazelcast by hazelcast.

the class ClientMetricsPropertiesTest method testDeprecatedPropertiesIgnored_whenNewPropertiesGiven.

@Test
public void testDeprecatedPropertiesIgnored_whenNewPropertiesGiven() {
    clientConfig.setProperty(ClientProperty.STATISTICS_ENABLED.getName(), "true");
    clientConfig.setProperty(ClientProperty.STATISTICS_PERIOD_SECONDS.getName(), "24");
    clientConfig.setProperty(ClientProperty.METRICS_ENABLED.getName(), "false");
    clientConfig.setProperty(ClientProperty.METRICS_COLLECTION_FREQUENCY.getName(), "30");
    HazelcastClientProxy client = createClient();
    ClientConfig clientConfig = client.getClientConfig();
    ClientMetricsConfig metricsConfig = clientConfig.getMetricsConfig();
    assertFalse(metricsConfig.isEnabled());
    assertEquals(30, metricsConfig.getCollectionFrequencySeconds());
}
Also used : ClientMetricsConfig(com.hazelcast.client.config.ClientMetricsConfig) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy) ClientConfig(com.hazelcast.client.config.ClientConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 38 with HazelcastClientProxy

use of com.hazelcast.client.impl.clientside.HazelcastClientProxy in project hazelcast by hazelcast.

the class ClientMapNearCacheBasicTest method createNearCacheContextBuilder.

private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder() {
    ClientConfig clientConfig = getClientConfig();
    HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
    IMap<K, V> clientMap = client.getMap(DEFAULT_NEAR_CACHE_NAME);
    NearCacheManager nearCacheManager = ((ClientMapProxy) clientMap).getContext().getNearCacheManager(clientMap.getServiceName());
    NearCache<Data, String> nearCache = nearCacheManager.getNearCache(DEFAULT_NEAR_CACHE_NAME);
    return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, client.getSerializationService()).setNearCacheInstance(client).setNearCacheAdapter(new IMapDataStructureAdapter<K, V>(clientMap)).setNearCache(nearCache).setNearCacheManager(nearCacheManager);
}
Also used : NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) NearCacheTestContextBuilder(com.hazelcast.internal.nearcache.impl.NearCacheTestContextBuilder) Data(com.hazelcast.internal.serialization.Data) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy)

Example 39 with HazelcastClientProxy

use of com.hazelcast.client.impl.clientside.HazelcastClientProxy in project hazelcast by hazelcast.

the class ClientMapNearCachePreloaderTest method createNearCacheContextBuilder.

private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder() {
    ClientConfig clientConfig = getClientConfig().addNearCacheConfig(nearCacheConfig);
    HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
    IMap<K, V> clientMap = client.getMap(nearCacheConfig.getName());
    NearCacheManager nearCacheManager = ((ClientMapProxy) clientMap).getContext().getNearCacheManager(clientMap.getServiceName());
    NearCache<Data, String> nearCache = nearCacheManager.getNearCache(nearCacheConfig.getName());
    return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, client.getSerializationService()).setNearCacheInstance(client).setNearCacheAdapter(new IMapDataStructureAdapter<K, V>(clientMap)).setNearCache(nearCache).setNearCacheManager(nearCacheManager);
}
Also used : NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) NearCacheTestContextBuilder(com.hazelcast.internal.nearcache.impl.NearCacheTestContextBuilder) Data(com.hazelcast.internal.serialization.Data) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy)

Example 40 with HazelcastClientProxy

use of com.hazelcast.client.impl.clientside.HazelcastClientProxy in project hazelcast by hazelcast.

the class TestDisabledSpringAwareAnnotation method testDisabledSpringManagedContext.

@Test
public void testDisabledSpringManagedContext() {
    HazelcastInstance instance = (HazelcastInstance) context.getBean("instance");
    assertNull(instance.getConfig().getManagedContext());
    HazelcastClientProxy client = (HazelcastClientProxy) context.getBean("client");
    assertNull(client.getClientConfig().getManagedContext());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

HazelcastClientProxy (com.hazelcast.client.impl.clientside.HazelcastClientProxy)42 ClientConfig (com.hazelcast.client.config.ClientConfig)27 Test (org.junit.Test)16 QuickTest (com.hazelcast.test.annotation.QuickTest)14 NearCacheManager (com.hazelcast.internal.nearcache.NearCacheManager)13 CachingProvider (javax.cache.spi.CachingProvider)13 CacheTestSupport.createClientCachingProvider (com.hazelcast.cache.CacheTestSupport.createClientCachingProvider)12 Data (com.hazelcast.internal.serialization.Data)12 CacheTestSupport.createServerCachingProvider (com.hazelcast.cache.CacheTestSupport.createServerCachingProvider)10 HazelcastInstance (com.hazelcast.core.HazelcastInstance)10 NearCacheTestContextBuilder (com.hazelcast.internal.nearcache.impl.NearCacheTestContextBuilder)9 HazelcastClientCacheManager (com.hazelcast.client.cache.impl.HazelcastClientCacheManager)7 HazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl)7 ClientMetricsConfig (com.hazelcast.client.config.ClientMetricsConfig)6 NearCacheConfig (com.hazelcast.config.NearCacheConfig)6 Config (com.hazelcast.config.Config)5 CacheManager (javax.cache.CacheManager)5 CacheConfig (com.hazelcast.config.CacheConfig)4 ICacheDataStructureAdapter (com.hazelcast.internal.adapter.ICacheDataStructureAdapter)4 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)4