HADOOP-16625: Backport HADOOP-14624 to branch-3.1.
(cherry picked from commit 79c97f6a0b
)
Conflicts:
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSaveNamespace.java
This commit is contained in:
parent
0160e2c97f
commit
76c30e4f3c
|
@ -501,7 +501,7 @@ public abstract class GenericTestUtils {
|
|||
* method is called, then waits on another before continuing.
|
||||
*/
|
||||
public static class DelayAnswer implements Answer<Object> {
|
||||
private final Log LOG;
|
||||
private final org.slf4j.Logger LOG;
|
||||
|
||||
private final CountDownLatch fireLatch = new CountDownLatch(1);
|
||||
private final CountDownLatch waitLatch = new CountDownLatch(1);
|
||||
|
@ -514,7 +514,7 @@ public abstract class GenericTestUtils {
|
|||
private volatile Throwable thrown;
|
||||
private volatile Object returnValue;
|
||||
|
||||
public DelayAnswer(Log log) {
|
||||
public DelayAnswer(org.slf4j.Logger log) {
|
||||
this.LOG = log;
|
||||
}
|
||||
|
||||
|
@ -611,13 +611,13 @@ public abstract class GenericTestUtils {
|
|||
*/
|
||||
public static class DelegateAnswer implements Answer<Object> {
|
||||
private final Object delegate;
|
||||
private final Log log;
|
||||
private final org.slf4j.Logger log;
|
||||
|
||||
public DelegateAnswer(Object delegate) {
|
||||
this(null, delegate);
|
||||
}
|
||||
|
||||
public DelegateAnswer(Log log, Object delegate) {
|
||||
public DelegateAnswer(org.slf4j.Logger log, Object delegate) {
|
||||
this.log = log;
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ import java.util.List;
|
|||
|
||||
import javax.net.SocketFactory;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
|
@ -67,7 +69,7 @@ import sun.net.spi.nameservice.NameService;
|
|||
|
||||
public class TestDFSClientFailover {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(TestDFSClientFailover.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TestDFSClientFailover.class);
|
||||
|
||||
private static final Path TEST_FILE = new Path("/tmp/failover-test-file");
|
||||
private static final int FILE_LENGTH_TO_VERIFY = 100;
|
||||
|
@ -239,7 +241,7 @@ public class TestDFSClientFailover {
|
|||
List<NameService> nsList = (List<NameService>) f.get(null);
|
||||
|
||||
NameService ns = nsList.get(0);
|
||||
Log log = LogFactory.getLog("NameServiceSpy");
|
||||
Logger log = LoggerFactory.getLogger("NameServiceSpy");
|
||||
|
||||
ns = Mockito.mock(NameService.class,
|
||||
new GenericTestUtils.DelegateAnswer(log, ns));
|
||||
|
|
|
@ -32,8 +32,8 @@ import java.io.OutputStream;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.FSDataOutputStream;
|
||||
import org.apache.hadoop.fs.FileSystem;
|
||||
|
@ -57,7 +57,7 @@ import org.junit.Test;
|
|||
* using append()/sync() to recover block information
|
||||
*/
|
||||
public class TestFileAppend4 {
|
||||
static final Log LOG = LogFactory.getLog(TestFileAppend4.class);
|
||||
static final Logger LOG = LoggerFactory.getLogger(TestFileAppend4.class);
|
||||
static final long BLOCK_SIZE = 1024;
|
||||
static final long BBW_SIZE = 500; // don't align on bytes/checksum
|
||||
|
||||
|
|
|
@ -36,6 +36,8 @@ import java.util.concurrent.TimeoutException;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.BlockLocation;
|
||||
import org.apache.hadoop.fs.FSDataInputStream;
|
||||
|
@ -81,8 +83,8 @@ public class TestReplication {
|
|||
"/d1/r1", "/d1/r1", "/d1/r2", "/d1/r2", "/d1/r2", "/d2/r3", "/d2/r3"
|
||||
};
|
||||
private static final int numDatanodes = racks.length;
|
||||
private static final Log LOG = LogFactory.getLog(
|
||||
"org.apache.hadoop.hdfs.TestReplication");
|
||||
private static final Logger LOG = LoggerFactory.getLogger(
|
||||
TestReplication.class);
|
||||
|
||||
/* check if there are at least two nodes are on the same rack */
|
||||
private void checkFile(FileSystem fileSys, Path name, int repl)
|
||||
|
|
|
@ -24,8 +24,8 @@ import java.net.InetSocketAddress;
|
|||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
||||
import org.apache.hadoop.hdfs.qjournal.client.IPCLoggerChannel;
|
||||
|
@ -43,7 +43,7 @@ import org.mockito.Mockito;
|
|||
import com.google.common.base.Supplier;
|
||||
|
||||
public class TestIPCLoggerChannel {
|
||||
private static final Log LOG = LogFactory.getLog(
|
||||
private static final Logger LOG = LoggerFactory.getLogger(
|
||||
TestIPCLoggerChannel.class);
|
||||
|
||||
private final Configuration conf = new Configuration();
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
package org.apache.hadoop.hdfs.server.blockmanagement;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.hdfs.HdfsConfiguration;
|
||||
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
||||
import org.apache.hadoop.hdfs.protocol.BlockListAsLongs;
|
||||
|
@ -38,6 +36,8 @@ import org.apache.hadoop.hdfs.server.protocol.StorageBlockReport;
|
|||
import org.apache.hadoop.hdfs.server.protocol.StorageReport;
|
||||
import org.apache.hadoop.test.GenericTestUtils.DelayAnswer;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -56,7 +56,7 @@ import static org.mockito.Mockito.spy;
|
|||
* Tests that BlockReportLease in BlockManager.
|
||||
*/
|
||||
public class TestBlockReportLease {
|
||||
private static final Log LOG = LogFactory.getLog(TestBlockReportLease.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TestBlockReportLease.class);
|
||||
/**
|
||||
* Test check lease about one BlockReport with many StorageBlockReport.
|
||||
* Before HDFS-12914, when batch storage report to NameNode, it will check
|
||||
|
|
|
@ -38,8 +38,8 @@ import java.util.concurrent.Future;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.FSDataOutputStream;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
|
@ -87,7 +87,7 @@ import org.mockito.invocation.InvocationOnMock;
|
|||
* and messages.
|
||||
*/
|
||||
public abstract class BlockReportTestBase {
|
||||
public static final Log LOG = LogFactory.getLog(BlockReportTestBase.class);
|
||||
public static final Logger LOG = LoggerFactory.getLogger(BlockReportTestBase.class);
|
||||
|
||||
private static short REPL_FACTOR = 1;
|
||||
private static final int RAND_LIMIT = 2000;
|
||||
|
@ -879,7 +879,7 @@ public abstract class BlockReportTestBase {
|
|||
private static void initLoggers() {
|
||||
DFSTestUtil.setNameNodeLogLevel(Level.ALL);
|
||||
GenericTestUtils.setLogLevel(DataNode.LOG, Level.ALL);
|
||||
GenericTestUtils.setLogLevel(BlockReportTestBase.LOG, Level.ALL);
|
||||
GenericTestUtils.setLogLevel(BlockReportTestBase.LOG, org.slf4j.event.Level.DEBUG);
|
||||
}
|
||||
|
||||
private Block findBlock(Path path, long size) throws IOException {
|
||||
|
|
|
@ -591,6 +591,19 @@ public abstract class FSImageTestUtil {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void logStorageContents(org.slf4j.Logger LOG, NNStorage storage) {
|
||||
LOG.info("current storages and corresponding sizes:");
|
||||
for (StorageDirectory sd : storage.dirIterable(null)) {
|
||||
File curDir = sd.getCurrentDir();
|
||||
LOG.info("In directory {}", curDir);
|
||||
File[] files = curDir.listFiles();
|
||||
Arrays.sort(files);
|
||||
for (File f : files) {
|
||||
LOG.info(" file {}; len = {}", f.getAbsolutePath(), f.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** get the fsImage*/
|
||||
public static FSImage getFSImage(NameNode node) {
|
||||
|
|
|
@ -46,6 +46,8 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
|
@ -111,7 +113,7 @@ public class TestCheckpoint {
|
|||
GenericTestUtils.setLogLevel(FSImage.LOG, Level.ALL);
|
||||
}
|
||||
|
||||
static final Log LOG = LogFactory.getLog(TestCheckpoint.class);
|
||||
static final Logger LOG = LoggerFactory.getLogger(TestCheckpoint.class);
|
||||
static final String NN_METRICS = "NameNodeActivity";
|
||||
|
||||
static final long seed = 0xDEADBEEFL;
|
||||
|
|
|
@ -28,8 +28,8 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hdfs.AddBlockFlag;
|
||||
import org.apache.hadoop.fs.FSDataOutputStream;
|
||||
|
@ -74,7 +74,7 @@ import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_LEASE_RECHECK_IN
|
|||
*/
|
||||
public class TestDeleteRace {
|
||||
private static final int BLOCK_SIZE = 4096;
|
||||
private static final Log LOG = LogFactory.getLog(TestDeleteRace.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TestDeleteRace.class);
|
||||
private static final Configuration conf = new HdfsConfiguration();
|
||||
private MiniDFSCluster cluster;
|
||||
|
||||
|
@ -171,7 +171,7 @@ public class TestDeleteRace {
|
|||
inodeMap.put(fileINode);
|
||||
LOG.info("Deleted" + path);
|
||||
} catch (Exception e) {
|
||||
LOG.info(e);
|
||||
LOG.info(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ public class TestDeleteRace {
|
|||
fs.rename(from, to);
|
||||
LOG.info("Renamed " + from + " to " + to);
|
||||
} catch (Exception e) {
|
||||
LOG.info(e);
|
||||
LOG.info(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,8 +40,6 @@ import java.util.concurrent.ExecutorService;
|
|||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.hadoop.util.StringUtils;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
|
@ -72,6 +70,9 @@ import org.mockito.Mockito;
|
|||
import org.mockito.internal.util.reflection.Whitebox;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Test various failure scenarios during saveNamespace() operation.
|
||||
|
@ -89,7 +90,7 @@ public class TestSaveNamespace {
|
|||
GenericTestUtils.setLogLevel(FSImage.LOG, Level.ALL);
|
||||
}
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(TestSaveNamespace.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TestSaveNamespace.class);
|
||||
|
||||
private static class FaultySaveImage implements Answer<Void> {
|
||||
private int count = 0;
|
||||
|
@ -332,7 +333,7 @@ public class TestSaveNamespace {
|
|||
try {
|
||||
fsn.close();
|
||||
} catch (Throwable t) {
|
||||
LOG.fatal("Failed to shut down", t);
|
||||
LOG.error("Failed to shut down", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -632,7 +633,7 @@ public class TestSaveNamespace {
|
|||
cluster.getNameNodeRpc().saveNamespace(0, 0);
|
||||
fs.setSafeMode(SafeModeAction.SAFEMODE_LEAVE);
|
||||
} finally {
|
||||
IOUtils.cleanup(LOG, out, fs);
|
||||
IOUtils.cleanupWithLogger(LOG, out, fs);
|
||||
cluster.shutdown();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ import java.util.concurrent.ThreadLocalRandom;
|
|||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.FSDataOutputStream;
|
||||
import org.apache.hadoop.fs.FileSystem;
|
||||
|
@ -69,7 +69,7 @@ import org.mockito.invocation.InvocationOnMock;
|
|||
|
||||
public class TestDNFencing {
|
||||
|
||||
protected static final Log LOG = LogFactory.getLog(TestDNFencing.class);
|
||||
protected static final Logger LOG = LoggerFactory.getLogger(TestDNFencing.class);
|
||||
private static final String TEST_FILE = "/testStandbyIsHot";
|
||||
private static final Path TEST_FILE_PATH = new Path(TEST_FILE);
|
||||
private static final int SMALL_BLOCK = 1024;
|
||||
|
|
|
@ -28,8 +28,8 @@ import java.util.Random;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.FSDataOutputStream;
|
||||
import org.apache.hadoop.fs.FileSystem;
|
||||
|
@ -70,12 +70,12 @@ import com.google.common.base.Supplier;
|
|||
*/
|
||||
public class TestPipelinesFailover {
|
||||
static {
|
||||
GenericTestUtils.setLogLevel(LogFactory.getLog(RetryInvocationHandler
|
||||
.class), Level.ALL);
|
||||
GenericTestUtils.setLogLevel(LoggerFactory.getLogger(RetryInvocationHandler
|
||||
.class), org.slf4j.event.Level.DEBUG);
|
||||
DFSTestUtil.setNameNodeLogLevel(Level.ALL);
|
||||
}
|
||||
|
||||
protected static final Log LOG = LogFactory.getLog(
|
||||
protected static final Logger LOG = LoggerFactory.getLogger(
|
||||
TestPipelinesFailover.class);
|
||||
private static final Path TEST_PATH =
|
||||
new Path("/test-file");
|
||||
|
|
|
@ -21,8 +21,8 @@ import com.google.common.base.Supplier;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
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.FSDataOutputStream;
|
||||
|
@ -72,7 +72,7 @@ public class TestStandbyCheckpoints {
|
|||
private final Random random = new Random();
|
||||
protected File tmpOivImgDir;
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(TestStandbyCheckpoints.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TestStandbyCheckpoints.class);
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Before
|
||||
|
|
Loading…
Reference in New Issue