Skip to content

Fix for Windows FileStore issue NIFI-3579#1580

Closed
PuspenduBanerjee wants to merge 3 commits intoapache:masterfrom
PuspenduBanerjee:NIFI-3579
Closed

Fix for Windows FileStore issue NIFI-3579#1580
PuspenduBanerjee wants to merge 3 commits intoapache:masterfrom
PuspenduBanerjee:NIFI-3579

Conversation

@PuspenduBanerjee
Copy link
Contributor

this fixes NIFI-3579.

final String containerName = container.getKey();

final long capacity = Files.getFileStore(container.getValue()).getTotalSpace();
final long capacity = container.getValue().toFile().getTotalSpace();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is a problem, FileStore.getTotalSpace() throws IOException but File.getTotalSpace() returns 0. I think you should throw an IOException if capacity == 0, in order to maintain similar behavior here.

Copy link
Contributor Author

@PuspenduBanerjee PuspenduBanerjee Mar 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you that exception should be thrown. I would prefer a RuntimeException with a message like

System returned total space of the partition for {reponame} is zero byte. Nifi can not create a zero sized FileSystemRepository

As Javadoc says that IOException signals that an I/O exception of some sort has occurred. This class is the general class of exceptions produced by failed or interrupted I/O operations.
Let me know your thought, then we can take a decision & change.

…ported volume or usable space is zero sized.
@PuspenduBanerjee
Copy link
Contributor Author

@mosermw Incorporated your comments. please review. Once your review is approved , @joewitt or any other committer can help to get that merged.

@mosermw
Copy link
Member

mosermw commented Mar 14, 2017

+1 looks good, passes checkstyle, runs in NiFi on Windows when creating content_repository on startup and when it already exists. I will squash and merge to master. Thanks @PuspenduBanerjee

@asfgit asfgit closed this in 78382c6 Mar 14, 2017
final long capacity = Files.getFileStore(container.getValue()).getTotalSpace();
final long capacity = container.getValue().toFile().getTotalSpace();
if(capacity==0) {
throw new RuntimeException("System returned total space of the partition for " + containerName + " is zero byte. Nifi can not create a zero sized FileSystemRepository");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PuspenduBanerjee the issue that @mosermw brought up is a valid point, I believe. The idea here was to ensure that things are backward compatible. However, this is essentially converting an IOException to a RuntimeException, which is certainly not backward compatible, because the code that calls this method would have been forced to catch IOException but likely is not catching RuntimeException. I believe this needs to remain an IOException or not be thrown at all.

}
long capacity = path.toFile().getTotalSpace();
if(capacity==0) {
throw new RuntimeException("System returned total space of the partition for " + containerName + " is zero byte. Nifi can not create a zero sized FileSystemRepository");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the same concern here as above. In the constructor above, it is likely not a huge deal since it's the constructor and if any Exception gets thrown, NiFi will fail to startup. However, here it is a much bigger concern, as this is called from a few different places where IOException is caught.

return Files.getFileStore(path).getUsableSpace();
long usableSpace=path.toFile().getUsableSpace();
if(usableSpace==0) {
throw new RuntimeException("System returned usable space of the partition for " + containerName + " is zero byte. Nifi can not create a zero sized FileSystemRepository");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't be throwing an Exception here at all. If the content repository runs out of disk space, it will return 0. This is a very valid value and should not result in an Exception being thrown.

Copy link
Contributor Author

@PuspenduBanerjee PuspenduBanerjee Mar 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @markap14 Let me share the thought process that I have. As per my understanding usableSpace==0 means the system is already in deep trouble and nothing is getting stored at your flow file repo. So, anyway we have faced write/flush error and either handled that or couldn't. Which signifies that checking or not checking zero usable space at this stage does not make any practical difference.
Secondly, for a 1GB usable storage the chance of hitting that Runtime exception is 1 in 1073.7 millions i.e. 9.31322575e-8% .
This comment is applicable for all 3 queries/concerns.
If you still think that we need to care about it, I am in.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After more thought, I agree with the concerns that @markap14 raised. I think the constructor can throw RuntimeException as it exists now. But I think the getContainerCapacity() should throw IOException and getContainerUsableSpace() should just return the 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mosermw Could you please explain the usecases. Please look into my thought process that I have shared.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PuspenduBanerjee if we run out of usable space then it's true that we won't be able to write to the content repository. As a result, processors will fail if they try. However, this is a completely unrelated concern. This is asking the repository how much space is available. This is used, for instance, to show the information in the UI, so that the user knows what is going on. If we throw an Exception here, now the user will be unable to see that there are 0 bytes available because an Exception is thrown so the HTTP request will return a 500 HTTP status code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @PuspenduBanerjee, since getContainerCapacity() and getContainerUsableSpace() are public methods, I would prefer that we try to maintain their existing contract. I would prefer to avoid even an extremely small chance of a RuntimeException.

@PuspenduBanerjee
Copy link
Contributor Author

PuspenduBanerjee commented Mar 16, 2017 via email

@PuspenduBanerjee
Copy link
Contributor Author

PuspenduBanerjee commented Mar 17, 2017

@mosermw & @markap14 please look into the updated PR#1602

josephxsxn pushed a commit to josephxsxn/nifi that referenced this pull request Mar 23, 2017
Signed-off-by: Mike Moser <mosermw@apache.org>

This closes apache#1580
aperepel pushed a commit to aperepel/nifi that referenced this pull request Mar 29, 2017
Signed-off-by: Mike Moser <mosermw@apache.org>

This closes apache#1580
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

Successfully merging this pull request may close these issues.

3 participants