[ https://issues.apache.org/jira/browse/STORM-1007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14735689#comment-14735689 ]
ASF GitHub Bot commented on STORM-1007: --------------------------------------- Github user HeartSaVioR commented on a diff in the pull request: https://github.com/apache/storm/pull/716#discussion_r38985117 --- Diff: storm-core/src/jvm/backtype/storm/utils/RateTracker.java --- @@ -0,0 +1,119 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * 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 backtype.storm.utils; + +import java.util.*; + +/** + * This class is a utility to track the rate. + */ +public class RateTracker{ + /* number of slides to keep in the history. */ + public final int _numOfSlides; // number of slides to keep in the history + + public final int _slideSizeInMils; + private final long[] _histograms;// an array storing the number of element for each time slide. + + private int _currentValidSlideNum; + + private static Timer _timer = new Timer(); + + /** + * @param validTimeWindowInMils events that happened before validTimeWindowInMils are not considered + * when reporting the rate. + * @param numOfSlides the number of time sildes to divide validTimeWindows. The more slides, + * the smother the reported results will be. + */ + public RateTracker(int validTimeWindowInMils, int numOfSlides) { + this(validTimeWindowInMils, numOfSlides, false); + } + + /** + * Constructor + * @param validTimeWindowInMils events that happened before validTimeWindow are not considered + * when reporting the rate. + * @param numOfSlides the number of time sildes to divide validTimeWindows. The more slides, + * the smother the reported results will be. + * @param simulate set true if it use simulated time rather than system time for testing purpose. + */ + public RateTracker(int validTimeWindowInMils, int numOfSlides, boolean simulate ){ + _numOfSlides = Math.max(numOfSlides, 1); + _slideSizeInMils = validTimeWindowInMils / _numOfSlides; + if (_slideSizeInMils < 1 ) { + throw new IllegalArgumentException("Illeggal argument for RateTracker"); + } + assert(_slideSizeInMils > 1); + _histograms = new long[_numOfSlides]; + Arrays.fill(_histograms,0L); + if(!simulate) { + _timer.scheduleAtFixedRate(new Fresher(), _slideSizeInMils, _slideSizeInMils); --- End diff -- @wangli1426 My bad, turns out I didn't understand Timer properly. Please ignore my last comment. > Add more metrics to DisruptorQueue > ---------------------------------- > > Key: STORM-1007 > URL: https://issues.apache.org/jira/browse/STORM-1007 > Project: Apache Storm > Issue Type: New Feature > Reporter: Li Wang > Assignee: Li Wang > Original Estimate: 672h > Remaining Estimate: 672h > > The metrics of the queues for each component are very helpful to reason about > the performance issues of a topology. > For instance, for the applications with strong time constraint (e.g., threat > detection), if the elements in the input queue of a bolt have a long sojourn > time, it indicates that the user should increase the parallelism of that bolt > to reduce the processing delay. > However, the metrics on the DisruptorQueue currently available are limited. > More useful metrics, such as average sojourn time and average throughput are > expected. -- This message was sent by Atlassian JIRA (v6.3.4#6332)