feat(hudi-query): 增加一个查询路径大小的接口

This commit is contained in:
v-zhangjc9
2024-04-29 14:41:35 +08:00
parent 0fa0a396ef
commit 5d3f0140f5
3 changed files with 15 additions and 0 deletions

View File

@@ -78,4 +78,7 @@ public interface HudiService {
@Get("/hdfs/download")
InputStream download(@Query("root") String root);
@Get("/hdfs/size")
String size(@Query("root") String root);
}

View File

@@ -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);
}
}

View File

@@ -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();
}
}
}