-
Notifications
You must be signed in to change notification settings - Fork 480
Modified Endpoints for multiple managers and new compaction summary #6251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
4f3a5c2
0766af4
103ca61
6a7ee3a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.Comparator; | ||
| import java.util.HashMap; | ||
| import java.util.HashSet; | ||
| import java.util.Iterator; | ||
| import java.util.List; | ||
|
|
@@ -348,6 +349,23 @@ public Stream<RunningCompactionInfo> stream() { | |
|
|
||
| } | ||
|
|
||
| public record CompactionSummary(Map<TableId,Long> tableCompactions, | ||
| Map<String,Long> groupCompactions, | ||
| Map<ServerId,Map<String,List<FMetric>>> compactionQueueMetrics) { | ||
|
|
||
| public List<FMetric> getQueueMetrics(String resourceGroup) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I look at the json output for this I am seeing "tableCompactions": {
"1": 6
},
"groupCompactions": {
"ci_small": 3,
"ci_lrg": 3
}, {
"name": "accumulo.compaction.queue.jobs.queued",
"type": "GAUGE",
"tags": [
{
"queue.id": "ci.small"
},
{
"statistic": "value"
}
],
"value": 0
}
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Looks right. I'm surprised we are not using that method in more places. I'll create a ticket for it. For now, suggest not using |
||
| final List<FMetric> metrics = new ArrayList<>(); | ||
| this.compactionQueueMetrics().forEach((k, v) -> { | ||
| v.forEach((k2, v2) -> { | ||
| if (k2.equals(resourceGroup)) { | ||
| metrics.addAll(v2); | ||
| } | ||
| }); | ||
| }); | ||
| return metrics; | ||
| } | ||
| }; | ||
|
|
||
| private static final Logger LOG = LoggerFactory.getLogger(SystemInformation.class); | ||
|
|
||
| private final DistributionStatisticConfig DSC = | ||
|
|
@@ -361,7 +379,7 @@ public Stream<RunningCompactionInfo> stream() { | |
| private final Set<String> resourceGroups = ConcurrentHashMap.newKeySet(); | ||
| private final Set<ServerId> problemHosts = ConcurrentHashMap.newKeySet(); | ||
| private final Set<ServerId> metricProblemHosts = ConcurrentHashMap.newKeySet(); | ||
| private final AtomicReference<ServerId> manager = new AtomicReference<>(); | ||
| private final Set<ServerId> managers = ConcurrentHashMap.newKeySet(); | ||
| private final AtomicReference<ServerId> gc = new AtomicReference<>(); | ||
|
|
||
| // index of resource group name to set of servers | ||
|
|
@@ -388,7 +406,8 @@ public Stream<RunningCompactionInfo> stream() { | |
| new ConcurrentHashMap<>(); | ||
|
|
||
| // Compaction Information | ||
| private final Map<String,List<FMetric>> queueMetrics = new ConcurrentHashMap<>(); | ||
| private final AtomicReference<CompactionSummary> compactionSummary = new AtomicReference<>(); | ||
|
|
||
| private volatile Set<ServerId> registeredCompactors = Set.of(); | ||
| private volatile HostAndPort coordinatorHost; | ||
|
|
||
|
|
@@ -426,6 +445,8 @@ public SystemInformation(Cache<ServerId,MetricResponse> allMetrics, ServerContex | |
| public void clear() { | ||
| resourceGroups.clear(); | ||
| problemHosts.clear(); | ||
| managers.clear(); | ||
| gc.set(null); | ||
| metricProblemHosts.clear(); | ||
| compactors.clear(); | ||
| sservers.clear(); | ||
|
|
@@ -436,9 +457,9 @@ public void clear() { | |
| rgCompactorMetrics.clear(); | ||
| rgSServerMetrics.clear(); | ||
| rgTServerMetrics.clear(); | ||
| queueMetrics.clear(); | ||
| registeredCompactors = Set.of(); | ||
| coordinatorHost = null; | ||
| compactionSummary.set(null); | ||
| longRunningCompactionsByRg.clear(); | ||
| tables.clear(); | ||
| tablets.clear(); | ||
|
|
@@ -486,20 +507,35 @@ private void updateAggregates(final MetricResponse response, | |
|
|
||
| } | ||
|
|
||
| private void createCompactionSummary(MetricResponse response) { | ||
| if (response.getMetrics() != null) { | ||
| for (final ByteBuffer binary : response.getMetrics()) { | ||
| FMetric fm = FMetric.getRootAsFMetric(binary); | ||
| for (int i = 0; i < fm.tagsLength(); i++) { | ||
| FTag t = fm.tags(i); | ||
| if (t.key().equals("queue.id")) { | ||
| queueMetrics | ||
| .computeIfAbsent(t.value(), (k) -> Collections.synchronizedList(new ArrayList<>())) | ||
| .add(fm); | ||
| private void createCompactionSummary() { | ||
|
|
||
| Map<TableId,Long> tableCompactions = new HashMap<>(); | ||
| runningCompactionsPerTable.forEach((k, v) -> tableCompactions.put(k, v.sum())); | ||
|
|
||
| Map<String,Long> groupCompactions = new HashMap<>(); | ||
| runningCompactionsPerGroup.forEach((k, v) -> groupCompactions.put(k, v.sum())); | ||
|
|
||
| Map<ServerId,Map<String,List<FMetric>>> coordinatorMetrics = new HashMap<>(); | ||
|
|
||
| for (ServerId manager : managers) { | ||
| MetricResponse managerMetrics = allMetrics.getIfPresent(manager); | ||
| if (managerMetrics.getMetrics() != null) { | ||
| Map<String,List<FMetric>> queueMetrics = new HashMap<>(); | ||
| for (final ByteBuffer binary : managerMetrics.getMetrics()) { | ||
| FMetric fm = FMetric.getRootAsFMetric(binary); | ||
| for (int i = 0; i < fm.tagsLength(); i++) { | ||
| FTag t = fm.tags(i); | ||
| if (t.key().equals("queue.id")) { | ||
| queueMetrics.computeIfAbsent(t.value(), | ||
| (k) -> Collections.synchronizedList(new ArrayList<>())).add(fm); | ||
| } | ||
| } | ||
| } | ||
| coordinatorMetrics.put(manager, queueMetrics); | ||
| } | ||
| } | ||
| compactionSummary | ||
| .set(new CompactionSummary(tableCompactions, groupCompactions, coordinatorMetrics)); | ||
| } | ||
|
|
||
| public void processResponse(final ServerId server, final MetricResponse response) { | ||
|
|
@@ -522,10 +558,7 @@ public void processResponse(final ServerId server, final MetricResponse response | |
| } | ||
| break; | ||
| case MANAGER: | ||
| if (manager.get() == null || !manager.get().equals(server)) { | ||
| manager.set(server); | ||
| } | ||
| createCompactionSummary(response); | ||
| managers.add(server); | ||
| break; | ||
| case SCAN_SERVER: | ||
| sservers.computeIfAbsent(response.getResourceGroup(), (rg) -> ConcurrentHashMap.newKeySet()) | ||
|
|
@@ -595,6 +628,9 @@ public void finish() { | |
| deployment.computeIfAbsent(serverId.getResourceGroup(), g -> new ConcurrentHashMap<>()) | ||
| .computeIfAbsent(serverId.getType(), t -> new ProcessSummary()).addNotResponded(serverId); | ||
| }); | ||
| // Create a summary of compaction information | ||
| createCompactionSummary(); | ||
|
|
||
| for (SystemTables table : SystemTables.values()) { | ||
| TableConfiguration tconf = this.ctx.getTableConfiguration(table.tableId()); | ||
| String balancerRG = tconf.get(TableLoadBalancer.TABLE_ASSIGNMENT_GROUP_PROPERTY); | ||
|
|
@@ -606,7 +642,7 @@ public void finish() { | |
| } | ||
| for (String rg : getResourceGroups()) { | ||
| Set<ServerId> rgCompactors = getCompactorResourceGroupServers(rg); | ||
| List<FMetric> metrics = queueMetrics.get(rg); | ||
| List<FMetric> metrics = compactionSummary.get().getQueueMetrics(rg); | ||
| if (metrics == null || metrics.isEmpty()) { | ||
| continue; | ||
| } | ||
|
|
@@ -667,8 +703,8 @@ public Set<ServerId> getProblemHosts() { | |
| return this.problemHosts; | ||
| } | ||
|
|
||
| public ServerId getManager() { | ||
| return this.manager.get(); | ||
| public Set<ServerId> getManagers() { | ||
| return this.managers; | ||
| } | ||
|
|
||
| public ServerId getGarbageCollector() { | ||
|
|
@@ -714,8 +750,8 @@ public Map<Id,CumulativeDistributionSummary> getTServerAllMetricSummary() { | |
| return this.totalTServerMetrics; | ||
| } | ||
|
|
||
| public Map<String,List<FMetric>> getCompactionMetricSummary() { | ||
| return this.queueMetrics; | ||
| public CompactionSummary getCompactionMetricSummary() { | ||
| return this.compactionSummary.get(); | ||
| } | ||
|
|
||
| public Set<ServerId> getCompactorServers() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.accumulo.monitor.next.serializers; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| import org.apache.accumulo.core.client.admin.servers.ServerId; | ||
|
|
||
| import com.fasterxml.jackson.core.JsonGenerator; | ||
| import com.fasterxml.jackson.databind.JsonSerializer; | ||
| import com.fasterxml.jackson.databind.SerializerProvider; | ||
|
|
||
| public class ServerIdSerializer extends JsonSerializer<ServerId> { | ||
|
|
||
| @Override | ||
| public void serialize(ServerId value, JsonGenerator gen, SerializerProvider serializers) | ||
| throws IOException { | ||
| StringBuilder buf = new StringBuilder(); | ||
| buf.append("type=").append(value.getType().name()).append(";group=") | ||
| .append(value.getResourceGroup().canonical()).append(";address=") | ||
| .append(value.toHostPortString()); | ||
| gen.writeFieldName(buf.toString()); | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would probably be easier on the front end code to roll the metrics up. Could do something like the following.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the list above should be maps.