List of usage examples for org.apache.hadoop.fs FileSystemLinkResolver FileSystemLinkResolver
FileSystemLinkResolver
From source file:com.mellanox.r4h.DistributedFileSystem.java
License:Apache License
@SuppressWarnings("deprecation") @Override//w ww . j a v a 2 s . c om public boolean rename(Path src, Path dst) throws IOException { statistics.incrementWriteOps(1); final Path absSrc = fixRelativePart(src); final Path absDst = fixRelativePart(dst); // Try the rename without resolving first try { return dfs.rename(getPathName(absSrc), getPathName(absDst)); } catch (UnresolvedLinkException e) { // Fully resolve the source final Path source = getFileLinkStatus(absSrc).getPath(); // Keep trying to resolve the destination return new FileSystemLinkResolver<Boolean>() { @Override public Boolean doCall(final Path p) throws IOException, UnresolvedLinkException { return dfs.rename(getPathName(source), getPathName(p)); } @Override public Boolean next(final FileSystem fs, final Path p) throws IOException { // Should just throw an error in FileSystem#checkPath return doCall(p); } }.resolve(this, absDst); } }
From source file:com.mellanox.r4h.DistributedFileSystem.java
License:Apache License
/** * This rename operation is guaranteed to be atomic. *///from ww w . j a v a2 s . c o m @SuppressWarnings("deprecation") @Override public void rename(Path src, Path dst, final Options.Rename... options) throws IOException { statistics.incrementWriteOps(1); final Path absSrc = fixRelativePart(src); final Path absDst = fixRelativePart(dst); // Try the rename without resolving first try { dfs.rename(getPathName(absSrc), getPathName(absDst), options); } catch (UnresolvedLinkException e) { // Fully resolve the source final Path source = getFileLinkStatus(absSrc).getPath(); // Keep trying to resolve the destination new FileSystemLinkResolver<Void>() { @Override public Void doCall(final Path p) throws IOException, UnresolvedLinkException { dfs.rename(getPathName(source), getPathName(p), options); return null; } @Override public Void next(final FileSystem fs, final Path p) throws IOException { // Should just throw an error in FileSystem#checkPath return doCall(p); } }.resolve(this, absDst); } }
From source file:com.mellanox.r4h.DistributedFileSystem.java
License:Apache License
@Override public boolean truncate(Path f, final long newLength) throws IOException { statistics.incrementWriteOps(1);//from ww w.j a v a 2s . co m Path absF = fixRelativePart(f); return new FileSystemLinkResolver<Boolean>() { @Override public Boolean doCall(final Path p) throws IOException, UnresolvedLinkException { return dfs.truncate(getPathName(p), newLength); } @Override public Boolean next(final FileSystem fs, final Path p) throws IOException { return fs.truncate(p, newLength); } }.resolve(this, absF); }
From source file:com.mellanox.r4h.DistributedFileSystem.java
License:Apache License
@Override public boolean delete(Path f, final boolean recursive) throws IOException { statistics.incrementWriteOps(1);//ww w .ja v a 2s.c o m Path absF = fixRelativePart(f); return new FileSystemLinkResolver<Boolean>() { @Override public Boolean doCall(final Path p) throws IOException, UnresolvedLinkException { return dfs.delete(getPathName(p), recursive); } @Override public Boolean next(final FileSystem fs, final Path p) throws IOException { return fs.delete(p, recursive); } }.resolve(this, absF); }
From source file:com.mellanox.r4h.DistributedFileSystem.java
License:Apache License
@Override public ContentSummary getContentSummary(Path f) throws IOException { statistics.incrementReadOps(1);//from w w w. j a v a2s. c o m Path absF = fixRelativePart(f); return new FileSystemLinkResolver<ContentSummary>() { @Override public ContentSummary doCall(final Path p) throws IOException, UnresolvedLinkException { return dfs.getContentSummary(getPathName(p)); } @Override public ContentSummary next(final FileSystem fs, final Path p) throws IOException { return fs.getContentSummary(p); } }.resolve(this, absF); }
From source file:com.mellanox.r4h.DistributedFileSystem.java
License:Apache License
/** * Set a directory's quotas//ww w. j a va 2 s . c o m * * @see org.apache.hadoop.hdfs.protocol.ClientProtocol#setQuota(String, long, long, StorageType) */ public void setQuota(Path src, final long namespaceQuota, final long storagespaceQuota) throws IOException { Path absF = fixRelativePart(src); new FileSystemLinkResolver<Void>() { @Override public Void doCall(final Path p) throws IOException, UnresolvedLinkException { dfs.setQuota(getPathName(p), namespaceQuota, storagespaceQuota); return null; } @Override public Void next(final FileSystem fs, final Path p) throws IOException { // setQuota is not defined in FileSystem, so we only can resolve // within this DFS return doCall(p); } }.resolve(this, absF); }
From source file:com.mellanox.r4h.DistributedFileSystem.java
License:Apache License
/** * Set the per type storage quota of a directory. * * @param src/*from ww w . j ava 2 s . c o m*/ * target directory whose quota is to be modified. * @param type * storage type of the specific storage type quota to be modified. * @param quota * value of the specific storage type quota to be modified. * Maybe {@link HdfsConstants#QUOTA_RESET} to clear quota by storage type. */ public void setQuotaByStorageType(Path src, final StorageType type, final long quota) throws IOException { Path absF = fixRelativePart(src); new FileSystemLinkResolver<Void>() { @Override public Void doCall(final Path p) throws IOException, UnresolvedLinkException { dfs.setQuotaByStorageType(getPathName(p), type, quota); return null; } @Override public Void next(final FileSystem fs, final Path p) throws IOException { // setQuotaByStorageType is not defined in FileSystem, so we only can resolve // within this DFS return doCall(p); } }.resolve(this, absF); }
From source file:com.mellanox.r4h.DistributedFileSystem.java
License:Apache License
/** * List all the entries of a directory//from w w w. j av a 2 s . c om * * Note that this operation is not atomic for a large directory. * The entries of a directory may be fetched from NameNode multiple times. * It only guarantees that each name occurs once if a directory * undergoes changes between the calls. */ @Override public FileStatus[] listStatus(Path p) throws IOException { Path absF = fixRelativePart(p); return new FileSystemLinkResolver<FileStatus[]>() { @Override public FileStatus[] doCall(final Path p) throws IOException, UnresolvedLinkException { return listStatusInternal(p); } @Override public FileStatus[] next(final FileSystem fs, final Path p) throws IOException { return fs.listStatus(p); } }.resolve(this, absF); }
From source file:com.mellanox.r4h.DistributedFileSystem.java
License:Apache License
@Override protected RemoteIterator<LocatedFileStatus> listLocatedStatus(final Path p, final PathFilter filter) throws IOException { Path absF = fixRelativePart(p); return new FileSystemLinkResolver<RemoteIterator<LocatedFileStatus>>() { @Override/*from w w w . j a v a 2 s. c o m*/ public RemoteIterator<LocatedFileStatus> doCall(final Path p) throws IOException, UnresolvedLinkException { return new DirListingIterator<LocatedFileStatus>(p, filter, true); } @Override public RemoteIterator<LocatedFileStatus> next(final FileSystem fs, final Path p) throws IOException { if (fs instanceof DistributedFileSystem) { return ((DistributedFileSystem) fs).listLocatedStatus(p, filter); } // symlink resolution for this methos does not work cross file systems // because it is a protected method. throw new IOException("Link resolution does not work with multiple " + "file systems for listLocatedStatus(): " + p); } }.resolve(this, absF); }
From source file:com.mellanox.r4h.DistributedFileSystem.java
License:Apache License
/** * Returns a remote iterator so that followup calls are made on demand * while consuming the entries. This reduces memory consumption during * listing of a large directory./*from w ww . j a va2s . c o m*/ * * @param p * target path * @return remote iterator */ @Override public RemoteIterator<FileStatus> listStatusIterator(final Path p) throws IOException { Path absF = fixRelativePart(p); return new FileSystemLinkResolver<RemoteIterator<FileStatus>>() { @Override public RemoteIterator<FileStatus> doCall(final Path p) throws IOException, UnresolvedLinkException { return new DirListingIterator<FileStatus>(p, false); } @Override public RemoteIterator<FileStatus> next(final FileSystem fs, final Path p) throws IOException { return ((DistributedFileSystem) fs).listStatusIterator(p); } }.resolve(this, absF); }