Repository: nifi Updated Branches: refs/heads/master 942483641 -> 78382c66b
NIFI-3579 Fix for Windows FileStore issue Signed-off-by: Mike Moser <[email protected]> This closes #1580 Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/78382c66 Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/78382c66 Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/78382c66 Branch: refs/heads/master Commit: 78382c66bc93181b3cfa2268a13da60074c9962f Parents: 9424836 Author: Puspendu Banerjee <[email protected]> Authored: Wed Mar 8 23:26:43 2017 -0600 Committer: Mike Moser <[email protected]> Committed: Tue Mar 14 13:58:06 2017 -0400 ---------------------------------------------------------------------- .../repository/FileSystemRepository.java | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/78382c66/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/FileSystemRepository.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/FileSystemRepository.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/FileSystemRepository.java index 67df539..b899a36 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/FileSystemRepository.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/repository/FileSystemRepository.java @@ -199,13 +199,16 @@ public class FileSystemRepository implements ContentRepository { for (final Map.Entry<String, Path> container : containers.entrySet()) { final String containerName = container.getKey(); - 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"); + } final long maxArchiveBytes = (long) (capacity * (1D - (maxArchiveRatio - 0.02))); minUsableContainerBytesForArchive.put(container.getKey(), Long.valueOf(maxArchiveBytes)); LOG.info("Maximum Threshold for Container {} set to {} bytes; if volume exceeds this size, archived data will be deleted until it no longer exceeds this size", containerName, maxArchiveBytes); - final long backPressureBytes = (long) (Files.getFileStore(container.getValue()).getTotalSpace() * archiveBackPressureRatio); + final long backPressureBytes = (long) (container.getValue().toFile().getTotalSpace() * archiveBackPressureRatio); final ContainerState containerState = new ContainerState(containerName, true, backPressureBytes, capacity); containerStateMap.put(containerName, containerState); } @@ -382,8 +385,12 @@ public class FileSystemRepository implements ContentRepository { if (path == null) { throw new IllegalArgumentException("No container exists with name " + containerName); } + 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"); + } - return Files.getFileStore(path).getTotalSpace(); + return capacity; } @Override @@ -392,8 +399,11 @@ public class FileSystemRepository implements ContentRepository { 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"); + } + return usableSpace; } @Override
