Search in sources :

Example 1 with ClientMetricsConfig

use of com.hazelcast.client.config.ClientMetricsConfig in project hazelcast by hazelcast.

the class TestClientApplicationContext method testMetrics.

@Test
public void testMetrics() {
    ClientMetricsConfig metricsConfig = metricsClient.getClientConfig().getMetricsConfig();
    assertFalse(metricsConfig.isEnabled());
    assertFalse(metricsConfig.getJmxConfig().isEnabled());
    assertEquals(42, metricsConfig.getCollectionFrequencySeconds());
}
Also used : ClientMetricsConfig(com.hazelcast.client.config.ClientMetricsConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with ClientMetricsConfig

use of com.hazelcast.client.config.ClientMetricsConfig in project hazelcast by hazelcast.

the class MetricsConfigHelper method overrideClientMetricsConfig.

/**
 * Overrides the {@link ClientMetricsConfig} in the provided {@link ClientConfig}
 * with the metrics system properties if present.
 * See the {@link ClientMetricsConfig} javadoc for the links between metrics
 * configuration fields and the system properties.
 *
 * @param config The configuration
 */
public static void overrideClientMetricsConfig(ClientConfig config, ILogger logger) {
    ClientMetricsConfig metricsConfig = config.getMetricsConfig();
    MetricsJmxConfig jmxConfig = metricsConfig.getJmxConfig();
    // Check old deprecated STATISTICS settings first.
    // MetricsConfig.collectionFrequencySeconds
    tryOverride(ClientProperty.STATISTICS_PERIOD_SECONDS, config::getProperty, prop -> metricsConfig.setCollectionFrequencySeconds(Integer.parseInt(prop)), () -> Integer.toString(metricsConfig.getCollectionFrequencySeconds()), "ClientMetricsConfig.collectionFrequencySeconds", logger);
    // MetricsConfig.enabled
    tryOverride(ClientProperty.STATISTICS_ENABLED, config::getProperty, prop -> metricsConfig.setEnabled(Boolean.parseBoolean(prop)), () -> Boolean.toString(metricsConfig.isEnabled()), "ClientMetricsConfig.enabled", logger);
    // MetricsConfig.enabled
    tryOverride(ClientProperty.METRICS_ENABLED, config::getProperty, prop -> metricsConfig.setEnabled(Boolean.parseBoolean(prop)), () -> Boolean.toString(metricsConfig.isEnabled()), "ClientMetricsConfig.enabled", logger);
    // MetricsJmxConfig.enabled
    tryOverride(ClientProperty.METRICS_JMX_ENABLED, config::getProperty, prop -> jmxConfig.setEnabled(Boolean.parseBoolean(prop)), () -> Boolean.toString(jmxConfig.isEnabled()), "MetricsJmxConfig.enabled", logger);
    // MetricsConfig.collectionFrequencySeconds
    tryOverride(ClientProperty.METRICS_COLLECTION_FREQUENCY, config::getProperty, prop -> metricsConfig.setCollectionFrequencySeconds(Integer.parseInt(prop)), () -> Integer.toString(metricsConfig.getCollectionFrequencySeconds()), "ClientMetricsConfig.collectionFrequencySeconds", logger);
}
Also used : ClientMetricsConfig(com.hazelcast.client.config.ClientMetricsConfig) MetricsJmxConfig(com.hazelcast.config.MetricsJmxConfig)

Example 3 with ClientMetricsConfig

use of com.hazelcast.client.config.ClientMetricsConfig 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 4 with ClientMetricsConfig

use of com.hazelcast.client.config.ClientMetricsConfig 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 5 with ClientMetricsConfig

use of com.hazelcast.client.config.ClientMetricsConfig 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)

Aggregations

ClientMetricsConfig (com.hazelcast.client.config.ClientMetricsConfig)9 QuickTest (com.hazelcast.test.annotation.QuickTest)7 Test (org.junit.Test)7 HazelcastClientProxy (com.hazelcast.client.impl.clientside.HazelcastClientProxy)6 ClientConfig (com.hazelcast.client.config.ClientConfig)4 MetricsConfig (com.hazelcast.config.MetricsConfig)1 MetricsJmxConfig (com.hazelcast.config.MetricsJmxConfig)1 NamedNodeMap (org.w3c.dom.NamedNodeMap)1 Node (org.w3c.dom.Node)1