File tree Expand file tree Collapse file tree 4 files changed +30
-1
lines changed
hadoop-common-project/hadoop-common
main/java/org/apache/hadoop/fs
test/java/org/apache/hadoop/fs Expand file tree Collapse file tree 4 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -294,6 +294,9 @@ Release 2.0.0 - UNRELEASED
294294
295295 HADOOP-8349. ViewFS doesn't work when the root of a file system is mounted. (atm)
296296
297+ HADOOP-8328. Duplicate FileSystem Statistics object for 'file' scheme.
298+ (tomwhite)
299+
297300 BREAKDOWN OF HADOOP-7454 SUBTASKS
298301
299302 HADOOP-7455. HA: Introduce HA Service Protocol Interface. (suresh)
Original file line number Diff line number Diff line change 5353public class FilterFileSystem extends FileSystem {
5454
5555 protected FileSystem fs ;
56- private String swapScheme ;
56+ protected String swapScheme ;
5757
5858 /*
5959 * so that extending classes can define it
Original file line number Diff line number Diff line change @@ -39,6 +39,17 @@ public class LocalFileSystem extends ChecksumFileSystem {
3939 public LocalFileSystem () {
4040 this (new RawLocalFileSystem ());
4141 }
42+
43+ @ Override
44+ public void initialize (URI name , Configuration conf ) throws IOException {
45+ if (fs .getConf () == null ) {
46+ fs .initialize (name , conf );
47+ }
48+ String scheme = name .getScheme ();
49+ if (!scheme .equals (fs .getUri ().getScheme ())) {
50+ swapScheme = scheme ;
51+ }
52+ }
4253
4354 /**
4455 * Return the protocol scheme for the FileSystem.
Original file line number Diff line number Diff line change 1818package org .apache .hadoop .fs ;
1919
2020import org .apache .hadoop .conf .Configuration ;
21+ import org .apache .hadoop .fs .FileSystem .Statistics ;
22+
2123import static org .apache .hadoop .fs .FileSystemTestHelper .*;
2224
2325import java .io .*;
2426
2527import static org .junit .Assert .*;
28+
2629import org .junit .Before ;
2730import org .junit .Test ;
2831
@@ -233,4 +236,16 @@ public void testBasicDelete() throws IOException {
233236 assertTrue ("Did not delete file" , fs .delete (file1 ));
234237 assertTrue ("Did not delete non-empty dir" , fs .delete (dir1 ));
235238 }
239+
240+ @ Test
241+ public void testStatistics () throws Exception {
242+ FileSystem .getLocal (new Configuration ());
243+ int fileSchemeCount = 0 ;
244+ for (Statistics stats : FileSystem .getAllStatistics ()) {
245+ if (stats .getScheme ().equals ("file" )) {
246+ fileSchemeCount ++;
247+ }
248+ }
249+ assertEquals (1 , fileSchemeCount );
250+ }
236251}
You can’t perform that action at this time.
0 commit comments