HDFS-14096. [SPS] : Add Support for Storage Policy Satisfier in ViewFs. Contributed by Ayush Saxena.
This commit is contained in:
parent
04c03476c9
commit
788e7473a4
@ -1254,6 +1254,16 @@ public void deleteSnapshot(final Path snapshotDir, final String snapshotName)
|
||||
+ " doesn't support deleteSnapshot");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the source path to satisfy storage policy.
|
||||
* @param path The source path referring to either a directory or a file.
|
||||
* @throws IOException
|
||||
*/
|
||||
public void satisfyStoragePolicy(final Path path) throws IOException {
|
||||
throw new UnsupportedOperationException(
|
||||
getClass().getSimpleName() + " doesn't support satisfyStoragePolicy");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the storage policy for a given file or directory.
|
||||
*
|
||||
|
@ -2780,6 +2780,24 @@ public Void next(final AbstractFileSystem fs, final Path p)
|
||||
}.resolve(this, absF);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the source path to satisfy storage policy.
|
||||
* @param path The source path referring to either a directory or a file.
|
||||
* @throws IOException
|
||||
*/
|
||||
public void satisfyStoragePolicy(final Path path)
|
||||
throws IOException {
|
||||
final Path absF = fixRelativePart(path);
|
||||
new FSLinkResolver<Void>() {
|
||||
@Override
|
||||
public Void next(final AbstractFileSystem fs, final Path p)
|
||||
throws IOException {
|
||||
fs.satisfyStoragePolicy(path);
|
||||
return null;
|
||||
}
|
||||
}.resolve(this, absF);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the storage policy for a given file or directory.
|
||||
*
|
||||
|
@ -3085,6 +3085,16 @@ public void removeXAttr(Path path, String name) throws IOException {
|
||||
+ " doesn't support removeXAttr");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the source path to satisfy storage policy.
|
||||
* @param path The source path referring to either a directory or a file.
|
||||
* @throws IOException
|
||||
*/
|
||||
public void satisfyStoragePolicy(final Path path) throws IOException {
|
||||
throw new UnsupportedOperationException(
|
||||
getClass().getSimpleName() + " doesn't support setStoragePolicy");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the storage policy for a given file or directory.
|
||||
*
|
||||
|
@ -645,6 +645,11 @@ public void removeXAttr(Path path, String name) throws IOException {
|
||||
fs.removeXAttr(path, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void satisfyStoragePolicy(Path src) throws IOException {
|
||||
fs.satisfyStoragePolicy(src);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoragePolicy(Path src, String policyName)
|
||||
throws IOException {
|
||||
|
@ -405,6 +405,11 @@ public void deleteSnapshot(final Path path, final String snapshotName)
|
||||
myFs.deleteSnapshot(path, snapshotName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void satisfyStoragePolicy(final Path path) throws IOException {
|
||||
myFs.satisfyStoragePolicy(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoragePolicy(Path path, String policyName)
|
||||
throws IOException {
|
||||
|
@ -449,6 +449,11 @@ public BlockStoragePolicySpi getStoragePolicy(Path src) throws IOException {
|
||||
return super.getStoragePolicy(fullPath(src));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void satisfyStoragePolicy(Path src) throws IOException {
|
||||
super.satisfyStoragePolicy(fullPath(src));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoragePolicy(Path src, String policyName) throws IOException {
|
||||
super.setStoragePolicy(fullPath(src), policyName);
|
||||
|
@ -398,6 +398,11 @@ public void deleteSnapshot(Path snapshotDir, String snapshotName)
|
||||
myFs.deleteSnapshot(fullPath(snapshotDir), snapshotName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void satisfyStoragePolicy(final Path path) throws IOException {
|
||||
myFs.satisfyStoragePolicy(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoragePolicy(Path path, String policyName)
|
||||
throws IOException {
|
||||
|
@ -810,6 +810,13 @@ public void deleteSnapshot(Path path, String snapshotName)
|
||||
res.targetFileSystem.deleteSnapshot(res.remainingPath, snapshotName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void satisfyStoragePolicy(Path src) throws IOException {
|
||||
InodeTree.ResolveResult<FileSystem> res =
|
||||
fsState.resolve(getUriPath(src), true);
|
||||
res.targetFileSystem.satisfyStoragePolicy(res.remainingPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoragePolicy(Path src, String policyName) throws IOException {
|
||||
InodeTree.ResolveResult<FileSystem> res = fsState.resolve(getUriPath(src),
|
||||
@ -1245,6 +1252,12 @@ public QuotaUsage getQuotaUsage(Path f) throws IOException {
|
||||
throw new NotInMountpointException(f, "getQuotaUsage");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void satisfyStoragePolicy(Path src) throws IOException {
|
||||
checkPathIsSlash(src);
|
||||
throw readOnlyMountTable("satisfyStoragePolicy", src);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoragePolicy(Path src, String policyName)
|
||||
throws IOException {
|
||||
|
@ -751,6 +751,13 @@ public void deleteSnapshot(Path path, String snapshotName) throws IOException {
|
||||
res.targetFileSystem.deleteSnapshot(res.remainingPath, snapshotName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void satisfyStoragePolicy(final Path path) throws IOException {
|
||||
InodeTree.ResolveResult<AbstractFileSystem> res =
|
||||
fsState.resolve(getUriPath(path), true);
|
||||
res.targetFileSystem.satisfyStoragePolicy(res.remainingPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoragePolicy(final Path path, final String policyName)
|
||||
throws IOException {
|
||||
@ -1154,6 +1161,11 @@ public void deleteSnapshot(Path path, String snapshotName)
|
||||
throw readOnlyMountTable("deleteSnapshot", path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void satisfyStoragePolicy(final Path path) throws IOException {
|
||||
throw readOnlyMountTable("satisfyStoragePolicy", path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoragePolicy(Path path, String policyName)
|
||||
throws IOException {
|
||||
|
@ -213,6 +213,8 @@ public Map<String, byte[]> getXAttrs(Path path, List<String> names)
|
||||
|
||||
public void access(Path path, FsAction mode) throws IOException;
|
||||
|
||||
void satisfyStoragePolicy(Path src) throws IOException;
|
||||
|
||||
public void setStoragePolicy(Path src, String policyName)
|
||||
throws IOException;
|
||||
|
||||
|
@ -968,6 +968,11 @@ public void testInternalUnsetStoragePolicy() throws IOException {
|
||||
fsView.unsetStoragePolicy(new Path("/internalDir"));
|
||||
}
|
||||
|
||||
@Test(expected = AccessControlException.class)
|
||||
public void testInternalSatisfyStoragePolicy() throws IOException {
|
||||
fsView.satisfyStoragePolicy(new Path("/internalDir"));
|
||||
}
|
||||
|
||||
@Test(expected = NotInMountpointException.class)
|
||||
public void testInternalgetStoragePolicy() throws IOException {
|
||||
fsView.getStoragePolicy(new Path("/internalDir"));
|
||||
|
@ -489,6 +489,11 @@ public void access(Path path, final FsAction mode) throws IOException {
|
||||
dfs.checkAccess(getUriPath(path), mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void satisfyStoragePolicy(Path path) throws IOException {
|
||||
dfs.satisfyStoragePolicy(getUriPath(path));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoragePolicy(Path path, String policyName) throws IOException {
|
||||
dfs.setStoragePolicy(getUriPath(path), policyName);
|
||||
|
@ -2870,11 +2870,7 @@ public Void next(final FileSystem fs, final Path p) throws IOException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the source path to satisfy storage policy. This API is non-recursive
|
||||
* in nature, i.e., if the source path is a directory then all the files
|
||||
* immediately under the directory would be considered for satisfying the
|
||||
* policy and the sub-directories if any under this path will be skipped.
|
||||
*
|
||||
* Set the source path to satisfy storage policy.
|
||||
* @param path The source path referring to either a directory or a file.
|
||||
* @throws IOException
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user