Skip to content

Commit f977c0b

Browse files
committed
Added descriptions to endpoints, fixed compaction topN endpoint
1 parent 274dcfa commit f977c0b

File tree

4 files changed

+84
-15
lines changed

4 files changed

+84
-15
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@
1818
#
1919

2020
core/src/main/thrift-gen-java/** linguist-generated=true
21+
core/src/main/flatbuffers-gen-java/** linguist-generated=true

server/manager/src/main/java/org/apache/accumulo/manager/compaction/coordinator/CompactionCoordinator.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1130,11 +1130,12 @@ public TExternalCompactionMap getRunningCompactions(TInfo tinfo, TCredentials cr
11301130
}
11311131

11321132
/**
1133-
* Return topN longest running compactions for each resource group
1133+
* Return top 50 longest running compactions for each resource group
11341134
*
11351135
* @param tinfo trace info
11361136
* @param credentials tcredentials object
1137-
* @return map of group name to list of compactions in sorted order, oldest compaction first.
1137+
* @return map of group name to list of up to 50 compactions in sorted order, oldest compaction
1138+
* first.
11381139
* @throws ThriftSecurityException permission error
11391140
*/
11401141
@Override

server/monitor/src/main/java/org/apache/accumulo/monitor/next/Endpoints.java

+69-10
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@
1818
*/
1919
package org.apache.accumulo.monitor.next;
2020

21+
import java.lang.annotation.ElementType;
22+
import java.lang.annotation.Retention;
23+
import java.lang.annotation.RetentionPolicy;
24+
import java.lang.annotation.Target;
2125
import java.lang.reflect.Method;
2226
import java.util.Collection;
23-
import java.util.HashSet;
2427
import java.util.List;
2528
import java.util.Map;
2629
import java.util.Set;
30+
import java.util.TreeMap;
2731
import java.util.stream.Collectors;
2832

2933
import jakarta.inject.Inject;
@@ -53,6 +57,12 @@
5357
@Path("/")
5458
public class Endpoints {
5559

60+
@Target(ElementType.METHOD)
61+
@Retention(RetentionPolicy.RUNTIME)
62+
public @interface Description {
63+
String value();
64+
}
65+
5666
@Inject
5767
private Monitor monitor;
5868

@@ -66,45 +76,61 @@ private void validateResourceGroup(String resourceGroup) {
6676
@GET
6777
@Path("endpoints")
6878
@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+
*/
7187
final String basePath = request.getRequestURL().toString();
72-
final Set<String> endpoints = new HashSet<>();
88+
final Map<String,String> documentation = new TreeMap<>();
7389

7490
for (Method m : Endpoints.class.getMethods()) {
7591
if (m.isAnnotationPresent(Path.class)) {
7692
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);
78100
}
79101
}
80102

81-
return endpoints;
103+
return documentation;
82104
}
83105

84106
@GET
85107
@Path("groups")
86108
@Produces(MediaType.APPLICATION_JSON)
109+
@Description("Returns a list of the resource groups that are in use")
87110
public Set<String> getResourceGroups() {
88111
return monitor.getInformationFetcher().getSummary().getResourceGroups();
89112
}
90113

91114
@GET
92115
@Path("problems")
93116
@Produces(MediaType.APPLICATION_JSON)
117+
@Description("Returns a list of the servers that are potentially down")
94118
public Collection<ServerId> getProblemHosts() {
95119
return monitor.getInformationFetcher().getSummary().getProblemHosts();
96120
}
97121

98122
@GET
99123
@Path("metrics")
100124
@Produces(MediaType.APPLICATION_JSON)
125+
@Description("Returns the metric responses for all servers")
101126
public Collection<MetricResponse> getAll() {
102127
return monitor.getInformationFetcher().getAllMetrics().asMap().values();
103128
}
104129

105130
@GET
106131
@Path("manager")
107132
@Produces(MediaType.APPLICATION_JSON)
133+
@Description("Returns the metric response for the Manager")
108134
public MetricResponse getManager() {
109135
final ServerId s = monitor.getInformationFetcher().getSummary().getManager();
110136
if (s == null) {
@@ -116,6 +142,7 @@ public MetricResponse getManager() {
116142
@GET
117143
@Path("gc")
118144
@Produces(MediaType.APPLICATION_JSON)
145+
@Description("Returns the metric response for the Garbage Collector")
119146
public MetricResponse getGarbageCollector() {
120147
final ServerId s = monitor.getInformationFetcher().getSummary().getGarbageCollector();
121148
if (s == null) {
@@ -127,6 +154,7 @@ public MetricResponse getGarbageCollector() {
127154
@GET
128155
@Path("instance")
129156
@Produces(MediaType.APPLICATION_JSON)
157+
@Description("Returns the instance name, instance id, version, zookeepers, and volumes")
130158
public InstanceSummary getInstanceSummary() {
131159
return new InstanceSummary(monitor.getContext().getInstanceName(),
132160
monitor.getContext().instanceOperations().getInstanceId().canonical(),
@@ -139,6 +167,7 @@ public InstanceSummary getInstanceSummary() {
139167
@GET
140168
@Path("compactors/detail/{group}")
141169
@Produces(MediaType.APPLICATION_JSON)
170+
@Description("Returns the metric responses for the Compactors in the supplied resource group")
142171
public Collection<MetricResponse> getCompactors(@PathParam("group") String resourceGroup) {
143172
validateResourceGroup(resourceGroup);
144173
final Set<ServerId> servers = monitor.getInformationFetcher().getSummary()
@@ -152,6 +181,7 @@ public Collection<MetricResponse> getCompactors(@PathParam("group") String resou
152181
@GET
153182
@Path("compactors/summary/{group}")
154183
@Produces(MediaType.APPLICATION_JSON)
184+
@Description("Returns an aggregate view of the metric responses for the Compactors in the supplied resource group")
155185
public Map<Id,CumulativeDistributionSummary>
156186
getCompactorResourceGroupMetricSummary(@PathParam("group") String resourceGroup) {
157187
validateResourceGroup(resourceGroup);
@@ -166,13 +196,15 @@ public Collection<MetricResponse> getCompactors(@PathParam("group") String resou
166196
@GET
167197
@Path("compactors/summary")
168198
@Produces(MediaType.APPLICATION_JSON)
199+
@Description("Returns an aggregate view of the metric responses for all Compactors")
169200
public Map<Id,CumulativeDistributionSummary> getCompactorAllMetricSummary() {
170201
return monitor.getInformationFetcher().getSummary().getCompactorAllMetricSummary();
171202
}
172203

173204
@GET
174205
@Path("sservers/detail/{group}")
175206
@Produces(MediaType.APPLICATION_JSON)
207+
@Description("Returns the metric responses for the ScanServers in the supplied resource group")
176208
public Collection<MetricResponse> getScanServers(@PathParam("group") String resourceGroup) {
177209
validateResourceGroup(resourceGroup);
178210
final Set<ServerId> servers =
@@ -186,6 +218,7 @@ public Collection<MetricResponse> getScanServers(@PathParam("group") String reso
186218
@GET
187219
@Path("sservers/summary/{group}")
188220
@Produces(MediaType.APPLICATION_JSON)
221+
@Description("Returns an aggregate view of the metric responses for the ScanServers in the supplied resource group")
189222
public Map<Id,CumulativeDistributionSummary>
190223
getScanServerResourceGroupMetricSummary(@PathParam("group") String resourceGroup) {
191224
validateResourceGroup(resourceGroup);
@@ -200,13 +233,15 @@ public Collection<MetricResponse> getScanServers(@PathParam("group") String reso
200233
@GET
201234
@Path("sservers/summary")
202235
@Produces(MediaType.APPLICATION_JSON)
236+
@Description("Returns an aggregate view of the metric responses for all ScanServers")
203237
public Map<Id,CumulativeDistributionSummary> getScanServerAllMetricSummary() {
204238
return monitor.getInformationFetcher().getSummary().getSServerAllMetricSummary();
205239
}
206240

207241
@GET
208242
@Path("tservers/detail/{group}")
209243
@Produces(MediaType.APPLICATION_JSON)
244+
@Description("Returns the metric responses for the TabletServers in the supplied resource group")
210245
public Collection<MetricResponse> getTabletServers(@PathParam("group") String resourceGroup) {
211246
validateResourceGroup(resourceGroup);
212247
final Set<ServerId> servers =
@@ -220,6 +255,7 @@ public Collection<MetricResponse> getTabletServers(@PathParam("group") String re
220255
@GET
221256
@Path("tservers/summary/{group}")
222257
@Produces(MediaType.APPLICATION_JSON)
258+
@Description("Returns an aggregate view of the metric responses for the TabletServers in the supplied resource group")
223259
public Map<Id,CumulativeDistributionSummary>
224260
getTabletServerResourceGroupMetricSummary(@PathParam("group") String resourceGroup) {
225261
validateResourceGroup(resourceGroup);
@@ -234,41 +270,58 @@ public Collection<MetricResponse> getTabletServers(@PathParam("group") String re
234270
@GET
235271
@Path("tservers/summary")
236272
@Produces(MediaType.APPLICATION_JSON)
273+
@Description("Returns an aggregate view of the metric responses for all TabletServers")
237274
public Map<Id,CumulativeDistributionSummary> getTabletServerAllMetricSummary() {
238275
return monitor.getInformationFetcher().getSummary().getTServerAllMetricSummary();
239276
}
240277

241278
@GET
242279
@Path("compactions/summary")
243280
@Produces(MediaType.APPLICATION_JSON)
281+
@Description("Returns the metrics for all compaction queues")
244282
public Map<String,List<FMetric>> getCompactionMetricSummary() {
245283
return monitor.getInformationFetcher().getSummary().getCompactionMetricSummary();
246284
}
247285

248286
@GET
249287
@Path("compactions/detail")
250288
@Produces(MediaType.APPLICATION_JSON)
289+
@Description("Returns a map of Compactor resource group to the 50 oldest running compactions")
251290
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;
253297
}
254298

255299
@GET
256-
@Path("compactions/detail/{num}")
300+
@Path("compactions/detail/{group}")
257301
@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;
260311
}
261312

262313
@GET
263314
@Path("tables")
264315
@Produces(MediaType.APPLICATION_JSON)
316+
@Description("Returns a map of table name to table details")
265317
public Map<String,TableSummary> getTables() {
266318
return monitor.getInformationFetcher().getSummary().getTables();
267319
}
268320

269321
@GET
270322
@Path("tables/{name}")
271323
@Produces(MediaType.APPLICATION_JSON)
324+
@Description("Returns table details for the supplied table name")
272325
public TableSummary getTable(@PathParam("name") String tableName) {
273326
TableSummary ts = monitor.getInformationFetcher().getSummary().getTables().get(tableName);
274327
if (ts == null) {
@@ -280,6 +333,7 @@ public TableSummary getTable(@PathParam("name") String tableName) {
280333
@GET
281334
@Path("tables/{name}/tablets")
282335
@Produces(MediaType.APPLICATION_JSON)
336+
@Description("Returns tablet details for the supplied table name")
283337
public List<TabletInformation> getTablets(@PathParam("name") String tableName) {
284338
List<TabletInformation> ti = monitor.getInformationFetcher().getSummary().getTablets(tableName);
285339
if (ti == null) {
@@ -291,27 +345,32 @@ public List<TabletInformation> getTablets(@PathParam("name") String tableName) {
291345
@GET
292346
@Path("deployment")
293347
@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")
294350
public Map<String,Map<String,ProcessSummary>> getDeploymentOverview() {
295351
return monitor.getInformationFetcher().getSummary().getDeploymentOverview();
296352
}
297353

298354
@GET
299355
@Path("suggestions")
300356
@Produces(MediaType.APPLICATION_JSON)
357+
@Description("Returns a list of suggestions")
301358
public Set<String> getSuggestions() {
302359
return monitor.getInformationFetcher().getSummary().getSuggestions();
303360
}
304361

305362
@GET
306363
@Path("lastUpdate")
307364
@Produces(MediaType.APPLICATION_JSON)
365+
@Description("Returns the timestamp of when the monitor information was last refreshed")
308366
public long getTimestamp() {
309367
return monitor.getInformationFetcher().getSummary().getTimestamp();
310368
}
311369

312370
@GET
313371
@Path("stats")
314372
@Produces(MediaType.TEXT_PLAIN)
373+
@Description("Returns connection statistics for the Jetty server")
315374
public String getConnectionStatistics() {
316375
return monitor.getConnectionStatisticsBean().dump();
317376
}

server/monitor/src/main/java/org/apache/accumulo/monitor/next/SystemInformation.java

+11-3
Original file line numberDiff line numberDiff line change
@@ -551,14 +551,14 @@ public Map<String,List<FMetric>> getCompactionMetricSummary() {
551551
return this.queueMetrics;
552552
}
553553

554-
public Map<String,List<TExternalCompaction>> getCompactions(int topN) {
555-
Map<String,List<TExternalCompaction>> results = new HashMap<>();
554+
public Map<String,List<TExternalCompaction>> getCompactions() {
556555

557556
Map<String,TExternalCompactionList> oldest = oldestCompactions.get();
558557
if (oldest == null) {
559-
return results;
558+
return null;
560559
}
561560

561+
Map<String,List<TExternalCompaction>> results = new HashMap<>();
562562
for (Entry<String,TExternalCompactionList> e : oldest.entrySet()) {
563563
List<TExternalCompaction> compactions = e.getValue().getCompactions();
564564
if (compactions != null && compactions.size() > 0) {
@@ -568,6 +568,14 @@ public Map<String,List<TExternalCompaction>> getCompactions(int topN) {
568568
return results;
569569
}
570570

571+
public List<TExternalCompaction> getCompactions(String group) {
572+
TExternalCompactionList list = oldestCompactions.get().get(group);
573+
if (list == null) {
574+
return null;
575+
}
576+
return list.getCompactions();
577+
}
578+
571579
public Map<String,TableSummary> getTables() {
572580
return this.tables;
573581
}

0 commit comments

Comments
 (0)