/
StoreStatsJmx.java
297 lines (261 loc) · 13.1 KB
/
StoreStatsJmx.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
package voldemort.store.stats;
import voldemort.annotations.jmx.JmxGetter;
import voldemort.annotations.jmx.JmxManaged;
import com.google.common.collect.ImmutableList;
import voldemort.annotations.metrics.Attribute;
import voldemort.annotations.metrics.Metric;
import voldemort.metrics.DataType;
import voldemort.metrics.MetricType;
/**
* A wrapper class to expose store stats via JMX
*
*
*/
@Metric
@JmxManaged
public class StoreStatsJmx {
private StoreStats stats;
public StoreStatsJmx(StoreStats stats) {
this.stats = stats;
}
@Attribute(name = "numberOfCallsToGetAll",
description = "The number of calls to GET_ALL since the last reset.",
metricType = MetricType.GAUGE,
dataType = DataType.LONG)
@JmxGetter(name = "numberOfCallsToGetAll", description = "The number of calls to GET_ALL since the last reset.")
public long getNumberOfCallsToGetAll() {
return stats.getCount(Tracked.GET_ALL);
}
@Attribute(name = "averageGetAllCompletionTimeInMs",
description = "The avg. time in ms for GET_ALL calls to complete.",
metricType = MetricType.GAUGE,
dataType = DataType.DURATION)
@JmxGetter(name = "averageGetAllCompletionTimeInMs", description = "The avg. time in ms for GET_ALL calls to complete.")
public double getAverageGetAllCompletionTimeInMs() {
return stats.getAvgTimeInMs(Tracked.GET_ALL);
}
@Attribute(name = "GetAllThroughput",
description = "Throughput of GET_ALL requests.",
metricType = MetricType.GAUGE,
dataType = DataType.DOUBLE)
@JmxGetter(name = "GetAllThroughput", description = "Throughput of GET_ALL requests.")
public float getGetAllThroughput() {
return stats.getThroughput(Tracked.GET_ALL);
}
@Attribute(name = "numberOfCallsToGet",
description = "The number of calls to GET since the last reset.",
metricType = MetricType.GAUGE,
dataType = DataType.LONG)
@JmxGetter(name = "numberOfCallsToGet", description = "The number of calls to GET since the last reset.")
public long getNumberOfCallsToGet() {
return stats.getCount(Tracked.GET);
}
@Attribute(name = "averageGetCompletionTimeInMs",
description = "The avg. time in ms for GET calls to complete.",
metricType = MetricType.GAUGE,
dataType = DataType.DURATION)
@JmxGetter(name = "averageGetCompletionTimeInMs", description = "The avg. time in ms for GET calls to complete.")
public double getAverageGetCompletionTimeInMs() {
return stats.getAvgTimeInMs(Tracked.GET);
}
@Attribute(name = "GetThroughput",
description = "Throughput of GET requests.",
metricType = MetricType.GAUGE,
dataType = DataType.DOUBLE)
@JmxGetter(name = "GetThroughput", description = "Throughput of GET requests.")
public float getGetThroughput() {
return stats.getThroughput(Tracked.GET);
}
@Attribute(name = "numberOfCallsToPut",
description = "The number of calls to PUT since the last reset.",
metricType = MetricType.GAUGE,
dataType = DataType.LONG)
@JmxGetter(name = "numberOfCallsToPut", description = "The number of calls to PUT since the last reset.")
public long getNumberOfCallsToPut() {
return stats.getCount(Tracked.PUT);
}
@Attribute(name = "averagePutCompletionTimeInMs",
description = "The avg. time in ms for PUT calls to complete.",
metricType = MetricType.GAUGE,
dataType = DataType.DURATION)
@JmxGetter(name = "averagePutCompletionTimeInMs", description = "The avg. time in ms for PUT calls to complete.")
public double getAveragePutCompletionTimeInMs() {
return stats.getAvgTimeInMs(Tracked.PUT);
}
@Attribute(name = "PutThroughput",
description = "Throughput of PUT requests.",
metricType = MetricType.GAUGE,
dataType = DataType.DOUBLE)
@JmxGetter(name = "PutThroughput", description = "Throughput of PUT requests.")
public float getPutThroughput() {
return stats.getThroughput(Tracked.PUT);
}
@Attribute(name = "numberOfCallsToDelete",
description = "The number of calls to DELETE since the last reset.",
metricType = MetricType.GAUGE,
dataType = DataType.LONG)
@JmxGetter(name = "numberOfCallsToDelete", description = "The number of calls to DELETE since the last reset.")
public long getNumberOfCallsToDelete() {
return stats.getCount(Tracked.DELETE);
}
@Attribute(name = "averageDeleteCompletionTimeInMs",
description = "The avg. time in ms for DELETE calls to complete.",
metricType = MetricType.GAUGE,
dataType = DataType.DURATION)
@JmxGetter(name = "averageDeleteCompletionTimeInMs", description = "The avg. time in ms for DELETE calls to complete.")
public double getAverageDeleteCompletionTimeInMs() {
return stats.getAvgTimeInMs(Tracked.DELETE);
}
@Attribute(name = "DeleteThroughput",
description = "Throughput of DELETE requests.",
metricType = MetricType.GAUGE,
dataType = DataType.DOUBLE)
@JmxGetter(name = "DeleteThroughput", description = "Throughput of DELETE requests.")
public float getDeleteThroughput() {
return stats.getThroughput(Tracked.DELETE);
}
@Attribute(name = "numberOfObsoleteVersions",
description = "Number of ObsoleteVersionExceptions since the last reset.",
metricType = MetricType.GAUGE,
dataType = DataType.LONG)
@JmxGetter(name = "numberOfObsoleteVersions", description = "Number of ObsoleteVersionExceptions since the last reset.")
public long getNumberOfObsoleteVersions() {
return stats.getCount(Tracked.OBSOLETE);
}
@Attribute(name = "numberOfExceptions",
description = "The number of exceptions since the last reset.",
metricType = MetricType.GAUGE,
dataType = DataType.LONG)
@JmxGetter(name = "numberOfExceptions", description = "The number of exceptions since the last reset.")
public long getNumberOfExceptions() {
return stats.getCount(Tracked.EXCEPTION);
}
@Attribute(name = "averageOperationTimeInMs",
description = "The total nuber of all operations that have occured.",
metricType = MetricType.GAUGE,
dataType = DataType.DURATION)
@JmxGetter(name = "averageOperationTimeInMs", description = "The total nuber of all operations that have occured.")
public double getAvgOperationCompletionTimeInMs() {
double sum = 0.0;
double weightedTime = 0.0;
for(Tracked stat: ImmutableList.of(Tracked.DELETE,
Tracked.GET,
Tracked.GET_ALL,
Tracked.PUT)) {
sum += stats.getCount(stat);
weightedTime += stats.getCount(stat) * stats.getAvgTimeInMs(stat);
}
if(sum <= 0)
return 0;
else
return weightedTime / sum;
}
@Attribute(name = "AllOperationThroughput",
description = "The number of exceptions since the last reset.",
metricType = MetricType.GAUGE,
dataType = DataType.DOUBLE)
@JmxGetter(name = "AllOperationThroughput", description = "The number of exceptions since the last reset.")
public double getOperationThroughput() {
return stats.getThroughput(Tracked.DELETE) + stats.getThroughput(Tracked.GET)
+ stats.getThroughput(Tracked.GET_ALL) + stats.getThroughput(Tracked.PUT);
}
@Attribute(name = "percentGetReturningEmptyResponse",
description = "The percentage of calls to GET for which no value was found.",
metricType = MetricType.GAUGE,
dataType = DataType.PERCENT)
@JmxGetter(name = "percentGetReturningEmptyResponse", description = "The percentage of calls to GET for which no value was found.")
public double getPercentGetReturningEmptyResponse() {
return numEmptyResponses(stats.getNumEmptyResponses(Tracked.GET), stats.getCount(Tracked.GET));
}
@Attribute(name = "percentGetAllReturningEmptyResponse",
description = "The percentage of calls to GET_ALL for which no value was found, taking into account multiple returned key-values.",
metricType = MetricType.GAUGE,
dataType = DataType.PERCENT)
@JmxGetter(name = "percentGetAllReturningEmptyResponse", description = "The percentage of calls to GET_ALL for which no value was found, taking into account multiple returned key-values.")
public double getPercentGetAllReturningEmptyResponse() {
return numEmptyResponses(stats.getNumEmptyResponses(Tracked.GET_ALL), stats.getGetAllAggregatedCount());
}
private double numEmptyResponses(long numEmpty, long total) {
return total == 0 ? 0.0d : numEmpty / (float)total;
}
@Attribute(name = "maxPutLatencyInMs",
description = "Maximum latency in ms of PUT",
metricType = MetricType.GAUGE,
dataType = DataType.DURATION)
@JmxGetter(name = "maxPutLatencyInMs", description = "Maximum latency in ms of PUT")
public long getMaxPutLatency() {
return stats.getMaxLatencyInMs(Tracked.PUT);
}
@Attribute(name = "maxGetLatencyInMs",
description = "Maximum latency in ms of GET",
metricType = MetricType.GAUGE,
dataType = DataType.DURATION)
@JmxGetter(name = "maxGetLatencyInMs", description = "Maximum latency in ms of GET")
public long getMaxGetLatency() {
return stats.getMaxLatencyInMs(Tracked.GET);
}
@Attribute(name = "maxGetAllLatencyInMs",
description = "Maximum latency in ms of GET_ALL",
metricType = MetricType.GAUGE,
dataType = DataType.DURATION)
@JmxGetter(name = "maxGetAllLatencyInMs", description = "Maximum latency in ms of GET_ALL")
public long getMaxGetAllLatency() {
return stats.getMaxLatencyInMs(Tracked.GET_ALL);
}
@Attribute(name = "maxDeleteLatencyInMs",
description = "Maximum latency in ms of DELETE",
metricType = MetricType.GAUGE,
dataType = DataType.DURATION)
@JmxGetter(name = "maxDeleteLatencyInMs", description = "Maximum latency in ms of DELETE")
public long getMaxDeleteLatency() {
return stats.getMaxLatencyInMs(Tracked.DELETE);
}
@Attribute(name = "maxPutSizeInBytes",
description = "Maximum size of value returned in bytes by PUT.",
metricType = MetricType.GAUGE,
dataType = DataType.STORAGE)
@JmxGetter(name = "maxPutSizeInBytes", description = "Maximum size of value returned in bytes by PUT.")
public long getMaxPutSizeInBytes() {
return stats.getMaxSizeInBytes(Tracked.PUT);
}
@Attribute(name = "maxGetAllSizeInBytes",
description = "Maximum size of value returned in bytes by GET_ALL.",
metricType = MetricType.GAUGE,
dataType = DataType.STORAGE)
@JmxGetter(name = "maxGetAllSizeInBytes", description = "Maximum size of value returned in bytes by GET_ALL.")
public long getMaxGetAllSizeInBytes() {
return stats.getMaxSizeInBytes(Tracked.GET_ALL);
}
@Attribute(name = "maxGetSizeInBytes",
description = "Maximum size of value returned in bytes by GET.",
metricType = MetricType.GAUGE,
dataType = DataType.STORAGE)
@JmxGetter(name = "maxGetSizeInBytes", description = "Maximum size of value returned in bytes by GET.")
public long getMaxGetSizeInBytes() {
return stats.getMaxSizeInBytes(Tracked.GET);
}
@Attribute(name = "averageGetValueSizeInBytes",
description = "Average size in bytes of GET request",
metricType = MetricType.GAUGE,
dataType = DataType.STORAGE)
@JmxGetter(name = "averageGetValueSizeInBytes", description = "Average size in bytes of GET request")
public double getAverageGetSizeInBytes() {
return stats.getAvgSizeinBytes(Tracked.GET);
}
@Attribute(name = "averageGetAllSizeInBytes",
description = "Average size in bytes of GET_ALL request",
metricType = MetricType.GAUGE,
dataType = DataType.STORAGE)
@JmxGetter(name = "averageGetAllSizeInBytes", description = "Average size in bytes of GET_ALL request")
public double getAverageGetAllSizeInBytes() {
return stats.getAvgSizeinBytes(Tracked.GET_ALL);
}
@Attribute(name = "averagePutSizeInBytes",
description = "Average size in bytes of PUT request",
metricType = MetricType.GAUGE,
dataType = DataType.STORAGE)
@JmxGetter(name = "averagePutSizeInBytes", description = "Average size in bytes of PUT request")
public double getAveragePutSizeInBytes() {
return stats.getAvgSizeinBytes(Tracked.PUT);
}
}