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 @InterfaceAudience.Private 051 public void init(String contextName, ContextFactory factory) { 052 super.init(contextName, factory); 053 parseAndSetPeriod(PERIOD_PROPERTY); 054 } 055 056 057 /** 058 * Do-nothing version of emitRecord 059 */ 060 @InterfaceAudience.Private 061 protected void emitRecord(String contextName, String recordName, 062 OutputRecord outRec) 063 {} 064 065 /** 066 * Do-nothing version of update 067 */ 068 @InterfaceAudience.Private 069 protected void update(MetricsRecordImpl record) { 070 } 071 072 /** 073 * Do-nothing version of remove 074 */ 075 @InterfaceAudience.Private 076 protected void remove(MetricsRecordImpl record) { 077 } 078}