Skip to content

Commit 0977ebe

Browse files
committed
Merge -r 1335084:1335085 from trunk to branch-2. Fixes: HADOOP-8328
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1335087 13f79535-47bb-0310-9956-ffa450edef68
1 parent e02fcf8 commit 0977ebe

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

hadoop-common-project/hadoop-common/CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
public 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

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff 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.

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@
1818
package org.apache.hadoop.fs;
1919

2020
import org.apache.hadoop.conf.Configuration;
21+
import org.apache.hadoop.fs.FileSystem.Statistics;
22+
2123
import static org.apache.hadoop.fs.FileSystemTestHelper.*;
2224

2325
import java.io.*;
2426

2527
import static org.junit.Assert.*;
28+
2629
import org.junit.Before;
2730
import 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
}

0 commit comments

Comments
 (0)