![JAR search and dependency download from the Maven repository](/logo.png)
com.nitorcreations.willow.metrics.ChildCpuMetric Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of willow-servers Show documentation
Show all versions of willow-servers Show documentation
Willow operational servlets and servers
The newest version!
package com.nitorcreations.willow.metrics;
import static com.nitorcreations.willow.metrics.MetricUtils.median;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.inject.Named;
import com.nitorcreations.willow.messages.ProcessCPU;
import com.nitorcreations.willow.messages.metrics.MetricConfig;
@Named("/childcpu")
public class ChildCpuMetric extends FullMessageMultiseriesMetric {
private static final String categoryPrefix = "category_processcpu_";
@Override
protected void addValue(Map> values, List preceeding, long stepTime, int stepLen, MetricConfig conf) {
HashMap> data = new HashMap<>();
for (ProcessCPU next : preceeding) {
String childName = next.getFirstTagWithPrefix(categoryPrefix);
if (childName != null) {
childName = childName.substring(categoryPrefix.length());
}
List nextData = data.get(childName);
if (nextData == null) {
nextData = new ArrayList();
data.put(childName, nextData);
}
nextData.add(next.getPercent());
}
for (Entry> next : data.entrySet()) {
SeriesData result = values.get(next.getKey());
if (result == null) {
result = new SeriesData<>();
result.key = next.getKey();
values.put(next.getKey(), result);
}
Point nextPoint = new Point<>();
nextPoint.x = stepTime;
nextPoint.y = median(next.getValue());
result.values.add(nextPoint);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy