HDFS-9894. Add unsetStoragePolicy API to FileContext/AbstractFileSystem and derivatives. Contributed by Xiaobing Zhou.
This commit is contained in:
parent
14ab7a81e2
commit
4a043b3fec
@ -1236,6 +1236,17 @@ public void setStoragePolicy(final Path path, final String policyName)
|
||||
+ " doesn't support setStoragePolicy");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unset the storage policy set for a given file or directory.
|
||||
* @param src file or directory path.
|
||||
* @throws IOException
|
||||
*/
|
||||
public void unsetStoragePolicy(final Path src) throws IOException {
|
||||
throw new UnsupportedOperationException(getClass().getSimpleName()
|
||||
+ " doesn't support unsetStoragePolicy");
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the storage policy for a given file or directory.
|
||||
*
|
||||
|
@ -2695,6 +2695,23 @@ public Void next(final AbstractFileSystem fs, final Path p)
|
||||
}.resolve(this, absF);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset the storage policy set for a given file or directory.
|
||||
* @param src file or directory path.
|
||||
* @throws IOException
|
||||
*/
|
||||
public void unsetStoragePolicy(final Path src) throws IOException {
|
||||
final Path absF = fixRelativePart(src);
|
||||
new FSLinkResolver<Void>() {
|
||||
@Override
|
||||
public Void next(final AbstractFileSystem fs, final Path p)
|
||||
throws IOException {
|
||||
fs.unsetStoragePolicy(src);
|
||||
return null;
|
||||
}
|
||||
}.resolve(this, absF);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the effective storage policy ID for the given file or directory.
|
||||
*
|
||||
|
@ -2663,7 +2663,7 @@ public void setStoragePolicy(final Path src, final String policyName)
|
||||
* @param src file or directory path.
|
||||
* @throws IOException
|
||||
*/
|
||||
public void unsetStoragePolicy(Path src) throws IOException {
|
||||
public void unsetStoragePolicy(final Path src) throws IOException {
|
||||
throw new UnsupportedOperationException(getClass().getSimpleName()
|
||||
+ " doesn't support unsetStoragePolicy");
|
||||
}
|
||||
|
@ -405,6 +405,12 @@ public void setStoragePolicy(Path path, String policyName)
|
||||
myFs.setStoragePolicy(path, policyName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsetStoragePolicy(final Path src)
|
||||
throws IOException {
|
||||
myFs.unsetStoragePolicy(src);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStoragePolicySpi getStoragePolicy(final Path src)
|
||||
throws IOException {
|
||||
|
@ -385,6 +385,12 @@ public void setStoragePolicy(Path path, String policyName)
|
||||
myFs.setStoragePolicy(fullPath(path), policyName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsetStoragePolicy(final Path src)
|
||||
throws IOException {
|
||||
myFs.unsetStoragePolicy(fullPath(src));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStoragePolicySpi getStoragePolicy(final Path src)
|
||||
throws IOException {
|
||||
|
@ -749,6 +749,14 @@ public void setStoragePolicy(final Path path, final String policyName)
|
||||
res.targetFileSystem.setStoragePolicy(res.remainingPath, policyName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsetStoragePolicy(final Path src)
|
||||
throws IOException {
|
||||
InodeTree.ResolveResult<AbstractFileSystem> res =
|
||||
fsState.resolve(getUriPath(src), true);
|
||||
res.targetFileSystem.unsetStoragePolicy(res.remainingPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the storage policy for a given file or directory.
|
||||
*
|
||||
|
@ -473,6 +473,11 @@ public void setStoragePolicy(Path path, String policyName) throws IOException {
|
||||
dfs.setStoragePolicy(getUriPath(path), policyName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsetStoragePolicy(final Path src) throws IOException {
|
||||
dfs.unsetStoragePolicy(getUriPath(src));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStoragePolicySpi getStoragePolicy(Path src) throws IOException {
|
||||
return dfs.getStoragePolicy(getUriPath(src));
|
||||
|
Loading…
Reference in New Issue
Block a user