This is an automated email from the ASF dual-hosted git repository. hulee pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/helix.git
commit b6aee9f7520b2b2741e8e175154f92fc485dc903 Author: chenboat <[email protected]> AuthorDate: Sat Aug 17 19:01:40 2019 -0700 Fix a typo. #382 --- .../mbeans/dynamicMBeans/DynamicMBeanProvider.java | 2 +- .../monitoring/mbeans/TestZkClientMonitor.java | 30 +++++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/dynamicMBeans/DynamicMBeanProvider.java b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/dynamicMBeans/DynamicMBeanProvider.java index 64e5c69..e45820e 100644 --- a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/dynamicMBeans/DynamicMBeanProvider.java +++ b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/dynamicMBeans/DynamicMBeanProvider.java @@ -230,7 +230,7 @@ public abstract class DynamicMBeanProvider implements DynamicMBean, SensorNamePr * Return the interval length for the underlying reservoir used by the MBean metric configured * in the system env variables. If not found, use default value. */ - public Long getResetIntervalInMs() { + protected Long getResetIntervalInMs() { return HelixUtil .getSystemPropertyAsLong(RESET_INTERVAL_SYSTEM_PROPERTY_KEY, DEFAULT_RESET_INTERVAL_MS); } diff --git a/helix-core/src/test/java/org/apache/helix/monitoring/mbeans/TestZkClientMonitor.java b/helix-core/src/test/java/org/apache/helix/monitoring/mbeans/TestZkClientMonitor.java index 5c92b0d..c427d44 100644 --- a/helix-core/src/test/java/org/apache/helix/monitoring/mbeans/TestZkClientMonitor.java +++ b/helix-core/src/test/java/org/apache/helix/monitoring/mbeans/TestZkClientMonitor.java @@ -153,11 +153,29 @@ public class TestZkClientMonitor { } @Test - public void testCustomizedResetInterval() { - // Use a customized reservoir length of 1 mins. - System.setProperty("reservoir.length.ms", "60000"); - ZkClientMonitor monitor = - new ZkClientMonitor("TEST_TAG", "TEST_KEY", "TEST_INSTANCE", false, null); - Assert.assertEquals(monitor.getResetIntervalInMs().longValue(), 60000L); + public void testCustomizedResetInterval() throws JMException, InterruptedException { + // Use a customized reservoir length of 1 ms. + System.setProperty("reservoir.length.ms", "1"); + final String TEST_TAG = "test_tag_3"; + final String TEST_KEY = "test_key_3"; + final String TEST_INSTANCE = "test_instance_3"; + + ZkClientMonitor monitor = new ZkClientMonitor(TEST_TAG, TEST_KEY, TEST_INSTANCE, false, null); + monitor.register(); + + ObjectName rootName = buildPathMonitorObjectName(TEST_TAG, TEST_KEY, TEST_INSTANCE, + ZkClientPathMonitor.PredefinedPath.Root.name()); + monitor + .recordDataPropagationLatency("TEST/INSTANCES/node_1/CURRENTSTATES/session_1/Resource", 5); + Assert + .assertEquals((long) _beanServer.getAttribute(rootName, "DataPropagationLatencyGuage.Max"), + 5); + // The reservoir length is 10 ms, so the prev max of 5 is not valid anymore. + Thread.sleep(10); + monitor + .recordDataPropagationLatency("TEST/INSTANCES/node_1/CURRENTSTATES/session_1/Resource", 4); + Assert + .assertEquals((long) _beanServer.getAttribute(rootName, "DataPropagationLatencyGuage.Max"), + 4); } }
