It is not clear to me how the new apis behave. Is the supplier for a particular id/name/descriptor remembered by the Statistics instance? So if you wanted to add an intSupplier for a int statistic you would do it once by calling sampleInt?
The name of these methods give the impression that calling it will take a sample. Perhaps it should be setSampler? Do you need the type (int, long, etc) in the name or is overloading ok? Does the supplier need to match the type of the stat otherwise you get IllegalArgumentException? Can you only have one sampler registered for a particular stat? If so should these methods return the old one? How does a sampler interact with the existing methods on the same stat? Do the "get" methods implicitly call the sampler to compute the result they return? If so then the "set" and "inc" methods become noops. On Wed, Jun 1, 2016 at 4:33 PM, Dan Smith <[email protected]> wrote: > I'm suggesting using standard Java 8 function interfaces for the > callbacks - IntSupplier, DoubleSupplier, etc. I can change the name of > the argument to supplier. > > -Dan > > On Wed, Jun 1, 2016 at 4:18 PM, Xiaojian Zhou <[email protected]> wrote: > > what's the difference btw supplier and sampler? > > > > On Wed, Jun 1, 2016 at 4:12 PM, Dan Smith <[email protected]> wrote: > > > >> Hi, > >> > >> I'd like to add some new methods to the Statistics interface to compute > >> statistics using callbacks. My original motivation for this is to make > it > >> easy to record statistics that come from lucene for our lucene > integration, > >> but I think this could simplify recording statistics in a lot of places. > >> > >> The basic idea is that the user provides a callback that returns the > value > >> of the statistic. Geode will call the callback every sample interval to > >> recompute the value. > >> > >> See the JIRA for more details: > >> https://issues.apache.org/jira/browse/GEODE-1494 > >> > >> Thoughts? > >> > >> -Dan > >> >
