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());
}
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);
}
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)));
}
}
}
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());
}
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);
}
Aggregations