001/*
002 * NullContext.java
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements.  See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership.  The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License.  You may obtain a copy of the License at
010 *
011 *     http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 */
019
020package org.apache.hadoop.metrics.spi;
021
022import org.apache.hadoop.classification.InterfaceAudience;
023import org.apache.hadoop.classification.InterfaceStability;
024
025/**
026 * Null metrics context: a metrics context which does nothing.  Used as the
027 * default context, so that no performance data is emitted if no configuration
028 * data is found.
029 * 
030 */
031@InterfaceAudience.Public
032@InterfaceStability.Evolving
033public class NullContext extends AbstractMetricsContext {
034    
035  /** Creates a new instance of NullContext */
036  @InterfaceAudience.Private
037  public NullContext() {
038  }
039    
040  /**
041   * Do-nothing version of startMonitoring
042   */
043  @Override
044  @InterfaceAudience.Private
045  public void startMonitoring() {
046  }
047    
048  /**
049   * Do-nothing version of emitRecord
050   */
051  @Override
052  @InterfaceAudience.Private
053  protected void emitRecord(String contextName, String recordName,
054                            OutputRecord outRec) 
055  {}
056    
057  /**
058   * Do-nothing version of update
059   */
060  @Override
061  @InterfaceAudience.Private
062  protected void update(MetricsRecordImpl record) {
063  }
064    
065  /**
066   * Do-nothing version of remove
067   */
068  @Override
069  @InterfaceAudience.Private
070  protected void remove(MetricsRecordImpl record) {
071  }
072}