|
@@ -190,6 +190,7 @@ public final class FileContext {
|
|
|
new FileContextFinalizer();
|
|
|
|
|
|
private static final PathFilter DEFAULT_FILTER = new PathFilter() {
|
|
|
+ @Override
|
|
|
public boolean accept(final Path file) {
|
|
|
return true;
|
|
|
}
|
|
@@ -318,6 +319,7 @@ public final class FileContext {
|
|
|
throws UnsupportedFileSystemException, IOException {
|
|
|
try {
|
|
|
return user.doAs(new PrivilegedExceptionAction<AbstractFileSystem>() {
|
|
|
+ @Override
|
|
|
public AbstractFileSystem run() throws UnsupportedFileSystemException {
|
|
|
return AbstractFileSystem.get(uri, conf);
|
|
|
}
|
|
@@ -660,6 +662,7 @@ public final class FileContext {
|
|
|
final CreateOpts[] updatedOpts =
|
|
|
CreateOpts.setOpt(CreateOpts.perms(permission), opts);
|
|
|
return new FSLinkResolver<FSDataOutputStream>() {
|
|
|
+ @Override
|
|
|
public FSDataOutputStream next(final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException {
|
|
|
return fs.create(p, createFlag, updatedOpts);
|
|
@@ -703,6 +706,7 @@ public final class FileContext {
|
|
|
final FsPermission absFerms = (permission == null ?
|
|
|
FsPermission.getDefault() : permission).applyUMask(umask);
|
|
|
new FSLinkResolver<Void>() {
|
|
|
+ @Override
|
|
|
public Void next(final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException, UnresolvedLinkException {
|
|
|
fs.mkdir(p, absFerms, createParent);
|
|
@@ -738,6 +742,7 @@ public final class FileContext {
|
|
|
UnsupportedFileSystemException, IOException {
|
|
|
Path absF = fixRelativePart(f);
|
|
|
return new FSLinkResolver<Boolean>() {
|
|
|
+ @Override
|
|
|
public Boolean next(final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException, UnresolvedLinkException {
|
|
|
return Boolean.valueOf(fs.delete(p, recursive));
|
|
@@ -766,6 +771,7 @@ public final class FileContext {
|
|
|
FileNotFoundException, UnsupportedFileSystemException, IOException {
|
|
|
final Path absF = fixRelativePart(f);
|
|
|
return new FSLinkResolver<FSDataInputStream>() {
|
|
|
+ @Override
|
|
|
public FSDataInputStream next(final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException, UnresolvedLinkException {
|
|
|
return fs.open(p);
|
|
@@ -796,6 +802,7 @@ public final class FileContext {
|
|
|
UnsupportedFileSystemException, IOException {
|
|
|
final Path absF = fixRelativePart(f);
|
|
|
return new FSLinkResolver<FSDataInputStream>() {
|
|
|
+ @Override
|
|
|
public FSDataInputStream next(final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException, UnresolvedLinkException {
|
|
|
return fs.open(p, bufferSize);
|
|
@@ -826,6 +833,7 @@ public final class FileContext {
|
|
|
IOException {
|
|
|
final Path absF = fixRelativePart(f);
|
|
|
return new FSLinkResolver<Boolean>() {
|
|
|
+ @Override
|
|
|
public Boolean next(final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException, UnresolvedLinkException {
|
|
|
return Boolean.valueOf(fs.setReplication(p, replication));
|
|
@@ -894,6 +902,7 @@ public final class FileContext {
|
|
|
*/
|
|
|
final Path source = resolveIntermediate(absSrc);
|
|
|
new FSLinkResolver<Void>() {
|
|
|
+ @Override
|
|
|
public Void next(final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException, UnresolvedLinkException {
|
|
|
fs.rename(source, p, options);
|
|
@@ -925,6 +934,7 @@ public final class FileContext {
|
|
|
UnsupportedFileSystemException, IOException {
|
|
|
final Path absF = fixRelativePart(f);
|
|
|
new FSLinkResolver<Void>() {
|
|
|
+ @Override
|
|
|
public Void next(final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException, UnresolvedLinkException {
|
|
|
fs.setPermission(p, permission);
|
|
@@ -967,6 +977,7 @@ public final class FileContext {
|
|
|
}
|
|
|
final Path absF = fixRelativePart(f);
|
|
|
new FSLinkResolver<Void>() {
|
|
|
+ @Override
|
|
|
public Void next(final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException, UnresolvedLinkException {
|
|
|
fs.setOwner(p, username, groupname);
|
|
@@ -1002,6 +1013,7 @@ public final class FileContext {
|
|
|
UnsupportedFileSystemException, IOException {
|
|
|
final Path absF = fixRelativePart(f);
|
|
|
new FSLinkResolver<Void>() {
|
|
|
+ @Override
|
|
|
public Void next(final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException, UnresolvedLinkException {
|
|
|
fs.setTimes(p, mtime, atime);
|
|
@@ -1034,6 +1046,7 @@ public final class FileContext {
|
|
|
IOException {
|
|
|
final Path absF = fixRelativePart(f);
|
|
|
return new FSLinkResolver<FileChecksum>() {
|
|
|
+ @Override
|
|
|
public FileChecksum next(final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException, UnresolvedLinkException {
|
|
|
return fs.getFileChecksum(p);
|
|
@@ -1089,6 +1102,7 @@ public final class FileContext {
|
|
|
FileNotFoundException, UnsupportedFileSystemException, IOException {
|
|
|
final Path absF = fixRelativePart(f);
|
|
|
return new FSLinkResolver<FileStatus>() {
|
|
|
+ @Override
|
|
|
public FileStatus next(final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException, UnresolvedLinkException {
|
|
|
return fs.getFileStatus(p);
|
|
@@ -1135,6 +1149,7 @@ public final class FileContext {
|
|
|
UnsupportedFileSystemException, IOException {
|
|
|
final Path absF = fixRelativePart(f);
|
|
|
return new FSLinkResolver<FileStatus>() {
|
|
|
+ @Override
|
|
|
public FileStatus next(final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException, UnresolvedLinkException {
|
|
|
FileStatus fi = fs.getFileLinkStatus(p);
|
|
@@ -1165,6 +1180,7 @@ public final class FileContext {
|
|
|
FileNotFoundException, UnsupportedFileSystemException, IOException {
|
|
|
final Path absF = fixRelativePart(f);
|
|
|
return new FSLinkResolver<Path>() {
|
|
|
+ @Override
|
|
|
public Path next(final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException, UnresolvedLinkException {
|
|
|
FileStatus fi = fs.getFileLinkStatus(p);
|
|
@@ -1208,6 +1224,7 @@ public final class FileContext {
|
|
|
UnsupportedFileSystemException, IOException {
|
|
|
final Path absF = fixRelativePart(f);
|
|
|
return new FSLinkResolver<BlockLocation[]>() {
|
|
|
+ @Override
|
|
|
public BlockLocation[] next(final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException, UnresolvedLinkException {
|
|
|
return fs.getFileBlockLocations(p, start, len);
|
|
@@ -1246,6 +1263,7 @@ public final class FileContext {
|
|
|
}
|
|
|
final Path absF = fixRelativePart(f);
|
|
|
return new FSLinkResolver<FsStatus>() {
|
|
|
+ @Override
|
|
|
public FsStatus next(final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException, UnresolvedLinkException {
|
|
|
return fs.getFsStatus(p);
|
|
@@ -1339,6 +1357,7 @@ public final class FileContext {
|
|
|
IOException {
|
|
|
final Path nonRelLink = fixRelativePart(link);
|
|
|
new FSLinkResolver<Void>() {
|
|
|
+ @Override
|
|
|
public Void next(final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException, UnresolvedLinkException {
|
|
|
fs.createSymlink(target, p, createParent);
|
|
@@ -1373,6 +1392,7 @@ public final class FileContext {
|
|
|
UnsupportedFileSystemException, IOException {
|
|
|
final Path absF = fixRelativePart(f);
|
|
|
return new FSLinkResolver<RemoteIterator<FileStatus>>() {
|
|
|
+ @Override
|
|
|
public RemoteIterator<FileStatus> next(
|
|
|
final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException, UnresolvedLinkException {
|
|
@@ -1432,6 +1452,7 @@ public final class FileContext {
|
|
|
UnsupportedFileSystemException, IOException {
|
|
|
final Path absF = fixRelativePart(f);
|
|
|
return new FSLinkResolver<RemoteIterator<LocatedFileStatus>>() {
|
|
|
+ @Override
|
|
|
public RemoteIterator<LocatedFileStatus> next(
|
|
|
final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException, UnresolvedLinkException {
|
|
@@ -1703,6 +1724,7 @@ public final class FileContext {
|
|
|
IOException {
|
|
|
final Path absF = fixRelativePart(f);
|
|
|
return new FSLinkResolver<FileStatus[]>() {
|
|
|
+ @Override
|
|
|
public FileStatus[] next(final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException, UnresolvedLinkException {
|
|
|
return fs.listStatus(p);
|
|
@@ -2232,6 +2254,7 @@ public final class FileContext {
|
|
|
* Deletes all the paths in deleteOnExit on JVM shutdown.
|
|
|
*/
|
|
|
static class FileContextFinalizer implements Runnable {
|
|
|
+ @Override
|
|
|
public synchronized void run() {
|
|
|
processDeleteOnExit();
|
|
|
}
|
|
@@ -2244,6 +2267,7 @@ public final class FileContext {
|
|
|
protected Path resolve(final Path f) throws FileNotFoundException,
|
|
|
UnresolvedLinkException, AccessControlException, IOException {
|
|
|
return new FSLinkResolver<Path>() {
|
|
|
+ @Override
|
|
|
public Path next(final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException, UnresolvedLinkException {
|
|
|
return fs.resolvePath(p);
|
|
@@ -2259,6 +2283,7 @@ public final class FileContext {
|
|
|
*/
|
|
|
protected Path resolveIntermediate(final Path f) throws IOException {
|
|
|
return new FSLinkResolver<FileStatus>() {
|
|
|
+ @Override
|
|
|
public FileStatus next(final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException, UnresolvedLinkException {
|
|
|
return fs.getFileLinkStatus(p);
|
|
@@ -2281,6 +2306,7 @@ public final class FileContext {
|
|
|
final HashSet<AbstractFileSystem> result
|
|
|
= new HashSet<AbstractFileSystem>();
|
|
|
new FSLinkResolver<Void>() {
|
|
|
+ @Override
|
|
|
public Void next(final AbstractFileSystem fs, final Path p)
|
|
|
throws IOException, UnresolvedLinkException {
|
|
|
result.add(fs);
|