[ https://issues.apache.org/jira/browse/GEODE-1494?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15327831#comment-15327831 ]
ASF subversion and git services commented on GEODE-1494: -------------------------------------------------------- Commit e9ffdce4fdf4f5c3b9f4ae45e19168e3de55ebe9 in incubator-geode's branch refs/heads/develop from [~upthewaterspout] [ https://git-wip-us.apache.org/repos/asf?p=incubator-geode.git;h=e9ffdce ] GEODE-1494: Changing stats list to be a CopyOnWriteArrayList The statsList used to track Statistics in InternalDistributedSystem was managed under a lock. That was problematic, because code that iterates on the list needs to hold the lock. If the code invoking callbacks for GEODE-1494 was slow, that means the lock would block other stats operations. Changing this list to a copy on write array list to holding a lock for a long period of time. > 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 > > 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)