Search in sources :

Example 6 with MetricsConfig

use of com.hazelcast.config.MetricsConfig in project hazelcast by hazelcast.

the class MetricsPropertiesTest method testSystemPropertiesOverrideConfig.

@Test
public void testSystemPropertiesOverrideConfig() {
    // setting non-defaults
    System.setProperty(ClusterProperty.METRICS_ENABLED.getName(), "false");
    System.setProperty(ClusterProperty.METRICS_MC_ENABLED.getName(), "false");
    System.setProperty(ClusterProperty.METRICS_MC_RETENTION.getName(), "42");
    System.setProperty(ClusterProperty.METRICS_JMX_ENABLED.getName(), "false");
    System.setProperty(ClusterProperty.METRICS_COLLECTION_FREQUENCY.getName(), "24");
    HazelcastInstance instance = createHazelcastInstance();
    Config instanceConfig = instance.getConfig();
    MetricsConfig metricsConfig = instanceConfig.getMetricsConfig();
    assertFalse(metricsConfig.isEnabled());
    assertFalse(metricsConfig.getManagementCenterConfig().isEnabled());
    assertEquals(42, metricsConfig.getManagementCenterConfig().getRetentionSeconds());
    assertFalse(metricsConfig.getJmxConfig().isEnabled());
    assertEquals(24, metricsConfig.getCollectionFrequencySeconds());
    // verify that the overridden config is used
    MetricsService metricsService = getNodeEngineImpl(instance).getService(MetricsService.SERVICE_NAME);
    assertSame(metricsConfig, metricsService.getConfig());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) MetricsConfig(com.hazelcast.config.MetricsConfig) MetricsConfig(com.hazelcast.config.MetricsConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with MetricsConfig

use of com.hazelcast.config.MetricsConfig in project hazelcast by hazelcast.

the class MetricsPropertiesTest method testInvalidConfigPropertiesIgnored.

@Test
public void testInvalidConfigPropertiesIgnored() {
    Config originalConfig = smallInstanceConfig();
    // setting non-defaults
    originalConfig.setProperty(ClusterProperty.METRICS_ENABLED.getName(), "invalid");
    originalConfig.setProperty(ClusterProperty.METRICS_MC_ENABLED.getName(), "invalid");
    originalConfig.setProperty(ClusterProperty.METRICS_MC_RETENTION.getName(), "invalid");
    originalConfig.setProperty(ClusterProperty.METRICS_JMX_ENABLED.getName(), "invalid");
    originalConfig.setProperty(ClusterProperty.METRICS_COLLECTION_FREQUENCY.getName(), "invalid");
    HazelcastInstance instance = createHazelcastInstance(originalConfig);
    Config instanceConfig = instance.getConfig();
    MetricsConfig defaultConfig = new MetricsConfig();
    // booleans result in false values even though they're "invalid"
    // therefore, all boolean config fields are set to false
    MetricsConfig metricsConfig = instanceConfig.getMetricsConfig();
    assertFalse(metricsConfig.isEnabled());
    assertFalse(metricsConfig.getManagementCenterConfig().isEnabled());
    assertEquals(defaultConfig.getManagementCenterConfig().getRetentionSeconds(), metricsConfig.getManagementCenterConfig().getRetentionSeconds());
    assertFalse(metricsConfig.getJmxConfig().isEnabled());
    assertEquals(defaultConfig.getCollectionFrequencySeconds(), metricsConfig.getCollectionFrequencySeconds());
    // verify that the overridden config is used
    MetricsService metricsService = getNodeEngineImpl(instance).getService(MetricsService.SERVICE_NAME);
    assertSame(metricsConfig, metricsService.getConfig());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) MetricsConfig(com.hazelcast.config.MetricsConfig) MetricsConfig(com.hazelcast.config.MetricsConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with MetricsConfig

use of com.hazelcast.config.MetricsConfig in project hazelcast by hazelcast.

the class MetricsPropertiesTest method testConfigPropertiesOverrideConfig.

@Test
public void testConfigPropertiesOverrideConfig() {
    Config originalConfig = smallInstanceConfig();
    // setting non-defaults
    originalConfig.setProperty(ClusterProperty.METRICS_ENABLED.getName(), "false");
    originalConfig.setProperty(ClusterProperty.METRICS_MC_ENABLED.getName(), "false");
    originalConfig.setProperty(ClusterProperty.METRICS_MC_RETENTION.getName(), "42");
    originalConfig.setProperty(ClusterProperty.METRICS_JMX_ENABLED.getName(), "false");
    originalConfig.setProperty(ClusterProperty.METRICS_COLLECTION_FREQUENCY.getName(), "24");
    HazelcastInstance instance = createHazelcastInstance(originalConfig);
    Config instanceConfig = instance.getConfig();
    MetricsConfig metricsConfig = instanceConfig.getMetricsConfig();
    assertFalse(metricsConfig.isEnabled());
    assertFalse(metricsConfig.getManagementCenterConfig().isEnabled());
    assertEquals(42, metricsConfig.getManagementCenterConfig().getRetentionSeconds());
    assertFalse(metricsConfig.getJmxConfig().isEnabled());
    assertEquals(24, metricsConfig.getCollectionFrequencySeconds());
    // verify that the overridden config is used
    MetricsService metricsService = getNodeEngineImpl(instance).getService(MetricsService.SERVICE_NAME);
    assertSame(metricsConfig, metricsService.getConfig());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) MetricsConfig(com.hazelcast.config.MetricsConfig) MetricsConfig(com.hazelcast.config.MetricsConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

MetricsConfig (com.hazelcast.config.MetricsConfig)8 QuickTest (com.hazelcast.test.annotation.QuickTest)6 Test (org.junit.Test)6 Config (com.hazelcast.config.Config)4 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 ClientMetricsConfig (com.hazelcast.client.config.ClientMetricsConfig)2 HazelcastClientProxy (com.hazelcast.client.impl.clientside.HazelcastClientProxy)1 MetricsJmxConfig (com.hazelcast.config.MetricsJmxConfig)1 MetricsManagementCenterConfig (com.hazelcast.config.MetricsManagementCenterConfig)1 NamedNodeMap (org.w3c.dom.NamedNodeMap)1 Node (org.w3c.dom.Node)1