Search in sources :

Example 1 with MetricsConfig

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

the class TestFullApplicationContext method testMetricsConfig.

@Test
public void testMetricsConfig() {
    MetricsConfig metricsConfig = config.getMetricsConfig();
    assertFalse(metricsConfig.isEnabled());
    assertFalse(metricsConfig.getManagementCenterConfig().isEnabled());
    assertEquals(42, metricsConfig.getManagementCenterConfig().getRetentionSeconds());
    assertFalse(metricsConfig.getJmxConfig().isEnabled());
    assertEquals(24, metricsConfig.getCollectionFrequencySeconds());
}
Also used : MetricsConfig(com.hazelcast.config.MetricsConfig) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Example 2 with MetricsConfig

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

the class MetricsConfigHelper method overrideMemberMetricsConfig.

/**
 * Overrides the {@link MetricsConfig} in the provided {@link Config}
 * with the metrics system properties if present.
 * See the {@link MetricsConfig} javadoc for the links between metrics
 * configuration fields and the system properties.
 *
 * @param config The configuration
 */
public static void overrideMemberMetricsConfig(Config config, ILogger logger) {
    MetricsConfig metricsConfig = config.getMetricsConfig();
    MetricsManagementCenterConfig managementCenterConfig = metricsConfig.getManagementCenterConfig();
    MetricsJmxConfig jmxConfig = metricsConfig.getJmxConfig();
    // MetricsConfig.enabled
    tryOverride(ClusterProperty.METRICS_ENABLED, config::getProperty, prop -> metricsConfig.setEnabled(Boolean.parseBoolean(prop)), () -> Boolean.toString(metricsConfig.isEnabled()), "MetricsConfig.enabled", logger);
    // MetricsManagementCenterConfig.enabled
    tryOverride(ClusterProperty.METRICS_MC_ENABLED, config::getProperty, prop -> managementCenterConfig.setEnabled(Boolean.parseBoolean(prop)), () -> Boolean.toString(managementCenterConfig.isEnabled()), "MetricsManagementCenterConfig.enabled", logger);
    // MetricsManagementCenterConfig.retentionSeconds
    tryOverride(ClusterProperty.METRICS_MC_RETENTION, config::getProperty, prop -> managementCenterConfig.setRetentionSeconds(Integer.parseInt(prop)), () -> Integer.toString(managementCenterConfig.getRetentionSeconds()), "MetricsManagementCenterConfig.retentionSeconds", logger);
    // MetricsJmxConfig.enabled
    tryOverride(ClusterProperty.METRICS_JMX_ENABLED, config::getProperty, prop -> jmxConfig.setEnabled(Boolean.parseBoolean(prop)), () -> Boolean.toString(jmxConfig.isEnabled()), "MetricsJmxConfig.enabled", logger);
    // MetricsConfig.collectionFrequencySeconds
    tryOverride(ClusterProperty.METRICS_COLLECTION_FREQUENCY, config::getProperty, prop -> metricsConfig.setCollectionFrequencySeconds(Integer.parseInt(prop)), () -> Integer.toString(metricsConfig.getCollectionFrequencySeconds()), "MetricsConfig.collectionFrequencySeconds", logger);
}
Also used : MetricsManagementCenterConfig(com.hazelcast.config.MetricsManagementCenterConfig) MetricsJmxConfig(com.hazelcast.config.MetricsJmxConfig) MetricsConfig(com.hazelcast.config.MetricsConfig) ClientMetricsConfig(com.hazelcast.client.config.ClientMetricsConfig)

Example 3 with MetricsConfig

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

the class MemberDomConfigProcessor method handleMetrics.

private void handleMetrics(Node node) {
    MetricsConfig metricsConfig = config.getMetricsConfig();
    NamedNodeMap attributes = node.getAttributes();
    for (int a = 0; a < attributes.getLength(); a++) {
        Node att = attributes.item(a);
        if (matches("enabled", att.getNodeName())) {
            boolean enabled = getBooleanValue(getAttribute(node, "enabled"));
            metricsConfig.setEnabled(enabled);
        }
    }
    for (Node child : childElements(node)) {
        String nodeName = cleanNodeName(child);
        if (matches("management-center", nodeName)) {
            handleMetricsManagementCenter(child);
        } else if (matches("jmx", nodeName)) {
            handleMetricsJmx(child);
        } else if (matches("collection-frequency-seconds", nodeName)) {
            metricsConfig.setCollectionFrequencySeconds(Integer.parseInt(getTextContent(child)));
        }
    }
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node) MetricsConfig(com.hazelcast.config.MetricsConfig)

Example 4 with MetricsConfig

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

the class MetricsPropertiesTest method testInvalidSystemPropertiesIgnored.

@Test
public void testInvalidSystemPropertiesIgnored() {
    // setting non-defaults
    System.setProperty(ClusterProperty.METRICS_ENABLED.getName(), "invalid");
    System.setProperty(ClusterProperty.METRICS_MC_ENABLED.getName(), "invalid");
    System.setProperty(ClusterProperty.METRICS_MC_RETENTION.getName(), "invalid");
    System.setProperty(ClusterProperty.METRICS_JMX_ENABLED.getName(), "invalid");
    System.setProperty(ClusterProperty.METRICS_COLLECTION_FREQUENCY.getName(), "invalid");
    HazelcastInstance instance = createHazelcastInstance();
    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 5 with MetricsConfig

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

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