本文整理汇总了Java中org.apache.hadoop.hdfs.protocol.HdfsFileStatus.getStoragePolicy方法的典型用法代码示例。如果您正苦于以下问题:Java HdfsFileStatus.getStoragePolicy方法的具体用法?Java HdfsFileStatus.getStoragePolicy怎么用?Java HdfsFileStatus.getStoragePolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hdfs.protocol.HdfsFileStatus
的用法示例。
在下文中一共展示了HdfsFileStatus.getStoragePolicy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus; //导入方法依赖的package包/类
@Override
public int run(Configuration conf, List<String> args) throws IOException {
final String path = StringUtils.popOptionWithArgument("-path", args);
if (path == null) {
System.err.println("Please specify the path with -path.\nUsage:" +
getLongUsage());
return 1;
}
final DistributedFileSystem dfs = AdminHelper.getDFS(conf);
try {
HdfsFileStatus status = dfs.getClient().getFileInfo(path);
if (status == null) {
System.err.println("File/Directory does not exist: " + path);
return 2;
}
byte storagePolicyId = status.getStoragePolicy();
if (storagePolicyId == BlockStoragePolicySuite.ID_UNSPECIFIED) {
System.out.println("The storage policy of " + path + " is unspecified");
return 0;
}
BlockStoragePolicy[] policies = dfs.getStoragePolicies();
for (BlockStoragePolicy p : policies) {
if (p.getId() == storagePolicyId) {
System.out.println("The storage policy of " + path + ":\n" + p);
return 0;
}
}
} catch (Exception e) {
System.err.println(AdminHelper.prettifyException(e));
return 2;
}
System.err.println("Cannot identify the storage policy for " + path);
return 2;
}
示例2: isLazyPersist
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus; //导入方法依赖的package包/类
private static boolean isLazyPersist(HdfsFileStatus stat) {
final BlockStoragePolicy p = blockStoragePolicySuite.getPolicy(
HdfsConstants.MEMORY_STORAGE_POLICY_NAME);
return p != null && stat.getStoragePolicy() == p.getId();
}