hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [47/50] hadoop git commit: HADOOP-14549. Use GenericTestUtils.setLogLevel when available in hadoop-tools. Contributed by wenxin he.
Date Mon, 26 Jun 2017 12:50:21 GMT
HADOOP-14549. Use GenericTestUtils.setLogLevel when available in hadoop-tools. Contributed
by wenxin he.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/a594f96f
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/a594f96f
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/a594f96f

Branch: refs/heads/HADOOP-13345
Commit: a594f96fb1155d94fe08ed8f85dca789a9a4c790
Parents: 0111711
Author: Akira Ajisaka <aajisaka@apache.org>
Authored: Mon Jun 26 16:41:00 2017 +0900
Committer: Akira Ajisaka <aajisaka@apache.org>
Committed: Mon Jun 26 16:41:00 2017 +0900

----------------------------------------------------------------------
 .../org/apache/hadoop/test/GenericTestUtils.java |  5 +++++
 .../apache/hadoop/tools/TestHadoopArchives.java  | 12 ++++++------
 .../java/org/apache/hadoop/tools/TestDistCh.java | 12 ++++++------
 .../mapred/gridmix/TestGridmixSubmission.java    | 10 +++++-----
 .../hadoop/mapred/gridmix/TestLoadJob.java       | 19 ++++++++++---------
 .../hadoop/mapred/gridmix/TestSleepJob.java      | 14 +++++++-------
 6 files changed, 39 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/a594f96f/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/GenericTestUtils.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/GenericTestUtils.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/GenericTestUtils.java
index fcc4e3c..00dc7f2 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/GenericTestUtils.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/GenericTestUtils.java
@@ -134,6 +134,11 @@ public abstract class GenericTestUtils {
     setLogLevel(toLog4j(logger), level);
   }
 
+  public static void setLogLevel(org.slf4j.Logger logger,
+                                 org.slf4j.event.Level level) {
+    setLogLevel(toLog4j(logger), Level.toLevel(level.toString()));
+  }
+
   /**
    * Extracts the name of the method where the invocation has happened
    * @return String name of the invoking method

http://git-wip-us.apache.org/repos/asf/hadoop/blob/a594f96f/hadoop-tools/hadoop-archives/src/test/java/org/apache/hadoop/tools/TestHadoopArchives.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-archives/src/test/java/org/apache/hadoop/tools/TestHadoopArchives.java
b/hadoop-tools/hadoop-archives/src/test/java/org/apache/hadoop/tools/TestHadoopArchives.java
index e9ecf04..c63bc42 100644
--- a/hadoop-tools/hadoop-archives/src/test/java/org/apache/hadoop/tools/TestHadoopArchives.java
+++ b/hadoop-tools/hadoop-archives/src/test/java/org/apache/hadoop/tools/TestHadoopArchives.java
@@ -28,8 +28,6 @@ import java.util.Collections;
 import java.util.List;
 import java.util.StringTokenizer;
 
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.impl.Log4JLogger;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FSDataInputStream;
 import org.apache.hadoop.fs.FSDataOutputStream;
@@ -43,15 +41,18 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.RemoteIterator;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.io.IOUtils;
+import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.util.JarFinder;
 import org.apache.hadoop.util.ToolRunner;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
-import org.apache.log4j.Level;
 import org.junit.After;
 import org.junit.Assert;
 import static org.junit.Assert.*;
+import static org.slf4j.LoggerFactory.getLogger;
+
 import org.junit.Before;
 import org.junit.Test;
+import org.slf4j.event.Level;
 
 /**
  * test {@link HadoopArchives}
@@ -62,9 +63,8 @@ public class TestHadoopArchives {
       .getJar(HadoopArchives.class);
 
   {
-    ((Log4JLogger) LogFactory.getLog(org.apache.hadoop.security.Groups.class))
-        .getLogger().setLevel(Level.ERROR);
-
+    GenericTestUtils.setLogLevel(
+        getLogger(org.apache.hadoop.security.Groups.class), Level.ERROR);
   }
 
   private static final String inputDir = "input";

http://git-wip-us.apache.org/repos/asf/hadoop/blob/a594f96f/hadoop-tools/hadoop-extras/src/test/java/org/apache/hadoop/tools/TestDistCh.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-extras/src/test/java/org/apache/hadoop/tools/TestDistCh.java
b/hadoop-tools/hadoop-extras/src/test/java/org/apache/hadoop/tools/TestDistCh.java
index 510d9ac..3704c5b 100644
--- a/hadoop-tools/hadoop-extras/src/test/java/org/apache/hadoop/tools/TestDistCh.java
+++ b/hadoop-tools/hadoop-extras/src/test/java/org/apache/hadoop/tools/TestDistCh.java
@@ -24,8 +24,6 @@ import java.io.PrintStream;
 import java.util.Arrays;
 import java.util.Random;
 
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.impl.Log4JLogger;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
@@ -40,14 +38,16 @@ import org.apache.hadoop.io.IOUtils;
 import org.apache.hadoop.mapred.MiniMRClientClusterFactory;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
-import org.apache.log4j.Level;
+import org.slf4j.event.Level;
+
+import static org.slf4j.LoggerFactory.getLogger;
 
 public class TestDistCh extends junit.framework.TestCase {
   {
-    ((Log4JLogger)LogFactory.getLog("org.apache.hadoop.hdfs.StateChange")
-        ).getLogger().setLevel(Level.ERROR);
+    GenericTestUtils.setLogLevel(
+        getLogger("org.apache.hadoop.hdfs.StateChange"), Level.ERROR);
     GenericTestUtils.setLogLevel(DataNode.LOG, Level.ERROR);
-    ((Log4JLogger)LogFactory.getLog(FSNamesystem.class)).getLogger().setLevel(Level.ERROR);
+    GenericTestUtils.setLogLevel(getLogger(FSNamesystem.class), Level.ERROR);
   }
 
   static final Long RANDOM_NUMBER_GENERATOR_SEED = null;

http://git-wip-us.apache.org/repos/asf/hadoop/blob/a594f96f/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestGridmixSubmission.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestGridmixSubmission.java
b/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestGridmixSubmission.java
index d4bfddc..f849843 100644
--- a/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestGridmixSubmission.java
+++ b/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestGridmixSubmission.java
@@ -17,19 +17,18 @@
  */
 package org.apache.hadoop.mapred.gridmix;
 
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.impl.Log4JLogger;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.tools.rumen.JobStory;
 import org.apache.hadoop.tools.rumen.JobStoryProducer;
 import org.apache.hadoop.util.ExitUtil;
-import org.apache.log4j.Level;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.slf4j.event.Level;
 
 
 import java.io.ByteArrayOutputStream;
@@ -41,6 +40,7 @@ import java.util.zip.GZIPInputStream;
 
 import static org.apache.hadoop.test.GenericTestUtils.assertExceptionContains;
 import static org.junit.Assert.*;
+import static org.slf4j.LoggerFactory.getLogger;
 
 public class TestGridmixSubmission extends CommonJobTest {
   private static File inSpace = new File("src" + File.separator + "test"
@@ -48,8 +48,8 @@ public class TestGridmixSubmission extends CommonJobTest {
 
 
   static {
-    ((Log4JLogger) LogFactory.getLog("org.apache.hadoop.mapred.gridmix"))
-            .getLogger().setLevel(Level.DEBUG);
+    GenericTestUtils.setLogLevel(
+        getLogger("org.apache.hadoop.mapred.gridmix"), Level.DEBUG);
   }
 
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/a594f96f/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestLoadJob.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestLoadJob.java
b/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestLoadJob.java
index 69c3a79..3ed3d4e 100644
--- a/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestLoadJob.java
+++ b/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestLoadJob.java
@@ -17,28 +17,29 @@
  */
 package org.apache.hadoop.mapred.gridmix;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.impl.Log4JLogger;
-import org.apache.log4j.Level;
+import org.apache.hadoop.test.GenericTestUtils;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.event.Level;
 
 import java.io.IOException;
 
+import static org.slf4j.LoggerFactory.getLogger;
+
 /*
  Test LoadJob Gridmix sends data to job and after that
  */
 public class TestLoadJob extends CommonJobTest {
 
-  public static final Log LOG = LogFactory.getLog(Gridmix.class);
+  public static final Logger LOG = getLogger(Gridmix.class);
 
   static {
-    ((Log4JLogger) LogFactory.getLog("org.apache.hadoop.mapred.gridmix"))
-            .getLogger().setLevel(Level.DEBUG);
-    ((Log4JLogger) LogFactory.getLog(StressJobFactory.class)).getLogger()
-            .setLevel(Level.DEBUG);
+    GenericTestUtils.setLogLevel(
+        getLogger("org.apache.hadoop.mapred.gridmix"), Level.DEBUG);
+    GenericTestUtils.setLogLevel(
+        getLogger(StressJobFactory.class), Level.DEBUG);
   }
 
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/a594f96f/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestSleepJob.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestSleepJob.java
b/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestSleepJob.java
index 580910c..5a648de 100644
--- a/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestSleepJob.java
+++ b/hadoop-tools/hadoop-gridmix/src/test/java/org/apache/hadoop/mapred/gridmix/TestSleepJob.java
@@ -17,32 +17,32 @@
  */
 package org.apache.hadoop.mapred.gridmix;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.impl.Log4JLogger;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.mapreduce.InputSplit;
 import org.apache.hadoop.mapreduce.Job;
 import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.tools.rumen.JobStory;
-import org.apache.log4j.Level;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.event.Level;
 
 import java.io.IOException;
 import java.util.List;
 
 import static org.junit.Assert.*;
+import static org.slf4j.LoggerFactory.getLogger;
 
 public class TestSleepJob extends CommonJobTest {
 
-  public static final Log LOG = LogFactory.getLog(Gridmix.class);
+  public static final Logger LOG = getLogger(Gridmix.class);
 
   static {
-    ((Log4JLogger) LogFactory.getLog("org.apache.hadoop.mapred.gridmix"))
-            .getLogger().setLevel(Level.DEBUG);
+    GenericTestUtils.setLogLevel(
+        getLogger("org.apache.hadoop.mapred.gridmix"), Level.DEBUG);
   }
 
   static GridmixJobSubmissionPolicy policy = GridmixJobSubmissionPolicy.REPLAY;


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message