From 53be075241f1ba92bfe47e89c2dfc3f0664e2578 Mon Sep 17 00:00:00 2001 From: Akira Ajisaka Date: Fri, 22 Sep 2017 13:27:59 +0900 Subject: [PATCH] =?UTF-8?q?MAPREDUCE-6947.=20Moving=20logging=20APIs=20ove?= =?UTF-8?q?r=20to=20slf4j=20in=20hadoop-mapreduce-examples.=20Contributed?= =?UTF-8?q?=20by=20Gergely=20Nov=C3=A1k.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hadoop-mapreduce-project/hadoop-mapreduce-examples/pom.xml | 4 ++++ .../org/apache/hadoop/examples/BaileyBorweinPlouffe.java | 7 ++++--- .../java/org/apache/hadoop/examples/DBCountPageView.java | 7 ++++--- .../org/apache/hadoop/examples/dancing/DancingLinks.java | 7 +++---- .../main/java/org/apache/hadoop/examples/pi/DistSum.java | 6 +++--- .../java/org/apache/hadoop/examples/terasort/TeraGen.java | 6 +++--- .../apache/hadoop/examples/terasort/TeraOutputFormat.java | 7 ++++--- .../org/apache/hadoop/examples/terasort/TeraScheduler.java | 7 ++++--- .../java/org/apache/hadoop/examples/terasort/TeraSort.java | 6 +++--- .../org/apache/hadoop/examples/terasort/TestTeraSort.java | 6 +++--- 10 files changed, 35 insertions(+), 28 deletions(-) diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-examples/pom.xml b/hadoop-mapreduce-project/hadoop-mapreduce-examples/pom.xml index 4a50ed35514..5e5dd8f2bca 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-examples/pom.xml +++ b/hadoop-mapreduce-project/hadoop-mapreduce-examples/pom.xml @@ -112,6 +112,10 @@ guava provided + + org.slf4j + slf4j-api + diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/BaileyBorweinPlouffe.java b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/BaileyBorweinPlouffe.java index b9987a54e52..2bda89d36e0 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/BaileyBorweinPlouffe.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/BaileyBorweinPlouffe.java @@ -29,8 +29,6 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configured; import org.apache.hadoop.fs.FileSystem; @@ -52,6 +50,8 @@ import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; import org.apache.hadoop.util.Time; import org.apache.hadoop.util.Tool; import org.apache.hadoop.util.ToolRunner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.common.base.Charsets; @@ -84,7 +84,8 @@ public class BaileyBorweinPlouffe extends Configured implements Tool { private static final String DIGIT_SIZE_PROPERTY = NAME + ".digit.size"; private static final String DIGIT_PARTS_PROPERTY = NAME + ".digit.parts"; - private static final Log LOG = LogFactory.getLog(BaileyBorweinPlouffe.class); + private static final Logger LOG = + LoggerFactory.getLogger(BaileyBorweinPlouffe.class); /** Mapper class computing digits of Pi. */ public static class BbpMapper extends diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/DBCountPageView.java b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/DBCountPageView.java index 8dec39d866a..7b73820ac41 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/DBCountPageView.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/DBCountPageView.java @@ -29,8 +29,6 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.Random; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configured; import org.apache.hadoop.io.LongWritable; @@ -49,6 +47,8 @@ import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.util.Tool; import org.apache.hadoop.util.ToolRunner; import org.hsqldb.server.Server; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This is a demonstrative program, which uses DBInputFormat for reading @@ -77,7 +77,8 @@ import org.hsqldb.server.Server; */ public class DBCountPageView extends Configured implements Tool { - private static final Log LOG = LogFactory.getLog(DBCountPageView.class); + private static final Logger LOG = + LoggerFactory.getLogger(DBCountPageView.class); private Connection connection; private boolean initialized = false; diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/dancing/DancingLinks.java b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/dancing/DancingLinks.java index 0401a25a1f8..eef44617ce3 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/dancing/DancingLinks.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/dancing/DancingLinks.java @@ -19,8 +19,8 @@ package org.apache.hadoop.examples.dancing; import java.util.*; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * A generic solver for tile laying problems using Knuth's dancing link @@ -35,8 +35,7 @@ import org.apache.commons.logging.LogFactory; * The type parameter ColumnName is the class of application's column names. */ public class DancingLinks { - private static final Log LOG = - LogFactory.getLog(DancingLinks.class.getName()); + private static final Logger LOG = LoggerFactory.getLogger(DancingLinks.class); /** * A cell in the table with up/down and left/right links that form doubly diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/pi/DistSum.java b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/pi/DistSum.java index 99f7c2485df..ffe63feba0a 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/pi/DistSum.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/pi/DistSum.java @@ -28,8 +28,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.Callable; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configured; import org.apache.hadoop.examples.pi.math.Summation; @@ -55,6 +53,8 @@ import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; import org.apache.hadoop.net.NetUtils; import org.apache.hadoop.util.Tool; import org.apache.hadoop.util.ToolRunner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * The main class for computing sums using map/reduce jobs. @@ -66,7 +66,7 @@ import org.apache.hadoop.util.ToolRunner; * a mix-type job may be executed on either side. */ public final class DistSum extends Configured implements Tool { - private static final Log LOG = LogFactory.getLog(DistSum.class); + private static final Logger LOG = LoggerFactory.getLogger(DistSum.class); private static final String NAME = DistSum.class.getSimpleName(); private static final String N_PARTS = "mapreduce.pi." + NAME + ".nParts"; diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/terasort/TeraGen.java b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/terasort/TeraGen.java index 53bbdc4bcf5..ef20c4c23bd 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/terasort/TeraGen.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/terasort/TeraGen.java @@ -25,8 +25,6 @@ import java.util.ArrayList; import java.util.List; import java.util.zip.Checksum; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configured; import org.apache.hadoop.fs.Path; @@ -49,6 +47,8 @@ import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; import org.apache.hadoop.util.PureJavaCrc32; import org.apache.hadoop.util.Tool; import org.apache.hadoop.util.ToolRunner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Generate the official GraySort input data set. @@ -66,7 +66,7 @@ import org.apache.hadoop.util.ToolRunner; * bin/hadoop jar hadoop-*-examples.jar teragen 10000000000 in-dir */ public class TeraGen extends Configured implements Tool { - private static final Log LOG = LogFactory.getLog(TeraGen.class); + private static final Logger LOG = LoggerFactory.getLogger(TeraGen.class); public enum Counters {CHECKSUM} diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/terasort/TeraOutputFormat.java b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/terasort/TeraOutputFormat.java index 96580b1e75a..e0ce36ce49a 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/terasort/TeraOutputFormat.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/terasort/TeraOutputFormat.java @@ -21,8 +21,6 @@ package org.apache.hadoop.examples.terasort; import java.io.FileNotFoundException; import java.io.IOException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FileStatus; @@ -38,12 +36,15 @@ import org.apache.hadoop.mapreduce.TaskAttemptContext; import org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; import org.apache.hadoop.mapreduce.security.TokenCache; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * An output format that writes the key and value appended together. */ public class TeraOutputFormat extends FileOutputFormat { - private static final Log LOG = LogFactory.getLog(TeraOutputFormat.class); + private static final Logger LOG = + LoggerFactory.getLogger(TeraOutputFormat.class); private OutputCommitter committer = null; /** diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/terasort/TeraScheduler.java b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/terasort/TeraScheduler.java index 3e12a3d9619..7a9e44b0353 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/terasort/TeraScheduler.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/terasort/TeraScheduler.java @@ -21,17 +21,18 @@ package org.apache.hadoop.examples.terasort; import java.io.*; import java.util.*; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.mapreduce.InputSplit; import org.apache.hadoop.mapreduce.lib.input.FileSplit; import org.apache.hadoop.mapreduce.server.tasktracker.TTConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.common.base.Charsets; class TeraScheduler { - private static final Log LOG = LogFactory.getLog(TeraScheduler.class); + private static final Logger LOG = + LoggerFactory.getLogger(TeraScheduler.class); private Split[] splits; private List hosts = new ArrayList(); private int slotsPerHost; diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/terasort/TeraSort.java b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/terasort/TeraSort.java index 040d13ffb6f..8b698e35dd9 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/terasort/TeraSort.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/terasort/TeraSort.java @@ -23,8 +23,6 @@ import java.io.IOException; import java.io.PrintStream; import java.net.URI; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configurable; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configured; @@ -38,6 +36,8 @@ import org.apache.hadoop.mapreduce.Partitioner; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; import org.apache.hadoop.util.Tool; import org.apache.hadoop.util.ToolRunner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Generates the sampled split points, launches the job, and waits for it to @@ -47,7 +47,7 @@ import org.apache.hadoop.util.ToolRunner; * bin/hadoop jar hadoop-*-examples.jar terasort in-dir out-dir */ public class TeraSort extends Configured implements Tool { - private static final Log LOG = LogFactory.getLog(TeraSort.class); + private static final Logger LOG = LoggerFactory.getLogger(TeraSort.class); /** * A partitioner that splits text keys into roughly equal partitions diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/test/java/org/apache/hadoop/examples/terasort/TestTeraSort.java b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/test/java/org/apache/hadoop/examples/terasort/TestTeraSort.java index b835a3b3d2b..b3016599d19 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/test/java/org/apache/hadoop/examples/terasort/TestTeraSort.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/test/java/org/apache/hadoop/examples/terasort/TestTeraSort.java @@ -20,8 +20,6 @@ package org.apache.hadoop.examples.terasort; import java.io.File; import java.io.IOException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.mapred.FileAlreadyExistsException; @@ -29,12 +27,14 @@ import org.apache.hadoop.mapred.HadoopTestCase; import org.apache.hadoop.util.ToolRunner; import org.junit.After; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; public class TestTeraSort extends HadoopTestCase { - private static Log LOG = LogFactory.getLog(TestTeraSort.class); + private static final Logger LOG = LoggerFactory.getLogger(TestTeraSort.class); public TestTeraSort() throws IOException {