本文整理汇总了Java中org.apache.hadoop.hdfs.protocol.DirectoryListing.getLastName方法的典型用法代码示例。如果您正苦于以下问题:Java DirectoryListing.getLastName方法的具体用法?Java DirectoryListing.getLastName怎么用?Java DirectoryListing.getLastName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hdfs.protocol.DirectoryListing
的用法示例。
在下文中一共展示了DirectoryListing.getLastName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recoverAllLeases
import org.apache.hadoop.hdfs.protocol.DirectoryListing; //导入方法依赖的package包/类
static void recoverAllLeases(DFSClient dfs,
Path path) throws IOException {
String pathStr = path.toString();
HdfsFileStatus status = dfs.getFileInfo(pathStr);
if (!status.isDir()) {
dfs.recoverLease(pathStr);
return;
}
byte prev[] = HdfsFileStatus.EMPTY_NAME;
DirectoryListing dirList;
do {
dirList = dfs.listPaths(pathStr, prev);
HdfsFileStatus files[] = dirList.getPartialListing();
for (HdfsFileStatus f : files) {
recoverAllLeases(dfs, f.getFullPath(path));
}
prev = dirList.getLastName();
} while (dirList.hasMore());
}
示例2: getHdfsFileList
import org.apache.hadoop.hdfs.protocol.DirectoryListing; //导入方法依赖的package包/类
/**
* Retrieve list of files under @hdfsDir for @hdfsClient.
*/
public static List<HdfsFileStatus> getHdfsFileList(DFSClient hdfsClient,
String hdfsDir)
throws IOException {
List<HdfsFileStatus> fileList = Lists.newArrayList();
// Build a list of files.
DirectoryListing listing = null;
String continuation = "";
while (true) {
listing = hdfsClient.listPaths(hdfsDir, continuation.getBytes());
for (HdfsFileStatus fileStatus : listing.getPartialListing()) {
fileList.add(fileStatus);
}
// Go through the listing and paginate.
if (!listing.hasMore()) {
break;
} else {
continuation = new String(listing.getLastName());
}
}
return fileList;
}