Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
*
* Copyright 2016 jshook
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* /
*/
package io.engineblock.metrics;
import com.codahale.metrics.*;
import com.codahale.metrics.Timer;
import io.engineblock.script.ReadOnlyBindings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
import java.util.stream.Collectors;
public class MetricRegistryBindings extends ReadOnlyBindings implements MetricRegistryListener {
private final static Logger logger = LoggerFactory.getLogger(MetricRegistryBindings.class);
private final MetricRegistry registry;
private MetricMap metricMap = new MetricMap("ROOT");
private boolean failfast = true;
public MetricRegistryBindings(MetricRegistry registry) {
this.registry = registry;
registry.addListener(this);
}
@Override
public int size() {
return metricMap.map.size();
}
@Override
public boolean isEmpty() {
return metricMap.map.isEmpty();
}
@Override
public boolean containsKey(Object key) {
return metricMap.map.containsKey(key);
}
@Override
public boolean containsValue(Object value) {
return metricMap.map.containsValue(value);
}
@Override
public Object get(Object key) {
Object got = metricMap.map.get(key);
if (got==null) {
throw new RuntimeException("Attempted to get metrics node with name '" + key + "', but it was not found. Perhaps you were looking for one of its children: "
+ this.keySet().stream().collect(Collectors.joining(",","[","]")));
}
return got;
}
@Override
public Set keySet() {
return metricMap.map.keySet();
}
@Override
public Collection