com.codahale.metrics.health.SharedHealthCheckRegistries Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of metrics-healthchecks Show documentation
Show all versions of metrics-healthchecks Show documentation
An addition to Metrics which provides the ability to run application-specific health checks,
allowing you to check your application's heath in production.
package com.codahale.metrics.health;
import com.codahale.metrics.MetricRegistry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* A map of shared, named health registries.
*/
public class SharedHealthCheckRegistries {
private static final ConcurrentMap REGISTRIES =
new ConcurrentHashMap();
private SharedHealthCheckRegistries() { /* singleton */ }
public static void clear() {
REGISTRIES.clear();
}
public static Set names() {
return REGISTRIES.keySet();
}
public static void remove(String key) {
REGISTRIES.remove(key);
}
public static HealthCheckRegistry add(String name, HealthCheckRegistry registry) {
return REGISTRIES.putIfAbsent(name, registry);
}
public static HealthCheckRegistry getOrCreate(String name) {
final HealthCheckRegistry existing = REGISTRIES.get(name);
if (existing == null) {
final HealthCheckRegistry created = new HealthCheckRegistry();
final HealthCheckRegistry raced = add(name, created);
if (raced == null) {
return created;
}
return raced;
}
return existing;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy