[ 
https://issues.apache.org/jira/browse/NIFI-3579?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15928335#comment-15928335
 ] 

ASF GitHub Bot commented on NIFI-3579:
--------------------------------------

Github user markap14 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1580#discussion_r106460083
  
    --- Diff: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/FileSystemRepository.java
 ---
    @@ -392,8 +399,11 @@ public long getContainerUsableSpace(String 
containerName) throws IOException {
             if (path == null) {
                 throw new IllegalArgumentException("No container exists with 
name " + containerName);
             }
    -
    -        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");
    --- End diff --
    
    @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.


> Nifi Failed to Start: nio Files.getFileStore(Path) is buggy in Windows
> ----------------------------------------------------------------------
>
>                 Key: NIFI-3579
>                 URL: https://issues.apache.org/jira/browse/NIFI-3579
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Core Framework
>    Affects Versions: 1.2.0, 1.1.1
>         Environment: Win 10 with Oracle JDK 1.8.0_121 on NTFS
>            Reporter: Puspendu Banerjee
>            Assignee: Puspendu Banerjee
>            Priority: Critical
>              Labels: windows
>             Fix For: 1.2.0
>
>         Attachments: nifi-app.log
>
>
> Nifi is failing to start due to IOException originating from 
> FileSystemRepository during calls to {code:java}
> Files.getFileStore(path).getTotalSpace();
> Files.getFileStore(path).getUsableSpace();
>  {code} with a read-access denied status.
> It looks like a buggy JDK implementation as on the other hand the following 
> code is yielding result:
> {code:java}
> path.toFile().getTotalSpace();
> path.toFile().getUsableSpace();
> {code}
> Interestingly, the both of the codes are yielding same results for C:\ or 
> System Drive.
> *sample*
> {code:java}
> import java.io.File;
> import java.io.IOException;
> import java.nio.file.Files;
> import java.nio.file.Path;
> import java.nio.file.Paths;
> import java.util.Arrays;
> import static java.lang.System.out;
> public class Blah {
>     public static void main(String [] args) throws IOException{
>         String [] _paths= {"D:\\workspace\\nifi", "c:\\Program Files"};
>         final float divisor=1024 * 1024 * 1024f;
>         for(String _path : _paths) {
>             try {
>                 Path path = Paths.get(_path);
>                 out.println(path.toFile().getTotalSpace() /divisor  + "GB");
>                 out.println(Files.getFileStore(path).getTotalSpace()/divisor 
> +"GB");
>             }catch (Exception ex){
>                 ex.printStackTrace();
>             }
>         }
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to