public interface Statistics
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 incInt.
Note that as of the 5.1 release the incInt
, 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.
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes these statistics.
|
java.lang.Number |
get(StatisticDescriptor descriptor)
Returns the value of the identified statistic.
|
java.lang.Number |
get(java.lang.String name)
Returns the value of the named statistic.
|
double |
getDouble(int id)
Returns the value of the identified statistic of type
double . |
double |
getDouble(StatisticDescriptor descriptor)
Returns the value of the described statistic of type
double . |
double |
getDouble(java.lang.String name)
Returns the value of the statistic of type
double at the given name. |
int |
getInt(int id)
Returns the value of the identified statistic of type
int . |
int |
getInt(StatisticDescriptor descriptor)
Returns the value of the described statistic of type
int . |
int |
getInt(java.lang.String name)
Returns the value of the statistic of type
int at the given name. |
long |
getLong(int id)
Returns the value of the identified statistic of type
long . |
long |
getLong(StatisticDescriptor descriptor)
Returns the value of the described statistic of type
long . |
long |
getLong(java.lang.String name)
Returns the value of the statistic of type
long at the given name. |
long |
getNumericId()
Gets the number associated with this instance that helps identify it.
|
long |
getRawBits(StatisticDescriptor descriptor)
Returns the bits that represent the raw value of the described statistic.
|
long |
getRawBits(java.lang.String name)
Returns the bits that represent the raw value of the named 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(StatisticDescriptor descriptor,
double delta)
Increments the value of the described 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 |
incInt(int id,
int delta)
Increments the value of the identified statistic of type
int by the given amount. |
void |
incInt(StatisticDescriptor descriptor,
int delta)
Increments the value of the described statistic of type
int by the given amount. |
void |
incInt(java.lang.String name,
int delta)
Increments the value of the statistic of type
int with the given name by a given
amount. |
void |
incLong(int id,
long delta)
Increments the value of the identified statistic of type
long by the given amount. |
void |
incLong(StatisticDescriptor descriptor,
long delta)
Increments the value of the described 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. |
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(StatisticDescriptor descriptor,
double value)
Sets the value of a described statistic of type
double |
void |
setDouble(java.lang.String name,
double value)
Sets the value of a named 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(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.
|
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.
|
void |
setInt(int id,
int value)
Sets the value of a statistic with the given
id whose type is int . |
void |
setInt(StatisticDescriptor descriptor,
int value)
Sets the value of a described statistic of type
int |
void |
setInt(java.lang.String name,
int value)
Sets the value of a named statistic of type
int |
java.util.function.IntSupplier |
setIntSupplier(int id,
java.util.function.IntSupplier 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.IntSupplier |
setIntSupplier(StatisticDescriptor descriptor,
java.util.function.IntSupplier 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.IntSupplier |
setIntSupplier(java.lang.String name,
java.util.function.IntSupplier supplier)
Provide a callback to compute the value of this statistic every sample interval and use that as
the value of the stat.
|
void |
setLong(int id,
long value)
Sets the value of a statistic with the given
id whose type is long . |
void |
setLong(StatisticDescriptor descriptor,
long value)
Sets the value of a described statistic of type
long |
void |
setLong(java.lang.String name,
long value)
Sets the value of a named 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(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.
|
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.
|
void close()
int nameToId(java.lang.String name)
java.lang.IllegalArgumentException
- No statistic named name
exists in this statistics
instance.StatisticsType.nameToId(java.lang.String)
StatisticDescriptor nameToDescriptor(java.lang.String name)
java.lang.IllegalArgumentException
- No statistic named name
exists in this statistics
instance.StatisticsType.nameToDescriptor(java.lang.String)
long getUniqueId()
StatisticsType getType()
StatisticsType
of this instance.java.lang.String getTextId()
long getNumericId()
boolean isAtomic()
Returns false if modifications are not atomic. This means that modifications to this instance are cheaper but not thread safe.
boolean isClosed()
closed
.void setInt(int id, int value)
id
whose type is int
.id
- a statistic id obtained with nameToId(java.lang.String)
or StatisticsType.nameToId(java.lang.String)
.java.lang.ArrayIndexOutOfBoundsException
- If the id is invalid.void setInt(java.lang.String name, int value)
int
java.lang.IllegalArgumentException
- If no statistic exists named name
or if the
statistic with name name
is not of type int
.void setInt(StatisticDescriptor descriptor, int value)
int
java.lang.IllegalArgumentException
- If no statistic exists for the given descriptor
or if the described statistic is not of type int
.void setLong(int id, long value)
id
whose type is long
.id
- a statistic id obtained with nameToId(java.lang.String)
or StatisticsType.nameToId(java.lang.String)
.java.lang.ArrayIndexOutOfBoundsException
- If the id is invalid.void setLong(StatisticDescriptor descriptor, long value)
long
java.lang.IllegalArgumentException
- If no statistic exists for the given descriptor
or if the described statistic is not of type long
.void setLong(java.lang.String name, long value)
long
.java.lang.IllegalArgumentException
- If no statistic exists named name
or if the
statistic with name name
is not of type long
.void setDouble(int id, double value)
id
whose type is double
.id
- a statistic id obtained with nameToId(java.lang.String)
or StatisticsType.nameToId(java.lang.String)
.java.lang.ArrayIndexOutOfBoundsException
- If the id is invalid.void setDouble(StatisticDescriptor descriptor, double value)
double
java.lang.IllegalArgumentException
- If no statistic exists for the given descriptor
or if the described statistic is not of type double
.void setDouble(java.lang.String name, double value)
double
.java.lang.IllegalArgumentException
- If no statistic exists named name
or if the
statistic with name name
is not of type double
.int getInt(int id)
int
.id
- a statistic id obtained with nameToId(java.lang.String)
or StatisticsType.nameToId(java.lang.String)
.java.lang.ArrayIndexOutOfBoundsException
- If the id is invalid.int getInt(StatisticDescriptor descriptor)
int
.java.lang.IllegalArgumentException
- If no statistic exists with the specified
descriptor
or if the described statistic is not of type int
.int getInt(java.lang.String name)
int
at the given name.java.lang.IllegalArgumentException
- If no statistic exists with name name
or if the
statistic named name
is not of type int
.long getLong(int id)
long
.id
- a statistic id obtained with nameToId(java.lang.String)
or StatisticsType.nameToId(java.lang.String)
.java.lang.ArrayIndexOutOfBoundsException
- If the id is invalid.long getLong(StatisticDescriptor descriptor)
long
.java.lang.IllegalArgumentException
- If no statistic exists with the specified
descriptor
or if the described statistic is not of type long
.long getLong(java.lang.String name)
long
at the given name.java.lang.IllegalArgumentException
- If no statistic exists with name name
or if the
statistic named name
is not of type long
.double getDouble(int id)
double
.id
- a statistic id obtained with nameToId(java.lang.String)
or StatisticsType.nameToId(java.lang.String)
.java.lang.ArrayIndexOutOfBoundsException
- If the id is invalid.double getDouble(StatisticDescriptor descriptor)
double
.java.lang.IllegalArgumentException
- If no statistic exists with the specified
descriptor
or if the described statistic is not of type
double
.double getDouble(java.lang.String name)
double
at the given name.java.lang.IllegalArgumentException
- If no statistic exists with name name
or if the
statistic named name
is not of type double
.java.lang.Number get(StatisticDescriptor descriptor)
descriptor
- a statistic descriptor obtained with nameToDescriptor(java.lang.String)
or
StatisticsType.nameToDescriptor(java.lang.String)
.java.lang.IllegalArgumentException
- If the described statistic does not existjava.lang.Number get(java.lang.String name)
java.lang.IllegalArgumentException
- If the named statistic does not existlong getRawBits(StatisticDescriptor descriptor)
descriptor
- a statistic descriptor obtained with nameToDescriptor(java.lang.String)
or
StatisticsType.nameToDescriptor(java.lang.String)
.java.lang.IllegalArgumentException
- If the described statistic does not existlong getRawBits(java.lang.String name)
java.lang.IllegalArgumentException
- If the named statistic does not existvoid incInt(int id, int delta)
int
by the given amount.id
- a statistic id obtained with nameToId(java.lang.String)
or StatisticsType.nameToId(java.lang.String)
.java.lang.ArrayIndexOutOfBoundsException
- If the id is invalid.void incInt(StatisticDescriptor descriptor, int delta)
int
by the given amount.java.lang.IllegalArgumentException
- If no statistic exists with the given descriptor
or if the described statistic is not of type int
.void incInt(java.lang.String name, int delta)
int
with the given name by a given
amount.java.lang.IllegalArgumentException
- If no statistic exists with name name
or if the
statistic named name
is not of type int
.void incLong(int id, long delta)
long
by the given amount.id
- a statistic id obtained with nameToId(java.lang.String)
or StatisticsType.nameToId(java.lang.String)
.java.lang.ArrayIndexOutOfBoundsException
- If the id is invalid.void incLong(StatisticDescriptor descriptor, long delta)
long
by the given amount.java.lang.IllegalArgumentException
- If no statistic exists with the given descriptor
or if the described statistic is not of type long
.void incLong(java.lang.String name, long delta)
long
with the given name by a given
amount.java.lang.IllegalArgumentException
- If no statistic exists with name name
or if the
statistic named name
is not of type long
.void incDouble(int id, double delta)
double
by the given
amount.id
- a statistic id obtained with nameToId(java.lang.String)
or StatisticsType.nameToId(java.lang.String)
.java.lang.ArrayIndexOutOfBoundsException
- If the id is invalid.void incDouble(StatisticDescriptor descriptor, double delta)
double
by the given
amount.java.lang.IllegalArgumentException
- If no statistic exists with the given descriptor
or if the described statistic is not of type double
.void incDouble(java.lang.String name, double delta)
double
with the given name by a
given amount.java.lang.IllegalArgumentException
- If no statistic exists with name name
or if the
statistic named name
is not of type double
.java.util.function.IntSupplier setIntSupplier(int id, java.util.function.IntSupplier supplier)
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
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
supplierjava.lang.IllegalArgumentException
- If the id is invalid.java.util.function.IntSupplier setIntSupplier(java.lang.String name, java.util.function.IntSupplier supplier)
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
name
- the name of the statistic to updatesupplier
- 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
supplierjava.lang.IllegalArgumentException
- If no statistic exists with name name
or if the
statistic named name
is not of type int
.java.util.function.IntSupplier setIntSupplier(StatisticDescriptor descriptor, java.util.function.IntSupplier supplier)
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
descriptor
- the descriptor of the statistic to updatesupplier
- 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
supplierjava.lang.IllegalArgumentException
- If no statistic exists with the given descriptor
or if the described statistic is not of type int
.java.util.function.LongSupplier setLongSupplier(int id, java.util.function.LongSupplier supplier)
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
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
supplierjava.lang.IllegalArgumentException
- If the id is invalid.java.util.function.LongSupplier setLongSupplier(java.lang.String name, java.util.function.LongSupplier supplier)
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
name
- the name of the statistic to updatesupplier
- 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
supplierjava.lang.IllegalArgumentException
- If no statistic exists with name name
or if the
statistic named name
is not of type long
.java.util.function.LongSupplier setLongSupplier(StatisticDescriptor descriptor, java.util.function.LongSupplier supplier)
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
descriptor
- the descriptor of the statistic to updatesupplier
- 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
supplierjava.lang.IllegalArgumentException
- If no statistic exists with the given descriptor
or if the described statistic is not of type long
.java.util.function.DoubleSupplier setDoubleSupplier(int id, java.util.function.DoubleSupplier supplier)
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
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
supplierjava.lang.IllegalArgumentException
- If the id is invalid.java.util.function.DoubleSupplier setDoubleSupplier(java.lang.String name, java.util.function.DoubleSupplier supplier)
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
name
- the name of the statistic to updatesupplier
- 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
supplierjava.lang.IllegalArgumentException
- If no statistic exists with name name
or if the
statistic named name
is not of type double
.java.util.function.DoubleSupplier setDoubleSupplier(StatisticDescriptor descriptor, java.util.function.DoubleSupplier supplier)
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
descriptor
- the descriptor of the statistic to updatesupplier
- 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
supplierjava.lang.IllegalArgumentException
- If no statistic exists with the given descriptor
or if the described statistic is not of type double
.