Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.codahale.metrics;
 
 import java.util.Set;
A map of shared, named metric registries.
 
public class SharedMetricRegistries {
    private static final ConcurrentMap<StringMetricRegistryREGISTRIES =
            new ConcurrentHashMap<StringMetricRegistry>();
    private SharedMetricRegistries() { /* singleton */ }
    public static void clear() {
        .clear();
    }
    public static Set<Stringnames() {
        return .keySet();
    }
    public static void remove(String key) {
        .remove(key);
    }
    public static MetricRegistry add(String nameMetricRegistry registry) {
        return .putIfAbsent(nameregistry);
    }
    public static MetricRegistry getOrCreate(String name) {
        final MetricRegistry existing = .get(name);
        if (existing == null) {
            final MetricRegistry created = new MetricRegistry();
            final MetricRegistry raced = add(namecreated);
            if (raced == null) {
                return created;
            }
            return raced;
        }
        return existing;
    }
New to GrepCode? Check out our FAQ X