Переглянути джерело

HADOOP-16657. Move remaining log4j APIs over to slf4j in hadoop-common. Contributed by Minni Mittal.

Abhishek Modi 5 роки тому
батько
коміт
4050471b45

+ 3 - 3
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/NflyFSystem.java

@@ -18,8 +18,8 @@
 package org.apache.hadoop.fs.viewfs;
 
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.apache.hadoop.classification.InterfaceAudience.Private;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.CommonConfigurationKeys;
@@ -59,7 +59,7 @@ import java.util.List;
  */
 @Private
 final class NflyFSystem extends FileSystem {
-  private static final Log LOG = LogFactory.getLog(NflyFSystem.class);
+  private static final Logger LOG = LoggerFactory.getLogger(NflyFSystem.class);
   private static final String NFLY_TMP_PREFIX = "_nfly_tmp_";
 
   enum NflyKey {

+ 3 - 3
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java

@@ -1384,7 +1384,7 @@ public abstract class Server {
         // If the connectionManager can't take it, close the connection.
         if (c == null) {
           if (channel.isOpen()) {
-            IOUtils.cleanup(null, channel);
+            IOUtils.cleanupWithLogger(LOG, channel);
           }
           connectionManager.droppedConnections.getAndIncrement();
           continue;
@@ -2823,9 +2823,9 @@ public abstract class Server {
         LOG.debug("Ignoring socket shutdown exception", e);
       }
       if (channel.isOpen()) {
-        IOUtils.cleanup(null, channel);
+        IOUtils.cleanupWithLogger(LOG, channel);
       }
-      IOUtils.cleanup(null, socket);
+      IOUtils.cleanupWithLogger(LOG, socket);
     }
   }
 

+ 1 - 1
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/DiskChecker.java

@@ -296,7 +296,7 @@ public class DiskChecker {
       }
       file = null;
     } finally {
-      IOUtils.cleanup(null, fos);
+      IOUtils.cleanupWithLogger(LOG, fos);
       FileUtils.deleteQuietly(file);
     }
   }

+ 10 - 6
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestBloomMapFile.java

@@ -27,6 +27,8 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.LocalFileSystem;
@@ -49,6 +51,8 @@ import org.junit.Before;
 import org.junit.Test;
 
 public class TestBloomMapFile {
+  private static final Logger LOG =
+      LoggerFactory.getLogger(TestBloomMapFile.class);
   private static Configuration conf = new Configuration();
   private static final Path TEST_ROOT = new Path(GenericTestUtils.getTempPath(
       TestMapFile.class.getSimpleName()));
@@ -107,7 +111,7 @@ public class TestBloomMapFile {
       System.out.println("False positives: " + falsePos);
       assertTrue(falsePos < 2);
     } finally {
-      IOUtils.cleanup(null, writer, reader);
+      IOUtils.cleanupWithLogger(LOG, writer, reader);
     }
   }
 
@@ -136,7 +140,7 @@ public class TestBloomMapFile {
       reader.close();
       fs.delete(qualifiedDirName, true);
     } finally {
-      IOUtils.cleanup(null, writer, reader);
+      IOUtils.cleanupWithLogger(LOG, writer, reader);
     }
   }
 
@@ -173,7 +177,7 @@ public class TestBloomMapFile {
     } catch (Exception ex) {
       fail("unexpect ex in testDeleteFile !!!");
     } finally {
-      IOUtils.cleanup(null, writer);
+      IOUtils.cleanupWithLogger(LOG, writer);
     }
   }
   
@@ -202,7 +206,7 @@ public class TestBloomMapFile {
     } catch (Exception ex) {
       fail("unexpect ex in testIOExceptionInWriterConstructor !!!");
     } finally {
-      IOUtils.cleanup(null, writer, reader);
+      IOUtils.cleanupWithLogger(LOG, writer, reader);
     }
   }
 
@@ -237,7 +241,7 @@ public class TestBloomMapFile {
     } catch (Exception ex) {
       fail("unexpect ex in testGetBloomMapFile !!!");
     } finally {
-      IOUtils.cleanup(null, writer, reader);
+      IOUtils.cleanupWithLogger(LOG, writer, reader);
     }
   }
 
@@ -286,7 +290,7 @@ public class TestBloomMapFile {
     } catch (Exception ex) {
       fail("testBloomMapFileConstructors error !!!");
     } finally {
-      IOUtils.cleanup(null, writer);
+      IOUtils.cleanupWithLogger(LOG, writer);
     }
   }
 

+ 20 - 18
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestMapFile.java

@@ -26,6 +26,8 @@ import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.LocalFileSystem;
@@ -48,7 +50,7 @@ import static org.junit.Assert.*;
 import static org.mockito.Mockito.*;
 
 public class TestMapFile {
-  
+  private static final Logger LOG = LoggerFactory.getLogger(TestMapFile.class);
   private static final Path TEST_DIR = new Path(GenericTestUtils.getTempPath(
       TestMapFile.class.getSimpleName()));
   
@@ -187,7 +189,7 @@ public class TestMapFile {
       closest = (Text) reader.getClosest(key, value, true);
       assertEquals(new Text("91"), closest);
     } finally {
-      IOUtils.cleanup(null, writer, reader);
+      IOUtils.cleanupWithLogger(LOG, writer, reader);
     }
   }
   
@@ -211,7 +213,7 @@ public class TestMapFile {
       reader = createReader(TEST_PREFIX, IntWritable.class);
       assertEquals(new IntWritable((SIZE - 1) / 2), reader.midKey());
     } finally {
-      IOUtils.cleanup(null, writer, reader);
+      IOUtils.cleanupWithLogger(LOG, writer, reader);
     }
   }
   
@@ -233,7 +235,7 @@ public class TestMapFile {
     } catch (IOException ex) {
       fail("testRename error " + ex);
     } finally {
-      IOUtils.cleanup(null, writer);
+      IOUtils.cleanupWithLogger(LOG, writer);
     }
   }
   
@@ -265,7 +267,7 @@ public class TestMapFile {
       assertEquals("testRenameWithException invalid IOExceptionMessage !!!",
           ex.getMessage(), ERROR_MESSAGE);
     } finally {
-      IOUtils.cleanup(null, writer);
+      IOUtils.cleanupWithLogger(LOG, writer);
     }
   }
 
@@ -292,7 +294,7 @@ public class TestMapFile {
       assertTrue("testRenameWithFalse invalid IOExceptionMessage error !!!", ex
           .getMessage().startsWith(ERROR_MESSAGE));
     } finally {
-      IOUtils.cleanup(null, writer);
+      IOUtils.cleanupWithLogger(LOG, writer);
     }
   }
   
@@ -319,7 +321,7 @@ public class TestMapFile {
       assertTrue("testWriteWithFailDirCreation ex error !!!", ex.getMessage()
           .startsWith(ERROR_MESSAGE));
     } finally {
-      IOUtils.cleanup(null, writer);
+      IOUtils.cleanupWithLogger(LOG, writer);
     }
   }
 
@@ -347,7 +349,7 @@ public class TestMapFile {
     } catch (IOException ex) {
       fail("testOnFinalKey error !!!");
     } finally {
-      IOUtils.cleanup(null, writer, reader);
+      IOUtils.cleanupWithLogger(LOG, writer, reader);
     }
   }
   
@@ -392,7 +394,7 @@ public class TestMapFile {
     } catch (IOException ex) {
       /* Should be thrown to pass the test */
     } finally {
-      IOUtils.cleanup(null, writer, reader);
+      IOUtils.cleanupWithLogger(LOG, writer, reader);
     }
   }
   
@@ -410,7 +412,7 @@ public class TestMapFile {
     } catch (IOException ex) {
       /* Should be thrown to pass the test */
     } finally {
-      IOUtils.cleanup(null, writer);
+      IOUtils.cleanupWithLogger(LOG, writer);
     }
   }
   
@@ -451,7 +453,7 @@ public class TestMapFile {
     } catch (IOException ex) {
       fail("reader seek error !!!");
     } finally {
-      IOUtils.cleanup(null, writer, reader);
+      IOUtils.cleanupWithLogger(LOG, writer, reader);
     }
   }
 
@@ -482,7 +484,7 @@ public class TestMapFile {
     } catch (Exception ex) {
       fail("testFix error !!!");
     } finally {
-      IOUtils.cleanup(null, writer);
+      IOUtils.cleanupWithLogger(LOG, writer);
     }
   }
 
@@ -588,7 +590,7 @@ public class TestMapFile {
     } catch (IOException e) {
       fail(e.getMessage());
     } finally {
-      IOUtils.cleanup(null, writer, reader);
+      IOUtils.cleanupWithLogger(LOG, writer, reader);
     }
   }
   
@@ -607,7 +609,7 @@ public class TestMapFile {
     } catch (Exception e) {
       fail("fail in testKeyLessWriterCreation. Other ex !!!");
     } finally {
-      IOUtils.cleanup(null, writer);
+      IOUtils.cleanupWithLogger(LOG, writer);
     }
   }
   /**
@@ -636,7 +638,7 @@ public class TestMapFile {
     } catch (Exception e) {
       fail("fail in testPathExplosionWriterCreation. Other ex !!!");
     } finally {
-      IOUtils.cleanup(null, writer);
+      IOUtils.cleanupWithLogger(LOG, writer);
     }
   }
 
@@ -657,7 +659,7 @@ public class TestMapFile {
     } catch (Exception e) {
       fail("testDescOrderWithThrowExceptionWriterAppend other ex throw !!!");
     } finally {
-      IOUtils.cleanup(null, writer);
+      IOUtils.cleanupWithLogger(LOG, writer);
     }
   }
 
@@ -745,7 +747,7 @@ public class TestMapFile {
       closest = (Text) reader.getClosest(key, value, true);
       assertEquals(new Text("90"), closest);
     } finally {
-      IOUtils.cleanup(null, writer, reader);
+      IOUtils.cleanupWithLogger(LOG, writer, reader);
     }
   }
 
@@ -768,7 +770,7 @@ public class TestMapFile {
       reader = new MapFile.Reader(qualifiedDirName, conf);
       assertEquals(new IntWritable(1), reader.midKey());
     } finally {
-      IOUtils.cleanup(null, writer, reader);
+      IOUtils.cleanupWithLogger(LOG, writer, reader);
     }
   }