Java源码示例:com.newrelic.metrics.publish.processors.EpochCounter
示例1
public Processor getProcessorForNode(String id, String nodeName)
{
String key = getProcessorKey(id, nodeName);
if (!processors.containsKey(key)) {
processors.put(key, new EpochCounter());
}
return processors.get(key);
}
示例2
public Processor getProcessor(String key)
{
if (!processors.containsKey(key)) {
processors.put(key, new EpochCounter());
}
return processors.get(key);
}
示例3
public MetricMeta(boolean isCounter, String unit) {
this.unit = unit;
if (isCounter) {
this.counter = new EpochCounter();
}
}
示例4
public MetricMeta(boolean isCounter) {
this.unit = isCounter ? DEFAULT_COUNTER_UNIT : DEFAULT_UNIT;
if (isCounter) {
this.counter = new EpochCounter();
}
}
示例5
public EpochCounter getCounter() {
return this.counter;
}
示例6
private Metric getMetric(Element n) throws ParseException {
String type = n.getElementsByTagName("type").item(0) != null ? n.getElementsByTagName("type").item(0).getTextContent() : null;
String ident = n.getElementsByTagName("ident").item(0) != null ? n.getElementsByTagName("ident").item(0).getTextContent() : null;
String name = n.getElementsByTagName("name").item(0) != null ? n.getElementsByTagName("name").item(0).getTextContent() : null;
String description = n.getElementsByTagName("description").item(0) != null ? n.getElementsByTagName("description").item(0).getTextContent()
: null;
String value = n.getElementsByTagName("value").item(0) != null ? n.getElementsByTagName("value").item(0).getTextContent() : null;
String flag = n.getElementsByTagName("flag").item(0) != null ? n.getElementsByTagName("flag").item(0).getTextContent() : null;
StringBuilder key = new StringBuilder();
key.append("Varnish/");
// does it have a custom group?
String group = getGroup(name);
if (group != null) {
key.append(group + "/");
} else if (type != null)
key.append(type + "/");
else {
key.append("main/");
int pos = name.indexOf("_");
if (pos != -1) {
key.append(name.substring(0, pos) + "/");
}
}
if (ident != null)
key.append(ident + "/");
key.append(description);
String actualKey = key.toString();
if ("a".equals(flag)) {
if (!epochCounters.containsKey(actualKey)) {
epochCounters.put(actualKey, new EpochCounter());
}
return new Metric(actualKey, getUnitName(name) + "/sec", epochCounters.get(actualKey).process(NumberFormat.getInstance().parse(value)));
} else {
return new Metric(actualKey, getUnitName(name), NumberFormat.getInstance().parse(value));
}
}