HDFS-4402. Some small DomainSocket fixes: avoid findbugs warning, change log level, etc. Contributed by Colin Patrick McCabe.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-347@1433242 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Todd Lipcon 2013-01-15 00:31:35 +00:00
parent d79868d3e5
commit 2fd41b3b42
5 changed files with 12 additions and 6 deletions

View File

@ -254,7 +254,7 @@ public class DomainSocket implements Closeable {
private void fdUnref(boolean checkClosed) throws AsynchronousCloseException {
int newCount = status.decrementAndGet();
assert (newCount & ~STATUS_CLOSED_MASK) >= 0;
if (checkClosed & ((newCount & STATUS_CLOSED_MASK) != 0)) {
if (checkClosed && ((newCount & STATUS_CLOSED_MASK) != 0)) {
throw new AsynchronousCloseException();
}
}

View File

@ -22,3 +22,6 @@ HDFS-4400. DFSInputStream#getBlockReader: last retries should ignore the cache
HDFS-4401. Fix bug in DomainSocket path validation
(Colin Patrick McCabe via todd)
HDFS-4402. Some small DomainSocket fixes: avoid findbugs warning, change log level, etc.
(Colin Patrick McCabe via todd)

View File

@ -19,6 +19,8 @@ package org.apache.hadoop.hdfs;
import java.io.DataInputStream;
import org.apache.hadoop.conf.Configuration;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
@ -118,7 +120,9 @@ class BlockReaderLocal implements BlockReader {
// read and handle the common header here. For now just a version
checksumIn.getChannel().position(0);
BlockMetadataHeader header = BlockMetadataHeader
.readHeader(new DataInputStream(checksumIn));
.readHeader(new DataInputStream(
new BufferedInputStream(checksumIn,
BlockMetadataHeader.getHeaderSize())));
short version = header.getVersion();
if (version != BlockMetadataHeader.VERSION) {
throw new IOException("Wrong version (" + version + ") of the " +

View File

@ -62,7 +62,7 @@ class DomainSocketFactory {
LOG.warn(feature + " is disabled because you have not set " +
DFSConfigKeys.DFS_DATANODE_DOMAIN_SOCKET_PATH_KEY);
} else if (DomainSocket.getLoadingFailureReason() != null) {
LOG.error(feature + " is disabled because " +
LOG.warn(feature + " is disabled because " +
DomainSocket.getLoadingFailureReason());
} else {
LOG.debug(feature + "is enabled.");
@ -113,7 +113,7 @@ class DomainSocketFactory {
sock.setAttribute(DomainSocket.RCV_TIMEO, conf.socketTimeout);
success = true;
} catch (IOException e) {
LOG.error("error creating DomainSocket", e);
LOG.warn("error creating DomainSocket", e);
// fall through
} finally {
if (!success) {

View File

@ -22,7 +22,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;