feat(hudi-query): 增加一个查询路径大小的接口
This commit is contained in:
@@ -66,4 +66,9 @@ public class HdfsController {
|
||||
public void download(@RequestParam("root")String root, HttpServletResponse response) throws IOException {
|
||||
hdfsService.download(root, response.getOutputStream());
|
||||
}
|
||||
|
||||
@GetMapping("size")
|
||||
public Long size(@RequestParam("root")String root) throws IOException {
|
||||
return hdfsService.size(root);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,4 +143,11 @@ public class HdfsService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Cacheable(value = "size-hpath", sync = true)
|
||||
public Long size(String root) throws IOException {
|
||||
try (FileSystem fileSystem = FileSystem.get(new Configuration())) {
|
||||
return fileSystem.getContentSummary(new Path(root)).getLength();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user