[ 
https://issues.apache.org/jira/browse/GEODE-1494?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dan Smith resolved GEODE-1494.
------------------------------
       Resolution: Fixed
    Fix Version/s: 1.0.0-incubating.M3

> Allow users to provide callbacks to sample statistics
> -----------------------------------------------------
>
>                 Key: GEODE-1494
>                 URL: https://issues.apache.org/jira/browse/GEODE-1494
>             Project: Geode
>          Issue Type: Improvement
>            Reporter: Dan Smith
>            Assignee: Dan Smith
>             Fix For: 1.0.0-incubating.M3
>
>
> The Statistics interface has methods to increment, set, and get the value of 
> various statistics. The statistics are sampled at the sample-rate by the stat 
> sampling thread.
> We should add a way to provide a callback that computes the value of the 
> statistic. The callback can be called by the stat sampling thread to compute 
> the value at the sample time.
> This is useful because some statistics are hard to update correctly using 
> using increment operations. For example, tracking the total number of entries 
> in a parallel async event queue is tricky, because buckets may move on and 
> off of a node while concurrent operations are also adding entries. But 
> measuring the current size of the queue is easy by just calling size on the 
> underlying regions.
> Here are the proposed new methods on the statistics interface:
> {code}
>    /**
>    * Provide a callback to compute the value of this statistic
>    * every sample interval and use that as the value of the stat.
>    * <p>
>    * The callback should return quickly because it is invoked on a shared 
> thread.
>    * It should not do any expensive computations, network calls, or access 
> any resources
>    * under locks that may be locked by long running processes.
>    * <p>
>    * This callback will only be invoked if the distributed system property
>    * statistic-sampling-enabled is set to true, and it will be invoked at 
> intervals
>    * determined by the statistic-sampling-rate.
>    * <p>
>    * Get methods are not guaranteed to recompute a new value, they may return
>    * the last sampled value
>    * @param id a statistic id obtained with {@link #nameToId}
>    * or {@link StatisticsType#nameToId}.
>    * @param supplier a callback that will return the value of the stat. This
>    * replaces any previously registered supplier. If the passed in suppplier 
> is null, it
>    * will remove any existing supplier
>    * @return the previously registered supplier, or null if there was no 
> previously registered supplier
>    * @throws ArrayIndexOutOfBoundsException If the id is invalid.
>    * @throws IllegalArgumentException if the type of this
>    * stat is not int
>    */
>   public IntSupplier setIntSupplier(int id, IntSupplier supplier);
>   public LongSupplier setLongSupplier(int id, LongSupplier supplier);
>   public DoubleSupplier setDoubleSupplier(int id, DoubleSupplier supplier);
>   public IntSupplier setIntSupplier(String name, IntSupplier supplier);
>   public LongSupplier setLongSupplier(String name, LongSupplier supplier);
>   public DoubleSupplier setDoubleSupplier(String name, DoubleSupplier 
> supplier);
>   public IntSupplier setIntSupplier(StatisticDescriptor descriptor, 
> IntSupplier supplier);
>   public LongSupplier setLongSupplier(StatisticDescriptor descriptor, 
> LongSupplier supplier);
>   public DoubleSupplier setDoubleSupplier(StatisticDescriptor descriptor, 
> DoubleSupplier supplier);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to