You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by om...@apache.org on 2011/03/08 05:39:05 UTC
svn commit: r1079142 - in /hadoop/common/branches/yahoo-merge: conf/
src/java/org/apache/hadoop/log/ src/java/org/apache/hadoop/log/metrics/
src/java/org/apache/hadoop/metrics/jvm/ src/java/org/apache/hadoop/util/
Author: omalley
Date: Tue Mar 8 04:39:05 2011
New Revision: 1079142
URL: http://svn.apache.org/viewvc?rev=1079142&view=rev
Log:
commit 59f754f5b06b28d21031a52d05ea85f3e393f53a
Author: Luke Lu <ll...@yahoo-inc.com>
Date: Mon Oct 25 14:57:51 2010 -0700
HADOOP:6728 Move EventCounter to org.apache.hadoop.log.metrics
in preparation of org.apache.hadoop.metrics deprecation.
See for patches/reviews.
Added:
hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/log/EventCounter.java
hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/log/metrics/
hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/log/metrics/EventCounter.java
Modified:
hadoop/common/branches/yahoo-merge/conf/log4j.properties
hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/metrics/jvm/EventCounter.java
hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/util/VersionInfo.java
Modified: hadoop/common/branches/yahoo-merge/conf/log4j.properties
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/conf/log4j.properties?rev=1079142&r1=1079141&r2=1079142&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/conf/log4j.properties (original)
+++ hadoop/common/branches/yahoo-merge/conf/log4j.properties Tue Mar 8 04:39:05 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.metrics.EventCounter
#
# Job Summary Appender
Added: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/log/EventCounter.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/log/EventCounter.java?rev=1079142&view=auto
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/log/EventCounter.java (added)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/log/EventCounter.java Tue Mar 8 04:39:05 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.log;
+
+/**
+ * A log4J Appender that simply counts logging events in three levels:
+ * fatal, error and warn. The class name is used in log4j.properties
+ * @deprecated use {@link org.apache.hadoop.log.metrics.EventCounter} instead
+ */
+@Deprecated
+public class EventCounter extends org.apache.hadoop.log.metrics.EventCounter {
+ static {
+ // The logging system is not started yet.
+ System.err.println("WARNING: "+ EventCounter.class.getName() +
+ " is deprecated. Please use "+
+ org.apache.hadoop.log.metrics.EventCounter.class.getName() +
+ " in all the log4j.properties files.");
+ }
+}
Added: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/log/metrics/EventCounter.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/log/metrics/EventCounter.java?rev=1079142&view=auto
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/log/metrics/EventCounter.java (added)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/log/metrics/EventCounter.java Tue Mar 8 04:39:05 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.log.metrics;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+
+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. The class name is used in log4j.properties
+ */
+@InterfaceAudience.Public
+@InterfaceStability.Stable
+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();
+
+ @InterfaceAudience.Private
+ public static long getFatal() {
+ return counts.get(FATAL);
+ }
+
+ @InterfaceAudience.Private
+ public static long getError() {
+ return counts.get(ERROR);
+ }
+
+ @InterfaceAudience.Private
+ public static long getWarn() {
+ return counts.get(WARN);
+ }
+
+ @InterfaceAudience.Private
+ public static long getInfo() {
+ return counts.get(INFO);
+ }
+
+ @Override
+ 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);
+ }
+
+ }
+
+ @Override
+ public void close() {
+ }
+
+ @Override
+ public boolean requiresLayout() {
+ return false;
+ }
+}
Modified: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/metrics/jvm/EventCounter.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/metrics/jvm/EventCounter.java?rev=1079142&r1=1079141&r2=1079142&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/metrics/jvm/EventCounter.java (original)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/metrics/jvm/EventCounter.java Tue Mar 8 04:39:05 2011
@@ -17,82 +17,19 @@
*/
package org.apache.hadoop.metrics.jvm;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.classification.InterfaceStability;
-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.
+ * @deprecated use {@link org.apache.hadoop.log.metrics.EventCounter} instead
*/
-@InterfaceAudience.Private
-@InterfaceStability.Evolving
-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);
- }
+@Deprecated
+public class EventCounter extends org.apache.hadoop.log.metrics.EventCounter {
- }
-
- // 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;
- }
-
-
-
+ static {
+ // The logging system is not started yet.
+ System.err.println("WARNING: "+ EventCounter.class.getName() +
+ " is deprecated. Please use "+
+ org.apache.hadoop.log.metrics.EventCounter.class.getName() +
+ " in all the log4j.properties files.");
+ }
}
Modified: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/util/VersionInfo.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/util/VersionInfo.java?rev=1079142&r1=1079141&r2=1079142&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/util/VersionInfo.java (original)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/util/VersionInfo.java Tue Mar 8 04:39:05 2011
@@ -18,6 +18,8 @@
package org.apache.hadoop.util;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.HadoopVersionAnnotation;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
@@ -29,6 +31,8 @@ import org.apache.hadoop.classification.
@InterfaceAudience.Private
@InterfaceStability.Unstable
public class VersionInfo {
+ private static final Log LOG = LogFactory.getLog(VersionInfo.class);
+
private static Package myPackage;
private static HadoopVersionAnnotation version;
@@ -112,6 +116,7 @@ public class VersionInfo {
}
public static void main(String[] args) {
+ LOG.debug("version: "+ version);
System.out.println("Hadoop " + getVersion());
System.out.println("Subversion " + getUrl() + " -r " + getRevision());
System.out.println("Compiled by " + getUser() + " on " + getDate());