You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kylin.apache.org by GitBox <gi...@apache.org> on 2021/01/22 05:25:54 UTC
[GitHub] [kylin] zzcclp commented on a change in pull request #1555: Fix storage clean up tool
zzcclp commented on a change in pull request #1555:
URL: https://github.com/apache/kylin/pull/1555#discussion_r562395655
##########
File path: server-base/src/main/java/org/apache/kylin/rest/job/StorageCleanupJob.java
##########
@@ -83,38 +86,27 @@ protected void execute(OptionsHelper optionsHelper) throws Exception {
public void cleanup() throws Exception {
ProjectManager projectManager = ProjectManager.getInstance(config);
CubeManager cubeManager = CubeManager.getInstance(config);
-
- //clean up job temp files
List<String> projects = projectManager.listAllProjects().stream().map(ProjectInstance::getName).collect(Collectors.toList());
- for (String project : projects) {
- String tmpPath = config.getJobTmpDir(project);
- if (delete) {
- logger.info("Deleting HDFS path " + tmpPath);
- if (fs.exists(new Path(tmpPath))) {
- fs.delete(new Path(tmpPath), true);
- }
- } else {
- logger.info("Dry run, pending delete HDFS path " + tmpPath);
- }
- }
//clean up deleted projects and cubes
List<CubeInstance> cubes = cubeManager.listAllCubes();
Path metadataPath = new Path(config.getHdfsWorkingDirectory());
if (fs.exists(metadataPath)) {
- FileStatus[] projectStatus = fs.listStatus(metadataPath);
- if (projectStatus != null) {
- for (FileStatus status : projectStatus) {
- String projectName = status.getPath().getName();
- if (!projects.contains(projectName)) {
- if (delete) {
- logger.info("Deleting HDFS path " + status.getPath());
- fs.delete(status.getPath(), true);
+ FileStatus[] fileStatus = fs.listStatus(metadataPath);
Review comment:
use fs.listStatus(file, PathFilter) to filter out 'protectedDir'
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org