| | |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.nio.file.FileStore; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Path; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.util.Platform; |
| | | |
| | | /** |
| | | * This class provides an application-wide disk space monitoring service. |
| | |
| | | File fsMountPoint; |
| | | try |
| | | { |
| | | fsMountPoint = Platform.getFilesystem(directory); |
| | | fsMountPoint = getMountPoint(directory); |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private File getMountPoint(File directory) throws IOException |
| | | { |
| | | Path mountPoint = directory.getAbsoluteFile().toPath(); |
| | | Path parentDir = mountPoint.getParent(); |
| | | FileStore dirFileStore = Files.getFileStore(mountPoint); |
| | | /* |
| | | * Since there is no concept of mount point in the APIs, iterate on all parents of |
| | | * the given directory until the FileSystem Store changes (hint of a different |
| | | * device, hence a mount point) or we get to root, which works too. |
| | | */ |
| | | while (parentDir != null) |
| | | { |
| | | if (!Files.getFileStore(parentDir).equals(dirFileStore)) |
| | | { |
| | | return mountPoint.toFile(); |
| | | } |
| | | mountPoint = mountPoint.getParent(); |
| | | parentDir = parentDir.getParent(); |
| | | } |
| | | return mountPoint.toFile(); |
| | | } |
| | | |
| | | /** |
| | | * Removes a directory from the set of monitored directories. |
| | | * |