[
https://issues.apache.org/jira/browse/HADOOP-15465?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16479580#comment-16479580
]
Giovanni Matteo Fumarola commented on HADOOP-15465:
---------------------------------------------------
Thanks [[email protected]] for the review.
I had the same thought about the failure to symlink and this is the analysis I
did.
Right now we have 3 possible callers, each of them have different behaviors in
case of failure. {{RawLocalFileSystem}} throws an IOException.
\{{LocalDistributedCache}} logs a warning, while the caller
{{DefaultContainerExecutor}} does not react.
*Currently* WinUtils (in Windows) / ln (in Unix) can return 0 on success and 1
on failure. In a specific security case, WinUtils can return 2.
In a case of either one of those throws an IOException, the code logs and
rethrows it.
From [Oracle Files
Javadoc|[https://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#createSymbolicLink(java.nio.file.Path,%20java.nio.file.Path,%20java.nio.file.attribute.FileAttribute...)]]
CreateSymbolicLink returns the path to the symbolic link and it can throws:
*
{{[UnsupportedOperationException|https://docs.oracle.com/javase/7/docs/api/java/lang/UnsupportedOperationException.html]}}
- if the implementation does not support symbolic links or the array contains
an attribute that cannot be set atomically when creating the symbolic link;
*
{{[FileAlreadyExistsException|https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileAlreadyExistsException.html]}}
- if a file with the name already exists _(optional specific exception);_
*
{{[IOException|https://docs.oracle.com/javase/7/docs/api/java/io/IOException.html]}}
- if an I/O error occurs;
*
{{[SecurityException|https://docs.oracle.com/javase/7/docs/api/java/lang/SecurityException.html]}}
- In the case of the default provider, and a security manager is installed, it
denies
[{{LinkPermission}}|https://docs.oracle.com/javase/7/docs/api/java/nio/file/LinkPermission.html]{{("symbolic")}}
or its
[{{checkWrite}}|https://docs.oracle.com/javase/7/docs/api/java/lang/SecurityManager.html#checkWrite(java.lang.String)]
method denies write access to the path of the symbolic link.
I did not find any references to it but I suppose {{CreateSymbolicLink}} can
succeed or can throw an exception and it cannot return null on failure.
In the *new code*, in case of SecurityException, it returns 2 in both
environments (Win and Unix).
In case of IOException, it logs and rethrows it - as it is happening in the
current code.
My only concerns are about FileAlreadyExists and UnsupportedOperation. We
should catch and return 1.
Thoughts?
> Deprecate WinUtils#Symlinks by using native java code
> -----------------------------------------------------
>
> Key: HADOOP-15465
> URL: https://issues.apache.org/jira/browse/HADOOP-15465
> Project: Hadoop Common
> Issue Type: Sub-task
> Reporter: Íñigo Goiri
> Assignee: Giovanni Matteo Fumarola
> Priority: Major
> Attachments: HADOOP-15465.v0.patch, HADOOP-15465.v0.proto.patch,
> HADOOP-15465.v1.patch, HADOOP-15465.v2.patch
>
>
> Hadoop uses the shell to create symbolic links. Now that Hadoop relies on
> Java 7+, we can deprecate all the shell code and rely on the Java APIs.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]