HDFS-11992. Replace commons-logging APIs with slf4j in FsDatasetImpl. Contributed by hu xiaodong.

This commit is contained in:
Akira Ajisaka 2017-06-21 11:19:48 +09:00
parent 5157f6c46e
commit 1a598479a9
No known key found for this signature in database
GPG Key ID: C1EDBB9CA400FD50
8 changed files with 26 additions and 24 deletions

View File

@ -25,9 +25,9 @@ import java.util.concurrent.locks.ReentrantLock;
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.classification.InterfaceStability;
import org.apache.commons.logging.Log;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import org.slf4j.Logger;
/** /**
* This is a debugging class that can be used by callers to track * This is a debugging class that can be used by callers to track
@ -44,7 +44,7 @@ import com.google.common.annotations.VisibleForTesting;
public class InstrumentedLock implements Lock { public class InstrumentedLock implements Lock {
private final Lock lock; private final Lock lock;
private final Log logger; private final Logger logger;
private final String name; private final String name;
private final Timer clock; private final Timer clock;
@ -70,20 +70,20 @@ public class InstrumentedLock implements Lock {
* @param lockWarningThresholdMs the time threshold to view lock held * @param lockWarningThresholdMs the time threshold to view lock held
* time as being "too long" * time as being "too long"
*/ */
public InstrumentedLock(String name, Log logger, long minLoggingGapMs, public InstrumentedLock(String name, Logger logger, long minLoggingGapMs,
long lockWarningThresholdMs) { long lockWarningThresholdMs) {
this(name, logger, new ReentrantLock(), this(name, logger, new ReentrantLock(),
minLoggingGapMs, lockWarningThresholdMs); minLoggingGapMs, lockWarningThresholdMs);
} }
public InstrumentedLock(String name, Log logger, Lock lock, public InstrumentedLock(String name, Logger logger, Lock lock,
long minLoggingGapMs, long lockWarningThresholdMs) { long minLoggingGapMs, long lockWarningThresholdMs) {
this(name, logger, lock, this(name, logger, lock,
minLoggingGapMs, lockWarningThresholdMs, new Timer()); minLoggingGapMs, lockWarningThresholdMs, new Timer());
} }
@VisibleForTesting @VisibleForTesting
InstrumentedLock(String name, Log logger, Lock lock, InstrumentedLock(String name, Logger logger, Lock lock,
long minLoggingGapMs, long lockWarningThresholdMs, Timer clock) { long minLoggingGapMs, long lockWarningThresholdMs, Timer clock) {
this.name = name; this.name = name;
this.lock = lock; this.lock = lock;

View File

@ -19,11 +19,11 @@ package org.apache.hadoop.util;
import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.commons.logging.Log;
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.classification.InterfaceStability;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import org.slf4j.Logger;
/** /**
* This is a wrap class of a <tt>ReadLock</tt>. * This is a wrap class of a <tt>ReadLock</tt>.
@ -51,7 +51,7 @@ public class InstrumentedReadLock extends InstrumentedLock {
}; };
}; };
public InstrumentedReadLock(String name, Log logger, public InstrumentedReadLock(String name, Logger logger,
ReentrantReadWriteLock readWriteLock, ReentrantReadWriteLock readWriteLock,
long minLoggingGapMs, long lockWarningThresholdMs) { long minLoggingGapMs, long lockWarningThresholdMs) {
this(name, logger, readWriteLock, minLoggingGapMs, lockWarningThresholdMs, this(name, logger, readWriteLock, minLoggingGapMs, lockWarningThresholdMs,
@ -59,7 +59,7 @@ public class InstrumentedReadLock extends InstrumentedLock {
} }
@VisibleForTesting @VisibleForTesting
InstrumentedReadLock(String name, Log logger, InstrumentedReadLock(String name, Logger logger,
ReentrantReadWriteLock readWriteLock, ReentrantReadWriteLock readWriteLock,
long minLoggingGapMs, long lockWarningThresholdMs, Timer clock) { long minLoggingGapMs, long lockWarningThresholdMs, Timer clock) {
super(name, logger, readWriteLock.readLock(), minLoggingGapMs, super(name, logger, readWriteLock.readLock(), minLoggingGapMs,

View File

@ -21,9 +21,9 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.commons.logging.Log;
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.classification.InterfaceStability;
import org.slf4j.Logger;
/** /**
* This is a wrap class of a {@link ReentrantReadWriteLock}. * This is a wrap class of a {@link ReentrantReadWriteLock}.
@ -37,7 +37,7 @@ public class InstrumentedReadWriteLock implements ReadWriteLock {
private final Lock readLock; private final Lock readLock;
private final Lock writeLock; private final Lock writeLock;
InstrumentedReadWriteLock(boolean fair, String name, Log logger, InstrumentedReadWriteLock(boolean fair, String name, Logger logger,
long minLoggingGapMs, long lockWarningThresholdMs) { long minLoggingGapMs, long lockWarningThresholdMs) {
ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock(fair); ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock(fair);
readLock = new InstrumentedReadLock(name, logger, readWriteLock, readLock = new InstrumentedReadLock(name, logger, readWriteLock,

View File

@ -19,11 +19,11 @@ package org.apache.hadoop.util;
import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.commons.logging.Log;
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.classification.InterfaceStability;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import org.slf4j.Logger;
/** /**
* This is a wrap class of a <tt>WriteLock</tt>. * This is a wrap class of a <tt>WriteLock</tt>.
@ -37,7 +37,7 @@ import com.google.common.annotations.VisibleForTesting;
@InterfaceStability.Unstable @InterfaceStability.Unstable
public class InstrumentedWriteLock extends InstrumentedLock { public class InstrumentedWriteLock extends InstrumentedLock {
public InstrumentedWriteLock(String name, Log logger, public InstrumentedWriteLock(String name, Logger logger,
ReentrantReadWriteLock readWriteLock, ReentrantReadWriteLock readWriteLock,
long minLoggingGapMs, long lockWarningThresholdMs) { long minLoggingGapMs, long lockWarningThresholdMs) {
this(name, logger, readWriteLock, minLoggingGapMs, lockWarningThresholdMs, this(name, logger, readWriteLock, minLoggingGapMs, lockWarningThresholdMs,
@ -45,7 +45,7 @@ public class InstrumentedWriteLock extends InstrumentedLock {
} }
@VisibleForTesting @VisibleForTesting
InstrumentedWriteLock(String name, Log logger, InstrumentedWriteLock(String name, Logger logger,
ReentrantReadWriteLock readWriteLock, ReentrantReadWriteLock readWriteLock,
long minLoggingGapMs, long lockWarningThresholdMs, Timer clock) { long minLoggingGapMs, long lockWarningThresholdMs, Timer clock) {
super(name, logger, readWriteLock.writeLock(), minLoggingGapMs, super(name, logger, readWriteLock.writeLock(), minLoggingGapMs,

View File

@ -21,8 +21,8 @@ import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
import org.apache.commons.logging.Log; import org.slf4j.Logger;
import org.apache.commons.logging.LogFactory; import org.slf4j.LoggerFactory;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TestName; import org.junit.rules.TestName;
@ -34,7 +34,7 @@ import static org.junit.Assert.*;
*/ */
public class TestInstrumentedLock { public class TestInstrumentedLock {
static final Log LOG = LogFactory.getLog(TestInstrumentedLock.class); static final Logger LOG = LoggerFactory.getLogger(TestInstrumentedLock.class);
@Rule public TestName name = new TestName(); @Rule public TestName name = new TestName();

View File

@ -24,18 +24,19 @@ import static org.junit.Assert.assertTrue;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TestName; import org.junit.rules.TestName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* A test class for InstrumentedReadLock and InstrumentedWriteLock. * A test class for InstrumentedReadLock and InstrumentedWriteLock.
*/ */
public class TestInstrumentedReadWriteLock { public class TestInstrumentedReadWriteLock {
static final Log LOG = LogFactory.getLog(TestInstrumentedReadWriteLock.class); static final Logger LOG = LoggerFactory.getLogger(
TestInstrumentedReadWriteLock.class);
@Rule @Rule
public TestName name = new TestName(); public TestName name = new TestName();

View File

@ -740,7 +740,8 @@ class BlockPoolSlice {
} }
} }
} catch (IOException e) { } catch (IOException e) {
FsDatasetImpl.LOG.warn(e); FsDatasetImpl.LOG.warn("Getting exception while validating integrity " +
"and setting length for blockFile", e);
return 0; return 0;
} }
} }

View File

@ -46,8 +46,6 @@ import javax.management.ObjectName;
import javax.management.StandardMBean; import javax.management.StandardMBean;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys; import org.apache.hadoop.fs.CommonConfigurationKeys;
@ -119,6 +117,8 @@ import org.apache.hadoop.util.Timer;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/************************************************** /**************************************************
* FSDataset manages a set of data blocks. Each block * FSDataset manages a set of data blocks. Each block
@ -127,7 +127,7 @@ import com.google.common.collect.Sets;
***************************************************/ ***************************************************/
@InterfaceAudience.Private @InterfaceAudience.Private
class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> { class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
static final Log LOG = LogFactory.getLog(FsDatasetImpl.class); static final Logger LOG = LoggerFactory.getLogger(FsDatasetImpl.class);
private final static boolean isNativeIOAvailable; private final static boolean isNativeIOAvailable;
private Timer timer; private Timer timer;
static { static {