Browse Source

HADOOP-8328. Duplicate FileSystem Statistics object for 'file' scheme.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1335127 13f79535-47bb-0310-9956-ffa450edef68
Robert Joseph Evans 13 years ago
parent
commit
cafc6367ca

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

@@ -58,6 +58,9 @@ Release 0.23.3 - UNRELEASED
     HADOOP-8327. distcpv2 and distcpv1 jars should not coexist (Dave Thompson
     HADOOP-8327. distcpv2 and distcpv1 jars should not coexist (Dave Thompson
     via bobby)
     via bobby)
 
 
+    HADOOP-8328. Duplicate FileSystem Statistics object for 'file' scheme.
+    (tomwhite)
+
 Release 0.23.2 - UNRELEASED 
 Release 0.23.2 - UNRELEASED 
 
 
   NEW FEATURES
   NEW FEATURES

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

@@ -53,7 +53,7 @@ import org.apache.hadoop.util.Progressable;
 public class FilterFileSystem extends FileSystem {
 public class FilterFileSystem extends FileSystem {
   
   
   protected FileSystem fs;
   protected FileSystem fs;
-  private String swapScheme;
+  protected String swapScheme;
   
   
   /*
   /*
    * so that extending classes can define it
    * so that extending classes can define it

+ 11 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/LocalFileSystem.java

@@ -40,6 +40,17 @@ public class LocalFileSystem extends ChecksumFileSystem {
     this(new RawLocalFileSystem());
     this(new RawLocalFileSystem());
   }
   }
   
   
+  @Override
+  public void initialize(URI name, Configuration conf) throws IOException {
+    if (fs.getConf() == null) {
+      fs.initialize(name, conf);
+    }
+    String scheme = name.getScheme();
+    if (!scheme.equals(fs.getUri().getScheme())) {
+      swapScheme = scheme;
+    }
+  }
+
   public FileSystem getRaw() {
   public FileSystem getRaw() {
     return getRawFileSystem();
     return getRawFileSystem();
   }
   }

+ 15 - 0
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystem.java

@@ -18,11 +18,14 @@
 package org.apache.hadoop.fs;
 package org.apache.hadoop.fs;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem.Statistics;
+
 import static org.apache.hadoop.fs.FileSystemTestHelper.*;
 import static org.apache.hadoop.fs.FileSystemTestHelper.*;
 
 
 import java.io.*;
 import java.io.*;
 
 
 import static org.junit.Assert.*;
 import static org.junit.Assert.*;
+
 import org.junit.Before;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.Test;
 
 
@@ -233,4 +236,16 @@ public class TestLocalFileSystem {
     assertTrue("Did not delete file", fs.delete(file1));
     assertTrue("Did not delete file", fs.delete(file1));
     assertTrue("Did not delete non-empty dir", fs.delete(dir1));
     assertTrue("Did not delete non-empty dir", fs.delete(dir1));
   }
   }
+  
+  @Test
+  public void testStatistics() throws Exception {
+    FileSystem.getLocal(new Configuration());
+    int fileSchemeCount = 0;
+    for (Statistics stats : FileSystem.getAllStatistics()) {
+      if (stats.getScheme().equals("file")) {
+        fileSchemeCount++;
+      }
+    }
+    assertEquals(1, fileSchemeCount);
+  }
 }
 }