@@ -0,0 +1,2422 @@
+/*%0A * Copyright 2015 Timothy Brooks%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage net.uncontended.precipice.metrics.registry;%0A%0Aimport net.uncontended.precipice.PrecipiceFunction;%0Aimport net.uncontended.precipice.Service;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0Aimport java.util.concurrent.Executors;%0Aimport java.util.concurrent.ScheduledExecutorService;%0Aimport java.util.concurrent.TimeUnit;%0A%0Apublic class MetricRegistry %7B%0A%0A    private Map%3CString, Summary%3E services = new HashMap%3C%3E();%0A    private volatile PrecipiceFunction%3CMap%3CString, Summary%3E%3E callback;%0A    // TODO: Name thread%0A    private ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();%0A%0A    public MetricRegistry() %7B%0A        executorService.scheduleAtFixedRate(new Task(), 0, 10, TimeUnit.SECONDS);%0A    %7D%0A%0A    public void register(Service service) %7B%0A        services.put(service.getName(), new Summary(service));%0A    %7D%0A%0A    public Summary getSummary(String name) %7B%0A        Summary summary = services.get(name);%0A        if (summary == null) %7B%0A            throw new IllegalArgumentException(%22Service: %22 + name + %22 not registered.%22);%0A        %7D%0A        return summary;%0A    %7D%0A%0A    public void setUpdateCallback(PrecipiceFunction%3CMap%3CString, Summary%3E%3E callback) %7B%0A        this.callback = callback;%0A    %7D%0A%0A    public void shutdown() %7B%0A        executorService.shutdown();%0A    %7D%0A%0A%0A    private static class Summary %7B%0A        private final Service service;%0A%0A        private Summary(Service service) %7B%0A            this.service = service;%0A        %7D%0A%0A        private void refresh() %7B%0A%0A        %7D%0A    %7D%0A%0A    private class Task implements Runnable %7B%0A%0A        @Override%0A        public void run() %7B%0A            for (Summary summary : services.values()) %7B%0A                summary.refresh();%0A            %7D%0A%0A            if (callback != null) %7B%0A                callback.apply(services);%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

Add class for the new metric registry