|
@@ -23,6 +23,8 @@ import java.io.IOException;
|
|
import java.net.InetSocketAddress;
|
|
import java.net.InetSocketAddress;
|
|
import java.net.URI;
|
|
import java.net.URI;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
|
|
+import java.util.Collection;
|
|
import java.util.EnumSet;
|
|
import java.util.EnumSet;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -32,6 +34,7 @@ import org.apache.hadoop.classification.InterfaceStability;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.fs.BlockLocation;
|
|
import org.apache.hadoop.fs.BlockLocation;
|
|
import org.apache.hadoop.fs.BlockStorageLocation;
|
|
import org.apache.hadoop.fs.BlockStorageLocation;
|
|
|
|
+import org.apache.hadoop.fs.BlockStoragePolicySpi;
|
|
import org.apache.hadoop.fs.CacheFlag;
|
|
import org.apache.hadoop.fs.CacheFlag;
|
|
import org.apache.hadoop.fs.ContentSummary;
|
|
import org.apache.hadoop.fs.ContentSummary;
|
|
import org.apache.hadoop.fs.CreateFlag;
|
|
import org.apache.hadoop.fs.CreateFlag;
|
|
@@ -531,6 +534,7 @@ public class DistributedFileSystem extends FileSystem {
|
|
* @param src The source path referring to either a directory or a file.
|
|
* @param src The source path referring to either a directory or a file.
|
|
* @param policyName The name of the storage policy.
|
|
* @param policyName The name of the storage policy.
|
|
*/
|
|
*/
|
|
|
|
+ @Override
|
|
public void setStoragePolicy(final Path src, final String policyName)
|
|
public void setStoragePolicy(final Path src, final String policyName)
|
|
throws IOException {
|
|
throws IOException {
|
|
statistics.incrementWriteOps(1);
|
|
statistics.incrementWriteOps(1);
|
|
@@ -545,19 +549,24 @@ public class DistributedFileSystem extends FileSystem {
|
|
@Override
|
|
@Override
|
|
public Void next(final FileSystem fs, final Path p)
|
|
public Void next(final FileSystem fs, final Path p)
|
|
throws IOException {
|
|
throws IOException {
|
|
- if (fs instanceof DistributedFileSystem) {
|
|
|
|
- ((DistributedFileSystem) fs).setStoragePolicy(p, policyName);
|
|
|
|
- return null;
|
|
|
|
- } else {
|
|
|
|
- throw new UnsupportedOperationException(
|
|
|
|
- "Cannot perform setStoragePolicy on a non-DistributedFileSystem: "
|
|
|
|
- + src + " -> " + p);
|
|
|
|
- }
|
|
|
|
|
|
+ fs.setStoragePolicy(p, policyName);
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
}.resolve(this, absF);
|
|
}.resolve(this, absF);
|
|
}
|
|
}
|
|
|
|
|
|
- /** Get all the existing storage policies */
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public Collection<BlockStoragePolicy> getAllStoragePolicies()
|
|
|
|
+ throws IOException {
|
|
|
|
+ return Arrays.asList(dfs.getStoragePolicies());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Deprecated. Prefer {@link FileSystem#getAllStoragePolicies()}
|
|
|
|
+ * @return
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ @Deprecated
|
|
public BlockStoragePolicy[] getStoragePolicies() throws IOException {
|
|
public BlockStoragePolicy[] getStoragePolicies() throws IOException {
|
|
statistics.incrementReadOps(1);
|
|
statistics.incrementReadOps(1);
|
|
return dfs.getStoragePolicies();
|
|
return dfs.getStoragePolicies();
|