瀏覽代碼

HADOOP-10052. Temporarily disable client-side symlink resolution (branch-2.2 only change). (wang)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2.2@1533273 13f79535-47bb-0310-9956-ffa450edef68
Andrew Wang 11 年之前
父節點
當前提交
370c050103

+ 3 - 0
hadoop-common-project/hadoop-common/CHANGES.txt

@@ -32,6 +32,9 @@ Release 2.2.1 - UNRELEASED
     HADOOP-10055. FileSystemShell.apt.vm doc has typo "numRepicas".
     (Akira Ajisaka via cnauroth)
 
+    HADOOP-10052. Temporarily disable client-side symlink resolution
+    (branch-2.2 only change). (wang)
+
 Release 2.2.0 - 2013-10-13
 
   INCOMPATIBLE CHANGES

+ 5 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FSLinkResolver.java

@@ -76,6 +76,7 @@ public abstract class FSLinkResolver<T> {
    * @return Generic type determined by the implementation of next.
    * @throws IOException
    */
+  @SuppressWarnings("deprecation")
   public T resolve(final FileContext fc, final Path path) throws IOException {
     int count = 0;
     T in = null;
@@ -95,6 +96,10 @@ public abstract class FSLinkResolver<T> {
               + " and symlink resolution is disabled ("
               + CommonConfigurationKeys.FS_CLIENT_RESOLVE_REMOTE_SYMLINKS_KEY + ").", e);
         }
+        if (!FileSystem.isSymlinksEnabled()) {
+          throw new IOException("Symlink resolution is disabled in"
+              + " this version of Hadoop.");
+        }
         if (count++ > FsConstants.MAX_PATH_LINKS) {
           throw new IOException("Possible cyclic loop while " +
                                 "following symbolic link " + path);

+ 1 - 6
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java

@@ -2808,17 +2808,12 @@ public abstract class FileSystem extends Configured implements Closeable {
     }
   }
   
-  // Symlinks are temporarily disabled - see Hadoop-10020
+  // Symlinks are temporarily disabled - see HADOOP-10020 and HADOOP-10052
   private static boolean symlinkEnabled = false;
-  private static Configuration conf = null;
   
   @Deprecated
   @VisibleForTesting
   public static boolean isSymlinksEnabled() {
-    if (conf == null) {
-      Configuration conf = new Configuration();
-      symlinkEnabled = conf.getBoolean("test.SymlinkEnabledForTesting", false); 
-    }
     return symlinkEnabled;
   }
   

+ 5 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystemLinkResolver.java

@@ -68,6 +68,7 @@ public abstract class FileSystemLinkResolver<T> {
    * @return Generic type determined by implementation
    * @throws IOException
    */
+  @SuppressWarnings("deprecation")
   public T resolve(final FileSystem filesys, final Path path)
       throws IOException {
     int count = 0;
@@ -87,6 +88,10 @@ public abstract class FileSystemLinkResolver<T> {
               + CommonConfigurationKeys.FS_CLIENT_RESOLVE_REMOTE_SYMLINKS_KEY
               + ").", e);
         }
+        if (!FileSystem.isSymlinksEnabled()) {
+          throw new IOException("Symlink resolution is disabled in"
+              + " this version of Hadoop.");
+        }
         if (count++ > FsConstants.MAX_PATH_LINKS) {
           throw new IOException("Possible cyclic loop while " +
                                 "following symbolic link " + path);

+ 6 - 0
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/SymlinkBaseTest.java

@@ -28,6 +28,7 @@ import org.apache.hadoop.test.GenericTestUtils;
 
 import static org.junit.Assert.*;
 import static org.junit.Assume.assumeTrue;
+
 import org.junit.Test;
 import org.junit.Before;
 import org.junit.After;
@@ -35,7 +36,12 @@ import org.junit.After;
 /**
  * Base test for symbolic links
  */
+@SuppressWarnings("deprecation")
 public abstract class SymlinkBaseTest {
+  // Re-enable symlinks for tests, see HADOOP-10020 and HADOOP-10052
+  static {
+    FileSystem.enableSymlinks();
+  }
   static final long seed = 0xDEADBEEFL;
   static final int  blockSize =  8192;
   static final int  fileSize  = 16384;

+ 0 - 5
hadoop-common-project/hadoop-common/src/test/resources/core-site.xml

@@ -78,9 +78,4 @@
   <name>nfs3.mountd.port</name>
   <value>4272</value>
 </property>
-
-<property>
-  <name>test.SymlinkEnabledForTesting</name>
-  <value>true</value>
-</property>
 </configuration>

+ 5 - 0
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestSymlinkHdfsDisable.java

@@ -29,7 +29,12 @@ import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.junit.Test;
 
+@SuppressWarnings("deprecation")
 public class TestSymlinkHdfsDisable {
+  // Re-enable symlinks for tests, see HADOOP-10020 and HADOOP-10052
+  static {
+    FileSystem.enableSymlinks();
+  }
 
   @Test(timeout=60000)
   public void testSymlinkHdfsDisable() throws Exception {

+ 0 - 4
hadoop-hdfs-project/hadoop-hdfs/src/test/resources/hdfs-site.xml

@@ -31,8 +31,4 @@
     <value>0</value>
   </property>
 
- <property>
-   <name>test.SymlinkEnabledForTesting</name>
-   <value>true</value>
- </property>
 </configuration>