Search in sources :

Example 6 with ClientMetricsConfig

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

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

the class ClientDomConfigProcessor method handleMetrics.

private void handleMetrics(Node node) {
    ClientMetricsConfig metricsConfig = clientConfig.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("jmx", nodeName)) {
            handleMetricsJmx(child);
        } else if (matches("collection-frequency-seconds", nodeName)) {
            metricsConfig.setCollectionFrequencySeconds(Integer.parseInt(getTextContent(child)));
        }
    }
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) ClientMetricsConfig(com.hazelcast.client.config.ClientMetricsConfig) Node(org.w3c.dom.Node)

Example 8 with ClientMetricsConfig

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

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

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