001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019package org.apache.hadoop.metrics.spi; 020 021import org.apache.hadoop.classification.InterfaceAudience; 022import org.apache.hadoop.classification.InterfaceStability; 023import org.apache.hadoop.metrics.ContextFactory; 024 025/** 026 * A null context which has a thread calling 027 * periodically when monitoring is started. This keeps the data sampled 028 * correctly. 029 * In all other respects, this is like the NULL context: No data is emitted. 030 * This is suitable for Monitoring systems like JMX which reads the metrics 031 * when someone reads the data from JMX. 032 * 033 * The default impl of start and stop monitoring: 034 * is the AbstractMetricsContext is good enough. 035 * 036 * @deprecated Use org.apache.hadoop.metrics2 package instead. 037 */ 038@Deprecated 039@InterfaceAudience.Public 040@InterfaceStability.Evolving 041public class NullContextWithUpdateThread extends AbstractMetricsContext { 042 043 private static final String PERIOD_PROPERTY = "period"; 044 045 /** Creates a new instance of NullContextWithUpdateThread */ 046 @InterfaceAudience.Private 047 public NullContextWithUpdateThread() { 048 } 049 050 @Override 051 @InterfaceAudience.Private 052 public void init(String contextName, ContextFactory factory) { 053 super.init(contextName, factory); 054 parseAndSetPeriod(PERIOD_PROPERTY); 055 } 056 057 058 /** 059 * Do-nothing version of emitRecord 060 */ 061 @Override 062 @InterfaceAudience.Private 063 protected void emitRecord(String contextName, String recordName, 064 OutputRecord outRec) 065 {} 066 067 /** 068 * Do-nothing version of update 069 */ 070 @Override 071 @InterfaceAudience.Private 072 protected void update(MetricsRecordImpl record) { 073 } 074 075 /** 076 * Do-nothing version of remove 077 */ 078 @Override 079 @InterfaceAudience.Private 080 protected void remove(MetricsRecordImpl record) { 081 } 082}