dev.jfr4jdbc.internal.ResourceMonitorManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jfr4jdbc-driver Show documentation
Show all versions of jfr4jdbc-driver Show documentation
A JDBC wrapper driver recording JDK Flight Recorder events
package dev.jfr4jdbc.internal;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
public class ResourceMonitorManager {
private static final Map instances = new ConcurrentHashMap<>(1);
private final Map monitors = new ConcurrentHashMap<>();
public static final ResourceMonitorManager getInstance(ResourceMonitorKind kind) {
return instances.computeIfAbsent(kind, k -> new ResourceMonitorManager());
}
public ResourceMonitor getMonitor(String label) {
return this.monitors.computeIfAbsent(label, id -> new ResourceMonitor(id));
}
public List getMonitors() {
return this.monitors.entrySet().stream().map(e -> e.getValue()).collect(Collectors.toList());
}
public void addMonitor(ResourceMonitor monitor) {
this.monitors.put(monitor.getLabel(), monitor);
}
public void removeMonitor(ResourceMonitor monitor) {
this.monitors.remove(monitor.getLabel());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy