1 | /* |
---|
2 | * OutputRecord.java |
---|
3 | * |
---|
4 | * Licensed to the Apache Software Foundation (ASF) under one |
---|
5 | * or more contributor license agreements. See the NOTICE file |
---|
6 | * distributed with this work for additional information |
---|
7 | * regarding copyright ownership. The ASF licenses this file |
---|
8 | * to you under the Apache License, Version 2.0 (the |
---|
9 | * "License"); you may not use this file except in compliance |
---|
10 | * with the License. You may obtain a copy of the License at |
---|
11 | * |
---|
12 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
13 | * |
---|
14 | * Unless required by applicable law or agreed to in writing, software |
---|
15 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
17 | * See the License for the specific language governing permissions and |
---|
18 | * limitations under the License. |
---|
19 | */ |
---|
20 | |
---|
21 | package org.apache.hadoop.metrics.spi; |
---|
22 | |
---|
23 | import java.util.Collections; |
---|
24 | import java.util.Set; |
---|
25 | import org.apache.hadoop.metrics.spi.AbstractMetricsContext.MetricMap; |
---|
26 | import org.apache.hadoop.metrics.spi.AbstractMetricsContext.TagMap; |
---|
27 | |
---|
28 | /** |
---|
29 | * Represents a record of metric data to be sent to a metrics system. |
---|
30 | */ |
---|
31 | public class OutputRecord { |
---|
32 | |
---|
33 | private TagMap tagMap; |
---|
34 | private MetricMap metricMap; |
---|
35 | |
---|
36 | /** Creates a new instance of OutputRecord */ |
---|
37 | OutputRecord(TagMap tagMap, MetricMap metricMap) { |
---|
38 | this.tagMap = tagMap; |
---|
39 | this.metricMap = metricMap; |
---|
40 | } |
---|
41 | |
---|
42 | /** |
---|
43 | * Returns the set of tag names |
---|
44 | */ |
---|
45 | public Set<String> getTagNames() { |
---|
46 | return Collections.unmodifiableSet(tagMap.keySet()); |
---|
47 | } |
---|
48 | |
---|
49 | /** |
---|
50 | * Returns a tag object which is can be a String, Integer, Short or Byte. |
---|
51 | * |
---|
52 | * @return the tag value, or null if there is no such tag |
---|
53 | */ |
---|
54 | public Object getTag(String name) { |
---|
55 | return tagMap.get(name); |
---|
56 | } |
---|
57 | |
---|
58 | /** |
---|
59 | * Returns the set of metric names. |
---|
60 | */ |
---|
61 | public Set<String> getMetricNames() { |
---|
62 | return Collections.unmodifiableSet(metricMap.keySet()); |
---|
63 | } |
---|
64 | |
---|
65 | /** |
---|
66 | * Returns the metric object which can be a Float, Integer, Short or Byte. |
---|
67 | */ |
---|
68 | public Number getMetric(String name) { |
---|
69 | return metricMap.get(name); |
---|
70 | } |
---|
71 | |
---|
72 | } |
---|