public class Snapshot extends Object implements Serializable
Encapsulates a single snapshot of statistics from a Rhino cluster at a particular point in time.
A snapshot contains a timestamp and a arrays of sample data (see getData()
), with one array for each subscription represented in the snapshot.
The sample data can be matched with a subscription id using getSubscriptionIds()
.
The array returned by getData()
is two dimensional.
For each subscription the index for that subscription in the first dimension equals that subscription id’s position within the array of subscription id’s (returned by getSubscriptionIds()
). So for a subscription id N, the data for that statistic within the snapshot is getData()[<position of N within getSubscriptionIds() array>]
and is of the type a long[]
. The content of the long[]
depends on the subscription mode of the subscription (see SubscriptionMode
).
SIMPLE_COUNTER a one element array containing the counter value
SIMPLE_GAUGE a one element array containing the gauge value
DELTA_COUNTER a two element array containing the counter delta followed by the current counter value, or zero elements if this is the first sample and no delta value is available yet
PER_SECOND_COUNTER a two element array containing the per-second counter delta followed by the current counter value, or zero elements if this is the first sample and no delta value is available yet
ROLLING_FREQUENCY_DISTRIBUTION, PERMANENT_FREQUENCY_DISTRIBUTION, RESETTING_FREQUENCY_DISTRIBUTION an N-element array containing the minimum observed sample, the maximum observed sample, the minimum bin, the maximum bin, a bin size, followed by a number of bins containing a count of the samples that fell within each
For example a snapshot containing samples of 3 statistics: foo (with subscription id = 2), bar (with subscription id = 3), and baz (with subscription id = 5) will contain the following results:
[0] == 2
[1] == 3
[2] == 5
[0] == [<values for foo>]
[1] == [<values for bar>]
[2] == [<values for baz>]
Constructor and Description |
---|
Snapshot(long timestamp,
int[] subscriptionIds,
int[] respondingNodeIds,
long[][] data) |
Modifier and Type | Method and Description |
---|---|
long[][] |
getData()
Returns the data attached to this snapshot
|
int[] |
getRespondingNodeIds()
Return an array containing the node id of the node that provided the returned value for each corresponding subscription id.
|
int[] |
getSubscriptionIds()
Returns the array of subscription id’s represented in this snapshot
The subscription id’s appear in the same order as the data for each subscription in
getData() . |
long |
getTimestamp()
The timestamp at which this snapshot was taken
|
public Snapshot(long timestamp, int[] subscriptionIds, int[] respondingNodeIds, long[][] data)
public final long[][] getData()
Returns the data attached to this snapshot
public final int[] getSubscriptionIds()
Returns the array of subscription id’s represented in this snapshot
The subscription id’s appear in the same order as the data for each subscription in getData()
.
public final long getTimestamp()
The timestamp at which this snapshot was taken
public int[] getRespondingNodeIds()
Return an array containing the node id of the node that provided the returned value for each corresponding subscription id.
This array will be the same length as that returned by getSubscriptionIds()
. It can be used to determine which value comes from which cluster node in case there are multiple values for a subscribed statistic in the snapshot (this will be the case if the subscription has used the special node if 0
to get values from all nodes (see also subscribe
methods in StatsManagementMBean
.
In case the client has subscribed to statistics from only an individual node there is no need to look at this array because the node will already be known from the subscription id.