Skip to content

Commit dc86d7d

Browse files
committed
revert HADOOP-9652
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1508248 13f79535-47bb-0310-9956-ffa450edef68
1 parent 805e29b commit dc86d7d

File tree

10 files changed

+158
-360
lines changed

10 files changed

+158
-360
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,6 @@ Release 2.3.0 - UNRELEASED
310310
HADOOP-9582. Non-existent file to "hadoop fs -conf" doesn't throw error
311311
(Ashwin Shankar via jlowe)
312312

313-
HADOOP-9652. RawLocalFs#getFileLinkStatus does not fill in the link owner
314-
and mode. (Andrew Wang via Colin Patrick McCabe)
315-
316313
Release 2.1.1-beta - UNRELEASED
317314

318315
INCOMPATIBLE CHANGES

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,7 @@ public FileStatus getFileStatus(Path f) throws IOException {
113113

114114
@Override
115115
public FileStatus getFileLinkStatus(final Path f) throws IOException {
116-
FileStatus status = fsImpl.getFileLinkStatus(f);
117-
// FileSystem#getFileLinkStatus qualifies the link target
118-
// AbstractFileSystem needs to return it plain since it's qualified
119-
// in FileContext, so re-get and set the plain target
120-
if (status.isSymlink()) {
121-
status.setSymlink(fsImpl.getLinkTarget(f));
122-
}
123-
return status;
116+
return getFileStatus(f);
124117
}
125118

126119
@Override
@@ -206,18 +199,22 @@ public void setVerifyChecksum(boolean verifyChecksum) throws IOException {
206199

207200
@Override
208201
public boolean supportsSymlinks() {
209-
return fsImpl.supportsSymlinks();
202+
return false;
210203
}
211204

212205
@Override
213206
public void createSymlink(Path target, Path link, boolean createParent)
214207
throws IOException {
215-
fsImpl.createSymlink(target, link, createParent);
208+
throw new IOException("File system does not support symlinks");
216209
}
217210

218211
@Override
219212
public Path getLinkTarget(final Path f) throws IOException {
220-
return fsImpl.getLinkTarget(f);
213+
/* We should never get here. Any file system that threw an
214+
* UnresolvedLinkException, causing this function to be called,
215+
* should override getLinkTarget.
216+
*/
217+
throw new AssertionError();
221218
}
222219

223220
@Override //AbstractFileSystem

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

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.util.Arrays;
2727

2828
import org.apache.hadoop.util.Shell;
29-
import org.apache.hadoop.util.Shell.OSType;
3029

3130
/**
3231
* Class for creating hardlinks.
@@ -42,19 +41,28 @@
4241
*/
4342
public class HardLink {
4443

45-
public static OSType osType = Shell.osType;
44+
public enum OSType {
45+
OS_TYPE_UNIX,
46+
OS_TYPE_WIN,
47+
OS_TYPE_SOLARIS,
48+
OS_TYPE_MAC,
49+
OS_TYPE_FREEBSD
50+
}
51+
52+
public static OSType osType;
4653
private static HardLinkCommandGetter getHardLinkCommand;
4754

4855
public final LinkStats linkStats; //not static
4956

5057
//initialize the command "getters" statically, so can use their
5158
//methods without instantiating the HardLink object
5259
static {
60+
osType = getOSType();
5361
if (osType == OSType.OS_TYPE_WIN) {
5462
// Windows
5563
getHardLinkCommand = new HardLinkCGWin();
5664
} else {
57-
// Unix or Linux
65+
// Unix
5866
getHardLinkCommand = new HardLinkCGUnix();
5967
//override getLinkCountCommand for the particular Unix variant
6068
//Linux is already set as the default - {"stat","-c%h", null}
@@ -71,7 +79,27 @@ public class HardLink {
7179
public HardLink() {
7280
linkStats = new LinkStats();
7381
}
74-
82+
83+
static private OSType getOSType() {
84+
String osName = System.getProperty("os.name");
85+
if (Shell.WINDOWS) {
86+
return OSType.OS_TYPE_WIN;
87+
}
88+
else if (osName.contains("SunOS")
89+
|| osName.contains("Solaris")) {
90+
return OSType.OS_TYPE_SOLARIS;
91+
}
92+
else if (osName.contains("Mac")) {
93+
return OSType.OS_TYPE_MAC;
94+
}
95+
else if (osName.contains("FreeBSD")) {
96+
return OSType.OS_TYPE_FREEBSD;
97+
}
98+
else {
99+
return OSType.OS_TYPE_UNIX;
100+
}
101+
}
102+
75103
/**
76104
* This abstract class bridges the OS-dependent implementations of the
77105
* needed functionality for creating hardlinks and querying link counts.

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

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,6 @@ public FileStatus[] listStatus(Path f) throws IOException {
385385
throw new FileNotFoundException("File " + f + " does not exist");
386386
}
387387
if (localf.isFile()) {
388-
if (!Shell.WINDOWS) {
389-
return new FileStatus[] { getFileStatus(f) };
390-
}
391388
return new FileStatus[] {
392389
new RawLocalFileStatus(localf, getDefaultBlockSize(f), this) };
393390
}
@@ -519,10 +516,6 @@ public String toString() {
519516

520517
@Override
521518
public FileStatus getFileStatus(Path f) throws IOException {
522-
if (!Shell.WINDOWS) {
523-
return getFileLinkStatusInternal(f, true);
524-
}
525-
526519
File path = pathToFile(f);
527520
if (path.exists()) {
528521
return new RawLocalFileStatus(pathToFile(f), getDefaultBlockSize(f), this);
@@ -531,7 +524,6 @@ public FileStatus getFileStatus(Path f) throws IOException {
531524
}
532525
}
533526

534-
@Deprecated
535527
static class RawLocalFileStatus extends FileStatus {
536528
/* We can add extra fields here. It breaks at least CopyFiles.FilePair().
537529
* We recognize if the information is already loaded by check if
@@ -705,7 +697,6 @@ public void createSymlink(Path target, Path link, boolean createParent)
705697
* the given path does not refer to a symlink or there is an error
706698
* accessing the symlink.
707699
*/
708-
@Deprecated
709700
private String readLink(Path p) {
710701
/* NB: Use readSymbolicLink in java.nio.file.Path once available. Could
711702
* use getCanonicalPath in File to get the target of the symlink but that
@@ -726,12 +717,7 @@ private String readLink(Path p) {
726717
*/
727718
@Override
728719
public FileStatus getFileLinkStatus(final Path f) throws IOException {
729-
FileStatus fi;
730-
if (!Shell.WINDOWS) {
731-
fi = getFileLinkStatusInternal(f, false);
732-
} else {
733-
fi = getFileLinkStatusInternal(f);
734-
}
720+
FileStatus fi = getFileLinkStatusInternal(f);
735721
// getFileLinkStatus is supposed to return a symlink with a
736722
// qualified path
737723
if (fi.isSymlink()) {
@@ -742,12 +728,6 @@ public FileStatus getFileLinkStatus(final Path f) throws IOException {
742728
return fi;
743729
}
744730

745-
/**
746-
* Deprecated. Remains for windows support. Should be removed in favor of
747-
* {@link #getFileLinkStatusInternal(Path, boolean)} when {@link Stat} gains
748-
* support for windows.
749-
*/
750-
@Deprecated
751731
private FileStatus getFileLinkStatusInternal(final Path f) throws IOException {
752732
String target = readLink(f);
753733

@@ -785,17 +765,9 @@ private FileStatus getFileLinkStatusInternal(final Path f) throws IOException {
785765
}
786766
}
787767

788-
private FileStatus getFileLinkStatusInternal(final Path f,
789-
boolean dereference) throws IOException {
790-
checkPath(f);
791-
Stat stat = new Stat(f, getDefaultBlockSize(f), dereference, this);
792-
FileStatus status = stat.getFileStatus();
793-
return status;
794-
}
795-
796768
@Override
797769
public Path getLinkTarget(Path f) throws IOException {
798-
FileStatus fi = getFileLinkStatusInternal(f, false);
770+
FileStatus fi = getFileLinkStatusInternal(f);
799771
// return an unqualified symlink target
800772
return fi.getSymlink();
801773
}

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

Lines changed: 0 additions & 159 deletions
This file was deleted.

0 commit comments

Comments
 (0)