hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r1077597 [1/6] - in /hadoop/common/branches/branch-0.20-security-patches: ./ conf/ ivy/ src/core/org/apache/hadoop/ipc/ src/core/org/apache/hadoop/ipc/metrics/ src/core/org/apache/hadoop/log/ src/core/org/apache/hadoop/metrics/ src/core/org...
Date Fri, 04 Mar 2011 04:34:00 GMT
Author: omalley
Date: Fri Mar  4 04:33:55 2011
New Revision: 1077597

URL: http://svn.apache.org/viewvc?rev=1077597&view=rev
Log:
commit 69743903766896b29354e8ecc1b60a15e74b57b8
Author: Arun C Murthy <acmurthy@apache.org>
Date:   Fri Jul 23 18:58:10 2010 -0700

    HADOOP-6728. Re-design and overhaul of the Metrics framework. Contributed by Luke Lu.
    
    +++ b/YAHOO-CHANGES.txt
    +    HADOOP-6728. Re-design and overhaul of the Metrics framework. (Luke Lu via
    +    acmurthy)
    +

Added:
    hadoop/common/branches/branch-0.20-security-patches/conf/hadoop-metrics2.properties
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/metrics/RpcInstrumentation.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/log/EventCounter.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/Metric.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricCounter.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricGauge.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsBuilder.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsException.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsFilter.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsPlugin.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsRecord.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsRecordBuilder.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsSink.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsSource.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsSystem.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsSystemMXBean.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsTag.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsVisitor.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/filter/
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/filter/AbstractPatternFilter.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/filter/GlobFilter.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/filter/RegexFilter.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/impl/
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/impl/Consumer.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/impl/MBeanInfoBuilder.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/impl/MetricCounterInt.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/impl/MetricCounterLong.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/impl/MetricGaugeDouble.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/impl/MetricGaugeFloat.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/impl/MetricGaugeInt.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/impl/MetricGaugeLong.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/impl/MetricsBuffer.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/impl/MetricsBufferBuilder.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/impl/MetricsBuilderImpl.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/impl/MetricsConfig.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/impl/MetricsConfigException.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/impl/MetricsRecordBuilderImpl.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/impl/MetricsRecordFiltered.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/impl/MetricsRecordImpl.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/impl/MetricsSinkAdapter.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/impl/MetricsSourceAdapter.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/impl/MetricsSystemImpl.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/impl/SinkQueue.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/lib/
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/lib/AbstractMetricsSource.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/lib/DefaultMetricsSystem.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/lib/MetricMutable.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/lib/MetricMutableCounter.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/lib/MetricMutableCounterInt.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/lib/MetricMutableCounterLong.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/lib/MetricMutableFactory.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/lib/MetricMutableGauge.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/lib/MetricMutableGaugeInt.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/lib/MetricMutableGaugeLong.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/lib/MetricMutableStat.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/lib/MetricsRegistry.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/package.html
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/sink/
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/sink/FileSink.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/source/
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/source/JvmMetricsSource.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/util/
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/util/Contracts.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/util/MBeans.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/util/SampleStat.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/util/TryIterator.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/security/UgiInstrumentation.java
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/datanode/metrics/DataNodeInstrumentation.java
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/namenode/metrics/NameNodeInstrumentation.java
    hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/InfoMap.java
    hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/JobTrackerMXBean.java
    hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/JobTrackerMetricsSource.java
    hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/ShuffleServerInstrumentation.java
    hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/TaskTrackerMXBean.java
    hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/TaskTrackerMetricsSource.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/metrics2/
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/metrics2/filter/
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/metrics2/filter/TestPatternFilter.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/metrics2/impl/
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/metrics2/impl/ConfigBuilder.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/metrics2/impl/ConfigUtil.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/metrics2/impl/TestMetricsBuilderImpl.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/metrics2/impl/TestMetricsConfig.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/metrics2/impl/TestMetricsSystemImpl.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/metrics2/impl/TestMetricsVisitor.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/metrics2/impl/TestSinkQueue.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/metrics2/lib/
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/metrics2/lib/TestMetricMutables.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/metrics2/lib/TestMetricsRegistry.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/metrics2/util/
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/metrics2/util/TestSampleStat.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/metrics2/util/TestTryIterator.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/test/MetricsAsserts.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/test/MoreAsserts.java
Removed:
    hadoop/common/branches/branch-0.20-security-patches/conf/hadoop-metrics.properties
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/metrics/RpcActivityMBean.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/metrics/RpcDetailedActivityMBean.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/metrics/RpcDetailedMetrics.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/metrics/RpcMetrics.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/metrics/RpcMgt.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/metrics/RpcMgtMBean.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/ContextFactory.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/MetricsContext.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/MetricsException.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/MetricsRecord.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/MetricsUtil.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/Updater.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/file/FileContext.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/file/package.html
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/ganglia/GangliaContext.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/ganglia/package.html
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/jvm/EventCounter.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/jvm/JvmMetrics.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/package.html
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/spi/AbstractMetricsContext.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/spi/CompositeContext.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/spi/MetricValue.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/spi/MetricsRecordImpl.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/spi/NullContext.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/spi/NullContextWithUpdateThread.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/spi/OutputRecord.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/spi/Util.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/spi/package.html
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/util/MBeanUtil.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/util/MetricsBase.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/util/MetricsDynamicMBeanBase.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/util/MetricsIntValue.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/util/MetricsLongValue.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/util/MetricsRegistry.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/util/MetricsTimeVaryingInt.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/util/MetricsTimeVaryingLong.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics/util/MetricsTimeVaryingRate.java
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/datanode/metrics/DataNodeActivityMBean.java
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/datanode/metrics/DataNodeMetrics.java
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/namenode/metrics/FSNamesystemMetrics.java
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/namenode/metrics/NameNodeActivtyMBean.java
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/namenode/metrics/NameNodeMetrics.java
    hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/JobTrackerMetricsInst.java
    hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/TaskTrackerMetricsInst.java
Modified:
    hadoop/common/branches/branch-0.20-security-patches/conf/log4j.properties
    hadoop/common/branches/branch-0.20-security-patches/ivy.xml
    hadoop/common/branches/branch-0.20-security-patches/ivy/libraries.properties
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/RPC.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/Server.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/security/UserGroupInformation.java
    hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/util/StringUtils.java
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/datanode/BlockReceiver.java
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataBlockScanner.java
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataNode.java
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/datanode/DataXceiver.java
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/datanode/FSDataset.java
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/namenode/NameNode.java
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java
    hadoop/common/branches/branch-0.20-security-patches/src/mapred/mapred-default.xml
    hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/Child.java
    hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/JobInProgress.java
    hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/JobTracker.java
    hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/JobTrackerInstrumentation.java
    hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/LocalJobRunner.java
    hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/ReduceTask.java
    hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/TaskTracker.java
    hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/TaskTrackerInstrumentation.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/hdfs/server/datanode/SimulatedFSDataset.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMetrics.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/hdfs/server/namenode/TestSaveNamespace.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/hdfs/server/namenode/metrics/TestNNMetricFilesInGetListingOps.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/hdfs/server/namenode/metrics/TestNameNodeMetrics.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/ipc/TestRPC.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/security/TestUserGroupInformation.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/util/TestStringUtils.java

Added: hadoop/common/branches/branch-0.20-security-patches/conf/hadoop-metrics2.properties
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/conf/hadoop-metrics2.properties?rev=1077597&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/conf/hadoop-metrics2.properties (added)
+++ hadoop/common/branches/branch-0.20-security-patches/conf/hadoop-metrics2.properties Fri Mar  4 04:33:55 2011
@@ -0,0 +1,3 @@
+#[prefix].[source|sink|jmx].[instance].[options]
+#namenode.sink.file0.class=org.apache.hadoop.metrics2.sink.FileSink
+#namenode.sink.file0.filename=nn.out

Modified: hadoop/common/branches/branch-0.20-security-patches/conf/log4j.properties
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/conf/log4j.properties?rev=1077597&r1=1077596&r2=1077597&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/conf/log4j.properties (original)
+++ hadoop/common/branches/branch-0.20-security-patches/conf/log4j.properties Fri Mar  4 04:33:55 2011
@@ -115,7 +115,7 @@ log4j.logger.org.jets3t.service.impl.res
 # Event Counter Appender
 # Sends counts of logging messages at different severity levels to Hadoop Metrics.
 #
-log4j.appender.EventCounter=org.apache.hadoop.metrics.jvm.EventCounter
+log4j.appender.EventCounter=org.apache.hadoop.log.EventCounter
 
 #
 # Job Summary Appender

Modified: hadoop/common/branches/branch-0.20-security-patches/ivy.xml
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/ivy.xml?rev=1077597&r1=1077596&r2=1077597&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/ivy.xml (original)
+++ hadoop/common/branches/branch-0.20-security-patches/ivy.xml Fri Mar  4 04:33:55 2011
@@ -126,6 +126,16 @@
       rev="${commons-net.version}"
       conf="ftp->default"/>
 
+    <dependency org="commons-configuration"
+      name="commons-configuration"
+      rev="${commons-configuration.version}"
+      conf="common->default"/>
+
+    <dependency org="org.apache.commons"
+      name="commons-math"
+      rev="${commons-math.version}"
+      conf="common->default"/>
+
     <!--Configuration: Jetty -->
 
 <!-- <dependency org="javax.servlet"

Modified: hadoop/common/branches/branch-0.20-security-patches/ivy/libraries.properties
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/ivy/libraries.properties?rev=1077597&r1=1077596&r2=1077597&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/ivy/libraries.properties (original)
+++ hadoop/common/branches/branch-0.20-security-patches/ivy/libraries.properties Fri Mar  4 04:33:55 2011
@@ -27,11 +27,13 @@ checkstyle.version=4.2
 commons-cli.version=1.2
 commons-codec.version=1.4
 commons-collections.version=3.1
+commons-configuration.version=1.6
 commons-daemon.version=1.0.1
 commons-httpclient.version=3.0.1
 commons-lang.version=2.4
 commons-logging.version=1.0.4
 commons-logging-api.version=1.0.4
+commons-math.version=2.1
 commons-el.version=1.0
 commons-fileupload.version=1.2
 commons-io.version=1.4
@@ -41,8 +43,7 @@ coreplugin.version=1.3.2
 
 hsqldb.version=1.8.0.10
 
-#ivy.version=2.0.0-beta2
-ivy.version=2.0.0-rc2
+ivy.version=2.1.0
 
 jasper.version=5.5.12
 #not able to figureout the version of jsp & jsp-api version to get it resolved throught ivy
@@ -61,7 +62,7 @@ kfs.version=0.1
 log4j.version=1.2.15
 lucene-core.version=2.3.1
 
-mockito-all.version=1.8.0
+mockito-all.version=1.8.5
 
 oro.version=2.0.8
 

Modified: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/RPC.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/RPC.java?rev=1077597&r1=1077596&r2=1077597&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/RPC.java (original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/RPC.java Fri Mar  4 04:33:55 2011
@@ -41,7 +41,6 @@ import org.apache.hadoop.security.UserGr
 import org.apache.hadoop.security.token.SecretManager;
 import org.apache.hadoop.security.token.TokenIdentifier;
 import org.apache.hadoop.conf.*;
-import org.apache.hadoop.metrics.util.MetricsTimeVaryingRate;
 
 import org.apache.hadoop.net.NetUtils;
 
@@ -528,24 +527,9 @@ public class RPC {
                     " queueTime= " + qTime +
                     " procesingTime= " + processingTime);
         }
-        rpcMetrics.rpcQueueTime.inc(qTime);
-        rpcMetrics.rpcProcessingTime.inc(processingTime);
-
-        MetricsTimeVaryingRate m =
-         (MetricsTimeVaryingRate) rpcDetailedMetrics.registry.get(call.getMethodName());
-      	if (m == null) {
-      	  try {
-      	    m = new MetricsTimeVaryingRate(call.getMethodName(),
-      	                                        rpcDetailedMetrics.registry);
-      	  } catch (IllegalArgumentException iae) {
-      	    // the metrics has been registered; re-fetch the handle
-      	    LOG.info("Error register " + call.getMethodName(), iae);
-      	    m = (MetricsTimeVaryingRate) rpcDetailedMetrics.registry.get(
-      	        call.getMethodName());
-      	  }
-      	}
-        m.inc(processingTime);
-
+        rpcMetrics.addRpcQueueTime(qTime);
+        rpcMetrics.addRpcProcessingTime(processingTime);
+        rpcMetrics.addRpcProcessingTime(call.getMethodName(), processingTime);
         if (verbose) log("Return: "+value);
 
         return new ObjectWritable(method.getReturnType(), value);

Modified: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/Server.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/Server.java?rev=1077597&r1=1077596&r2=1077597&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/Server.java (original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/Server.java Fri Mar  4 04:33:55 2011
@@ -66,8 +66,7 @@ import org.apache.hadoop.io.IntWritable;
 import static org.apache.hadoop.fs.CommonConfigurationKeys.*;
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.io.WritableUtils;
-import org.apache.hadoop.ipc.metrics.RpcDetailedMetrics;
-import org.apache.hadoop.ipc.metrics.RpcMetrics;
+import org.apache.hadoop.ipc.metrics.RpcInstrumentation;
 import org.apache.hadoop.security.AccessControlException;
 import org.apache.hadoop.security.SaslRpcServer;
 import org.apache.hadoop.security.SaslRpcServer.SaslStatus;
@@ -187,8 +186,7 @@ public abstract class Server {
                                                   // connections to nuke
                                                   //during a cleanup
   
-  protected RpcMetrics rpcMetrics;
-  protected RpcDetailedMetrics rpcDetailedMetrics;
+  protected RpcInstrumentation rpcMetrics;
   
   private Configuration conf;
   private SecretManager<TokenIdentifier> secretManager;
@@ -245,7 +243,7 @@ public abstract class Server {
    * Returns a handle to the rpcMetrics (required in tests)
    * @return rpc metrics
    */
-  public RpcMetrics getRpcMetrics() {
+  public RpcInstrumentation getRpcMetrics() {
     return rpcMetrics;
   }
 
@@ -1019,7 +1017,7 @@ public abstract class Server {
           }
           doSaslReply(SaslStatus.ERROR, null, sendToClient.getClass().getName(), 
               sendToClient.getLocalizedMessage());
-          rpcMetrics.authenticationFailures.inc();
+          rpcMetrics.incrAuthenticationFailures();
           String clientIP = this.toString();
           // attempting user could be null
           AUDITLOG.warn(AUTH_FAILED_FOR + clientIP + ":" + attemptingUser);
@@ -1039,7 +1037,7 @@ public abstract class Server {
           useWrap = qop != null && !"auth".equalsIgnoreCase(qop);
           user = getAuthorizedUgi(saslServer.getAuthorizationID());
           LOG.info("SASL server successfully authenticated client: " + user);
-          rpcMetrics.authenticationSuccesses.inc();
+          rpcMetrics.incrAuthenticationSuccesses();
           AUDITLOG.info(AUTH_SUCCESSFULL_FOR + user);
           saslContextEstablished = true;
         }
@@ -1319,9 +1317,9 @@ public abstract class Server {
         if (LOG.isDebugEnabled()) {
           LOG.debug("Successfully authorized " + header);
         }
-        rpcMetrics.authorizationSuccesses.inc();
+        rpcMetrics.incrAuthorizationSuccesses();
       } catch (AuthorizationException ae) {
-        rpcMetrics.authorizationFailures.inc();
+        rpcMetrics.incrAuthorizationFailures();
         setupResponse(authFailedResponse, authFailedCall, Status.FATAL, null,
             ae.getClass().getName(), ae.getMessage());
         responder.doRespond(authFailedCall);
@@ -1480,10 +1478,7 @@ public abstract class Server {
     // Start the listener here and let it bind to the port
     listener = new Listener();
     this.port = listener.getAddress().getPort();    
-    this.rpcMetrics = new RpcMetrics(serverName,
-                          Integer.toString(this.port), this);
-    this.rpcDetailedMetrics = new RpcDetailedMetrics(serverName,
-                            Integer.toString(this.port));
+    this.rpcMetrics = RpcInstrumentation.create(serverName, this.port);
     this.tcpNoDelay = conf.getBoolean("ipc.server.tcpnodelay", false);
 
     // Create the responder here
@@ -1603,9 +1598,6 @@ public abstract class Server {
     if (this.rpcMetrics != null) {
       this.rpcMetrics.shutdown();
     }
-    if (this.rpcDetailedMetrics != null) {
-      this.rpcDetailedMetrics.shutdown();
-    }
   }
 
   /** Wait for the server to be stopped.
@@ -1704,7 +1696,7 @@ public abstract class Server {
     int count =  (buffer.remaining() <= NIO_BUFFER_LIMIT) ?
                  channel.write(buffer) : channelIO(null, channel, buffer);
     if (count > 0) {
-      rpcMetrics.sentBytes.inc(count);
+      rpcMetrics.incrSentBytes(count);
     }
     return count;
   }
@@ -1724,7 +1716,7 @@ public abstract class Server {
     int count = (buffer.remaining() <= NIO_BUFFER_LIMIT) ?
                 channel.read(buffer) : channelIO(channel, null, buffer);
     if (count > 0) {
-      rpcMetrics.receivedBytes.inc(count);
+      rpcMetrics.incrReceivedBytes(count);
     }
     return count;
   }

Added: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/metrics/RpcInstrumentation.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/metrics/RpcInstrumentation.java?rev=1077597&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/metrics/RpcInstrumentation.java (added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/ipc/metrics/RpcInstrumentation.java Fri Mar  4 04:33:55 2011
@@ -0,0 +1,210 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ipc.metrics;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.metrics2.MetricsBuilder;
+import org.apache.hadoop.metrics2.MetricsSource;
+import org.apache.hadoop.metrics2.MetricsSystem;
+import org.apache.hadoop.metrics2.lib.AbstractMetricsSource;
+import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
+import org.apache.hadoop.metrics2.lib.MetricMutableCounterInt;
+import org.apache.hadoop.metrics2.lib.MetricMutableCounterLong;
+import org.apache.hadoop.metrics2.lib.MetricMutableGaugeInt;
+import org.apache.hadoop.metrics2.lib.MetricMutableStat;
+import org.apache.hadoop.metrics2.lib.MetricsRegistry;
+
+/**
+ * The RPC metrics instrumentation
+ */
+public class RpcInstrumentation implements MetricsSource {
+
+  static final Log LOG = LogFactory.getLog(RpcInstrumentation.class);
+
+  final MetricsRegistry registry = new MetricsRegistry("rpc");
+  final MetricMutableCounterInt authenticationSuccesses =
+      registry.newCounter("rpcAuthenticationSuccesses",
+                          "RPC authentication successes count", 0);
+  final MetricMutableCounterInt authenticationFailures =
+      registry.newCounter("rpcAuthenticationFailures",
+                          "RPC authentication failures count", 0);
+  final MetricMutableCounterInt authorizationSuccesses =
+      registry.newCounter("rpcAuthorizationSuccesses",
+                          "RPC authorization successes count", 0);
+  final MetricMutableCounterInt authorizationFailures =
+      registry.newCounter("rpcAuthorizationFailures",
+                          "RPC authorization failures count", 0);
+  final MetricMutableCounterLong receivedBytes =
+      registry.newCounter("ReceivedBytes", "RPC received bytes count", 0L);
+  final MetricMutableCounterLong sentBytes =
+      registry.newCounter("SentBytes", "RPC sent bytes count", 0L);
+  final MetricMutableStat rpcQueueTime = registry.newStat("RpcQueueTime",
+      "RPC queue time stats", "ops", "time");
+  final MetricMutableStat rpcProcessingTime = registry.newStat(
+      "RpcProcessingTime", "RPC processing time", "ops", "time");
+  final MetricMutableGaugeInt numOpenConnections = registry.newGauge(
+      "NumOpenConnections", "Number of open connections", 0);
+  final MetricMutableGaugeInt callQueueLen = registry.newGauge("callQueueLen",
+      "RPC call queue length", 0);
+
+  final Detailed detailed;
+
+  RpcInstrumentation(String serverName, int port) {
+    String portStr = String.valueOf(port);
+    registry.setContext("rpc").tag("port", "RPC port", portStr);
+    detailed = new Detailed(portStr);
+  }
+
+  @Override
+  public void getMetrics(MetricsBuilder builder, boolean all) {
+    registry.snapshot(builder.addRecord(registry.name()), all);
+  }
+
+  /**
+   * Create an RPC instrumentation object
+   * @param serverName  name of the server
+   * @param port  the RPC port
+   * @return the instrumentation object
+   */
+  public static RpcInstrumentation create(String serverName, int port) {
+    return create(serverName, port, DefaultMetricsSystem.INSTANCE);
+  }
+
+  /**
+   * Create an RPC instrumentation object
+   * Mostly useful for testing.
+   * @param serverName  name of the server
+   * @param port  the RPC port
+   * @param ms  the metrics system object
+   * @return the instrumentation object
+   */
+  public static RpcInstrumentation create(String serverName, int port,
+                                          MetricsSystem ms) {
+    RpcInstrumentation rpc = new RpcInstrumentation(serverName, port);
+    ms.register("RpcDetailedActivityForPort"+ port, "Per call", rpc.detailed());
+    return ms.register("RpcActivityForPort"+ port, "Aggregate metrics", rpc);
+  }
+
+  /**
+   * @return the detailed (per call) metrics source for RPC
+   */
+  public MetricsSource detailed() {
+    return detailed;
+  }
+
+  // Start of public instrumentation methods that could be extracted to an
+  // abstract class if we decide to allow custom instrumentation classes a la
+  // JobTrackerInstrumenation.
+
+  /**
+   * One authentication failure event
+   */
+  public void incrAuthenticationFailures() {
+    this.authenticationFailures.incr();
+  }
+
+  /**
+   * One authentication success event
+   */
+  public void incrAuthenticationSuccesses() {
+    this.authenticationSuccesses.incr();
+  }
+
+  /**
+   * One authorization success event
+   */
+  public void incrAuthorizationSuccesses() {
+    this.authorizationSuccesses.incr();
+  }
+
+  /**
+   * One authorization failure event
+   */
+  public void incrAuthorizationFailures() {
+    this.authorizationFailures.incr();
+  }
+
+  /**
+   * Shutdown the instrumentation for the process
+   */
+  public void shutdown() {
+    LOG.info("shut down");
+  }
+
+  /**
+   * Increment sent bytes by count
+   * @param count to increment
+   */
+  public void incrSentBytes(int count) {
+    this.sentBytes.incr(count);
+  }
+
+  /**
+   * Increment received bytes by count
+   * @param count to increment
+   */
+  public void incrReceivedBytes(int count) {
+    this.receivedBytes.incr(count);
+  }
+
+  /**
+   * Add an RPC queue time sample
+   * @param qTime
+   */
+  public void addRpcQueueTime(int qTime) {
+    this.rpcQueueTime.add(qTime);
+  }
+
+  /**
+   * Add an RPC processing time sample
+   * @param processingTime
+   */
+  public void addRpcProcessingTime(int processingTime) {
+    this.rpcProcessingTime.add(processingTime);
+  }
+
+  /**
+   * Add an RPC processing time sample for a particular RPC method
+   * @param methodName  method name of the RPC
+   * @param processingTime  elapsed processing time of the RPC
+   */
+  public void addRpcProcessingTime(String methodName, int processingTime) {
+    detailed.addRpcProcessingTime(methodName, processingTime);
+  }
+
+  /**
+   * Use a separate source for detailed (per call) RPC metrics for
+   * easy and efficient filtering
+   */
+  public static class Detailed extends AbstractMetricsSource {
+
+    Detailed(String port) {
+      super("rpcdetailed");
+      registry.setContext("rpcdetailed").tag("port", "RPC port", port);
+    }
+
+    public synchronized void addRpcProcessingTime(String methodName,
+                                                  int processingTime) {
+      registry.add(methodName, processingTime);
+    }
+
+  }
+
+}

Added: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/log/EventCounter.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/log/EventCounter.java?rev=1077597&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/log/EventCounter.java (added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/log/EventCounter.java Fri Mar  4 04:33:55 2011
@@ -0,0 +1,92 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.log;
+
+import org.apache.log4j.AppenderSkeleton;
+import org.apache.log4j.Level;
+import org.apache.log4j.spi.LoggingEvent;
+
+/**
+ * A log4J Appender that simply counts logging events in three levels:
+ * fatal, error and warn.
+ */
+public class EventCounter extends AppenderSkeleton {
+        
+    private static final int FATAL = 0;
+    private static final int ERROR = 1;
+    private static final int WARN  = 2;
+    private static final int INFO  = 3;
+    
+    private static class EventCounts {
+        private final long[] counts = { 0, 0, 0, 0 };
+    
+        private synchronized void incr(int i) { 
+            ++counts[i]; 
+        }
+        
+        private synchronized long get(int i) { 
+            return counts[i]; 
+        }
+    }
+    private static EventCounts counts = new EventCounts();
+    
+    public static long getFatal() { 
+        return counts.get(FATAL); 
+    }
+    
+    public static long getError() { 
+        return counts.get(ERROR); 
+    }
+    
+    public static long getWarn() { 
+        return counts.get(WARN);  
+    }
+    
+    public static long getInfo() {
+        return counts.get(INFO);
+    }
+    
+    public void append(LoggingEvent event) {
+        Level level = event.getLevel();
+        if (level == Level.INFO) {
+            counts.incr(INFO);
+        }
+        else if (level == Level.WARN) {
+            counts.incr(WARN);
+        }
+        else if (level == Level.ERROR) {
+            counts.incr(ERROR);
+        }
+        else if (level == Level.FATAL) {
+            counts.incr(FATAL);
+        }
+
+    }
+    
+    // Strange: these two methods are abstract in AppenderSkeleton, but not
+    // included in the javadoc (log4j 1.2.13).
+    
+    public void close() {
+    }
+    public boolean requiresLayout() {
+        return false;
+    }
+    
+    
+    
+}

Added: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/Metric.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/Metric.java?rev=1077597&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/Metric.java (added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/Metric.java Fri Mar  4 04:33:55 2011
@@ -0,0 +1,108 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.metrics2;
+
+/**
+ * The immutable metric
+ */
+public abstract class Metric {
+
+  public static final String NO_DESCRIPTION = "<<no description>>";
+  private final String name;
+  private final String description;
+
+  /**
+   * Construct the metric with name only
+   * @param name  of the metric
+   */
+  public Metric(String name) {
+    this.name = name;
+    this.description = NO_DESCRIPTION;
+  }
+
+  /**
+   * Construct the metric with a name and a description
+   * @param name  of the metric
+   * @param desc  description of the metric
+   */
+  public Metric(String name, String desc) {
+    this.name = name;
+    this.description = desc;
+  }
+
+  /**
+   * Get the name of the metric
+   * @return  the name
+   */
+  public String name() {
+    return name;
+  }
+
+  /**
+   * Get the description of the metric
+   * @return  the description
+   */
+  public String description() {
+    return description;
+  }
+
+  /**
+   * Get the value of the metric
+   * @return  the value of the metric
+   */
+  public abstract Number value();
+
+  /**
+   * Accept a visitor interface
+   * @param visitor of the metric
+   */
+  public abstract void visit(MetricsVisitor visitor);
+
+  // Mostly for testing
+  @Override public boolean equals(Object obj) {
+    if (obj == null) {
+      return false;
+    }
+    if (getClass() != obj.getClass()) {
+      return false;
+    }
+    final Metric other = (Metric) obj;
+    if (!this.name.equals(other.name())) {
+      return false;
+    }
+    if (!this.description.equals(other.description())) {
+      return false;
+    }
+    if (!value().equals(other.value())) {
+      return false;
+    }
+    return true;
+  }
+
+  @Override public int hashCode() {
+    return name.hashCode();
+  }
+
+  @Override
+  public String toString() {
+    return "Metric{" + "name='" + name + "' description='" + description +
+           "' value="+ value() +'}';
+  }
+
+}

Added: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricCounter.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricCounter.java?rev=1077597&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricCounter.java (added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricCounter.java Fri Mar  4 04:33:55 2011
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.metrics2;
+
+/**
+ * A generic immutable counter metric type
+ * @param <T> value type of the metric
+ */
+public abstract class MetricCounter<T extends Number> extends Metric {
+
+  /**
+   * Construct a counter metric
+   * @param name  of the metric
+   * @param description of the metric
+   */
+  public MetricCounter(String name, String description) {
+    super(name, description);
+  }
+
+  public abstract T value();
+
+}

Added: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricGauge.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricGauge.java?rev=1077597&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricGauge.java (added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricGauge.java Fri Mar  4 04:33:55 2011
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.metrics2;
+
+/**
+ * A generic immutable gauge metric
+ * @param <T> value type of the metric
+ */
+public abstract class MetricGauge<T extends Number> extends Metric {
+
+  /**
+   * Construct a gauge metric
+   * @param name  of the metric
+   * @param description of the metric
+   */
+  public MetricGauge(String name, String description) {
+    super(name, description);
+  }
+
+  public abstract T value();
+}

Added: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsBuilder.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsBuilder.java?rev=1077597&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsBuilder.java (added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsBuilder.java Fri Mar  4 04:33:55 2011
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.metrics2;
+
+/**
+ * The metrics builder interface
+ */
+public interface MetricsBuilder {
+
+  /**
+   * Add a metrics record
+   * @param name  of the record
+   * @return  a metrics record builder for the record
+   */
+  public MetricsRecordBuilder addRecord(String name);
+
+}

Added: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsException.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsException.java?rev=1077597&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsException.java (added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsException.java Fri Mar  4 04:33:55 2011
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.metrics2;
+
+/**
+ * A general metrics exception wrapper
+ */
+public class MetricsException extends RuntimeException {
+  private static final long serialVersionUID = 1L;
+
+  /**
+   * Construct the exception with a message
+   * @param message for the exception
+   */
+  public MetricsException(String message) {
+    super(message);
+  }
+
+  /**
+   * Construct the exception with a message and a cause
+   * @param message for the exception
+   * @param cause of the exception
+   */
+  public MetricsException(String message, Throwable cause) {
+    super(message, cause);
+  }
+
+  /**
+   * Construct the exception with a cause
+   * @param cause of the exception
+   */
+  public MetricsException(Throwable cause) {
+    super(cause);
+  }
+}

Added: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsFilter.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsFilter.java?rev=1077597&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsFilter.java (added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsFilter.java Fri Mar  4 04:33:55 2011
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.metrics2;
+
+import org.apache.commons.configuration.SubsetConfiguration;
+
+/**
+ * The metrics filter interface
+ */
+public abstract class MetricsFilter implements MetricsPlugin {
+
+  public abstract void init(SubsetConfiguration conf);
+
+  /**
+   * Whether to accept the name
+   * @param name  to filter on
+   * @return  true to accept; false otherwise.
+   */
+  public abstract boolean accepts(String name);
+
+  /**
+   * Whether to accept the tag
+   * @param tag to filter on
+   * @return  true to accept; false otherwise
+   */
+  public abstract boolean accepts(MetricsTag tag);
+
+  /**
+   * Whether to accept the tags
+   * @param tags to filter on
+   * @return  true to accept; false otherwise
+   */
+  public abstract boolean accepts(Iterable<MetricsTag> tags);
+
+  /**
+   * Whether to accept the record
+   * @param record  to filter on
+   * @return  true to accept; false otherwise.
+   */
+  public boolean accepts(MetricsRecord record) {
+    return accepts(record.tags());
+  }
+
+}

Added: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsPlugin.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsPlugin.java?rev=1077597&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsPlugin.java (added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsPlugin.java Fri Mar  4 04:33:55 2011
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.metrics2;
+
+import org.apache.commons.configuration.SubsetConfiguration;
+
+/**
+ * A fairly generic plugin interface
+ */
+public interface MetricsPlugin {
+
+  /**
+   * Initialize the plugin
+   * @param conf  the configuration object for the plugin
+   */
+  void init(SubsetConfiguration conf);
+
+}

Added: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsRecord.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsRecord.java?rev=1077597&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsRecord.java (added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsRecord.java Fri Mar  4 04:33:55 2011
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.metrics2;
+
+/**
+ * An immutable snapshot of metrics with a timestamp
+ */
+public interface MetricsRecord {
+  /**
+   * Get the timestamp of the metrics
+   * @return  the timestamp
+   */
+  long timestamp();
+
+  /**
+   * Get the record name of the metrics
+   * @return  the record name
+   */
+  String name();
+
+  /**
+   * Get the context name of the metrics
+   * @return  the context name
+   */
+  String context();
+
+  /**
+   * Get the tags of the record
+   * @return  the tags
+   */
+  Iterable<MetricsTag> tags();
+
+  /**
+   * Get the metrics of the record
+   * @return  the metrics
+   */
+  Iterable<Metric> metrics();
+
+}

Added: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsRecordBuilder.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsRecordBuilder.java?rev=1077597&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsRecordBuilder.java (added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsRecordBuilder.java Fri Mar  4 04:33:55 2011
@@ -0,0 +1,121 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.metrics2;
+
+/**
+ * The metrics record builder interface
+ */
+public abstract class MetricsRecordBuilder {
+
+  /**
+   * Add a metrics tag
+   * @param name  of the tag
+   * @param description of the tag
+   * @param value of the tag
+   * @return  self
+   */
+  public abstract MetricsRecordBuilder tag(String name, String description,
+                                           String value);
+
+  /**
+   * Add an immutable metrics tag object
+   * @param tag a pre-made tag object (potentially save an object construction)
+   * @return  self
+   */
+  public abstract MetricsRecordBuilder add(MetricsTag tag);
+
+  /**
+   * Set the context tag
+   * @param value of the context
+   * @return  self
+   */
+  public abstract MetricsRecordBuilder setContext(String value);
+
+  /**
+   * Add an int counter metric
+   * @param name  of the metric
+   * @param description of the metric
+   * @param value of the metric
+   * @return  self
+   */
+  public abstract MetricsRecordBuilder addCounter(String name,
+                                                  String description,
+                                                  int value);
+
+  /**
+   * Add an long counter metric
+   * @param name  of the metric
+   * @param description of the metric
+   * @param value of the metric
+   * @return  self
+   */
+  public abstract MetricsRecordBuilder addCounter(String name,
+                                                  String description,
+                                                  long value);
+
+  /**
+   * Add a int gauge metric
+   * @param name  of the metric
+   * @param description of the metric
+   * @param value of the metric
+   * @return  self
+   */
+  public abstract MetricsRecordBuilder addGauge(String name,
+                                                String description, int value);
+
+  /**
+   * Add a long gauge metric
+   * @param name  of the metric
+   * @param description of the metric
+   * @param value of the metric
+   * @return  self
+   */
+  public abstract MetricsRecordBuilder addGauge(String name,
+                                                String description, long value);
+
+  /**
+   * Add a float gauge metric
+   * @param name  of the metric
+   * @param description of the metric
+   * @param value of the metric
+   * @return  self
+   */
+  public abstract MetricsRecordBuilder addGauge(String name,
+                                                String description,
+                                                float value);
+
+  /**
+   * Add a double gauge metric
+   * @param name  of the metric
+   * @param description of the metric
+   * @param value of the metric
+   * @return  self
+   */
+  public abstract MetricsRecordBuilder addGauge(String name,
+                                                String description,
+                                                double value);
+
+  /**
+   * Add a pre-made immutable metric object
+   * @param metric  the pre-made metric to save an object construction
+   * @return  self
+   */
+  public abstract MetricsRecordBuilder add(Metric metric);
+
+}

Added: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsSink.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsSink.java?rev=1077597&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsSink.java (added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsSink.java Fri Mar  4 04:33:55 2011
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.metrics2;
+
+/**
+ * The metrics sink interface
+ */
+public interface MetricsSink extends MetricsPlugin {
+
+  /**
+   * Put a metrics record in the sink
+   * @param record  the record to put
+   */
+  void putMetrics(MetricsRecord record);
+
+  /**
+   * Flush any buffered metrics
+   */
+  void flush();
+
+}

Added: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsSource.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsSource.java?rev=1077597&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsSource.java (added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsSource.java Fri Mar  4 04:33:55 2011
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.metrics2;
+
+/**
+ * The metrics source interface
+ */
+public interface MetricsSource {
+
+  /**
+   * Get metrics from the source
+   * @param builder to contain the resulting metrics snapshot
+   * @param all     if true, return all metrics even if unchanged.
+   */
+  void getMetrics(MetricsBuilder builder, boolean all);
+
+}

Added: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsSystem.java?rev=1077597&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsSystem.java (added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsSystem.java Fri Mar  4 04:33:55 2011
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.metrics2;
+
+/**
+ * The metrics system interface
+ */
+public interface MetricsSystem extends MetricsSystemMXBean {
+
+  /**
+   * Register a metrics source
+   * @param <T>   the type of the source
+   * @param source  to register
+   * @param name  of the source. Must be unique.
+   * @param desc  the description of the source.
+   * @return the source
+   * @exception MetricsException
+   */
+  <T extends MetricsSource> T register(String name, String desc, T source);
+
+  /**
+   * Register a metrics sink
+   * @param <T>   the type of the sink
+   * @param sink  to register
+   * @param name  of the sink. Must be unique.
+   * @param desc  the description of the sink
+   * @return the sink
+   * @exception MetricsException
+   */
+  <T extends MetricsSink> T register(String name, String desc, T sink);
+
+  /**
+   * Register a callback interface for JMX events
+   * @param callback  the callback object implementing the MBean interface.
+   */
+  void register(Callback callback);
+
+  /**
+   * Shutdown the metrics system completely (usually during server shutdown.)
+   * The MetricsSystemMXBean will be unregistered.
+   */
+  void shutdown();
+
+  /**
+   * The metrics system callback interface
+   */
+  @SuppressWarnings("PublicInnerClass")
+  static interface Callback {
+
+    /**
+     * Called before start()
+     */
+    void preStart();
+
+    /**
+     * Called after start()
+     */
+    void postStart();
+
+    /**
+     * Called before stop()
+     */
+    void preStop();
+
+    /**
+     * Called after stop()
+     */
+    void postStop();
+
+  }
+
+  /**
+   * Convenient abstract class for implementing callback interface
+   */
+  @SuppressWarnings("PublicInnerClass")
+  public static abstract class AbstractCallback implements Callback {
+
+    public void preStart() {}
+    public void postStart() {}
+    public void preStop() {}
+    public void postStop() {}
+
+  }
+
+}

Added: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsSystemMXBean.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsSystemMXBean.java?rev=1077597&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsSystemMXBean.java (added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsSystemMXBean.java Fri Mar  4 04:33:55 2011
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.metrics2;
+
+/**
+ * The JMX interface to the metrics system
+ */
+public interface MetricsSystemMXBean {
+
+  /**
+   * Start the metrics system
+   * @exception MetricsException
+   */
+  public void start();
+
+  /**
+   * Stop the metrics system
+   * @exception MetricsException
+   */
+  public void stop();
+
+  /**
+   * Force a refresh of MBeans
+   * @exception MetricsException
+   */
+  public void refreshMBeans();
+
+  /**
+   * @return the current config
+   * Note, avoid getConfig, as it'll turn it into an attribute,
+   * which doesn't support multiple lines in the values.
+   * @exception MetricsException
+   */
+  public String currentConfig();
+
+}

Added: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsTag.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsTag.java?rev=1077597&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsTag.java (added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsTag.java Fri Mar  4 04:33:55 2011
@@ -0,0 +1,99 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.metrics2;
+
+/**
+ * Immutable tag for metrics (for grouping on host/queue/username etc.)
+ */
+public class MetricsTag {
+
+  private final String name;
+  private final String description;
+  private final String value;
+
+  /**
+   * Construct the tag with name, description and value
+   * @param name  of the tag
+   * @param description of the tag
+   * @param value of the tag
+   */
+  public MetricsTag(String name, String description, String value) {
+    this.name = name;
+    this.description = description;
+    this.value = value;
+  }
+
+  /**
+   * Get the name of the tag
+   * @return  the name
+   */
+  public String name() {
+    return name;
+  }
+
+  /**
+   * Get the description of the tag
+   * @return  the description
+   */
+  public String description() {
+    return description;
+  }
+
+  /**
+   * Get the value of the tag
+   * @return  the value
+   */
+  public String value() {
+    return value;
+  }
+
+  // Mostly for testing
+  @Override
+  public boolean equals(Object obj) {
+    if (obj == null) {
+      return false;
+    }
+    if (getClass() != obj.getClass()) {
+      return false;
+    }
+    final MetricsTag other = (MetricsTag) obj;
+    if (!this.name.equals(other.name())) {
+      return false;
+    }
+    if (!this.description.equals(other.description())) {
+      return false;
+    }
+    if (!this.value.equals(other.value())) {
+      return false;
+    }
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    return name.hashCode() ^ value.hashCode();
+  }
+
+  @Override
+  public String toString() {
+    return "MetricsTag{" + "name='" + name + "' description='" + description +
+           "' value='" + value + "'}";
+  }
+
+}

Added: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsVisitor.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsVisitor.java?rev=1077597&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsVisitor.java (added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/MetricsVisitor.java Fri Mar  4 04:33:55 2011
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.metrics2;
+
+/**
+ * A visitor interface for metrics
+ */
+public interface MetricsVisitor {
+
+  /**
+   * Callback for int value gauges
+   * @param metric the metric object
+   * @param value of the metric
+   */
+  public void gauge(MetricGauge<Integer> metric, int value);
+
+  /**
+   * Callback for long value gauges
+   * @param metric the metric object
+   * @param value of the metric
+   */
+  public void gauge(MetricGauge<Long> metric, long value);
+
+  /**
+   * Callback for float value gauges
+   * @param metric the metric object
+   * @param value of the metric
+   */
+  public void gauge(MetricGauge<Float> metric, float value);
+
+  /**
+   * Callback for double value gauges
+   * @param metric the metric object
+   * @param value of the metric
+   */
+  public void gauge(MetricGauge<Double> metric, double value);
+
+  /**
+   * Callback for integer value counters
+   * @param metric the metric object
+   * @param value of the metric
+   */
+  public void counter(MetricCounter<Integer> metric, int value);
+
+  /**
+   * Callback for long value counters
+   * @param metric the metric object
+   * @param value of the metric
+   */
+  public void counter(MetricCounter<Long> metric, long value);
+
+}

Added: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/filter/AbstractPatternFilter.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/filter/AbstractPatternFilter.java?rev=1077597&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/filter/AbstractPatternFilter.java (added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/filter/AbstractPatternFilter.java Fri Mar  4 04:33:55 2011
@@ -0,0 +1,165 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.metrics2.filter;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.commons.configuration.SubsetConfiguration;
+import org.apache.hadoop.metrics2.MetricsException;
+import org.apache.hadoop.metrics2.MetricsFilter;
+import org.apache.hadoop.metrics2.MetricsRecord;
+import org.apache.hadoop.metrics2.MetricsTag;
+
+/**
+ * Base class for pattern based filters
+ */
+abstract class AbstractPatternFilter extends MetricsFilter {
+
+  protected static final String INCLUDE_KEY = "include";
+  protected static final String EXCLUDE_KEY = "exclude";
+  protected static final String INCLUDE_TAGS_KEY = "include.tags";
+  protected static final String EXCLUDE_TAGS_KEY = "exclude.tags";
+
+  private Pattern includePattern;
+  private Pattern excludePattern;
+  private final Map<String, Pattern> includeTagPatterns;
+  private final Map<String, Pattern> excludeTagPatterns;
+  private final Pattern tagPattern = Pattern.compile("^(\\w+):(.*)");
+
+  AbstractPatternFilter() {
+    includeTagPatterns = new HashMap<String, Pattern>();
+    excludeTagPatterns = new HashMap<String, Pattern>();
+  }
+
+  @Override
+  public void init(SubsetConfiguration conf) {
+    String patternString = conf.getString(INCLUDE_KEY);
+    if (patternString != null && !patternString.isEmpty()) {
+      setIncludePattern(compile(patternString));
+    }
+    patternString = conf.getString(EXCLUDE_KEY);
+    if (patternString != null && !patternString.isEmpty()) {
+      setExcludePattern(compile(patternString));
+    }
+    String[] patternStrings = conf.getStringArray(INCLUDE_TAGS_KEY);
+    if (patternStrings != null && patternStrings.length != 0) {
+      for (String pstr : patternStrings) {
+        Matcher matcher = tagPattern.matcher(pstr);
+        if (!matcher.matches()) {
+          throw new MetricsException("Illegal tag pattern: "+ pstr);
+        }
+        setIncludeTagPattern(matcher.group(1), compile(matcher.group(2)));
+      }
+    }
+    patternStrings = conf.getStringArray(EXCLUDE_TAGS_KEY);
+    if (patternStrings != null && patternStrings.length != 0) {
+      for (String pstr : patternStrings) {
+        Matcher matcher = tagPattern.matcher(pstr);
+        if (!matcher.matches()) {
+          throw new MetricsException("Illegal tag pattern: "+ pstr);
+        }
+        setExcludeTagPattern(matcher.group(1), compile(matcher.group(2)));
+      }
+    }
+  }
+
+  void setIncludePattern(Pattern includePattern) {
+    this.includePattern = includePattern;
+  }
+
+  void setExcludePattern(Pattern excludePattern) {
+    this.excludePattern = excludePattern;
+  }
+
+  void setIncludeTagPattern(String name, Pattern pattern) {
+    includeTagPatterns.put(name, pattern);
+  }
+
+  void setExcludeTagPattern(String name, Pattern pattern) {
+    excludeTagPatterns.put(name, pattern);
+  }
+
+  @Override
+  public boolean accepts(MetricsTag tag) {
+    // Accept if whitelisted
+    Pattern ipat = includeTagPatterns.get(tag.name());
+    if (ipat != null && ipat.matcher(tag.value()).matches()) {
+      return true;
+    }
+    // Reject if blacklisted
+    Pattern epat = excludeTagPatterns.get(tag.name());
+    if (epat != null && epat.matcher(tag.value()).matches()) {
+      return false;
+    }
+    // Reject if no match in whitelist only mode
+    if (ipat != null && epat == null) {
+      return false;
+    }
+    return true;
+  }
+
+  @Override
+  public boolean accepts(Iterable<MetricsTag> tags) {
+    // Accept if any include tag pattern matches
+    for (MetricsTag t : tags) {
+      Pattern pat = includeTagPatterns.get(t.name());
+      if (pat != null && pat.matcher(t.value()).matches()) {
+        return true;
+      }
+    }
+    // Reject if any exclude tag pattern matches
+    for (MetricsTag t : tags) {
+      Pattern pat = excludeTagPatterns.get(t.name());
+      if (pat != null && pat.matcher(t.value()).matches()) {
+        return false;
+      }
+    }
+    // Reject if no match in whitelist only mode
+    if (!includeTagPatterns.isEmpty() && excludeTagPatterns.isEmpty()) {
+      return false;
+    }
+    return true;
+  }
+
+  @Override
+  public boolean accepts(String name) {
+    // Accept if whitelisted
+    if (includePattern != null && includePattern.matcher(name).matches()) {
+      return true;
+    }
+    // Reject if blacklisted
+    if ((excludePattern != null && excludePattern.matcher(name).matches())) {
+      return false;
+    }
+    // Reject if no match in whitelist only mode
+    if (includePattern != null && excludePattern == null) {
+      return false;
+    }
+    return true;
+  }
+
+  /**
+   * Compile a string pattern in to a pattern object
+   * @param s the string pattern to compile
+   * @return the compiled pattern object
+   */
+  protected abstract Pattern compile(String s);
+}

Added: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/filter/GlobFilter.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/filter/GlobFilter.java?rev=1077597&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/filter/GlobFilter.java (added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/filter/GlobFilter.java Fri Mar  4 04:33:55 2011
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.metrics2.filter;
+
+import java.util.regex.Pattern;
+import org.apache.hadoop.fs.GlobPattern;
+
+/**
+ * A glob pattern filter for metrics
+ */
+public class GlobFilter extends AbstractPatternFilter {
+
+  @Override
+  protected Pattern compile(String s) {
+    return GlobPattern.compile(s);
+  }
+
+}

Added: hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/filter/RegexFilter.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/filter/RegexFilter.java?rev=1077597&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/filter/RegexFilter.java (added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/core/org/apache/hadoop/metrics2/filter/RegexFilter.java Fri Mar  4 04:33:55 2011
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.metrics2.filter;
+
+import java.util.regex.Pattern;
+
+/**
+ * A regex pattern filter for metrics
+ */
+public class RegexFilter extends AbstractPatternFilter {
+
+  @Override
+  protected Pattern compile(String s) {
+    return Pattern.compile(s);
+  }
+
+}



Mime
View raw message