001/*
002 * OutputRecord.java
003 *
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *     http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020
021package org.apache.hadoop.metrics.spi;
022
023import java.util.Collections;
024import java.util.Set;
025import org.apache.hadoop.classification.InterfaceAudience;
026import org.apache.hadoop.classification.InterfaceStability;
027import org.apache.hadoop.metrics.spi.AbstractMetricsContext.MetricMap;
028import org.apache.hadoop.metrics.spi.AbstractMetricsContext.TagMap;
029
030/**
031 * Represents a record of metric data to be sent to a metrics system.
032 *
033 * @deprecated Use org.apache.hadoop.metrics2 package instead.
034 */
035@Deprecated
036@InterfaceAudience.Public
037@InterfaceStability.Evolving
038public class OutputRecord {
039    
040  private TagMap tagMap;
041  private MetricMap metricMap;
042    
043  /** Creates a new instance of OutputRecord */
044  OutputRecord(TagMap tagMap, MetricMap metricMap) {
045    this.tagMap = tagMap;
046    this.metricMap = metricMap;
047  }
048    
049  /**
050   * Returns the set of tag names
051   */
052  public Set<String> getTagNames() {
053    return Collections.unmodifiableSet(tagMap.keySet());
054  }
055    
056  /**
057   * Returns a tag object which is can be a String, Integer, Short or Byte.
058   *
059   * @return the tag value, or null if there is no such tag
060   */
061  public Object getTag(String name) {
062    return tagMap.get(name);
063  }
064    
065  /**
066   * Returns the set of metric names.
067   */
068  public Set<String> getMetricNames() {
069    return Collections.unmodifiableSet(metricMap.keySet());
070  }
071    
072  /**
073   * Returns the metric object which can be a Float, Integer, Short or Byte.
074   */
075  public Number getMetric(String name) {
076    return metricMap.get(name);
077  }
078  
079
080  /**
081   * Returns a copy of this record's tags.
082   */
083  public TagMap getTagsCopy() {
084    return new TagMap(tagMap);
085  }
086  
087  /**
088   * Returns a copy of this record's metrics.
089   */
090  public MetricMap getMetricsCopy() {
091    return new MetricMap(metricMap);
092  }
093}