18
18
*/
19
19
package org .apache .accumulo .monitor .next ;
20
20
21
+ import java .lang .annotation .ElementType ;
22
+ import java .lang .annotation .Retention ;
23
+ import java .lang .annotation .RetentionPolicy ;
24
+ import java .lang .annotation .Target ;
21
25
import java .lang .reflect .Method ;
22
26
import java .util .Collection ;
23
- import java .util .HashSet ;
24
27
import java .util .List ;
25
28
import java .util .Map ;
26
29
import java .util .Set ;
30
+ import java .util .TreeMap ;
27
31
import java .util .stream .Collectors ;
28
32
29
33
import jakarta .inject .Inject ;
53
57
@ Path ("/" )
54
58
public class Endpoints {
55
59
60
+ @ Target (ElementType .METHOD )
61
+ @ Retention (RetentionPolicy .RUNTIME )
62
+ public @interface Description {
63
+ String value ();
64
+ }
65
+
56
66
@ Inject
57
67
private Monitor monitor ;
58
68
@@ -66,45 +76,61 @@ private void validateResourceGroup(String resourceGroup) {
66
76
@ GET
67
77
@ Path ("endpoints" )
68
78
@ Produces (MediaType .APPLICATION_JSON )
69
- public Set <String > getEndpoints (@ Context HttpServletRequest request ) {
70
-
79
+ @ Description ("Returns a list of the available endpoints and a description for each" )
80
+ public Map <String ,String > getEndpoints (@ Context HttpServletRequest request ) {
81
+
82
+ /**
83
+ * Attemtped to use OpenAPI annotation for use with Swagger-UI, but ran into potential
84
+ * dependency convergence issues as we were using newer version of some of the same
85
+ * dependencies.
86
+ */
71
87
final String basePath = request .getRequestURL ().toString ();
72
- final Set <String > endpoints = new HashSet <>();
88
+ final Map <String , String > documentation = new TreeMap <>();
73
89
74
90
for (Method m : Endpoints .class .getMethods ()) {
75
91
if (m .isAnnotationPresent (Path .class )) {
76
92
Path pathAnnotation = m .getAnnotation (Path .class );
77
- endpoints .add (basePath + "/" + pathAnnotation .value ());
93
+ String path = basePath + "/" + pathAnnotation .value ();
94
+ String description = "" ;
95
+ if (m .isAnnotationPresent (Description .class )) {
96
+ Description desc = m .getAnnotation (Description .class );
97
+ description = desc .value ();
98
+ }
99
+ documentation .put (path , description );
78
100
}
79
101
}
80
102
81
- return endpoints ;
103
+ return documentation ;
82
104
}
83
105
84
106
@ GET
85
107
@ Path ("groups" )
86
108
@ Produces (MediaType .APPLICATION_JSON )
109
+ @ Description ("Returns a list of the resource groups that are in use" )
87
110
public Set <String > getResourceGroups () {
88
111
return monitor .getInformationFetcher ().getSummary ().getResourceGroups ();
89
112
}
90
113
91
114
@ GET
92
115
@ Path ("problems" )
93
116
@ Produces (MediaType .APPLICATION_JSON )
117
+ @ Description ("Returns a list of the servers that are potentially down" )
94
118
public Collection <ServerId > getProblemHosts () {
95
119
return monitor .getInformationFetcher ().getSummary ().getProblemHosts ();
96
120
}
97
121
98
122
@ GET
99
123
@ Path ("metrics" )
100
124
@ Produces (MediaType .APPLICATION_JSON )
125
+ @ Description ("Returns the metric responses for all servers" )
101
126
public Collection <MetricResponse > getAll () {
102
127
return monitor .getInformationFetcher ().getAllMetrics ().asMap ().values ();
103
128
}
104
129
105
130
@ GET
106
131
@ Path ("manager" )
107
132
@ Produces (MediaType .APPLICATION_JSON )
133
+ @ Description ("Returns the metric response for the Manager" )
108
134
public MetricResponse getManager () {
109
135
final ServerId s = monitor .getInformationFetcher ().getSummary ().getManager ();
110
136
if (s == null ) {
@@ -116,6 +142,7 @@ public MetricResponse getManager() {
116
142
@ GET
117
143
@ Path ("gc" )
118
144
@ Produces (MediaType .APPLICATION_JSON )
145
+ @ Description ("Returns the metric response for the Garbage Collector" )
119
146
public MetricResponse getGarbageCollector () {
120
147
final ServerId s = monitor .getInformationFetcher ().getSummary ().getGarbageCollector ();
121
148
if (s == null ) {
@@ -127,6 +154,7 @@ public MetricResponse getGarbageCollector() {
127
154
@ GET
128
155
@ Path ("instance" )
129
156
@ Produces (MediaType .APPLICATION_JSON )
157
+ @ Description ("Returns the instance name, instance id, version, zookeepers, and volumes" )
130
158
public InstanceSummary getInstanceSummary () {
131
159
return new InstanceSummary (monitor .getContext ().getInstanceName (),
132
160
monitor .getContext ().instanceOperations ().getInstanceId ().canonical (),
@@ -139,6 +167,7 @@ public InstanceSummary getInstanceSummary() {
139
167
@ GET
140
168
@ Path ("compactors/detail/{group}" )
141
169
@ Produces (MediaType .APPLICATION_JSON )
170
+ @ Description ("Returns the metric responses for the Compactors in the supplied resource group" )
142
171
public Collection <MetricResponse > getCompactors (@ PathParam ("group" ) String resourceGroup ) {
143
172
validateResourceGroup (resourceGroup );
144
173
final Set <ServerId > servers = monitor .getInformationFetcher ().getSummary ()
@@ -152,6 +181,7 @@ public Collection<MetricResponse> getCompactors(@PathParam("group") String resou
152
181
@ GET
153
182
@ Path ("compactors/summary/{group}" )
154
183
@ Produces (MediaType .APPLICATION_JSON )
184
+ @ Description ("Returns an aggregate view of the metric responses for the Compactors in the supplied resource group" )
155
185
public Map <Id ,CumulativeDistributionSummary >
156
186
getCompactorResourceGroupMetricSummary (@ PathParam ("group" ) String resourceGroup ) {
157
187
validateResourceGroup (resourceGroup );
@@ -166,13 +196,15 @@ public Collection<MetricResponse> getCompactors(@PathParam("group") String resou
166
196
@ GET
167
197
@ Path ("compactors/summary" )
168
198
@ Produces (MediaType .APPLICATION_JSON )
199
+ @ Description ("Returns an aggregate view of the metric responses for all Compactors" )
169
200
public Map <Id ,CumulativeDistributionSummary > getCompactorAllMetricSummary () {
170
201
return monitor .getInformationFetcher ().getSummary ().getCompactorAllMetricSummary ();
171
202
}
172
203
173
204
@ GET
174
205
@ Path ("sservers/detail/{group}" )
175
206
@ Produces (MediaType .APPLICATION_JSON )
207
+ @ Description ("Returns the metric responses for the ScanServers in the supplied resource group" )
176
208
public Collection <MetricResponse > getScanServers (@ PathParam ("group" ) String resourceGroup ) {
177
209
validateResourceGroup (resourceGroup );
178
210
final Set <ServerId > servers =
@@ -186,6 +218,7 @@ public Collection<MetricResponse> getScanServers(@PathParam("group") String reso
186
218
@ GET
187
219
@ Path ("sservers/summary/{group}" )
188
220
@ Produces (MediaType .APPLICATION_JSON )
221
+ @ Description ("Returns an aggregate view of the metric responses for the ScanServers in the supplied resource group" )
189
222
public Map <Id ,CumulativeDistributionSummary >
190
223
getScanServerResourceGroupMetricSummary (@ PathParam ("group" ) String resourceGroup ) {
191
224
validateResourceGroup (resourceGroup );
@@ -200,13 +233,15 @@ public Collection<MetricResponse> getScanServers(@PathParam("group") String reso
200
233
@ GET
201
234
@ Path ("sservers/summary" )
202
235
@ Produces (MediaType .APPLICATION_JSON )
236
+ @ Description ("Returns an aggregate view of the metric responses for all ScanServers" )
203
237
public Map <Id ,CumulativeDistributionSummary > getScanServerAllMetricSummary () {
204
238
return monitor .getInformationFetcher ().getSummary ().getSServerAllMetricSummary ();
205
239
}
206
240
207
241
@ GET
208
242
@ Path ("tservers/detail/{group}" )
209
243
@ Produces (MediaType .APPLICATION_JSON )
244
+ @ Description ("Returns the metric responses for the TabletServers in the supplied resource group" )
210
245
public Collection <MetricResponse > getTabletServers (@ PathParam ("group" ) String resourceGroup ) {
211
246
validateResourceGroup (resourceGroup );
212
247
final Set <ServerId > servers =
@@ -220,6 +255,7 @@ public Collection<MetricResponse> getTabletServers(@PathParam("group") String re
220
255
@ GET
221
256
@ Path ("tservers/summary/{group}" )
222
257
@ Produces (MediaType .APPLICATION_JSON )
258
+ @ Description ("Returns an aggregate view of the metric responses for the TabletServers in the supplied resource group" )
223
259
public Map <Id ,CumulativeDistributionSummary >
224
260
getTabletServerResourceGroupMetricSummary (@ PathParam ("group" ) String resourceGroup ) {
225
261
validateResourceGroup (resourceGroup );
@@ -234,41 +270,58 @@ public Collection<MetricResponse> getTabletServers(@PathParam("group") String re
234
270
@ GET
235
271
@ Path ("tservers/summary" )
236
272
@ Produces (MediaType .APPLICATION_JSON )
273
+ @ Description ("Returns an aggregate view of the metric responses for all TabletServers" )
237
274
public Map <Id ,CumulativeDistributionSummary > getTabletServerAllMetricSummary () {
238
275
return monitor .getInformationFetcher ().getSummary ().getTServerAllMetricSummary ();
239
276
}
240
277
241
278
@ GET
242
279
@ Path ("compactions/summary" )
243
280
@ Produces (MediaType .APPLICATION_JSON )
281
+ @ Description ("Returns the metrics for all compaction queues" )
244
282
public Map <String ,List <FMetric >> getCompactionMetricSummary () {
245
283
return monitor .getInformationFetcher ().getSummary ().getCompactionMetricSummary ();
246
284
}
247
285
248
286
@ GET
249
287
@ Path ("compactions/detail" )
250
288
@ Produces (MediaType .APPLICATION_JSON )
289
+ @ Description ("Returns a map of Compactor resource group to the 50 oldest running compactions" )
251
290
public Map <String ,List <TExternalCompaction >> getCompactions () {
252
- return monitor .getInformationFetcher ().getSummary ().getCompactions (25 );
291
+ Map <String ,List <TExternalCompaction >> all =
292
+ monitor .getInformationFetcher ().getSummary ().getCompactions ();
293
+ if (all == null ) {
294
+ return Map .of ();
295
+ }
296
+ return all ;
253
297
}
254
298
255
299
@ GET
256
- @ Path ("compactions/detail/{num }" )
300
+ @ Path ("compactions/detail/{group }" )
257
301
@ Produces (MediaType .APPLICATION_JSON )
258
- public Map <String ,List <TExternalCompaction >> getCompactions (@ PathParam ("num" ) int topN ) {
259
- return monitor .getInformationFetcher ().getSummary ().getCompactions (topN );
302
+ @ Description ("Returns a list of the 50 oldest running compactions in the supplied resource group" )
303
+ public List <TExternalCompaction > getCompactions (@ PathParam ("group" ) String resourceGroup ) {
304
+ validateResourceGroup (resourceGroup );
305
+ List <TExternalCompaction > compactions =
306
+ monitor .getInformationFetcher ().getSummary ().getCompactions (resourceGroup );
307
+ if (compactions == null ) {
308
+ return List .of ();
309
+ }
310
+ return compactions ;
260
311
}
261
312
262
313
@ GET
263
314
@ Path ("tables" )
264
315
@ Produces (MediaType .APPLICATION_JSON )
316
+ @ Description ("Returns a map of table name to table details" )
265
317
public Map <String ,TableSummary > getTables () {
266
318
return monitor .getInformationFetcher ().getSummary ().getTables ();
267
319
}
268
320
269
321
@ GET
270
322
@ Path ("tables/{name}" )
271
323
@ Produces (MediaType .APPLICATION_JSON )
324
+ @ Description ("Returns table details for the supplied table name" )
272
325
public TableSummary getTable (@ PathParam ("name" ) String tableName ) {
273
326
TableSummary ts = monitor .getInformationFetcher ().getSummary ().getTables ().get (tableName );
274
327
if (ts == null ) {
@@ -280,6 +333,7 @@ public TableSummary getTable(@PathParam("name") String tableName) {
280
333
@ GET
281
334
@ Path ("tables/{name}/tablets" )
282
335
@ Produces (MediaType .APPLICATION_JSON )
336
+ @ Description ("Returns tablet details for the supplied table name" )
283
337
public List <TabletInformation > getTablets (@ PathParam ("name" ) String tableName ) {
284
338
List <TabletInformation > ti = monitor .getInformationFetcher ().getSummary ().getTablets (tableName );
285
339
if (ti == null ) {
@@ -291,27 +345,32 @@ public List<TabletInformation> getTablets(@PathParam("name") String tableName) {
291
345
@ GET
292
346
@ Path ("deployment" )
293
347
@ Produces (MediaType .APPLICATION_JSON )
348
+ @ Description ("Returns a map of resource group to server type to process summary."
349
+ + " The process summary contains the number of configured, responding, and not responding servers" )
294
350
public Map <String ,Map <String ,ProcessSummary >> getDeploymentOverview () {
295
351
return monitor .getInformationFetcher ().getSummary ().getDeploymentOverview ();
296
352
}
297
353
298
354
@ GET
299
355
@ Path ("suggestions" )
300
356
@ Produces (MediaType .APPLICATION_JSON )
357
+ @ Description ("Returns a list of suggestions" )
301
358
public Set <String > getSuggestions () {
302
359
return monitor .getInformationFetcher ().getSummary ().getSuggestions ();
303
360
}
304
361
305
362
@ GET
306
363
@ Path ("lastUpdate" )
307
364
@ Produces (MediaType .APPLICATION_JSON )
365
+ @ Description ("Returns the timestamp of when the monitor information was last refreshed" )
308
366
public long getTimestamp () {
309
367
return monitor .getInformationFetcher ().getSummary ().getTimestamp ();
310
368
}
311
369
312
370
@ GET
313
371
@ Path ("stats" )
314
372
@ Produces (MediaType .TEXT_PLAIN )
373
+ @ Description ("Returns connection statistics for the Jetty server" )
315
374
public String getConnectionStatistics () {
316
375
return monitor .getConnectionStatisticsBean ().dump ();
317
376
}
0 commit comments