From 16d0035eaf915a9c477fa86631d3bae99c9c4a72 Mon Sep 17 00:00:00 2001 From: Zoltan Baranyi Date: Thu, 17 Oct 2019 21:09:30 +0200 Subject: [PATCH] Refine member metrics configuration This change refines the member-side metrics configuration to address two issues with the previously added config: - It was not clear that `retention-seconds` was for MC only - Further improving the MC and JMX configs was not supported by the attributes To address these, the configuration changes as follows. Before this change: ``` 10 30 true DEBUG ``` After this change: ``` 30 10 true DEBUG ``` The programmatic and YAML configuration follows the same structure. It is also a requirement that all metrics configurations should overrideable via system properties. This is also implemented in this change by overriding the configuration from the properties during the `Node` instances is created. The concrete system properties are added to the javadocs of the metrics config classes and to the xsd too. Besides refining the changes above, the following gaps were also closed: - Extends javadoc and xsd documentation for the metrics config elements - Add Spring XML configuration - Add full-example config comments - Add metrics config to hazelcast-fullconfig.[xml|yaml] - Add metrics metrics config to hazelcast-default.[xml|yaml] --- .../HazelcastConfigBeanDefinitionParser.java | 47 +++- .../main/resources/hazelcast-spring-4.0.xsd | 109 ++++++++++ .../spring/TestFullApplicationContext.java | 16 +- ...ullConfig-applicationContext-hazelcast.xml | 10 + .../HazelcastClientInstanceImpl.java | 2 +- .../hazelcast/config/ConfigXmlGenerator.java | 16 +- .../config/MemberDomConfigProcessor.java | 60 +++-- .../com/hazelcast/config/MetricsConfig.java | 205 +++++++----------- .../hazelcast/config/MetricsJmxConfig.java | 92 ++++++++ .../config/MetricsManagementCenterConfig.java | 139 ++++++++++++ .../com/hazelcast/instance/impl/Node.java | 2 + .../internal/diagnostics/MetricsPlugin.java | 2 +- .../metrics/impl/MetricsConfigHelper.java | 101 +++++++++ .../internal/metrics/impl/MetricsService.java | 21 +- .../hazelcast/spi/impl/NodeEngineImpl.java | 6 +- .../spi/properties/GroupProperty.java | 112 ++++++++++ .../main/resources/hazelcast-config-4.0.xsd | 72 +++++- .../src/main/resources/hazelcast-default.xml | 10 + .../src/main/resources/hazelcast-default.yaml | 11 + .../main/resources/hazelcast-full-example.xml | 69 +++++- .../resources/hazelcast-full-example.yaml | 69 +++++- .../config/ConfigCompatibilityChecker.java | 19 +- .../config/ConfigXmlGeneratorTest.java | 16 +- .../hazelcast/config/MetricsConfigTest.java | 15 +- .../config/XMLConfigBuilderTest.java | 50 +++-- .../config/YamlConfigBuilderTest.java | 50 +++-- .../DistributedDatastructuresMetricsTest.java | 4 +- .../impl/MetricsConfigOverrideTest.java | 173 +++++++++++++++ .../metrics/impl/MetricsServiceTest.java | 34 +-- .../impl/ReadMetricsOperationTest.java | 2 +- .../managementcenter/ReadMetricsTest.java | 2 +- .../properties/HazelcastPropertiesTest.java | 6 +- .../hazelcast-fullconfig-without-network.xml | 10 + .../hazelcast-fullconfig-without-network.yaml | 11 + 34 files changed, 1287 insertions(+), 276 deletions(-) create mode 100644 hazelcast/src/main/java/com/hazelcast/config/MetricsJmxConfig.java create mode 100644 hazelcast/src/main/java/com/hazelcast/config/MetricsManagementCenterConfig.java create mode 100644 hazelcast/src/main/java/com/hazelcast/internal/metrics/impl/MetricsConfigHelper.java create mode 100644 hazelcast/src/test/java/com/hazelcast/internal/metrics/impl/MetricsConfigOverrideTest.java diff --git a/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastConfigBeanDefinitionParser.java b/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastConfigBeanDefinitionParser.java index ecebac481f4cb..83bc1becef5c8 100644 --- a/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastConfigBeanDefinitionParser.java +++ b/hazelcast-spring/src/main/java/com/hazelcast/spring/HazelcastConfigBeanDefinitionParser.java @@ -19,6 +19,7 @@ import com.hazelcast.config.AdvancedNetworkConfig; import com.hazelcast.config.AliasedDiscoveryConfig; import com.hazelcast.config.AliasedDiscoveryConfigUtils; +import com.hazelcast.config.AttributeConfig; import com.hazelcast.config.CRDTReplicationConfig; import com.hazelcast.config.CachePartitionLostListenerConfig; import com.hazelcast.config.CacheSimpleConfig; @@ -52,7 +53,6 @@ import com.hazelcast.config.LoginModuleConfig; import com.hazelcast.config.MCMutualAuthConfig; import com.hazelcast.config.ManagementCenterConfig; -import com.hazelcast.config.AttributeConfig; import com.hazelcast.config.MapConfig; import com.hazelcast.config.MapPartitionLostListenerConfig; import com.hazelcast.config.MapStoreConfig; @@ -65,6 +65,9 @@ import com.hazelcast.config.MemcacheProtocolConfig; import com.hazelcast.config.MergePolicyConfig; import com.hazelcast.config.MerkleTreeConfig; +import com.hazelcast.config.MetricsConfig; +import com.hazelcast.config.MetricsJmxConfig; +import com.hazelcast.config.MetricsManagementCenterConfig; import com.hazelcast.config.MultiMapConfig; import com.hazelcast.config.MulticastConfig; import com.hazelcast.config.NativeMemoryConfig; @@ -110,6 +113,9 @@ import com.hazelcast.config.WanReplicationConfig; import com.hazelcast.config.WanReplicationRef; import com.hazelcast.config.WanSyncConfig; +import com.hazelcast.config.cp.CPSubsystemConfig; +import com.hazelcast.config.cp.FencedLockConfig; +import com.hazelcast.config.cp.RaftAlgorithmConfig; import com.hazelcast.config.cp.SemaphoreConfig; import com.hazelcast.config.security.JaasAuthenticationConfig; import com.hazelcast.config.security.LdapAuthenticationConfig; @@ -120,18 +126,15 @@ import com.hazelcast.config.security.TokenEncoding; import com.hazelcast.config.security.TokenIdentityConfig; import com.hazelcast.config.security.UsernamePasswordIdentityConfig; -import com.hazelcast.config.cp.CPSubsystemConfig; -import com.hazelcast.config.cp.FencedLockConfig; -import com.hazelcast.config.cp.RaftAlgorithmConfig; import com.hazelcast.instance.EndpointQualifier; import com.hazelcast.instance.ProtocolType; +import com.hazelcast.internal.nio.ClassLoaderUtil; import com.hazelcast.internal.services.ServiceConfigurationParser; +import com.hazelcast.internal.util.ExceptionUtil; import com.hazelcast.map.eviction.MapEvictionPolicy; import com.hazelcast.memory.MemorySize; import com.hazelcast.memory.MemoryUnit; -import com.hazelcast.internal.nio.ClassLoaderUtil; import com.hazelcast.splitbrainprotection.SplitBrainProtectionOn; -import com.hazelcast.internal.util.ExceptionUtil; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; @@ -338,6 +341,8 @@ public void handleConfig(Element element) { handlePNCounter(node); } else if ("cp-subsystem".equals(nodeName)) { handleCPSubSystem(node); + } else if ("metrics".equals(nodeName)) { + handleMetrics(node); } } } @@ -2159,5 +2164,35 @@ private void handleMemcacheProtocol(Node node, BeanDefinitionBuilder networkConf private EndpointQualifier createEndpointQualifier(ProtocolType type, Node node) { return EndpointQualifier.resolve(type, getAttribute(node, "name")); } + + private void handleMetrics(Node node) { + BeanDefinitionBuilder metricsConfigBuilder = createBeanBuilder(MetricsConfig.class); + + fillValues(node, metricsConfigBuilder, "managementCenter", "jmx"); + + NamedNodeMap attributes = node.getAttributes(); + Node attrEnabled = attributes.getNamedItem("enabled"); + boolean enabled = attrEnabled != null && getBooleanValue(getTextContent(attrEnabled)); + metricsConfigBuilder.addPropertyValue("enabled", enabled); + + for (Node child : childElements(node)) { + String nodeName = cleanNodeName(child); + if ("management-center".equals(nodeName)) { + BeanDefinitionBuilder metricsMcConfigBuilder = createBeanBuilder(MetricsManagementCenterConfig.class); + fillValues(child, metricsMcConfigBuilder); + + metricsConfigBuilder.addPropertyValue("managementCenterConfig", + metricsMcConfigBuilder.getBeanDefinition()); + } else if ("jmx".equals(nodeName)) { + BeanDefinitionBuilder metricsJmxConfigBuilder = createBeanBuilder(MetricsJmxConfig.class); + fillValues(child, metricsJmxConfigBuilder); + + metricsConfigBuilder.addPropertyValue("jmxConfig", + metricsJmxConfigBuilder.getBeanDefinition()); + } + } + + configBuilder.addPropertyValue("metricsConfig", metricsConfigBuilder.getBeanDefinition()); + } } } diff --git a/hazelcast-spring/src/main/resources/hazelcast-spring-4.0.xsd b/hazelcast-spring/src/main/resources/hazelcast-spring-4.0.xsd index 428471a50e9f2..7856b0aa0fc85 100644 --- a/hazelcast-spring/src/main/resources/hazelcast-spring-4.0.xsd +++ b/hazelcast-spring/src/main/resources/hazelcast-spring-4.0.xsd @@ -1310,6 +1310,7 @@ + @@ -4709,6 +4710,114 @@ + + + + + + + + Sets the metrics collection frequency in seconds. + By default, metrics are collected every 5 seconds. + May be overridden by 'hazelcast.metrics.collection.frequency' + system property. + + + + + + + Controls if metrics should be collected for the + distributed data structures (maps, caches etc). + It is disabled by default. + May be overridden by 'hazelcast.metrics.datastructures' + system property. + + + + + + + Sets the minimum metrics level to be collected. By default + it is set to INFO so metrics collect at INFO and MANDATORY + levels are collected, DEBUG metrics are not. + May be overridden by 'hazelcast.metrics.level' + system property. + + + + + + + + Master-switch for the metrics system. Controls whether + the metrics are collected and publishers are enabled. + May be overridden by 'hazelcast.metrics.enabled' + system property. + + + + + + + + + + + Sets the number of seconds the metrics will be retained on the + instance. By default, metrics are retained for 5 seconds (that is for + one collection of metrics values, if default "collection-frequency-seconds" + collection frequency is used). More retention means more heap memory, but + allows for longer client hiccups without losing a value (for example to + restart the Management Center). + May be overridden by 'hazelcast.metrics.mc.retention' + system property. + + + + + + + + Controls whether the metrics collected are exposed to + Hazelcast Management Center. It is enabled by default. + Please note that the metrics are polled by the + Hazelcast Management Center, hence the members need to + buffer the collected metrics between two polls. The aim + for this switch is to reduce memory consumption of the + metrics system if the Hazelcast Management Center is not + used. + In order to expose the metrics, the metrics system need + to be enabled via the enabled master-switch attribute. + May be overridden by 'hazelcast.metrics.mc.enabled' + system property. + + + + + + + + + + Controls whether the metrics collected are exposed to + through JMX. It is enabled by default. + In order to expose the metrics, the metrics system need + to be enabled via the enabled master-switch attribute. + May be overridden by 'hazelcast.metrics.jmx.enabled' + system property. + + + + + + + + + + + + diff --git a/hazelcast-spring/src/test/java/com/hazelcast/spring/TestFullApplicationContext.java b/hazelcast-spring/src/test/java/com/hazelcast/spring/TestFullApplicationContext.java index f8121c57bedbc..82dd30dbe3720 100644 --- a/hazelcast-spring/src/test/java/com/hazelcast/spring/TestFullApplicationContext.java +++ b/hazelcast-spring/src/test/java/com/hazelcast/spring/TestFullApplicationContext.java @@ -68,6 +68,7 @@ import com.hazelcast.config.MemcacheProtocolConfig; import com.hazelcast.config.MergePolicyConfig; import com.hazelcast.config.MetadataPolicy; +import com.hazelcast.config.MetricsConfig; import com.hazelcast.config.MultiMapConfig; import com.hazelcast.config.NativeMemoryConfig; import com.hazelcast.config.NearCacheConfig; @@ -102,7 +103,6 @@ import com.hazelcast.config.WanAcknowledgeType; import com.hazelcast.config.WanBatchReplicationPublisherConfig; import com.hazelcast.config.WanConsumerConfig; -import com.hazelcast.wan.WanPublisherState; import com.hazelcast.config.WanQueueFullBehavior; import com.hazelcast.config.WanReplicationConfig; import com.hazelcast.config.WanReplicationRef; @@ -143,6 +143,7 @@ import com.hazelcast.test.annotation.QuickTest; import com.hazelcast.topic.ITopic; import com.hazelcast.topic.TopicOverloadPolicy; +import com.hazelcast.wan.WanPublisherState; import com.hazelcast.wan.WanReplicationPublisher; import org.junit.AfterClass; import org.junit.Before; @@ -170,6 +171,7 @@ import java.util.concurrent.ExecutorService; import static com.hazelcast.config.HotRestartClusterDataRecoveryPolicy.PARTIAL_RECOVERY_MOST_COMPLETE; +import static com.hazelcast.internal.metrics.ProbeLevel.DEBUG; import static com.hazelcast.internal.util.CollectionUtil.isNotEmpty; import static com.hazelcast.spi.properties.GroupProperty.MERGE_FIRST_RUN_DELAY_SECONDS; import static com.hazelcast.spi.properties.GroupProperty.MERGE_NEXT_RUN_DELAY_SECONDS; @@ -1410,4 +1412,16 @@ public void testCPSubsystemConfig() { assertEquals(1, lockConfig1.getLockAcquireLimit()); assertEquals(2, lockConfig2.getLockAcquireLimit()); } + + @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()); + assertTrue(metricsConfig.isDataStructureMetricsEnabled()); + assertEquals(DEBUG, metricsConfig.getLevel()); + } } diff --git a/hazelcast-spring/src/test/resources/com/hazelcast/spring/fullConfig-applicationContext-hazelcast.xml b/hazelcast-spring/src/test/resources/com/hazelcast/spring/fullConfig-applicationContext-hazelcast.xml index 71cf950ca7723..7908348e5fb8d 100644 --- a/hazelcast-spring/src/test/resources/com/hazelcast/spring/fullConfig-applicationContext-hazelcast.xml +++ b/hazelcast-spring/src/test/resources/com/hazelcast/spring/fullConfig-applicationContext-hazelcast.xml @@ -915,6 +915,16 @@ + + + + 42 + + + 24 + true + DEBUG + diff --git a/hazelcast/src/main/java/com/hazelcast/client/impl/clientside/HazelcastClientInstanceImpl.java b/hazelcast/src/main/java/com/hazelcast/client/impl/clientside/HazelcastClientInstanceImpl.java index 4678bfeea406e..35ba37a2383ac 100644 --- a/hazelcast/src/main/java/com/hazelcast/client/impl/clientside/HazelcastClientInstanceImpl.java +++ b/hazelcast/src/main/java/com/hazelcast/client/impl/clientside/HazelcastClientInstanceImpl.java @@ -310,7 +310,7 @@ private Diagnostics initDiagnostics() { } private MetricsRegistryImpl initMetricsRegistry() { - ProbeLevel probeLevel = config.getMetricsConfig().getMinimumLevel(); + ProbeLevel probeLevel = config.getMetricsConfig().getLevel(); ILogger logger = loggingService.getLogger(MetricsRegistryImpl.class); MetricsRegistryImpl metricsRegistry = new MetricsRegistryImpl(getName(), logger, probeLevel); return metricsRegistry; diff --git a/hazelcast/src/main/java/com/hazelcast/config/ConfigXmlGenerator.java b/hazelcast/src/main/java/com/hazelcast/config/ConfigXmlGenerator.java index 3b8d96208cad1..0f9ec4cfd8b0d 100644 --- a/hazelcast/src/main/java/com/hazelcast/config/ConfigXmlGenerator.java +++ b/hazelcast/src/main/java/com/hazelcast/config/ConfigXmlGenerator.java @@ -1550,13 +1550,15 @@ private static void cpSubsystemConfig(XmlGenerator gen, Config config) { private static void metricsConfig(XmlGenerator gen, Config config) { MetricsConfig metricsConfig = config.getMetricsConfig(); gen.open("metrics", - "enabled", metricsConfig.isEnabled(), - "mc-enabled", metricsConfig.isMcEnabled(), - "jmx-enabled", metricsConfig.isJmxEnabled()) - .node("collection-interval-seconds", metricsConfig.getCollectionIntervalSeconds()) - .node("retention-seconds", metricsConfig.getRetentionSeconds()) - .node("metrics-for-data-structures", metricsConfig.isMetricsForDataStructuresEnabled()) - .node("minimum-level", metricsConfig.getMinimumLevel()) + "enabled", metricsConfig.isEnabled()) + .open("management-center", "enabled", metricsConfig.getManagementCenterConfig().isEnabled()) + .node("retention-seconds", metricsConfig.getManagementCenterConfig().getRetentionSeconds()) + .close() + .open("jmx", "enabled", metricsConfig.getJmxConfig().isEnabled()) + .close() + .node("collection-frequency-seconds", metricsConfig.getCollectionFrequencySeconds()) + .node("data-structure-metrics-enabled", metricsConfig.isDataStructureMetricsEnabled()) + .node("level", metricsConfig.getLevel()) .close(); } diff --git a/hazelcast/src/main/java/com/hazelcast/config/MemberDomConfigProcessor.java b/hazelcast/src/main/java/com/hazelcast/config/MemberDomConfigProcessor.java index 93795baf5b9e4..45100adc594ae 100644 --- a/hazelcast/src/main/java/com/hazelcast/config/MemberDomConfigProcessor.java +++ b/hazelcast/src/main/java/com/hazelcast/config/MemberDomConfigProcessor.java @@ -30,12 +30,12 @@ import com.hazelcast.core.HazelcastException; import com.hazelcast.instance.ProtocolType; import com.hazelcast.internal.metrics.ProbeLevel; +import com.hazelcast.internal.nio.ClassLoaderUtil; import com.hazelcast.internal.services.ServiceConfigurationParser; import com.hazelcast.internal.util.ExceptionUtil; import com.hazelcast.logging.ILogger; import com.hazelcast.logging.Logger; import com.hazelcast.map.eviction.MapEvictionPolicy; -import com.hazelcast.internal.nio.ClassLoaderUtil; import com.hazelcast.query.impl.IndexUtils; import com.hazelcast.splitbrainprotection.SplitBrainProtectionOn; import com.hazelcast.topic.TopicOverloadPolicy; @@ -2921,26 +2921,56 @@ private void handleMetrics(Node node) { if ("enabled".equals(att.getNodeName())) { boolean enabled = getBooleanValue(getAttribute(node, "enabled")); metricsConfig.setEnabled(enabled); - } else if ("mc-enabled".equals(att.getNodeName())) { - boolean enabled = getBooleanValue(getAttribute(node, "mc-enabled")); - metricsConfig.setMcEnabled(enabled); - } else if ("jmx-enabled".equals(att.getNodeName())) { - boolean enabled = getBooleanValue(getAttribute(node, "jmx-enabled")); - metricsConfig.setJmxEnabled(enabled); } } for (Node child : childElements(node)) { String nodeName = cleanNodeName(child); String value = getTextContent(child).trim(); - if ("collection-interval-seconds".equals(nodeName)) { - metricsConfig.setCollectionIntervalSeconds(Integer.parseInt(value)); - } else if ("retention-seconds".equals(nodeName)) { - metricsConfig.setRetentionSeconds(Integer.parseInt(value)); - } else if ("metrics-for-data-structures".equals(nodeName)) { - metricsConfig.setMetricsForDataStructuresEnabled(Boolean.parseBoolean(value)); - } else if ("minimum-level".equals(nodeName)) { - metricsConfig.setMinimumLevel(ProbeLevel.valueOf(value)); + if ("management-center".equals(nodeName)) { + handleMetricsManagementCenter(child); + } else if ("jmx".equals(nodeName)) { + handleMetricsJmx(child); + } else if ("collection-frequency-seconds".equals(nodeName)) { + metricsConfig.setCollectionFrequencySeconds(Integer.parseInt(value)); + } else if ("data-structure-metrics-enabled".equals(nodeName)) { + metricsConfig.setDataStructureMetricsEnabled(Boolean.parseBoolean(value)); + } else if ("level".equals(nodeName)) { + metricsConfig.setLevel(ProbeLevel.valueOf(value)); + } + } + } + + private void handleMetricsManagementCenter(Node node) { + MetricsManagementCenterConfig managementCenterConfig = config.getMetricsConfig().getManagementCenterConfig(); + + NamedNodeMap attributes = node.getAttributes(); + for (int a = 0; a < attributes.getLength(); a++) { + Node att = attributes.item(a); + if ("enabled".equals(att.getNodeName())) { + boolean enabled = getBooleanValue(getAttribute(node, "enabled")); + managementCenterConfig.setEnabled(enabled); + } + + for (Node child : childElements(node)) { + String nodeName = cleanNodeName(child); + String value = getTextContent(child).trim(); + if ("retention-seconds".equals(nodeName)) { + managementCenterConfig.setRetentionSeconds(Integer.parseInt(value)); + } + } + } + } + + private void handleMetricsJmx(Node node) { + MetricsJmxConfig jmxConfig = config.getMetricsConfig().getJmxConfig(); + + NamedNodeMap attributes = node.getAttributes(); + for (int a = 0; a < attributes.getLength(); a++) { + Node att = attributes.item(a); + if ("enabled".equals(att.getNodeName())) { + boolean enabled = getBooleanValue(getAttribute(node, "enabled")); + jmxConfig.setEnabled(enabled); } } } diff --git a/hazelcast/src/main/java/com/hazelcast/config/MetricsConfig.java b/hazelcast/src/main/java/com/hazelcast/config/MetricsConfig.java index f2e6ddafa9576..f17890ab05359 100644 --- a/hazelcast/src/main/java/com/hazelcast/config/MetricsConfig.java +++ b/hazelcast/src/main/java/com/hazelcast/config/MetricsConfig.java @@ -18,8 +18,12 @@ import com.hazelcast.internal.metrics.ProbeLevel; import com.hazelcast.internal.util.Preconditions; +import com.hazelcast.spi.properties.GroupProperty; import javax.annotation.Nonnull; +import java.util.Objects; + +import static java.util.Objects.requireNonNull; /** * Configuration options specific to metrics collection. @@ -33,36 +37,32 @@ public class MetricsConfig { */ public static final int DEFAULT_METRICS_COLLECTION_SECONDS = 5; - /** - * Default retention period for metrics. - */ - public static final int DEFAULT_METRICS_RETENTION_SECONDS = 5; - private boolean enabled = true; - private boolean mcEnabled = true; - private boolean jmxEnabled = true; - private int retentionSeconds = DEFAULT_METRICS_RETENTION_SECONDS; - private boolean metricsForDataStructuresEnabled; - private int intervalSeconds = DEFAULT_METRICS_COLLECTION_SECONDS; - private ProbeLevel minimumLevel = ProbeLevel.INFO; + private MetricsManagementCenterConfig managementCenterConfig = new MetricsManagementCenterConfig(); + private MetricsJmxConfig jmxConfig = new MetricsJmxConfig(); + private boolean dataStructureMetricsEnabled; + private int collectionFrequencySeconds = DEFAULT_METRICS_COLLECTION_SECONDS; + private ProbeLevel level = ProbeLevel.INFO; public MetricsConfig() { } public MetricsConfig(MetricsConfig metricsConfig) { this.enabled = metricsConfig.enabled; - this.mcEnabled = metricsConfig.mcEnabled; - this.jmxEnabled = metricsConfig.jmxEnabled; - this.retentionSeconds = metricsConfig.retentionSeconds; - this.metricsForDataStructuresEnabled = metricsConfig.metricsForDataStructuresEnabled; - this.intervalSeconds = metricsConfig.intervalSeconds; - this.minimumLevel = metricsConfig.minimumLevel; + this.managementCenterConfig = new MetricsManagementCenterConfig(metricsConfig.managementCenterConfig); + this.jmxConfig = new MetricsJmxConfig(metricsConfig.jmxConfig); + this.dataStructureMetricsEnabled = metricsConfig.dataStructureMetricsEnabled; + this.collectionFrequencySeconds = metricsConfig.collectionFrequencySeconds; + this.level = metricsConfig.level; } /** * Sets whether metrics collection should be enabled for the node. If * enabled, Hazelcast Management Center will be able to connect to this * member. It's enabled by default. + *

+ * May be overridden by {@link GroupProperty#METRICS_ENABLED} + * system property. */ @Nonnull public MetricsConfig setEnabled(boolean enabled) { @@ -77,137 +77,85 @@ public boolean isEnabled() { return enabled; } - /** - * Returns whether metrics will be exposed to Hazelcast Management - * Center. If enabled, Hazelcast Management Center will be able to read - * out the recorder metrics from this member. It's enabled by default. - *

- * This configuration acts as a fine-tuning option beyond - * enabling/disabling the Metrics collection entirely via the {@link #enabled} - * master switch. - * - * @return true if exporting to Hazelcast Management Center is enabled. - * @see #isEnabled() - */ - public boolean isMcEnabled() { - return mcEnabled; - } - - /** - * Enables exposing metrics to Hazelcast Management Center. If enabled, - * Hazelcast Management Center will be able to read out the recorded - * metrics from this member. It's enabled by default. - *

- * This configuration acts as a fine-tuning option beyond - * enabling/disabling the Metrics collection entirely via the {@link #enabled} - * master switch. - * - * @see #setEnabled(boolean) - */ - public MetricsConfig setMcEnabled(boolean mcEnabled) { - this.mcEnabled = mcEnabled; + @Nonnull + public MetricsConfig setManagementCenterConfig(MetricsManagementCenterConfig managementCenterConfig) { + this.managementCenterConfig = requireNonNull(managementCenterConfig, "Management Center config must not be null"); return this; } - /** - * Returns whether metrics will be exposed through JMX MBeans. - *

- * This configuration acts as a fine-tuning option beyond - * enabling/disabling the Metrics collection entirely via the {@link #enabled} - * master switch. - */ - public boolean isJmxEnabled() { - return jmxEnabled; - } - - /** - * Enables metrics exposure through JMX. It's enabled by default. Metric - * values are collected in the {@linkplain #setCollectionIntervalSeconds - * metric collection interval} and written to a set of MBeans. - *

- * This configuration acts as a fine-tuning option beyond - * enabling/disabling the Metrics collection entirely via the {@link #enabled} - * master switch. - */ - public MetricsConfig setJmxEnabled(boolean jmxEnabled) { - this.jmxEnabled = jmxEnabled; - return this; + @Nonnull + public MetricsManagementCenterConfig getManagementCenterConfig() { + return managementCenterConfig; } - /** - * Sets the number of seconds the metrics will be retained on the - * instance. By default, metrics are retained for 5 seconds (that is for - * one collection of metrics values, if default {@linkplain - * #setCollectionIntervalSeconds(int) collection interval} is used). More - * retention means more heap memory, but allows for longer client hiccups - * without losing a value (for example to restart the Management Center). - *

- * This setting applies only to Management Center metrics API. It - * doesn't affect how metrics are exposed through JMX. - */ @Nonnull - public MetricsConfig setRetentionSeconds(int retentionSeconds) { - Preconditions.checkPositive(intervalSeconds, "retentionSeconds must be positive"); - this.retentionSeconds = retentionSeconds; + public MetricsConfig setJmxConfig(MetricsJmxConfig jmxConfig) { + this.jmxConfig = requireNonNull(jmxConfig, "JMX config must not be null"); return this; } - /** - * Returns the number of seconds the metrics will be retained on the - * instance. - */ - public int getRetentionSeconds() { - return retentionSeconds; + @Nonnull + public MetricsJmxConfig getJmxConfig() { + return jmxConfig; } /** - * Sets the metrics collection interval in seconds. The same interval is + * Sets the metrics collection frequency in seconds. The same interval is * used for collection for Management Center and for JMX publisher. By default, * metrics are collected every 5 seconds. + *

+ * May be overridden by {@link GroupProperty#METRICS_COLLECTION_FREQUENCY} + * system property. */ @Nonnull - public MetricsConfig setCollectionIntervalSeconds(int intervalSeconds) { - Preconditions.checkPositive(intervalSeconds, "intervalSeconds must be positive"); - this.intervalSeconds = intervalSeconds; + public MetricsConfig setCollectionFrequencySeconds(int intervalSeconds) { + Preconditions.checkPositive(intervalSeconds, "collectionFrequencySeconds must be positive"); + this.collectionFrequencySeconds = intervalSeconds; return this; } /** - * Returns the metrics collection interval. + * Returns the metrics collection frequency in seconds. */ - public int getCollectionIntervalSeconds() { - return this.intervalSeconds; + public int getCollectionFrequencySeconds() { + return this.collectionFrequencySeconds; } /** * Sets whether statistics for data structures are added to metrics. * It's disabled by default. *

- * Note that enabling the data structures metrics also sets {@link #minimumLevel} + * Note that enabling the data structures metrics also sets {@link #level} * to {@link ProbeLevel#INFO}. + *

+ * May be overridden by {@link GroupProperty#METRICS_DATASTRUCTURES} + * system property. * - * @see #setMinimumLevel(ProbeLevel) + * @see #setLevel(ProbeLevel) */ @Nonnull - public MetricsConfig setMetricsForDataStructuresEnabled(boolean metricsForDataStructuresEnabled) { - this.metricsForDataStructuresEnabled = metricsForDataStructuresEnabled; - return setMinimumLevel(ProbeLevel.INFO); + public MetricsConfig setDataStructureMetricsEnabled(boolean dataStructureMetricsEnabled) { + this.dataStructureMetricsEnabled = dataStructureMetricsEnabled; + return setLevel(ProbeLevel.INFO); } /** * Returns if statistics for data structures are added to metrics. */ - public boolean isMetricsForDataStructuresEnabled() { - return metricsForDataStructuresEnabled; + public boolean isDataStructureMetricsEnabled() { + return dataStructureMetricsEnabled; } /** * Sets the minimum probe level to be collected. + *

+ * May be overridden by {@link GroupProperty#METRICS_LEVEL} * - * @param minimumLevel The minimum level to be collected + * @param level The minimum level to be collected */ - public MetricsConfig setMinimumLevel(ProbeLevel minimumLevel) { - this.minimumLevel = minimumLevel; + @Nonnull + public MetricsConfig setLevel(ProbeLevel level) { + this.level = level; return this; } @@ -217,17 +165,17 @@ public MetricsConfig setMinimumLevel(ProbeLevel minimumLevel) { * @return the minimum probe level */ @Nonnull - public ProbeLevel getMinimumLevel() { - return minimumLevel; + public ProbeLevel getLevel() { + return level; } @Override @SuppressWarnings("checkstyle:NPathComplexity") - public final boolean equals(Object o) { + public boolean equals(Object o) { if (this == o) { return true; } - if (o == null || !(o instanceof MetricsConfig)) { + if (o == null || getClass() != o.getClass()) { return false; } @@ -236,33 +184,29 @@ public final boolean equals(Object o) { if (enabled != that.enabled) { return false; } - if (mcEnabled != that.mcEnabled) { - return false; - } - if (jmxEnabled != that.jmxEnabled) { + if (dataStructureMetricsEnabled != that.dataStructureMetricsEnabled) { return false; } - if (retentionSeconds != that.retentionSeconds) { + if (collectionFrequencySeconds != that.collectionFrequencySeconds) { return false; } - if (metricsForDataStructuresEnabled != that.metricsForDataStructuresEnabled) { + if (!Objects.equals(managementCenterConfig, that.managementCenterConfig)) { return false; } - if (intervalSeconds != that.intervalSeconds) { + if (!Objects.equals(jmxConfig, that.jmxConfig)) { return false; } - return minimumLevel == that.minimumLevel; + return level == that.level; } @Override - public final int hashCode() { + public int hashCode() { int result = (enabled ? 1 : 0); - result = 31 * result + (mcEnabled ? 1 : 0); - result = 31 * result + (jmxEnabled ? 1 : 0); - result = 31 * result + retentionSeconds; - result = 31 * result + (metricsForDataStructuresEnabled ? 1 : 0); - result = 31 * result + intervalSeconds; - result = 31 * result + (minimumLevel != null ? minimumLevel.hashCode() : 0); + result = 31 * result + (managementCenterConfig != null ? managementCenterConfig.hashCode() : 0); + result = 31 * result + (jmxConfig != null ? jmxConfig.hashCode() : 0); + result = 31 * result + (dataStructureMetricsEnabled ? 1 : 0); + result = 31 * result + collectionFrequencySeconds; + result = 31 * result + (level != null ? level.hashCode() : 0); return result; } @@ -270,12 +214,11 @@ public final int hashCode() { public String toString() { return "MetricsConfig{" + "enabled=" + enabled - + ", mcEnabled=" + mcEnabled - + ", jmxEnabled=" + jmxEnabled - + ", retentionSeconds=" + retentionSeconds - + ", metricsForDataStructuresEnabled=" + metricsForDataStructuresEnabled - + ", intervalSeconds=" + intervalSeconds - + ", minimumLevel=" + minimumLevel + + ", managementCenterConfig=" + managementCenterConfig + + ", jmxConfig=" + jmxConfig + + ", dataStructureMetricsEnabled=" + dataStructureMetricsEnabled + + ", collectionFrequencySeconds=" + collectionFrequencySeconds + + ", level=" + level + '}'; } } diff --git a/hazelcast/src/main/java/com/hazelcast/config/MetricsJmxConfig.java b/hazelcast/src/main/java/com/hazelcast/config/MetricsJmxConfig.java new file mode 100644 index 0000000000000..19e29b13db189 --- /dev/null +++ b/hazelcast/src/main/java/com/hazelcast/config/MetricsJmxConfig.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hazelcast.config; + +import com.hazelcast.spi.properties.GroupProperty; + +import javax.annotation.Nonnull; + +/** + * JMX related metrics configuration. + * + * @since 4.0 + */ +public class MetricsJmxConfig { + private boolean enabled = true; + + public MetricsJmxConfig() { + } + + public MetricsJmxConfig(MetricsJmxConfig jmxConfig) { + this.enabled = jmxConfig.enabled; + } + + /** + * Returns whether metrics will be exposed through JMX MBeans. + *

+ * This configuration acts as a fine-tuning option beyond + * enabling/disabling the Metrics collection entirely via the {@link #enabled} + * master switch. + */ + public boolean isEnabled() { + return enabled; + } + + /** + * Enables metrics exposure through JMX. It's enabled by default. Metric + * values are collected in the {@link MetricsConfig#getCollectionFrequencySeconds()} + * metric collection interval} and written to a set of MBeans. + *

+ * This configuration acts as a fine-tuning option beyond + * enabling/disabling the Metrics collection entirely via the {@link #enabled} + * master switch. + *

+ * May be overridden by {@link GroupProperty#METRICS_JMX_ENABLED} + * system property. + */ + @Nonnull + public MetricsJmxConfig setEnabled(boolean enabled) { + this.enabled = enabled; + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + MetricsJmxConfig that = (MetricsJmxConfig) o; + + return enabled == that.enabled; + } + + @Override + public int hashCode() { + return (enabled ? 1 : 0); + } + + @Override + public String toString() { + return "MetricsJmxConfig{" + + "enabled=" + enabled + + '}'; + } +} diff --git a/hazelcast/src/main/java/com/hazelcast/config/MetricsManagementCenterConfig.java b/hazelcast/src/main/java/com/hazelcast/config/MetricsManagementCenterConfig.java new file mode 100644 index 0000000000000..a42a8b9634795 --- /dev/null +++ b/hazelcast/src/main/java/com/hazelcast/config/MetricsManagementCenterConfig.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hazelcast.config; + +import com.hazelcast.spi.properties.GroupProperty; + +import javax.annotation.Nonnull; + +/** + * Management Center related metrics configuration. + * + * @since 4.0 + */ +public class MetricsManagementCenterConfig { + + /** + * Default retention period for metrics. + */ + public static final int DEFAULT_METRICS_RETENTION_SECONDS = 5; + + private boolean enabled = true; + private int retentionSeconds = DEFAULT_METRICS_RETENTION_SECONDS; + + public MetricsManagementCenterConfig() { + } + + public MetricsManagementCenterConfig(MetricsManagementCenterConfig managementCenterConfig) { + this.enabled = managementCenterConfig.enabled; + this.retentionSeconds = managementCenterConfig.retentionSeconds; + } + + /** + * Returns whether metrics will be exposed to Hazelcast Management + * Center. If enabled, Hazelcast Management Center will be able to read + * out the collected metrics from this member. It's enabled by default. + *

+ * This configuration acts as a fine-tuning option beyond + * enabling/disabling the Metrics collection entirely via the + * {@link MetricsConfig#isEnabled()} master switch. + * + * @return true if exposing to Hazelcast Management Center is enabled. + * @see MetricsConfig#isEnabled() + */ + public boolean isEnabled() { + return enabled; + } + + /** + * Enables exposing metrics to Hazelcast Management Center. If enabled, + * Hazelcast Management Center will be able to read out the recorded + * metrics from this member. It's enabled by default. + *

+ * This configuration acts as a fine-tuning option beyond + * enabling/disabling the Metrics collection entirely via the {@link #enabled} + * master switch. + *

+ * May be overridden by {@link GroupProperty#METRICS_MC_ENABLED} + * system property. + * + * @see #setEnabled(boolean) + */ + @Nonnull + public MetricsManagementCenterConfig setEnabled(boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Returns the number of seconds the metrics will be retained on the + * instance. + */ + public int getRetentionSeconds() { + return retentionSeconds; + } + + /** + * Sets the number of seconds the metrics will be retained on the + * instance. By default, metrics are retained for 5 seconds (that is for + * one collection of metrics values, if default + * {@link MetricsConfig#setCollectionFrequencySeconds(int)} interval seconds + * is used). More retention means more heap memory, but allows for longer + * client hiccups without losing a value (for example to restart the + * Management Center). + *

+ * May be overridden by {@link GroupProperty#METRICS_MC_RETENTION} + * system property. + */ + @Nonnull + public MetricsManagementCenterConfig setRetentionSeconds(int retentionSeconds) { + this.retentionSeconds = retentionSeconds; + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + MetricsManagementCenterConfig that = (MetricsManagementCenterConfig) o; + + if (enabled != that.enabled) { + return false; + } + return retentionSeconds == that.retentionSeconds; + } + + @Override + public int hashCode() { + int result = (enabled ? 1 : 0); + result = 31 * result + retentionSeconds; + return result; + } + + @Override + public String toString() { + return "MetricsManagementCenterConfig{" + + "enabled=" + enabled + + ", retentionSeconds=" + retentionSeconds + + '}'; + } +} diff --git a/hazelcast/src/main/java/com/hazelcast/instance/impl/Node.java b/hazelcast/src/main/java/com/hazelcast/instance/impl/Node.java index deaa814e963eb..56fee967be548 100644 --- a/hazelcast/src/main/java/com/hazelcast/instance/impl/Node.java +++ b/hazelcast/src/main/java/com/hazelcast/instance/impl/Node.java @@ -60,6 +60,7 @@ import com.hazelcast.internal.dynamicconfig.DynamicConfigurationAwareConfig; import com.hazelcast.internal.management.ManagementCenterService; import com.hazelcast.internal.metrics.MetricsRegistry; +import com.hazelcast.internal.metrics.impl.MetricsConfigHelper; import com.hazelcast.internal.networking.ServerSocketRegistry; import com.hazelcast.internal.partition.InternalPartitionService; import com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl; @@ -196,6 +197,7 @@ public class Node { @SuppressWarnings({"checkstyle:executablestatementcount", "checkstyle:methodlength"}) public Node(HazelcastInstanceImpl hazelcastInstance, Config staticConfig, NodeContext nodeContext) { this.properties = new HazelcastProperties(staticConfig); + MetricsConfigHelper.overrideMetricsConfig(staticConfig); DynamicConfigurationAwareConfig config = new DynamicConfigurationAwareConfig(staticConfig, this.properties); this.hazelcastInstance = hazelcastInstance; this.config = config; diff --git a/hazelcast/src/main/java/com/hazelcast/internal/diagnostics/MetricsPlugin.java b/hazelcast/src/main/java/com/hazelcast/internal/diagnostics/MetricsPlugin.java index 5a9ee93aa449b..fb4cd0498412f 100644 --- a/hazelcast/src/main/java/com/hazelcast/internal/diagnostics/MetricsPlugin.java +++ b/hazelcast/src/main/java/com/hazelcast/internal/diagnostics/MetricsPlugin.java @@ -42,7 +42,7 @@ public class MetricsPlugin extends DiagnosticsPlugin { * The MetricsPlugin periodically writes the contents of the MetricsRegistry * to the logfile. For debugging purposes make sure the minimum metrics * level is set to {@link com.hazelcast.internal.metrics.ProbeLevel#DEBUG} - * with {@link com.hazelcast.config.MetricsConfig#setMinimumLevel(ProbeLevel)}. + * with {@link com.hazelcast.config.MetricsConfig#setLevel(ProbeLevel)}. *

* This plugin is very cheap to use. *

diff --git a/hazelcast/src/main/java/com/hazelcast/internal/metrics/impl/MetricsConfigHelper.java b/hazelcast/src/main/java/com/hazelcast/internal/metrics/impl/MetricsConfigHelper.java new file mode 100644 index 0000000000000..bd5f066ed9889 --- /dev/null +++ b/hazelcast/src/main/java/com/hazelcast/internal/metrics/impl/MetricsConfigHelper.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hazelcast.internal.metrics.impl; + +import com.hazelcast.config.Config; +import com.hazelcast.config.MetricsConfig; +import com.hazelcast.config.MetricsJmxConfig; +import com.hazelcast.config.MetricsManagementCenterConfig; +import com.hazelcast.internal.metrics.ProbeLevel; +import com.hazelcast.logging.ILogger; +import com.hazelcast.logging.Logger; +import com.hazelcast.spi.properties.GroupProperty; +import com.hazelcast.spi.properties.HazelcastProperty; + +import java.util.function.Consumer; +import java.util.function.Supplier; + +public final class MetricsConfigHelper { + private static final ILogger LOGGER = Logger.getLogger(MetricsConfigHelper.class); + + private MetricsConfigHelper() { + } + + /** + * 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 overrideMetricsConfig(Config config) { + MetricsConfig metricsConfig = config.getMetricsConfig(); + MetricsManagementCenterConfig managementCenterConfig = metricsConfig.getManagementCenterConfig(); + MetricsJmxConfig jmxConfig = metricsConfig.getJmxConfig(); + + // MetricsConfig.enabled + tryOverride(config, GroupProperty.METRICS_ENABLED, prop -> metricsConfig.setEnabled(Boolean.parseBoolean(prop)), + () -> Boolean.toString(metricsConfig.isEnabled()), "MetricsConfig.enabled"); + + // MetricsManagementCenterConfig.enabled + tryOverride(config, GroupProperty.METRICS_MC_ENABLED, + prop -> managementCenterConfig.setEnabled(Boolean.parseBoolean(prop)), + () -> Boolean.toString(managementCenterConfig.isEnabled()), "MetricsManagementCenterConfig.enabled"); + + // MetricsManagementCenterConfig.retentionSeconds + tryOverride(config, GroupProperty.METRICS_MC_RETENTION, + prop -> managementCenterConfig.setRetentionSeconds(Integer.parseInt(prop)), + () -> Integer.toString(managementCenterConfig.getRetentionSeconds()), + "MetricsManagementCenterConfig.retentionSeconds"); + + // MetricsJmxConfig.enabled + tryOverride(config, GroupProperty.METRICS_JMX_ENABLED, prop -> jmxConfig.setEnabled(Boolean.parseBoolean(prop)), + () -> Boolean.toString(jmxConfig.isEnabled()), "MetricsJmxConfig.enabled"); + + // MetricsConfig.collectionFrequencySeconds + tryOverride(config, GroupProperty.METRICS_COLLECTION_FREQUENCY, + prop -> metricsConfig.setCollectionFrequencySeconds(Integer.parseInt(prop)), + () -> Integer.toString(metricsConfig.getCollectionFrequencySeconds()), + "MetricsConfig.collectionFrequencySeconds"); + + // MetricsConfig.dataStructuresEnabled + tryOverride(config, GroupProperty.METRICS_DATASTRUCTURES, + prop -> metricsConfig.setDataStructureMetricsEnabled(Boolean.parseBoolean(prop)), + () -> Boolean.toString(metricsConfig.isDataStructureMetricsEnabled()), "MetricsConfig.dataStructuresEnabled"); + + // MetricsConfig.level + tryOverride(config, GroupProperty.METRICS_LEVEL, + prop -> metricsConfig.setLevel(ProbeLevel.valueOf(prop)), + () -> metricsConfig.getLevel().name(), "MetricsConfig.level"); + } + + private static void tryOverride(Config hzConfig, HazelcastProperty property, Consumer setterFn, + Supplier getterFn, String configOverridden) { + String propertyValue = hzConfig.getProperty(property.getName()); + try { + if (propertyValue != null) { + setterFn.accept(propertyValue); + LOGGER.warning(String.format("Overridden metrics configuration with system property '%s'='%s' -> '%s'='%s'", + property, propertyValue, configOverridden, getterFn.get())); + } + } catch (Exception ex) { + LOGGER.warning(String.format("Failed to override metrics configuration with system property '%s'='%s'. Kept " + + "'%s'='%s'", property.getName(), propertyValue, configOverridden, getterFn.get()), ex); + } + } +} diff --git a/hazelcast/src/main/java/com/hazelcast/internal/metrics/impl/MetricsService.java b/hazelcast/src/main/java/com/hazelcast/internal/metrics/impl/MetricsService.java index 463eca0cb35b1..3a900c61d6392 100644 --- a/hazelcast/src/main/java/com/hazelcast/internal/metrics/impl/MetricsService.java +++ b/hazelcast/src/main/java/com/hazelcast/internal/metrics/impl/MetricsService.java @@ -98,11 +98,11 @@ public MetricsService(NodeEngine nodeEngine, Supplier metricsRe public void init(NodeEngine nodeEngine, Properties properties) { if (config.isEnabled()) { - if (config.isMcEnabled()) { + if (config.getManagementCenterConfig().isEnabled()) { publishers.add(createMcPublisher()); } - if (config.isJmxEnabled()) { + if (config.getJmxConfig().isEnabled()) { publishers.add(createJmxPublisher()); } @@ -136,17 +136,22 @@ public void registerPublisher(Function registerFun private void scheduleMetricsCollectorIfNeeded() { if (!collectorScheduled && !publishers.isEmpty()) { - logger.fine("Configuring metrics collection, collection interval=" + config.getCollectionIntervalSeconds() - + " seconds, retention=" + config.getRetentionSeconds() + " seconds, publishers=" + logger.fine("Configuring metrics collection, collection interval=" + config.getCollectionFrequencySeconds() + + " seconds, retention=" + config.getManagementCenterConfig().getRetentionSeconds() + " seconds, publishers=" + publishers.stream().map(MetricsPublisher::name).collect(joining(", ", "[", "]"))); ExecutionService executionService = nodeEngine.getExecutionService(); scheduledFuture = executionService.scheduleWithRepetition("MetricsPublisher", this::collectMetrics, 1, - config.getCollectionIntervalSeconds(), TimeUnit.SECONDS); + config.getCollectionFrequencySeconds(), TimeUnit.SECONDS); collectorScheduled = true; } } + // visible for testing + MetricsConfig getConfig() { + return config; + } + // visible for testing void collectMetrics() { collectMetrics(metricsCollector); @@ -227,9 +232,9 @@ private JmxPublisher createJmxPublisher() { } private ManagementCenterPublisher createMcPublisher() { - int journalSize = Math.max( - 1, (int) Math.ceil((double) config.getRetentionSeconds() / config.getCollectionIntervalSeconds()) - ); + int retentionSeconds = config.getManagementCenterConfig().getRetentionSeconds(); + int frequency = config.getCollectionFrequencySeconds(); + int journalSize = Math.max(1, (int) Math.ceil((double) retentionSeconds / frequency)); metricsJournal = new ConcurrentArrayRingbuffer<>(journalSize); return new ManagementCenterPublisher(this.nodeEngine.getLoggingService(), (blob, ts) -> { diff --git a/hazelcast/src/main/java/com/hazelcast/spi/impl/NodeEngineImpl.java b/hazelcast/src/main/java/com/hazelcast/spi/impl/NodeEngineImpl.java index e72e0f8a3caa9..1ebbaf93a4351 100644 --- a/hazelcast/src/main/java/com/hazelcast/spi/impl/NodeEngineImpl.java +++ b/hazelcast/src/main/java/com/hazelcast/spi/impl/NodeEngineImpl.java @@ -16,6 +16,7 @@ package com.hazelcast.spi.impl; +import com.hazelcast.cluster.Address; import com.hazelcast.cluster.impl.MemberImpl; import com.hazelcast.config.Config; import com.hazelcast.config.MetricsConfig; @@ -50,7 +51,6 @@ import com.hazelcast.logging.ILogger; import com.hazelcast.logging.LoggingService; import com.hazelcast.logging.impl.LoggingServiceImpl; -import com.hazelcast.cluster.Address; import com.hazelcast.nio.serialization.Data; import com.hazelcast.spi.exception.RetryableHazelcastException; import com.hazelcast.spi.exception.ServiceNotFoundException; @@ -182,7 +182,7 @@ private ConcurrencyDetection newConcurrencyDetection() { } private MetricsRegistryImpl newMetricRegistry(Node node) { - ProbeLevel minimumLevel = node.getConfig().getMetricsConfig().getMinimumLevel(); + ProbeLevel minimumLevel = node.getConfig().getMetricsConfig().getLevel(); return new MetricsRegistryImpl(getHazelcastInstance().getName(), node.getLogger(MetricsRegistry.class), minimumLevel); } @@ -215,7 +215,7 @@ public void start() { FileMetricSet.register(metricsRegistry); MetricsConfig metricsConfig = node.getConfig().getMetricsConfig(); - if (metricsConfig.isEnabled() && metricsConfig.isMetricsForDataStructuresEnabled()) { + if (metricsConfig.isEnabled() && metricsConfig.isDataStructureMetricsEnabled()) { StatisticsAwareMetricsSet.register(serviceManager, metricsRegistry); } diff --git a/hazelcast/src/main/java/com/hazelcast/spi/properties/GroupProperty.java b/hazelcast/src/main/java/com/hazelcast/spi/properties/GroupProperty.java index dccddae6d120e..d62e50becbc6c 100644 --- a/hazelcast/src/main/java/com/hazelcast/spi/properties/GroupProperty.java +++ b/hazelcast/src/main/java/com/hazelcast/spi/properties/GroupProperty.java @@ -19,6 +19,9 @@ import com.hazelcast.config.AdvancedNetworkConfig; import com.hazelcast.config.Config; import com.hazelcast.config.EndpointConfig; +import com.hazelcast.config.MetricsConfig; +import com.hazelcast.config.MetricsJmxConfig; +import com.hazelcast.config.MetricsManagementCenterConfig; import com.hazelcast.config.NetworkConfig; import com.hazelcast.config.SSLConfig; import com.hazelcast.core.HazelcastInstance; @@ -28,6 +31,7 @@ import com.hazelcast.instance.EndpointQualifier; import com.hazelcast.internal.cluster.fd.ClusterFailureDetectorType; import com.hazelcast.internal.diagnostics.HealthMonitorLevel; +import com.hazelcast.internal.metrics.ProbeLevel; import com.hazelcast.internal.util.RuntimeAvailableProcessors; import com.hazelcast.map.IMap; import com.hazelcast.map.QueryResultSizeExceededException; @@ -1108,6 +1112,114 @@ private int getWhenNoSSLDetected() { public static final HazelcastProperty NETWORK_STATS_REFRESH_INTERVAL_SECONDS = new HazelcastProperty("hazelcast.network.stats.refresh.interval.seconds", 3, SECONDS); + /** + * Enables/disables metrics collection altogether. This is a master + * switch for all metrics related functionality. + *

+ * NOTE: This property overrides {@link MetricsConfig#isEnabled()}. + *

+ * Using {@link MetricsConfig#setEnabled(boolean)} and the declarative + * counterparts are preferred over using this property. The main purpose + * of making metrics collection configurable from properties too is + * allowing operators to configure the metrics subsystem from the outside + * during investigation without touching or copying the configuration + * potentially embedded into a signed artifact. + */ + public static final HazelcastProperty METRICS_ENABLED + = new HazelcastProperty("hazelcast.metrics.enabled"); + + /** + * Enables/disables collecting metrics for Management Center. If disabled, + * Management Center can't consume the metrics from this member. + *

+ * NOTE: This property overrides {@link MetricsManagementCenterConfig#isEnabled()}. + *

+ * Using {@link MetricsManagementCenterConfig#setEnabled(boolean)} and the declarative + * counterparts are preferred over using this property. The main purpose + * of making metrics collection configurable from properties too is + * allowing operators to configure the metrics subsystem from the outside + * during investigation without touching or copying the configuration + * potentially embedded into a signed artifact. + */ + public static final HazelcastProperty METRICS_MC_ENABLED + = new HazelcastProperty("hazelcast.metrics.mc.enabled"); + + /** + * Sets the duration in seconds for which the collected metrics are retained + * and Management Center can consume them. + *

+ * NOTE: This property overrides {@link MetricsManagementCenterConfig#getRetentionSeconds()}. + *

+ * Using {@link MetricsManagementCenterConfig#setRetentionSeconds(int)} and the declarative + * counterparts are preferred over using this property. The main purpose + * of making metrics collection configurable from properties too is + * allowing operators to configure the metrics subsystem from the outside + * during investigation without touching or copying the configuration + * potentially embedded into a signed artifact. + */ + public static final HazelcastProperty METRICS_MC_RETENTION + = new HazelcastProperty("hazelcast.metrics.mc.retention"); + + /** + * Enables/disables exposing metrics on JMX. + *

+ * NOTE: This property overrides {@link MetricsJmxConfig#isEnabled()}. + *

+ * Using {@link MetricsJmxConfig#setEnabled(boolean)} and the declarative + * counterparts are preferred over using this property. The main purpose + * of making metrics collection configurable from properties too is + * allowing operators to configure the metrics subsystem from the outside + * during investigation without touching or copying the configuration + * potentially embedded into a signed artifact. + */ + public static final HazelcastProperty METRICS_JMX_ENABLED + = new HazelcastProperty("hazelcast.metrics.jmx.enabled"); + + /** + * Sets the minimum level of metrics to be collected. + *

+ * NOTE: This property overrides {@link MetricsConfig#getLevel()}. + *

+ * Using {@link MetricsConfig#setLevel(ProbeLevel)} and the declarative + * counterparts are preferred over using this property. The main purpose + * of making metrics collection configurable from properties too is + * allowing operators to configure the metrics subsystem from the outside + * during investigation without touching or copying the configuration + * potentially embedded into a signed artifact. + */ + public static final HazelcastProperty METRICS_LEVEL + = new HazelcastProperty("hazelcast.metrics.level"); + + /** + * Enables/disables collecting metrics from the distributed datastructures. + *

+ * NOTE: This property overrides {@link MetricsConfig#isDataStructureMetricsEnabled()}. + *

+ * Using {@link MetricsConfig#setDataStructureMetricsEnabled(boolean)} and the declarative + * counterparts are preferred over using this property. The main purpose + * of making metrics collection configurable from properties too is + * allowing operators to configure the metrics subsystem from the outside + * during investigation without touching or copying the configuration + * potentially embedded into a signed artifact. + */ + public static final HazelcastProperty METRICS_DATASTRUCTURES + = new HazelcastProperty("hazelcast.metrics.datastructures"); + + /** + * Sets the metrics collection frequency in seconds. + *

+ * NOTE: This property overrides {@link MetricsConfig#getCollectionFrequencySeconds()}. + *

+ * Using {@link MetricsConfig#setCollectionFrequencySeconds(int)} and the declarative + * counterparts are preferred over using this property. The main purpose + * of making metrics collection configurable from properties too is + * allowing operators to configure the metrics subsystem from the outside + * during investigation without touching or copying the configuration + * potentially embedded into a signed artifact. + */ + public static final HazelcastProperty METRICS_COLLECTION_FREQUENCY + = new HazelcastProperty("hazelcast.metrics.collection.frequency"); + private GroupProperty() { } } diff --git a/hazelcast/src/main/resources/hazelcast-config-4.0.xsd b/hazelcast/src/main/resources/hazelcast-config-4.0.xsd index 861afe5824969..1b65217c9cd45 100644 --- a/hazelcast/src/main/resources/hazelcast-config-4.0.xsd +++ b/hazelcast/src/main/resources/hazelcast-config-4.0.xsd @@ -4708,20 +4708,71 @@ - - - - + + + + + + Sets the metrics collection frequency in seconds. + By default, metrics are collected every 5 seconds. + May be overridden by 'hazelcast.metrics.collection.frequency' + system property. + + + + + + + Controls if metrics should be collected for the + distributed data structures (maps, caches etc). + It is disabled by default. + May be overridden by 'hazelcast.metrics.datastructures' + system property. + + + + + + + Sets the minimum metrics level to be collected. By default + it is set to INFO so metrics collect at INFO and MANDATORY + levels are collected, DEBUG metrics are not. + May be overridden by 'hazelcast.metrics.level' + system property. + + + Master-switch for the metrics system. Controls whether the metrics are collected and publishers are enabled. + May be overridden by 'hazelcast.metrics.enabled' + system property. - + + + + + + + + Sets the number of seconds the metrics will be retained on the + instance. By default, metrics are retained for 5 seconds (that is for + one collection of metrics values, if default "collection-frequency-seconds" + collection frequency is used). More retention means more heap memory, but + allows for longer client hiccups without losing a value (for example to + restart the Management Center). + May be overridden by 'hazelcast.metrics.mc.retention' + system property. + + + + + Controls whether the metrics collected are exposed to @@ -4734,22 +4785,29 @@ used. In order to expose the metrics, the metrics system need to be enabled via the enabled master-switch attribute. + May be overridden by 'hazelcast.metrics.mc.enabled' + system property. - + + + + Controls whether the metrics collected are exposed to through JMX. It is enabled by default. In order to expose the metrics, the metrics system need to be enabled via the enabled master-switch attribute. + May be overridden by 'hazelcast.metrics.jmx.enabled' + system property. - + diff --git a/hazelcast/src/main/resources/hazelcast-default.xml b/hazelcast/src/main/resources/hazelcast-default.xml index a61691f366303..9ec08dfa6d6d1 100644 --- a/hazelcast/src/main/resources/hazelcast-default.xml +++ b/hazelcast/src/main/resources/hazelcast-default.xml @@ -331,4 +331,14 @@ 100 + + + + 5 + + + 5 + false + INFO + diff --git a/hazelcast/src/main/resources/hazelcast-default.yaml b/hazelcast/src/main/resources/hazelcast-default.yaml index cde88e86c7643..41571113e3cd0 100644 --- a/hazelcast/src/main/resources/hazelcast-default.yaml +++ b/hazelcast/src/main/resources/hazelcast-default.yaml @@ -325,3 +325,14 @@ hazelcast: # locks: # default: # lock-acquire-limit: 0 + + metrics: + enabled: true + management-center: + enabled: true + retention-seconds: 5 + jmx: + enabled: true + collection-frequency-seconds: 5 + data-structure-metrics-enabled: false + level: INFO diff --git a/hazelcast/src/main/resources/hazelcast-full-example.xml b/hazelcast/src/main/resources/hazelcast-full-example.xml index 115396e40ec8b..3b0129c9355ee 100644 --- a/hazelcast/src/main/resources/hazelcast-full-example.xml +++ b/hazelcast/src/main/resources/hazelcast-full-example.xml @@ -3311,11 +3311,70 @@ - - 10 - 30 - true - DEBUG + + + + 30 + + + 10 + true + DEBUG diff --git a/hazelcast/src/main/resources/hazelcast-full-example.yaml b/hazelcast/src/main/resources/hazelcast-full-example.yaml index 756d2c1df611e..301fd47332c36 100644 --- a/hazelcast/src/main/resources/hazelcast-full-example.yaml +++ b/hazelcast/src/main/resources/hazelcast-full-example.yaml @@ -3232,11 +3232,68 @@ hazelcast: lock2: lock-acquire-limit: 2 + # + # ===== HAZELCAST METRICS CONFIGURATION ===== + # + # Configuration element's name is "metrics". + # + # It has the following sub-elements: + # * "management-center": + # Defines the Hazelcast Management Center related metrics configuration. + # + # It has the following attributes: + # * "enabled": + # Controls whether the metrics collected are exposed to + # Hazelcast Management Center. It is enabled by default. + # Please note that the metrics are polled by the + # Hazelcast Management Center, hence the members need to + # buffer the collected metrics between two polls. The aim + # for this switch is to reduce memory consumption of the + # metrics system if the Hazelcast Management Center is not + # used. + # + # It has the following sub-elements: + # * "retention-seconds": + # Sets the number of seconds the metrics will be retained on the + # instance. By default, metrics are retained for 5 seconds (that is for + # one collection of metrics values, if default "collection-frequency-seconds" + # collection frequency is used). More retention means more heap memory, but + # allows for longer client hiccups without losing a value (for example to + # restart the Management Center). + # + # * "jmx": + # Defines the JMX related metrics configuration. + # + # It has the following attributes: + # * "enabled": + # Controls whether the metrics collected are exposed to + # through JMX. It is enabled by default. + # In order to expose the metrics, the metrics system need + # to be enabled via the enabled master-switch attribute. + # + # * "collection-frequency-seconds": + # Sets the metrics collection frequency in seconds. + # By default, metrics are collected every 5 seconds. + # + # * "data-structure-metrics": + # Controls if metrics should be collected for the + # distributed data structures (maps, caches etc). + # It is disabled by default. + # + # * "level": + # Sets the minimum metrics level to be collected. By default + # it is set to INFO so metrics collect at INFO and MANDATORY + # levels are collected, DEBUG metrics are not. + # + # Possible values are MANDATORY, INFO, DEBUG. + # metrics: enabled: false - mc-enabled: false - jmx-enabled: false - collection-interval-seconds: 10 - retention-seconds: 30 - metrics-for-data-structures: true - minimum-level: DEBUG + management-center: + enabled: false + retention-seconds: 30 + jmx: + enabled: false + collection-frequency-seconds: 10 + data-structure-metrics-enabled: true + level: DEBUG diff --git a/hazelcast/src/test/java/com/hazelcast/config/ConfigCompatibilityChecker.java b/hazelcast/src/test/java/com/hazelcast/config/ConfigCompatibilityChecker.java index 49b5851c4d0e8..6ec2cd4bc0776 100644 --- a/hazelcast/src/test/java/com/hazelcast/config/ConfigCompatibilityChecker.java +++ b/hazelcast/src/test/java/com/hazelcast/config/ConfigCompatibilityChecker.java @@ -19,6 +19,9 @@ import com.hazelcast.config.CacheSimpleConfig.ExpiryPolicyFactoryConfig; import com.hazelcast.config.CacheSimpleConfig.ExpiryPolicyFactoryConfig.DurationConfig; import com.hazelcast.config.CacheSimpleConfig.ExpiryPolicyFactoryConfig.TimedExpiryPolicyFactoryConfig; +import com.hazelcast.config.cp.CPSubsystemConfig; +import com.hazelcast.config.cp.FencedLockConfig; +import com.hazelcast.config.cp.RaftAlgorithmConfig; import com.hazelcast.config.cp.SemaphoreConfig; import com.hazelcast.config.security.JaasAuthenticationConfig; import com.hazelcast.config.security.LdapAuthenticationConfig; @@ -26,9 +29,6 @@ import com.hazelcast.config.security.TlsAuthenticationConfig; import com.hazelcast.config.security.TokenIdentityConfig; import com.hazelcast.config.security.UsernamePasswordIdentityConfig; -import com.hazelcast.config.cp.CPSubsystemConfig; -import com.hazelcast.config.cp.FencedLockConfig; -import com.hazelcast.config.cp.RaftAlgorithmConfig; import com.hazelcast.core.HazelcastException; import com.hazelcast.instance.EndpointQualifier; import com.hazelcast.internal.util.CollectionUtil; @@ -625,12 +625,13 @@ boolean check(MetricsConfig c1, MetricsConfig c2) { } return c1.isEnabled() == c2.isEnabled() - && c1.isMcEnabled() == c2.isMcEnabled() - && c1.isJmxEnabled() == c2.isJmxEnabled() - && c1.getCollectionIntervalSeconds() == c2.getCollectionIntervalSeconds() - && c1.getRetentionSeconds() == c2.getRetentionSeconds() - && c1.isMetricsForDataStructuresEnabled() == c2.isMetricsForDataStructuresEnabled() - && c1.getMinimumLevel() == c2.getMinimumLevel(); + && c1.getManagementCenterConfig().isEnabled() == c2.getManagementCenterConfig().isEnabled() + && c1.getManagementCenterConfig().getRetentionSeconds() == c2.getManagementCenterConfig() + .getRetentionSeconds() + && c1.getJmxConfig().isEnabled() == c2.getJmxConfig().isEnabled() + && c1.getCollectionFrequencySeconds() == c2.getCollectionFrequencySeconds() + && c1.isDataStructureMetricsEnabled() == c2.isDataStructureMetricsEnabled() + && c1.getLevel() == c2.getLevel(); } @Override diff --git a/hazelcast/src/test/java/com/hazelcast/config/ConfigXmlGeneratorTest.java b/hazelcast/src/test/java/com/hazelcast/config/ConfigXmlGeneratorTest.java index 2f3d288c3c039..90dafb88f38e5 100644 --- a/hazelcast/src/test/java/com/hazelcast/config/ConfigXmlGeneratorTest.java +++ b/hazelcast/src/test/java/com/hazelcast/config/ConfigXmlGeneratorTest.java @@ -1459,12 +1459,16 @@ public void testMetricsConfig() { config.getMetricsConfig() .setEnabled(false) - .setMcEnabled(false) - .setJmxEnabled(false) - .setCollectionIntervalSeconds(10) - .setRetentionSeconds(11) - .setMetricsForDataStructuresEnabled(true) - .setMinimumLevel(DEBUG); + .setCollectionFrequencySeconds(10) + .setDataStructureMetricsEnabled(true) + .setLevel(DEBUG); + + config.getMetricsConfig().getManagementCenterConfig() + .setEnabled(false) + .setRetentionSeconds(11); + + config.getMetricsConfig().getJmxConfig() + .setEnabled(false); MetricsConfig generatedConfig = getNewConfigViaXMLGenerator(config).getMetricsConfig(); assertTrue(generatedConfig + " should be compatible with " + config.getMetricsConfig(), diff --git a/hazelcast/src/test/java/com/hazelcast/config/MetricsConfigTest.java b/hazelcast/src/test/java/com/hazelcast/config/MetricsConfigTest.java index 5d6ee9e927e7a..e9ff34ca5d146 100644 --- a/hazelcast/src/test/java/com/hazelcast/config/MetricsConfigTest.java +++ b/hazelcast/src/test/java/com/hazelcast/config/MetricsConfigTest.java @@ -47,11 +47,16 @@ public void testCloneEquals() { // create MetricsConfig with non-defaults MetricsConfig original = new MetricsConfig() .setEnabled(false) - .setJmxEnabled(false) - .setRetentionSeconds(1) - .setCollectionIntervalSeconds(1) - .setMetricsForDataStructuresEnabled(true) - .setMinimumLevel(ProbeLevel.DEBUG); + .setCollectionFrequencySeconds(1) + .setDataStructureMetricsEnabled(true) + .setLevel(ProbeLevel.DEBUG); + + original.getManagementCenterConfig() + .setEnabled(false) + .setRetentionSeconds(1); + + original.getJmxConfig() + .setEnabled(false); MetricsConfig clone = new MetricsConfig(original); diff --git a/hazelcast/src/test/java/com/hazelcast/config/XMLConfigBuilderTest.java b/hazelcast/src/test/java/com/hazelcast/config/XMLConfigBuilderTest.java index fa9b3cd38bbb9..90bafd78bd208 100644 --- a/hazelcast/src/test/java/com/hazelcast/config/XMLConfigBuilderTest.java +++ b/hazelcast/src/test/java/com/hazelcast/config/XMLConfigBuilderTest.java @@ -19,11 +19,11 @@ import com.google.common.collect.ImmutableSet; import com.hazelcast.config.LoginModuleConfig.LoginModuleUsage; import com.hazelcast.config.PermissionConfig.PermissionType; -import com.hazelcast.config.cp.SemaphoreConfig; -import com.hazelcast.config.security.RealmConfig; import com.hazelcast.config.cp.CPSubsystemConfig; import com.hazelcast.config.cp.FencedLockConfig; import com.hazelcast.config.cp.RaftAlgorithmConfig; +import com.hazelcast.config.cp.SemaphoreConfig; +import com.hazelcast.config.security.RealmConfig; import com.hazelcast.instance.EndpointQualifier; import com.hazelcast.internal.nio.IOUtil; import com.hazelcast.splitbrainprotection.SplitBrainProtectionOn; @@ -3435,22 +3435,26 @@ protected Config buildCompleteAdvancedNetworkConfig() { @Test public void testMetricsConfig() { String xml = HAZELCAST_START_TAG - + "\n" - + " 10\n" - + " 11\n" - + " true\n" - + " DEBUG\n" + + "" + + " " + + " 11" + + " " + + " " + + " 10\n" + + " true\n" + + " DEBUG\n" + "" + HAZELCAST_END_TAG; Config config = new InMemoryXmlConfig(xml); MetricsConfig metricsConfig = config.getMetricsConfig(); + MetricsManagementCenterConfig metricsMcConfig = metricsConfig.getManagementCenterConfig(); assertFalse(metricsConfig.isEnabled()); - assertFalse(metricsConfig.isMcEnabled()); - assertFalse(metricsConfig.isJmxEnabled()); - assertEquals(10, metricsConfig.getCollectionIntervalSeconds()); - assertEquals(11, metricsConfig.getRetentionSeconds()); - assertTrue(metricsConfig.isMetricsForDataStructuresEnabled()); - assertEquals(DEBUG, metricsConfig.getMinimumLevel()); + assertFalse(metricsMcConfig.isEnabled()); + assertFalse(metricsConfig.getJmxConfig().isEnabled()); + assertEquals(10, metricsConfig.getCollectionFrequencySeconds()); + assertEquals(11, metricsMcConfig.getRetentionSeconds()); + assertTrue(metricsConfig.isDataStructureMetricsEnabled()); + assertEquals(DEBUG, metricsConfig.getLevel()); } @Override @@ -3462,33 +3466,37 @@ public void testMetricsConfigMasterSwitchDisabled() { Config config = new InMemoryXmlConfig(xml); MetricsConfig metricsConfig = config.getMetricsConfig(); assertFalse(metricsConfig.isEnabled()); - assertTrue(metricsConfig.isMcEnabled()); - assertTrue(metricsConfig.isJmxEnabled()); + assertTrue(metricsConfig.getManagementCenterConfig().isEnabled()); + assertTrue(metricsConfig.getJmxConfig().isEnabled()); } @Override @Test public void testMetricsConfigMcDisabled() { String xml = HAZELCAST_START_TAG - + "" + + "" + + " " + + "" + HAZELCAST_END_TAG; Config config = new InMemoryXmlConfig(xml); MetricsConfig metricsConfig = config.getMetricsConfig(); assertTrue(metricsConfig.isEnabled()); - assertFalse(metricsConfig.isMcEnabled()); - assertTrue(metricsConfig.isJmxEnabled()); + assertFalse(metricsConfig.getManagementCenterConfig().isEnabled()); + assertTrue(metricsConfig.getJmxConfig().isEnabled()); } @Override @Test public void testMetricsConfigJmxDisabled() { String xml = HAZELCAST_START_TAG - + "" + + "" + + " " + + "" + HAZELCAST_END_TAG; Config config = new InMemoryXmlConfig(xml); MetricsConfig metricsConfig = config.getMetricsConfig(); assertTrue(metricsConfig.isEnabled()); - assertTrue(metricsConfig.isMcEnabled()); - assertFalse(metricsConfig.isJmxEnabled()); + assertTrue(metricsConfig.getManagementCenterConfig().isEnabled()); + assertFalse(metricsConfig.getJmxConfig().isEnabled()); } } diff --git a/hazelcast/src/test/java/com/hazelcast/config/YamlConfigBuilderTest.java b/hazelcast/src/test/java/com/hazelcast/config/YamlConfigBuilderTest.java index d9ebd997aa4f0..2dcf20a69aefe 100644 --- a/hazelcast/src/test/java/com/hazelcast/config/YamlConfigBuilderTest.java +++ b/hazelcast/src/test/java/com/hazelcast/config/YamlConfigBuilderTest.java @@ -17,12 +17,12 @@ package com.hazelcast.config; import com.google.common.collect.ImmutableSet; -import com.hazelcast.config.cp.SemaphoreConfig; -import com.hazelcast.config.security.RealmConfig; import com.hazelcast.config.LoginModuleConfig.LoginModuleUsage; import com.hazelcast.config.cp.CPSubsystemConfig; import com.hazelcast.config.cp.FencedLockConfig; import com.hazelcast.config.cp.RaftAlgorithmConfig; +import com.hazelcast.config.cp.SemaphoreConfig; +import com.hazelcast.config.security.RealmConfig; import com.hazelcast.instance.EndpointQualifier; import com.hazelcast.internal.nio.IOUtil; import com.hazelcast.splitbrainprotection.SplitBrainProtectionOn; @@ -3466,21 +3466,24 @@ public void testMetricsConfig() { + "hazelcast:\n" + " metrics:\n" + " enabled: false\n" - + " mc-enabled: false\n" - + " jmx-enabled: false\n" - + " collection-interval-seconds: 10\n" - + " retention-seconds: 11\n" - + " metrics-for-data-structures: true\n" - + " minimum-level: DEBUG"; + + " management-center:\n" + + " enabled: false\n" + + " retention-seconds: 11\n" + + " jmx:\n" + + " enabled: false\n" + + " collection-frequency-seconds: 10\n" + + " data-structure-metrics-enabled: true\n" + + " level: DEBUG"; Config config = new InMemoryYamlConfig(yaml); MetricsConfig metricsConfig = config.getMetricsConfig(); assertFalse(metricsConfig.isEnabled()); - assertFalse(metricsConfig.isMcEnabled()); - assertFalse(metricsConfig.isJmxEnabled()); - assertEquals(10, metricsConfig.getCollectionIntervalSeconds()); - assertEquals(11, metricsConfig.getRetentionSeconds()); - assertTrue(metricsConfig.isMetricsForDataStructuresEnabled()); - assertEquals(DEBUG, metricsConfig.getMinimumLevel()); + MetricsManagementCenterConfig metricsMcConfig = metricsConfig.getManagementCenterConfig(); + assertFalse(metricsMcConfig.isEnabled()); + assertFalse(metricsConfig.getJmxConfig().isEnabled()); + assertEquals(10, metricsConfig.getCollectionFrequencySeconds()); + assertEquals(11, metricsMcConfig.getRetentionSeconds()); + assertTrue(metricsConfig.isDataStructureMetricsEnabled()); + assertEquals(DEBUG, metricsConfig.getLevel()); } @Override @@ -3493,8 +3496,8 @@ public void testMetricsConfigMasterSwitchDisabled() { Config config = new InMemoryYamlConfig(yaml); MetricsConfig metricsConfig = config.getMetricsConfig(); assertFalse(metricsConfig.isEnabled()); - assertTrue(metricsConfig.isMcEnabled()); - assertTrue(metricsConfig.isJmxEnabled()); + assertTrue(metricsConfig.getManagementCenterConfig().isEnabled()); + assertTrue(metricsConfig.getJmxConfig().isEnabled()); } @Override @@ -3503,12 +3506,13 @@ public void testMetricsConfigMcDisabled() { String yaml = "" + "hazelcast:\n" + " metrics:\n" - + " mc-enabled: false"; + + " management-center:\n" + + " enabled: false"; Config config = new InMemoryYamlConfig(yaml); MetricsConfig metricsConfig = config.getMetricsConfig(); assertTrue(metricsConfig.isEnabled()); - assertFalse(metricsConfig.isMcEnabled()); - assertTrue(metricsConfig.isJmxEnabled()); + assertFalse(metricsConfig.getManagementCenterConfig().isEnabled()); + assertTrue(metricsConfig.getJmxConfig().isEnabled()); } @Override @@ -3517,12 +3521,12 @@ public void testMetricsConfigJmxDisabled() { String yaml = "" + "hazelcast:\n" + " metrics:\n" - + " jmx-enabled: false"; + + " jmx:\n" + + " enabled: false"; Config config = new InMemoryYamlConfig(yaml); MetricsConfig metricsConfig = config.getMetricsConfig(); assertTrue(metricsConfig.isEnabled()); - assertTrue(metricsConfig.isMcEnabled()); - assertFalse(metricsConfig.isJmxEnabled()); - + assertTrue(metricsConfig.getManagementCenterConfig().isEnabled()); + assertFalse(metricsConfig.getJmxConfig().isEnabled()); } } diff --git a/hazelcast/src/test/java/com/hazelcast/internal/diagnostics/DistributedDatastructuresMetricsTest.java b/hazelcast/src/test/java/com/hazelcast/internal/diagnostics/DistributedDatastructuresMetricsTest.java index 5650b93ed39f2..8465df56e2c0b 100644 --- a/hazelcast/src/test/java/com/hazelcast/internal/diagnostics/DistributedDatastructuresMetricsTest.java +++ b/hazelcast/src/test/java/com/hazelcast/internal/diagnostics/DistributedDatastructuresMetricsTest.java @@ -68,8 +68,8 @@ public void setup() { Config config = new Config(); config.addMapConfig(new MapConfig(NEAR_CACHE_MAP_NAME).setNearCacheConfig(new NearCacheConfig("nearCache"))); config.getMetricsConfig() - .setMetricsForDataStructuresEnabled(true) - .setMinimumLevel(ProbeLevel.INFO); + .setDataStructureMetricsEnabled(true) + .setLevel(ProbeLevel.INFO); hz = createHazelcastInstance(config); diff --git a/hazelcast/src/test/java/com/hazelcast/internal/metrics/impl/MetricsConfigOverrideTest.java b/hazelcast/src/test/java/com/hazelcast/internal/metrics/impl/MetricsConfigOverrideTest.java new file mode 100644 index 0000000000000..cb1d8d5f70045 --- /dev/null +++ b/hazelcast/src/test/java/com/hazelcast/internal/metrics/impl/MetricsConfigOverrideTest.java @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.hazelcast.internal.metrics.impl; + +import com.hazelcast.config.Config; +import com.hazelcast.config.MetricsConfig; +import com.hazelcast.core.HazelcastInstance; +import com.hazelcast.internal.metrics.MetricsRegistry; +import com.hazelcast.spi.properties.GroupProperty; +import com.hazelcast.test.HazelcastParallelClassRunner; +import com.hazelcast.test.HazelcastTestSupport; +import com.hazelcast.test.annotation.ParallelJVMTest; +import com.hazelcast.test.annotation.QuickTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; + +import static com.hazelcast.internal.metrics.ProbeLevel.DEBUG; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + +@RunWith(HazelcastParallelClassRunner.class) +@Category({QuickTest.class, ParallelJVMTest.class}) +public class MetricsConfigOverrideTest extends HazelcastTestSupport { + + @Test + public void testSystemPropertiesOverrideConfig() { + // setting non-defaults + System.setProperty(GroupProperty.METRICS_ENABLED.getName(), "false"); + System.setProperty(GroupProperty.METRICS_MC_ENABLED.getName(), "false"); + System.setProperty(GroupProperty.METRICS_MC_RETENTION.getName(), "42"); + System.setProperty(GroupProperty.METRICS_JMX_ENABLED.getName(), "false"); + System.setProperty(GroupProperty.METRICS_COLLECTION_FREQUENCY.getName(), "24"); + System.setProperty(GroupProperty.METRICS_DATASTRUCTURES.getName(), "true"); + System.setProperty(GroupProperty.METRICS_LEVEL.getName(), "DEBUG"); + + 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()); + assertTrue(metricsConfig.isDataStructureMetricsEnabled()); + assertEquals(DEBUG, metricsConfig.getLevel()); + + // verify that the overridden config is used + MetricsRegistry metricsRegistry = getNodeEngineImpl(instance).getMetricsRegistry(); + MetricsService metricsService = getNodeEngineImpl(instance).getService(MetricsService.SERVICE_NAME); + assertEquals(DEBUG, metricsRegistry.minimumLevel()); + assertSame(metricsConfig, metricsService.getConfig()); + } + + @Test + public void testInvalidSystemPropertiesIgnored() { + // setting non-defaults + System.setProperty(GroupProperty.METRICS_ENABLED.getName(), "invalid"); + System.setProperty(GroupProperty.METRICS_MC_ENABLED.getName(), "invalid"); + System.setProperty(GroupProperty.METRICS_MC_RETENTION.getName(), "invalid"); + System.setProperty(GroupProperty.METRICS_JMX_ENABLED.getName(), "invalid"); + System.setProperty(GroupProperty.METRICS_COLLECTION_FREQUENCY.getName(), "invalid"); + System.setProperty(GroupProperty.METRICS_DATASTRUCTURES.getName(), "invalid"); + System.setProperty(GroupProperty.METRICS_LEVEL.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()); + assertFalse(metricsConfig.isDataStructureMetricsEnabled()); + assertEquals(defaultConfig.getLevel(), metricsConfig.getLevel()); + + // verify that the overridden config is used + MetricsRegistry metricsRegistry = getNodeEngineImpl(instance).getMetricsRegistry(); + MetricsService metricsService = getNodeEngineImpl(instance).getService(MetricsService.SERVICE_NAME); + assertEquals(defaultConfig.getLevel(), metricsRegistry.minimumLevel()); + assertSame(metricsConfig, metricsService.getConfig()); + } + + @Test + public void testConfigPropertiesOverrideConfig() { + Config originalConfig = smallInstanceConfig(); + // setting non-defaults + originalConfig.setProperty(GroupProperty.METRICS_ENABLED.getName(), "false"); + originalConfig.setProperty(GroupProperty.METRICS_MC_ENABLED.getName(), "false"); + originalConfig.setProperty(GroupProperty.METRICS_MC_RETENTION.getName(), "42"); + originalConfig.setProperty(GroupProperty.METRICS_JMX_ENABLED.getName(), "false"); + originalConfig.setProperty(GroupProperty.METRICS_COLLECTION_FREQUENCY.getName(), "24"); + originalConfig.setProperty(GroupProperty.METRICS_DATASTRUCTURES.getName(), "true"); + originalConfig.setProperty(GroupProperty.METRICS_LEVEL.getName(), "DEBUG"); + + 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()); + assertTrue(metricsConfig.isDataStructureMetricsEnabled()); + assertEquals(DEBUG, metricsConfig.getLevel()); + + // verify that the overridden config is used + MetricsRegistry metricsRegistry = getNodeEngineImpl(instance).getMetricsRegistry(); + MetricsService metricsService = getNodeEngineImpl(instance).getService(MetricsService.SERVICE_NAME); + assertEquals(DEBUG, metricsRegistry.minimumLevel()); + assertSame(metricsConfig, metricsService.getConfig()); + } + + @Test + public void testInvalidConfigPropertiesIgnored() { + Config originalConfig = smallInstanceConfig(); + // setting non-defaults + originalConfig.setProperty(GroupProperty.METRICS_ENABLED.getName(), "invalid"); + originalConfig.setProperty(GroupProperty.METRICS_MC_ENABLED.getName(), "invalid"); + originalConfig.setProperty(GroupProperty.METRICS_MC_RETENTION.getName(), "invalid"); + originalConfig.setProperty(GroupProperty.METRICS_JMX_ENABLED.getName(), "invalid"); + originalConfig.setProperty(GroupProperty.METRICS_COLLECTION_FREQUENCY.getName(), "invalid"); + originalConfig.setProperty(GroupProperty.METRICS_DATASTRUCTURES.getName(), "invalid"); + originalConfig.setProperty(GroupProperty.METRICS_LEVEL.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()); + assertFalse(metricsConfig.isDataStructureMetricsEnabled()); + assertEquals(defaultConfig.getLevel(), metricsConfig.getLevel()); + + // verify that the overridden config is used + MetricsRegistry metricsRegistry = getNodeEngineImpl(instance).getMetricsRegistry(); + MetricsService metricsService = getNodeEngineImpl(instance).getService(MetricsService.SERVICE_NAME); + assertEquals(defaultConfig.getLevel(), metricsRegistry.minimumLevel()); + assertSame(metricsConfig, metricsService.getConfig()); + } +} diff --git a/hazelcast/src/test/java/com/hazelcast/internal/metrics/impl/MetricsServiceTest.java b/hazelcast/src/test/java/com/hazelcast/internal/metrics/impl/MetricsServiceTest.java index bf11987e637c4..77d38386bcc06 100644 --- a/hazelcast/src/test/java/com/hazelcast/internal/metrics/impl/MetricsServiceTest.java +++ b/hazelcast/src/test/java/com/hazelcast/internal/metrics/impl/MetricsServiceTest.java @@ -98,7 +98,6 @@ public class MetricsServiceTest extends HazelcastTestSupport { public void setUp() { initMocks(this); - config.getMetricsConfig().setCollectionIntervalSeconds(10); metricsRegistry = new MetricsRegistryImpl(loggerMock, ProbeLevel.INFO); when(nodeMock.getLogger(any(Class.class))).thenReturn(loggerMock); @@ -149,8 +148,9 @@ public void testUpdatesRenderedInOrder() { public void testReadMetricsReadsLastTwoCollections() throws Exception { // configure metrics to keep the result of the last 2 collection cycles config.getMetricsConfig() - .setRetentionSeconds(2) - .setCollectionIntervalSeconds(1); + .setCollectionFrequencySeconds(1) + .getManagementCenterConfig() + .setRetentionSeconds(2); MetricsService metricsService = new MetricsService(nodeEngineMock, () -> metricsRegistry); metricsService.init(nodeEngineMock, new Properties()); @@ -180,8 +180,9 @@ public void testReadMetricsReadsLastTwoCollections() throws Exception { public void testReadMetricsReadsOnlyLastCollection() throws Exception { // configure metrics to keep the result only of the last collection cycle config.getMetricsConfig() - .setRetentionSeconds(1) - .setCollectionIntervalSeconds(5); + .setCollectionFrequencySeconds(5) + .getManagementCenterConfig() + .setRetentionSeconds(1); MetricsService metricsService = new MetricsService(nodeEngineMock, () -> metricsRegistry); metricsService.init(nodeEngineMock, new Properties()); @@ -222,9 +223,12 @@ public void testNoCollectionIfMetricsDisabled() { @Test public void testNoCollectionIfMetricsEnabledAndMcJmxDisabled() { config.getMetricsConfig() - .setEnabled(true) - .setMcEnabled(false) - .setJmxEnabled(false); + .setEnabled(true); + config.getMetricsConfig().getManagementCenterConfig() + .setEnabled(false); + config.getMetricsConfig().getJmxConfig() + .setEnabled(false); + ExecutionService executionServiceMock = mock(ExecutionService.class); when(nodeEngineMock.getExecutionService()).thenReturn(executionServiceMock); @@ -237,9 +241,11 @@ public void testNoCollectionIfMetricsEnabledAndMcJmxDisabled() { @Test public void testMetricsCollectedIfMetricsEnabledAndMcJmxDisabledButCustomPublisherRegistered() { config.getMetricsConfig() - .setEnabled(true) - .setMcEnabled(false) - .setJmxEnabled(false); + .setEnabled(true); + config.getMetricsConfig().getManagementCenterConfig() + .setEnabled(false); + config.getMetricsConfig().getJmxConfig() + .setEnabled(false); MetricsPublisher publisherMock = mock(MetricsPublisher.class); MetricsService metricsService = new MetricsService(nodeEngineMock, () -> metricsRegistry); @@ -301,8 +307,9 @@ public void testCustomPublisherIsNotRegisteredIfMetricsDisabled() { public void testExclusion() throws Exception { // configure metrics to keep the result only of the last collection cycle config.getMetricsConfig() - .setRetentionSeconds(1) - .setCollectionIntervalSeconds(5); + .setCollectionFrequencySeconds(5) + .getManagementCenterConfig() + .setRetentionSeconds(1); ExclusionProbeSource metricsSource = new ExclusionProbeSource(); metricsRegistry.registerStaticMetrics(metricsSource, "testExclusion"); @@ -334,7 +341,6 @@ private void readMetrics(MetricsService metricsService, long sequence, MetricCon Iterator metricIterator = decompressingIterator(entry.getValue()); metricIterator.forEachRemaining(metric -> metric.provide(metricConsumer)); }); - } private static class TestProbeSource { diff --git a/hazelcast/src/test/java/com/hazelcast/internal/metrics/impl/ReadMetricsOperationTest.java b/hazelcast/src/test/java/com/hazelcast/internal/metrics/impl/ReadMetricsOperationTest.java index c2f17df799c23..7a06dc03e78ca 100644 --- a/hazelcast/src/test/java/com/hazelcast/internal/metrics/impl/ReadMetricsOperationTest.java +++ b/hazelcast/src/test/java/com/hazelcast/internal/metrics/impl/ReadMetricsOperationTest.java @@ -52,7 +52,7 @@ public void testMetricsPresent_map() { Config config = new Config(); config.getMetricsConfig() .setEnabled(true) - .setMetricsForDataStructuresEnabled(true); + .setDataStructureMetricsEnabled(true); HazelcastInstance hzInstance = createHazelcastInstance(config); IMap map = hzInstance.getMap("map"); diff --git a/hazelcast/src/test/java/com/hazelcast/internal/metrics/managementcenter/ReadMetricsTest.java b/hazelcast/src/test/java/com/hazelcast/internal/metrics/managementcenter/ReadMetricsTest.java index 0549b975912f8..153f9d89177e4 100644 --- a/hazelcast/src/test/java/com/hazelcast/internal/metrics/managementcenter/ReadMetricsTest.java +++ b/hazelcast/src/test/java/com/hazelcast/internal/metrics/managementcenter/ReadMetricsTest.java @@ -65,7 +65,7 @@ public void when_readMetricsAsync() { Config conf = getConfig(); conf.getMetricsConfig() .setEnabled(true) - .setCollectionIntervalSeconds(1); + .setCollectionFrequencySeconds(1); HazelcastInstance instance = hazelcastFactory.newHazelcastInstance(conf); HazelcastClientInstanceImpl client = getHazelcastClientInstanceImpl(hazelcastFactory.newHazelcastClient()); diff --git a/hazelcast/src/test/java/com/hazelcast/spi/properties/HazelcastPropertiesTest.java b/hazelcast/src/test/java/com/hazelcast/spi/properties/HazelcastPropertiesTest.java index b02693540d075..a46585f1e22f0 100644 --- a/hazelcast/src/test/java/com/hazelcast/spi/properties/HazelcastPropertiesTest.java +++ b/hazelcast/src/test/java/com/hazelcast/spi/properties/HazelcastPropertiesTest.java @@ -264,16 +264,16 @@ public void getTimeUnit_noTimeUnitProperty() { @Test public void getEnum() { - config.getMetricsConfig().setMinimumLevel(ProbeLevel.DEBUG); + config.getMetricsConfig().setLevel(ProbeLevel.DEBUG); - ProbeLevel level = config.getMetricsConfig().getMinimumLevel(); + ProbeLevel level = config.getMetricsConfig().getLevel(); assertEquals(ProbeLevel.DEBUG, level); } @Test public void getEnum_default() { - ProbeLevel level = config.getMetricsConfig().getMinimumLevel(); + ProbeLevel level = config.getMetricsConfig().getLevel(); assertEquals(ProbeLevel.INFO, level); } diff --git a/hazelcast/src/test/resources/hazelcast-fullconfig-without-network.xml b/hazelcast/src/test/resources/hazelcast-fullconfig-without-network.xml index 415306e731140..b52d8db6e3633 100644 --- a/hazelcast/src/test/resources/hazelcast-fullconfig-without-network.xml +++ b/hazelcast/src/test/resources/hazelcast-fullconfig-without-network.xml @@ -844,4 +844,14 @@ + + + + 42 + + + 24 + true + DEBUG + diff --git a/hazelcast/src/test/resources/hazelcast-fullconfig-without-network.yaml b/hazelcast/src/test/resources/hazelcast-fullconfig-without-network.yaml index 91ec1f20837c2..b2fc32a0d8ba2 100644 --- a/hazelcast/src/test/resources/hazelcast-fullconfig-without-network.yaml +++ b/hazelcast/src/test/resources/hazelcast-fullconfig-without-network.yaml @@ -818,3 +818,14 @@ hazelcast: lock-acquire-limit: 1 lock2: lock-acquire-limit: 2 + + metrics: + enabled: false + management-center: + enabled: false + retention-seconds: 42 + jmx: + enabled: false + collection-frequency-seconds: 24 + data-structure-metrics-enabled: true + level: DEBUG