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 cc73afd2747358adf3266f5937329d507436b5d3 Author: chenboat <[email protected]> AuthorDate: Mon Aug 12 22:47:54 2019 -0700 Use the system property value as the sliding window length. #382 --- .../monitoring/mbeans/ClusterEventMonitor.java | 4 +--- .../monitoring/mbeans/HelixCallbackMonitor.java | 4 +--- .../apache/helix/monitoring/mbeans/JobMonitor.java | 19 +++++++---------- .../monitoring/mbeans/MessageLatencyMonitor.java | 4 +--- .../mbeans/RoutingTableProviderMonitor.java | 9 +++----- .../mbeans/StateTransitionStatMonitor.java | 14 +++++-------- .../monitoring/mbeans/ZkClientPathMonitor.java | 24 ++++++++-------------- .../mbeans/dynamicMBeans/DynamicMBeanProvider.java | 10 +++++++++ 8 files changed, 37 insertions(+), 51 deletions(-) diff --git a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterEventMonitor.java b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterEventMonitor.java index 06c29a8..9691597 100644 --- a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterEventMonitor.java +++ b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterEventMonitor.java @@ -58,9 +58,7 @@ public class ClusterEventMonitor extends DynamicMBeanProvider { _clusterStatusMonitor = clusterStatusMonitor; _duration = new HistogramDynamicMetric("DurationGauge", new Histogram( - new SlidingTimeWindowArrayReservoir(HelixUtil - .getSystemPropertyAsLong(RESET_INTERVAL_SYSTEM_PROPERTY_KEY, DEFAULT_RESET_INTERVAL_MS), - TimeUnit.MILLISECONDS))); + new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS))); _count = new SimpleDynamicMetric("EventCounter", 0l); _maxDuration = new SimpleDynamicMetric("MaxSingleDurationGauge", 0l); _totalDuration = new SimpleDynamicMetric("TotalDurationCounter", 0l); diff --git a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/HelixCallbackMonitor.java b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/HelixCallbackMonitor.java index f469609..9053daf 100644 --- a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/HelixCallbackMonitor.java +++ b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/HelixCallbackMonitor.java @@ -65,9 +65,7 @@ public class HelixCallbackMonitor extends DynamicMBeanProvider { changeType.name()); _latencyGauge = new HistogramDynamicMetric("LatencyGauge", new Histogram( - new SlidingTimeWindowArrayReservoir(HelixUtil - .getSystemPropertyAsLong(RESET_INTERVAL_SYSTEM_PROPERTY_KEY, DEFAULT_RESET_INTERVAL_MS), - TimeUnit.MILLISECONDS))); + new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS))); _totalLatencyCounter = new SimpleDynamicMetric("LatencyCounter", 0l); _unbatchedCounter = new SimpleDynamicMetric("UnbatchedCounter", 0l); _counter = new SimpleDynamicMetric("Counter", 0l); diff --git a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/JobMonitor.java b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/JobMonitor.java index 68ebcd5..75fd77b 100644 --- a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/JobMonitor.java +++ b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/JobMonitor.java @@ -86,21 +86,16 @@ public class JobMonitor extends DynamicMBeanProvider { // Instantiate histogram dynamic metrics _jobLatencyGauge = new HistogramDynamicMetric("JobLatencyGauge", new Histogram( - new SlidingTimeWindowArrayReservoir(HelixUtil - .getSystemPropertyAsLong(RESET_INTERVAL_SYSTEM_PROPERTY_KEY, DEFAULT_RESET_INTERVAL_MS), - TimeUnit.MILLISECONDS))); + new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS))); _submissionToProcessDelayGauge = new HistogramDynamicMetric("SubmissionToProcessDelayGauge", - new Histogram(new SlidingTimeWindowArrayReservoir(HelixUtil - .getSystemPropertyAsLong(RESET_INTERVAL_SYSTEM_PROPERTY_KEY, DEFAULT_RESET_INTERVAL_MS), - TimeUnit.MILLISECONDS))); + new Histogram( + new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS))); _submissionToScheduleDelayGauge = new HistogramDynamicMetric("SubmissionToScheduleDelayGauge", - new Histogram(new SlidingTimeWindowArrayReservoir(HelixUtil - .getSystemPropertyAsLong(RESET_INTERVAL_SYSTEM_PROPERTY_KEY, DEFAULT_RESET_INTERVAL_MS), - TimeUnit.MILLISECONDS))); + new Histogram( + new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS))); _controllerInducedDelayGauge = new HistogramDynamicMetric("ControllerInducedDelayGauge", - new Histogram(new SlidingTimeWindowArrayReservoir(HelixUtil - .getSystemPropertyAsLong(RESET_INTERVAL_SYSTEM_PROPERTY_KEY, DEFAULT_RESET_INTERVAL_MS), - TimeUnit.MILLISECONDS))); + new Histogram( + new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS))); } @Override diff --git a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/MessageLatencyMonitor.java b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/MessageLatencyMonitor.java index 81ca719..e056e1d 100644 --- a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/MessageLatencyMonitor.java +++ b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/MessageLatencyMonitor.java @@ -50,9 +50,7 @@ public class MessageLatencyMonitor extends DynamicMBeanProvider { "MessageLatency"); _messageLatencyGauge = new HistogramDynamicMetric("MessagelatencyGauge", new Histogram( - new SlidingTimeWindowArrayReservoir(HelixUtil - .getSystemPropertyAsLong(RESET_INTERVAL_SYSTEM_PROPERTY_KEY, DEFAULT_RESET_INTERVAL_MS), - TimeUnit.MILLISECONDS))); + new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS))); _totalMessageLatency = new SimpleDynamicMetric("TotalMessageLatency", 0l); _totalMessageCount = new SimpleDynamicMetric("TotalMessageCount", 0l); } diff --git a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/RoutingTableProviderMonitor.java b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/RoutingTableProviderMonitor.java index ef4c90e..4875099 100644 --- a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/RoutingTableProviderMonitor.java +++ b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/RoutingTableProviderMonitor.java @@ -61,17 +61,14 @@ public class RoutingTableProviderMonitor extends DynamicMBeanProvider { _propertyType.name()); _dataRefreshLatencyGauge = new HistogramDynamicMetric("DataRefreshLatencyGauge", new Histogram( - new SlidingTimeWindowArrayReservoir(HelixUtil - .getSystemPropertyAsLong(RESET_INTERVAL_SYSTEM_PROPERTY_KEY, DEFAULT_RESET_INTERVAL_MS), - TimeUnit.MILLISECONDS))); + new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS))); _callbackCounter = new SimpleDynamicMetric("CallbackCounter", 0l); _eventQueueSizeGauge = new SimpleDynamicMetric("EventQueueSizeGauge", 0l); _dataRefreshCounter = new SimpleDynamicMetric("DataRefreshCounter", 0l); if (propertyType.equals(PropertyType.CURRENTSTATES)) { _statePropLatencyGauge = new HistogramDynamicMetric("StatePropagationLatencyGauge", - new Histogram(new SlidingTimeWindowArrayReservoir(HelixUtil - .getSystemPropertyAsLong(RESET_INTERVAL_SYSTEM_PROPERTY_KEY, - DEFAULT_RESET_INTERVAL_MS), TimeUnit.MILLISECONDS))); + new Histogram( + new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS))); } } diff --git a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/StateTransitionStatMonitor.java b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/StateTransitionStatMonitor.java index 2473378..bf40b39 100644 --- a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/StateTransitionStatMonitor.java +++ b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/StateTransitionStatMonitor.java @@ -65,17 +65,13 @@ public class StateTransitionStatMonitor extends DynamicMBeanProvider { _totalSuccessTransitionCounter = new SimpleDynamicMetric<>("TotalSuccessTransitionCounter", 0L); _transitionLatencyGauge = new HistogramDynamicMetric("TransitionLatencyGauge", new Histogram( - new SlidingTimeWindowArrayReservoir(HelixUtil - .getSystemPropertyAsLong(RESET_INTERVAL_SYSTEM_PROPERTY_KEY, DEFAULT_RESET_INTERVAL_MS), - TimeUnit.MILLISECONDS))); + new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS))); _transitionExecutionLatencyGauge = new HistogramDynamicMetric("TransitionExecutionLatencyGauge", - new Histogram(new SlidingTimeWindowArrayReservoir(HelixUtil - .getSystemPropertyAsLong(RESET_INTERVAL_SYSTEM_PROPERTY_KEY, DEFAULT_RESET_INTERVAL_MS), - TimeUnit.MILLISECONDS))); + new Histogram( + new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS))); _transitionMessageLatency = new HistogramDynamicMetric("TransitionMessageLatencyGauge", - new Histogram(new SlidingTimeWindowArrayReservoir(HelixUtil - .getSystemPropertyAsLong(RESET_INTERVAL_SYSTEM_PROPERTY_KEY, DEFAULT_RESET_INTERVAL_MS), - TimeUnit.MILLISECONDS))); + new Histogram( + new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS))); } @Override diff --git a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ZkClientPathMonitor.java b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ZkClientPathMonitor.java index 869aa88..1b67c29 100644 --- a/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ZkClientPathMonitor.java +++ b/helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ZkClientPathMonitor.java @@ -129,27 +129,21 @@ public class ZkClientPathMonitor extends DynamicMBeanProvider { _readCounter = new SimpleDynamicMetric(PredefinedMetricDomains.ReadCounter.name(), 0l); _readLatencyGauge = new HistogramDynamicMetric(PredefinedMetricDomains.ReadLatencyGauge.name(), - new Histogram(new SlidingTimeWindowArrayReservoir(HelixUtil - .getSystemPropertyAsLong(RESET_INTERVAL_SYSTEM_PROPERTY_KEY, DEFAULT_RESET_INTERVAL_MS), - TimeUnit.MILLISECONDS))); + new Histogram( + new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS))); _writeLatencyGauge = new HistogramDynamicMetric(PredefinedMetricDomains.WriteLatencyGauge.name(), new Histogram( - new SlidingTimeWindowArrayReservoir(HelixUtil - .getSystemPropertyAsLong(RESET_INTERVAL_SYSTEM_PROPERTY_KEY, - DEFAULT_RESET_INTERVAL_MS), TimeUnit.MILLISECONDS))); + new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS))); _readBytesGauge = new HistogramDynamicMetric(PredefinedMetricDomains.ReadBytesGauge.name(), - new Histogram(new SlidingTimeWindowArrayReservoir(HelixUtil - .getSystemPropertyAsLong(RESET_INTERVAL_SYSTEM_PROPERTY_KEY, DEFAULT_RESET_INTERVAL_MS), - TimeUnit.MILLISECONDS))); + new Histogram( + new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS))); _writeBytesGauge = new HistogramDynamicMetric(PredefinedMetricDomains.WriteBytesGauge.name(), - new Histogram(new SlidingTimeWindowArrayReservoir(HelixUtil - .getSystemPropertyAsLong(RESET_INTERVAL_SYSTEM_PROPERTY_KEY, DEFAULT_RESET_INTERVAL_MS), - TimeUnit.MILLISECONDS))); + new Histogram( + new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), TimeUnit.MILLISECONDS))); _dataPropagationLatencyGauge = new HistogramDynamicMetric(PredefinedMetricDomains.DataPropagationLatencyGuage.name(), - new Histogram(new SlidingTimeWindowArrayReservoir(HelixUtil - .getSystemPropertyAsLong(RESET_INTERVAL_SYSTEM_PROPERTY_KEY, - DEFAULT_RESET_INTERVAL_MS), TimeUnit.MILLISECONDS))); + new Histogram(new SlidingTimeWindowArrayReservoir(getResetIntervalInMs(), + TimeUnit.MILLISECONDS))); } public ZkClientPathMonitor register() throws JMException { 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 d371571..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 @@ -42,6 +42,7 @@ import java.util.Map; import org.apache.helix.monitoring.SensorNameProvider; import org.apache.helix.monitoring.mbeans.MBeanRegistrar; +import org.apache.helix.util.HelixUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -224,4 +225,13 @@ public abstract class DynamicMBeanProvider implements DynamicMBean, SensorNamePr protected void incrementSimpleDynamicMetric(SimpleDynamicMetric<Long> metric, long value) { metric.updateValue(metric.getValue() + value); } + + /** + * 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. + */ + protected Long getResetIntervalInMs() { + return HelixUtil + .getSystemPropertyAsLong(RESET_INTERVAL_SYSTEM_PROPERTY_KEY, DEFAULT_RESET_INTERVAL_MS); + } }
