Interface Statistics


  • public interface Statistics
    Instances of this interface maintain the values of various application-defined statistics. The statistics themselves are described by an instance of StatisticsType.

    To get an instance of this interface use an instance of StatisticsFactory.

    For improved performance, each statistic may be referred to by its descriptor.

    For optimal performance, each statistic may be referred to by its id in the statistics object. Note that ids can not be mapped back to their name and methods that take ids are unsafe. It is important to call the correct type of method for the given id. For example if your stat is a long then incLong must be called instead of incDouble.

    Note that as of the 5.1 release the incLong, and incDouble methods no longer return the new value of the statistic. They now return void. This incompatible change was made to allow for a more efficient concurrent increment implementation.

    Since:
    GemFire 3.0
    See Also:
    Package introduction
    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method Description
      void close()
      Closes these statistics.
      java.lang.Number get​(java.lang.String name)
      Returns the value of the named statistic.
      java.lang.Number get​(StatisticDescriptor descriptor)
      Returns the value of the identified statistic.
      double getDouble​(int id)
      Returns the value of the identified statistic of type double.
      double getDouble​(java.lang.String name)
      Returns the value of the statistic of type double at the given name.
      double getDouble​(StatisticDescriptor descriptor)
      Returns the value of the described statistic of type double.
      int getInt​(int id)
      Deprecated.
      as of Geode 1.10, use getLong(int) instead
      int getInt​(java.lang.String name)
      Deprecated.
      as of Geode 1.10, use getLong(String) instead
      int getInt​(StatisticDescriptor descriptor)
      Deprecated.
      as of Geode 1.10, use getLong(StatisticDescriptor) instead
      long getLong​(int id)
      Returns the value of the identified statistic of type long.
      long getLong​(java.lang.String name)
      Returns the value of the statistic of type long at the given name.
      long getLong​(StatisticDescriptor descriptor)
      Returns the value of the described statistic of type long.
      long getNumericId()
      Gets the number associated with this instance that helps identify it.
      long getRawBits​(java.lang.String name)
      Returns the bits that represent the raw value of the named statistic.
      long getRawBits​(StatisticDescriptor descriptor)
      Returns the bits that represent the raw value of the described statistic.
      java.lang.String getTextId()
      Gets the text associated with this instance that helps identify it.
      StatisticsType getType()
      Gets the StatisticsType of this instance.
      long getUniqueId()
      Gets a value that uniquely identifies this statistics.
      void incDouble​(int id, double delta)
      Increments the value of the identified statistic of type double by the given amount.
      void incDouble​(java.lang.String name, double delta)
      Increments the value of the statistic of type double with the given name by a given amount.
      void incDouble​(StatisticDescriptor descriptor, double delta)
      Increments the value of the described statistic of type double by the given amount.
      void incInt​(int id, int delta)
      Deprecated.
      as of Geode 1.10, use incLong(int, long) instead
      void incInt​(java.lang.String name, int delta)
      Deprecated.
      as of Geode 1.10, use incLong(String, long) instead
      void incInt​(StatisticDescriptor descriptor, int delta)
      Deprecated.
      as of Geode 1.10, use incLong(StatisticDescriptor, long) instead
      void incLong​(int id, long delta)
      Increments the value of the identified statistic of type long by the given amount.
      void incLong​(java.lang.String name, long delta)
      Increments the value of the statistic of type long with the given name by a given amount.
      void incLong​(StatisticDescriptor descriptor, long delta)
      Increments the value of the described statistic of type long by the given amount.
      boolean isAtomic()
      Returns true if modifications are atomic.
      boolean isClosed()
      Returns true if the instance has been closed.
      StatisticDescriptor nameToDescriptor​(java.lang.String name)
      Returns the descriptor of the statistic with the given name in this statistics instance.
      int nameToId​(java.lang.String name)
      Returns the id of the statistic with the given name in this statistics instance.
      void setDouble​(int id, double value)
      Sets the value of a statistic with the given id whose type is double.
      void setDouble​(java.lang.String name, double value)
      Sets the value of a named statistic of type double.
      void setDouble​(StatisticDescriptor descriptor, double value)
      Sets the value of a described statistic of type double
      java.util.function.DoubleSupplier setDoubleSupplier​(int id, java.util.function.DoubleSupplier supplier)
      Provide a callback to compute the value of this statistic every sample interval and use that as the value of the stat.
      java.util.function.DoubleSupplier setDoubleSupplier​(java.lang.String name, java.util.function.DoubleSupplier supplier)
      Provide a callback to compute the value of this statistic every sample interval and use that as the value of the stat.
      java.util.function.DoubleSupplier setDoubleSupplier​(StatisticDescriptor descriptor, java.util.function.DoubleSupplier supplier)
      Provide a callback to compute the value of this statistic every sample interval and use that as the value of the stat.
      void setInt​(int id, int value)
      Deprecated.
      as of Geode 1.10, use setLong(int, long) instead
      void setInt​(java.lang.String name, int value)
      Deprecated.
      as of Geode 1.10, use setLong(String, long) instead
      void setInt​(StatisticDescriptor descriptor, int value)
      Deprecated.
      as of Geode 1.10, use setLong(StatisticDescriptor, long) instead
      java.util.function.IntSupplier setIntSupplier​(int id, java.util.function.IntSupplier supplier)
      Deprecated.
      as of Geode 1.10, use setLongSupplier(int, LongSupplier) instead
      java.util.function.IntSupplier setIntSupplier​(java.lang.String name, java.util.function.IntSupplier supplier)
      Deprecated.
      as of Geode 1.10, use setLongSupplier(String, LongSupplier) instead
      java.util.function.IntSupplier setIntSupplier​(StatisticDescriptor descriptor, java.util.function.IntSupplier supplier)
      Deprecated.
      void setLong​(int id, long value)
      Sets the value of a statistic with the given id whose type is long.
      void setLong​(java.lang.String name, long value)
      Sets the value of a named statistic of type long.
      void setLong​(StatisticDescriptor descriptor, long value)
      Sets the value of a described statistic of type long
      java.util.function.LongSupplier setLongSupplier​(int id, java.util.function.LongSupplier supplier)
      Provide a callback to compute the value of this statistic every sample interval and use that as the value of the stat.
      java.util.function.LongSupplier setLongSupplier​(java.lang.String name, java.util.function.LongSupplier supplier)
      Provide a callback to compute the value of this statistic every sample interval and use that as the value of the stat.
      java.util.function.LongSupplier setLongSupplier​(StatisticDescriptor descriptor, java.util.function.LongSupplier supplier)
      Provide a callback to compute the value of this statistic every sample interval and use that as the value of the stat.
    • Method Detail

      • close

        void close()
        Closes these statistics. After statistics have been closed, they are no longer archived. A value access on a closed statistics always results in zero. A value modification on a closed statistics is ignored.
      • nameToId

        int nameToId​(java.lang.String name)
        Returns the id of the statistic with the given name in this statistics instance.
        Parameters:
        name - the name of the statistic
        Returns:
        the id of the statistic
        Throws:
        java.lang.IllegalArgumentException - No statistic named name exists in this statistics instance.
        See Also:
        StatisticsType.nameToId(java.lang.String)
      • nameToDescriptor

        StatisticDescriptor nameToDescriptor​(java.lang.String name)
        Returns the descriptor of the statistic with the given name in this statistics instance.
        Parameters:
        name - the name of the statistic
        Returns:
        the descriptor of the statistic
        Throws:
        java.lang.IllegalArgumentException - No statistic named name exists in this statistics instance.
        See Also:
        StatisticsType.nameToDescriptor(java.lang.String)
      • getUniqueId

        long getUniqueId()
        Gets a value that uniquely identifies this statistics.
        Returns:
        a value that uniquely identifies this statistics
      • getTextId

        java.lang.String getTextId()
        Gets the text associated with this instance that helps identify it.
        Returns:
        the text associated with this instance that helps identify it
      • getNumericId

        long getNumericId()
        Gets the number associated with this instance that helps identify it.
        Returns:
        the number associated with this instance that helps identify it
      • isAtomic

        boolean isAtomic()
        Returns true if modifications are atomic. This means that multiple threads, can safely modify this instance without extra synchronization.

        Returns false if modifications are not atomic. This means that modifications to this instance are cheaper but not thread safe.

        Returns:
        whether modifications are atomic
      • isClosed

        boolean isClosed()
        Returns true if the instance has been closed.
        Returns:
        whether the instance has been closed.
      • setInt

        @Deprecated
        void setInt​(java.lang.String name,
                    int value)
        Deprecated.
        as of Geode 1.10, use setLong(String, long) instead
        Sets the value of a named statistic of type int
        Parameters:
        name - the name of the statistic
        value - the value to set the statistic to
        Throws:
        java.lang.IllegalArgumentException - If no statistic exists named name or if the statistic with name name is not of type int.
      • setLong

        void setLong​(int id,
                     long value)
        Sets the value of a statistic with the given id whose type is long.
        Parameters:
        id - a statistic id obtained with nameToId(java.lang.String) or StatisticsType.nameToId(java.lang.String).
        value - the value to set the statistic to
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - If the id is invalid.
      • setLong

        void setLong​(java.lang.String name,
                     long value)
        Sets the value of a named statistic of type long.
        Parameters:
        name - the name of the statistic
        value - the value to set the statistic to
        Throws:
        java.lang.IllegalArgumentException - If no statistic exists named name or if the statistic with name name is not of type long.
      • setDouble

        void setDouble​(int id,
                       double value)
        Sets the value of a statistic with the given id whose type is double.
        Parameters:
        id - a statistic id obtained with nameToId(java.lang.String) or StatisticsType.nameToId(java.lang.String).
        value - the value to set the statistic to
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - If the id is invalid.
      • setDouble

        void setDouble​(java.lang.String name,
                       double value)
        Sets the value of a named statistic of type double.
        Parameters:
        name - the name of the statistic
        value - the value to set the statistic to
        Throws:
        java.lang.IllegalArgumentException - If no statistic exists named name or if the statistic with name name is not of type double.
      • getInt

        @Deprecated
        int getInt​(java.lang.String name)
        Deprecated.
        as of Geode 1.10, use getLong(String) instead
        Returns the value of the statistic of type int at the given name.
        Parameters:
        name - the name of the statistic
        Returns:
        the value of the statistic
        Throws:
        java.lang.IllegalArgumentException - If no statistic exists with name name or if the statistic named name is not of type int.
      • getLong

        long getLong​(java.lang.String name)
        Returns the value of the statistic of type long at the given name.
        Parameters:
        name - the name of the statistic
        Returns:
        the value of the statistic
        Throws:
        java.lang.IllegalArgumentException - If no statistic exists with name name or if the statistic named name is not of type long.
      • getDouble

        double getDouble​(java.lang.String name)
        Returns the value of the statistic of type double at the given name.
        Parameters:
        name - the name of the statistic
        Returns:
        the value of the statistic
        Throws:
        java.lang.IllegalArgumentException - If no statistic exists with name name or if the statistic named name is not of type double.
      • get

        java.lang.Number get​(java.lang.String name)
        Returns the value of the named statistic.
        Parameters:
        name - the name of the statistic
        Returns:
        the value of the statistic
        Throws:
        java.lang.IllegalArgumentException - If the named statistic does not exist
      • getRawBits

        long getRawBits​(java.lang.String name)
        Returns the bits that represent the raw value of the named statistic.
        Parameters:
        name - the name of the statistic
        Returns:
        the bits that represent the raw value of the named statistic
        Throws:
        java.lang.IllegalArgumentException - If the named statistic does not exist
      • incInt

        @Deprecated
        void incInt​(int id,
                    int delta)
        Deprecated.
        as of Geode 1.10, use incLong(int, long) instead
        Increments the value of the identified statistic of type int by the given amount.
        Parameters:
        id - a statistic id obtained with nameToId(java.lang.String) or StatisticsType.nameToId(java.lang.String).
        delta - the amount by which to increment the statistic value
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - If the id is invalid.
      • incInt

        @Deprecated
        void incInt​(StatisticDescriptor descriptor,
                    int delta)
        Deprecated.
        as of Geode 1.10, use incLong(StatisticDescriptor, long) instead
        Increments the value of the described statistic of type int by the given amount.
        Parameters:
        descriptor - the descriptor for the statistic to increment
        delta - the amount by which to increment the statistic value
        Throws:
        java.lang.IllegalArgumentException - If no statistic exists with the given descriptor or if the described statistic is not of type int.
      • incInt

        @Deprecated
        void incInt​(java.lang.String name,
                    int delta)
        Deprecated.
        as of Geode 1.10, use incLong(String, long) instead
        Increments the value of the statistic of type int with the given name by a given amount.
        Parameters:
        name - the name of the statistic to increment
        delta - the amount by which to increment the statistic value
        Throws:
        java.lang.IllegalArgumentException - If no statistic exists with name name or if the statistic named name is not of type int.
      • incLong

        void incLong​(int id,
                     long delta)
        Increments the value of the identified statistic of type long by the given amount.
        Parameters:
        id - a statistic id obtained with nameToId(java.lang.String) or StatisticsType.nameToId(java.lang.String).
        delta - the amount by which to increment the statistic value
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - If the id is invalid.
      • incLong

        void incLong​(StatisticDescriptor descriptor,
                     long delta)
        Increments the value of the described statistic of type long by the given amount.
        Parameters:
        descriptor - the descriptor for the statistic to increment
        delta - the amount by which to increment the statistic value
        Throws:
        java.lang.IllegalArgumentException - If no statistic exists with the given descriptor or if the described statistic is not of type long.
      • incLong

        void incLong​(java.lang.String name,
                     long delta)
        Increments the value of the statistic of type long with the given name by a given amount.
        Parameters:
        name - the name of the statistic to increment
        delta - the amount by which to increment the statistic value
        Throws:
        java.lang.IllegalArgumentException - If no statistic exists with name name or if the statistic named name is not of type long.
      • incDouble

        void incDouble​(int id,
                       double delta)
        Increments the value of the identified statistic of type double by the given amount.
        Parameters:
        id - a statistic id obtained with nameToId(java.lang.String) or StatisticsType.nameToId(java.lang.String).
        delta - the amount by which to increment the statistic value
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - If the id is invalid.
      • incDouble

        void incDouble​(StatisticDescriptor descriptor,
                       double delta)
        Increments the value of the described statistic of type double by the given amount.
        Parameters:
        descriptor - the descriptor for the statistic to increment
        delta - the amount by which to increment the statistic value
        Throws:
        java.lang.IllegalArgumentException - If no statistic exists with the given descriptor or if the described statistic is not of type double.
      • incDouble

        void incDouble​(java.lang.String name,
                       double delta)
        Increments the value of the statistic of type double with the given name by a given amount.
        Parameters:
        name - the name of the statistic to increment
        delta - the amount by which to increment the statistic value
        Throws:
        java.lang.IllegalArgumentException - If no statistic exists with name name or if the statistic named name is not of type double.
      • setIntSupplier

        @Deprecated
        java.util.function.IntSupplier setIntSupplier​(int id,
                                                      java.util.function.IntSupplier supplier)
        Deprecated.
        as of Geode 1.10, use setLongSupplier(int, LongSupplier) instead
        Provide a callback to compute the value of this statistic every sample interval and use that as the value of the stat.

        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.

        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.

        Get methods are not guaranteed to recompute a new value, they may return the last sampled value

        Parameters:
        id - a statistic id obtained with nameToId(java.lang.String) or StatisticsType.nameToId(java.lang.String).
        supplier - a callback that will return the value of the stat. This replaces any previously registered supplier. If the passed in supplier is null, it will remove any existing supplier
        Returns:
        the previously registered supplier, or null if there was no previously registered supplier
        Throws:
        java.lang.IllegalArgumentException - If the id is invalid.
        Since:
        Geode 1.0
      • setIntSupplier

        @Deprecated
        java.util.function.IntSupplier setIntSupplier​(java.lang.String name,
                                                      java.util.function.IntSupplier supplier)
        Deprecated.
        as of Geode 1.10, use setLongSupplier(String, LongSupplier) instead
        Provide a callback to compute the value of this statistic every sample interval and use that as the value of the stat.

        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.

        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.

        Get methods are not guaranteed to recompute a new value, they may return the last sampled value

        Parameters:
        name - the name of the statistic to update
        supplier - a callback that will return the value of the stat. This replaces any previously registered supplier. If the passed in supplier is null, it will remove any existing supplier
        Returns:
        the previously registered supplier, or null if there was no previously registered supplier
        Throws:
        java.lang.IllegalArgumentException - If no statistic exists with name name or if the statistic named name is not of type int.
        Since:
        Geode 1.0
      • setIntSupplier

        @Deprecated
        java.util.function.IntSupplier setIntSupplier​(StatisticDescriptor descriptor,
                                                      java.util.function.IntSupplier supplier)
        Deprecated.
        Provide a callback to compute the value of this statistic every sample interval and use that as the value of the stat.

        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.

        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.

        Get methods are not guaranteed to recompute a new value, they may return the last sampled value

        Parameters:
        descriptor - the descriptor of the statistic to update
        supplier - a callback that will return the value of the stat. This replaces any previously registered supplier. If the passed in supplier is null, it will remove any existing supplier
        Returns:
        the previously registered supplier, or null if there was no previously registered supplier
        Throws:
        java.lang.IllegalArgumentException - If no statistic exists with the given descriptor or if the described statistic is not of type int.
        Since:
        Geode 1.0
      • setLongSupplier

        java.util.function.LongSupplier setLongSupplier​(int id,
                                                        java.util.function.LongSupplier supplier)
        Provide a callback to compute the value of this statistic every sample interval and use that as the value of the stat.

        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.

        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.

        Get methods are not guaranteed to recompute a new value, they may return the last sampled value

        Parameters:
        id - a statistic id obtained with nameToId(java.lang.String) or StatisticsType.nameToId(java.lang.String).
        supplier - a callback that will return the value of the stat. This replaces any previously registered supplier. If the passed in supplier is null, it will remove any existing supplier
        Returns:
        the previously registered supplier, or null if there was no previously registered supplier
        Throws:
        java.lang.IllegalArgumentException - If the id is invalid.
        Since:
        Geode 1.0
      • setLongSupplier

        java.util.function.LongSupplier setLongSupplier​(java.lang.String name,
                                                        java.util.function.LongSupplier supplier)
        Provide a callback to compute the value of this statistic every sample interval and use that as the value of the stat.

        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.

        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.

        Get methods are not guaranteed to recompute a new value, they may return the last sampled value

        Parameters:
        name - the name of the statistic to update
        supplier - a callback that will return the value of the stat. This replaces any previously registered supplier. If the passed in supplier is null, it will remove any existing supplier
        Returns:
        the previously registered supplier, or null if there was no previously registered supplier
        Throws:
        java.lang.IllegalArgumentException - If no statistic exists with name name or if the statistic named name is not of type long.
      • setLongSupplier

        java.util.function.LongSupplier setLongSupplier​(StatisticDescriptor descriptor,
                                                        java.util.function.LongSupplier supplier)
        Provide a callback to compute the value of this statistic every sample interval and use that as the value of the stat.

        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.

        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.

        Get methods are not guaranteed to recompute a new value, they may return the last sampled value

        Parameters:
        descriptor - the descriptor of the statistic to update
        supplier - a callback that will return the value of the stat. This replaces any previously registered supplier. If the passed in supplier is null, it will remove any existing supplier
        Returns:
        the previously registered supplier, or null if there was no previously registered supplier
        Throws:
        java.lang.IllegalArgumentException - If no statistic exists with the given descriptor or if the described statistic is not of type long.
        Since:
        Geode 1.0
      • setDoubleSupplier

        java.util.function.DoubleSupplier setDoubleSupplier​(int id,
                                                            java.util.function.DoubleSupplier supplier)
        Provide a callback to compute the value of this statistic every sample interval and use that as the value of the stat.

        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 double running processes.

        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.

        Get methods are not guaranteed to recompute a new value, they may return the last sampled value

        Parameters:
        id - a statistic id obtained with nameToId(java.lang.String) or StatisticsType.nameToId(java.lang.String).
        supplier - a callback that will return the value of the stat. This replaces any previously registered supplier. If the passed in supplier is null, it will remove any existing supplier
        Returns:
        the previously registered supplier, or null if there was no previously registered supplier
        Throws:
        java.lang.IllegalArgumentException - If the id is invalid.
        Since:
        Geode 1.0
      • setDoubleSupplier

        java.util.function.DoubleSupplier setDoubleSupplier​(java.lang.String name,
                                                            java.util.function.DoubleSupplier supplier)
        Provide a callback to compute the value of this statistic every sample interval and use that as the value of the stat.

        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 double running processes.

        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.

        Get methods are not guaranteed to recompute a new value, they may return the last sampled value

        Parameters:
        name - the name of the statistic to update
        supplier - a callback that will return the value of the stat. This replaces any previously registered supplier. If the passed in supplier is null, it will remove any existing supplier
        Returns:
        the previously registered supplier, or null if there was no previously registered supplier
        Throws:
        java.lang.IllegalArgumentException - If no statistic exists with name name or if the statistic named name is not of type double.
        Since:
        Geode 1.0
      • setDoubleSupplier

        java.util.function.DoubleSupplier setDoubleSupplier​(StatisticDescriptor descriptor,
                                                            java.util.function.DoubleSupplier supplier)
        Provide a callback to compute the value of this statistic every sample interval and use that as the value of the stat.

        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 double running processes.

        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.

        Get methods are not guaranteed to recompute a new value, they may return the last sampled value

        Parameters:
        descriptor - the descriptor of the statistic to update
        supplier - a callback that will return the value of the stat. This replaces any previously registered supplier. If the passed in supplier is null, it will remove any existing supplier
        Returns:
        the previously registered supplier, or null if there was no previously registered supplier
        Throws:
        java.lang.IllegalArgumentException - If no statistic exists with the given descriptor or if the described statistic is not of type double.
        Since:
        Geode 1.0