Search in sources :

Example 16 with HazelcastClientProxy

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

the class ClientMetricsPropertiesTest method testSystemPropertiesOverrideConfig.

@Test
public void testSystemPropertiesOverrideConfig() {
    // setting non-defaults
    System.setProperty(ClientProperty.METRICS_ENABLED.getName(), "false");
    System.setProperty(ClientProperty.METRICS_JMX_ENABLED.getName(), "false");
    System.setProperty(ClientProperty.METRICS_COLLECTION_FREQUENCY.getName(), "24");
    HazelcastClientProxy client = createClient();
    ClientConfig clientConfig = client.getClientConfig();
    ClientMetricsConfig metricsConfig = clientConfig.getMetricsConfig();
    assertFalse(metricsConfig.isEnabled());
    assertFalse(metricsConfig.getJmxConfig().isEnabled());
    assertEquals(24, 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 17 with HazelcastClientProxy

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

the class ClientMetricsPropertiesTest method testConfigPropertiesOverrideConfig.

@Test
public void testConfigPropertiesOverrideConfig() {
    // setting non-defaults
    clientConfig.setProperty(ClientProperty.METRICS_ENABLED.getName(), "false");
    clientConfig.setProperty(ClientProperty.METRICS_JMX_ENABLED.getName(), "false");
    clientConfig.setProperty(ClientProperty.METRICS_COLLECTION_FREQUENCY.getName(), "24");
    HazelcastClientProxy client = createClient();
    assertFalse(originalMetricsConfig.isEnabled());
    assertFalse(originalMetricsConfig.getJmxConfig().isEnabled());
    assertEquals(24, originalMetricsConfig.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) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 18 with HazelcastClientProxy

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

the class ClientMetricsPropertiesTest method testDeprecatedPropertiesStillEffective.

@Test
public void testDeprecatedPropertiesStillEffective() {
    // setting non-defaults
    clientConfig.setProperty(ClientProperty.STATISTICS_ENABLED.getName(), "false");
    clientConfig.setProperty(ClientProperty.STATISTICS_PERIOD_SECONDS.getName(), "24");
    HazelcastClientProxy client = createClient();
    ClientConfig clientConfig = client.getClientConfig();
    ClientMetricsConfig metricsConfig = clientConfig.getMetricsConfig();
    assertFalse(metricsConfig.isEnabled());
    assertEquals(24, 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 19 with HazelcastClientProxy

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

the class ClientMetricsPropertiesTest method testInvalidConfigPropertiesIgnored.

@Test
public void testInvalidConfigPropertiesIgnored() {
    // setting non-defaults
    clientConfig.setProperty(ClientProperty.METRICS_ENABLED.getName(), "invalid");
    clientConfig.setProperty(ClientProperty.METRICS_JMX_ENABLED.getName(), "invalid");
    clientConfig.setProperty(ClientProperty.METRICS_COLLECTION_FREQUENCY.getName(), "invalid");
    HazelcastClientProxy client = createClient();
    MetricsConfig defaultConfig = new MetricsConfig();
    // booleans result in false values even though they're "invalid"
    // therefore, all boolean config fields are set to false
    assertFalse(originalMetricsConfig.isEnabled());
    assertFalse(originalMetricsConfig.getJmxConfig().isEnabled());
    assertEquals(defaultConfig.getCollectionFrequencySeconds(), originalMetricsConfig.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) MetricsConfig(com.hazelcast.config.MetricsConfig) ClientMetricsConfig(com.hazelcast.client.config.ClientMetricsConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 20 with HazelcastClientProxy

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

the class ClientMapNearCacheSerializationCountTest method createNearCacheContextBuilder.

private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder() {
    ClientConfig clientConfig = getClientConfig();
    if (nearCacheConfig != null) {
        clientConfig.addNearCacheConfig(nearCacheConfig);
    }
    prepareSerializationConfig(clientConfig.getSerializationConfig());
    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)

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