feat(hudi-query): 增加一个查询路径大小的接口
This commit is contained in:
@@ -78,4 +78,7 @@ public interface HudiService {
|
|||||||
|
|
||||||
@Get("/hdfs/download")
|
@Get("/hdfs/download")
|
||||||
InputStream download(@Query("root") String root);
|
InputStream download(@Query("root") String root);
|
||||||
|
|
||||||
|
@Get("/hdfs/size")
|
||||||
|
String size(@Query("root") String root);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,4 +66,9 @@ public class HdfsController {
|
|||||||
public void download(@RequestParam("root")String root, HttpServletResponse response) throws IOException {
|
public void download(@RequestParam("root")String root, HttpServletResponse response) throws IOException {
|
||||||
hdfsService.download(root, response.getOutputStream());
|
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