1
0
Prechádzať zdrojové kódy

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
Todd Lipcon 12 rokov pred
rodič
commit
2fd41b3b42

+ 1 - 1
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/unix/DomainSocket.java

@@ -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();
     }
   }

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-347.txt

@@ -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)

+ 5 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/BlockReaderLocal.java

@@ -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 " +

+ 3 - 3
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DomainSocketFactory.java

@@ -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) {
@@ -134,4 +134,4 @@ class DomainSocketFactory {
   public void disableDomainSocketPath(String path) {
     pathInfo.put(path, PathStatus.UNUSABLE);
   }
-}
+}

+ 0 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/FileInputStreamCache.java

@@ -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;