Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A modified MoveFileRotation to not rotate zero files #22

Open
rangatdt opened this issue Jan 9, 2015 · 0 comments
Open

A modified MoveFileRotation to not rotate zero files #22

rangatdt opened this issue Jan 9, 2015 · 0 comments

Comments

@rangatdt
Copy link

rangatdt commented Jan 9, 2015

MoveFileRotation rotates even 0-sized files. For non-continous streams and especially when microbatching, the number of 0-sized files can become problematic. A modification to the MoveFileRotation to delete 0-sized files instead of moving would be useful. Probably as a configurable option.

E.g.:
public void execute(FileSystem fs, Path filePath) throws IOException {
Path destPath=new Path(destination,filePath.getName());
long size=fs.getFileStatus(filePath).getLen();
if(size>0) {
LOG.info("Moving file {} to {}",filePath,destPath);
boolean success=fs.rename(filePath,destPath);
if(!success)
LOG.warn("Unable to move file {} to {}",filePath,destPath);
} else {
LOG.info("Deleting 0-sized file {}",filePath);
boolean success=fs.delete(filePath);
if(!success)
LOG.warn("Delete of file {} failed",filePath);
}
return;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant