@SuppressForbidden(reason = "tries to determine if disk is spinning") // TODO: move PathUtils to be package-private here instead of // public+forbidden api! ESFileStore(final FileStore in) { this.in = in; if (Constants.LINUX) { try { final List<String> lines = Files.readAllLines(PathUtils.get("/proc/self/mountinfo")); for (final String line : lines) { final String[] fields = line.trim().split("\\s+"); final String mountPoint = fields[4]; if (mountPoint.equals(getMountPointLinux(in))) { final String[] deviceNumbers = fields[2].split(":"); majorDeviceNumber = Integer.parseInt(deviceNumbers[0]); minorDeviceNumber = Integer.parseInt(deviceNumbers[1]); break; } } } catch (final Exception e) { majorDeviceNumber = -1; minorDeviceNumber = -1; } } else { majorDeviceNumber = -1; minorDeviceNumber = -1; } }
public static FileStore getFileStore(final Path path) throws IOException { return new ESFileStore(Files.getFileStore(path)); }
static FileStore getMatchingFileStore(Path path, FileStore fileStores[]) throws IOException { if (Constants.WINDOWS) { return getFileStoreWindows(path, fileStores); String mount = getMountPointLinux(store); FileStore sameMountPoint = null; for (FileStore fs : fileStores) { if (mount.equals(getMountPointLinux(fs))) { if (sameMountPoint == null) { sameMountPoint = fs;
/** * Looks up the filestore associated with a Path. * <p> * This is an enhanced version of {@link Files#getFileStore(Path)}: * <ul> * <li>On *nix systems, the store returned for the root filesystem will contain * the actual filesystem type (e.g. {@code ext4}) instead of {@code rootfs}. * <li>On some systems, the custom attribute {@code lucene:spins} is supported * via the {@link FileStore#getAttribute(String)} method. * <li>Only requires the security permissions of {@link Files#getFileStore(Path)}, * no permissions to the actual mount point are required. * <li>Exception handling has the same semantics as {@link Files#getFileStore(Path)}. * <li>Works around https://bugs.openjdk.java.net/browse/JDK-8034057. * <li>Gives a better exception when filestore cannot be retrieved from inside a FreeBSD jail. * </ul> */ public static FileStore getFileStore(Path path) throws IOException { return ESFileStore.getMatchingFileStore(path, fileStores); }
static FileStore getMatchingFileStore(Path path, FileStore fileStores[]) throws IOException { if (Constants.WINDOWS) { return getFileStoreWindows(path, fileStores); String mount = getMountPointLinux(store); FileStore sameMountPoint = null; for (FileStore fs : fileStores) { if (mount.equals(getMountPointLinux(fs))) { if (sameMountPoint == null) { sameMountPoint = fs;
/** * Looks up the filestore associated with a Path. * <p> * This is an enhanced version of {@link Files#getFileStore(Path)}: * <ul> * <li>On *nix systems, the store returned for the root filesystem will contain * the actual filesystem type (e.g. {@code ext4}) instead of {@code rootfs}. * <li>On some systems, the custom attribute {@code lucene:spins} is supported * via the {@link FileStore#getAttribute(String)} method. * <li>Only requires the security permissions of {@link Files#getFileStore(Path)}, * no permissions to the actual mount point are required. * <li>Exception handling has the same semantics as {@link Files#getFileStore(Path)}. * <li>Works around https://bugs.openjdk.java.net/browse/JDK-8034057. * <li>Gives a better exception when filestore cannot be retrieved from inside a FreeBSD jail. * </ul> */ public static FileStore getFileStore(Path path) throws IOException { return ESFileStore.getMatchingFileStore(path, fileStores); }
@SuppressForbidden(reason = "tries to determine if disk is spinning") // TODO: move PathUtils to be package-private here instead of // public+forbidden api! ESFileStore(final FileStore in) { this.in = in; if (Constants.LINUX) { try { final List<String> lines = Files.readAllLines(PathUtils.get("/proc/self/mountinfo")); for (final String line : lines) { final String[] fields = line.trim().split("\\s+"); final String mountPoint = fields[4]; if (mountPoint.equals(getMountPointLinux(in))) { final String[] deviceNumbers = fields[2].split(":"); majorDeviceNumber = Integer.parseInt(deviceNumbers[0]); minorDeviceNumber = Integer.parseInt(deviceNumbers[1]); break; } } } catch (final Exception e) { majorDeviceNumber = -1; minorDeviceNumber = -1; } } else { majorDeviceNumber = -1; minorDeviceNumber = -1; } }
public static FileStore getFileStore(final Path path) throws IOException { return new ESFileStore(Files.getFileStore(path)); }
@SuppressForbidden(reason = "tries to determine if disk is spinning") // TODO: move PathUtils to be package-private here instead of // public+forbidden api! ESFileStore(final FileStore in) { this.in = in; if (Constants.LINUX) { try { final List<String> lines = Files.readAllLines(PathUtils.get("/proc/self/mountinfo")); for (final String line : lines) { final String[] fields = line.trim().split("\\s+"); final String mountPoint = fields[4]; if (mountPoint.equals(getMountPointLinux(in))) { final String[] deviceNumbers = fields[2].split(":"); majorDeviceNumber = Integer.parseInt(deviceNumbers[0]); minorDeviceNumber = Integer.parseInt(deviceNumbers[1]); break; } } } catch (final Exception e) { majorDeviceNumber = -1; minorDeviceNumber = -1; } } else { majorDeviceNumber = -1; minorDeviceNumber = -1; } }
public static FileStore getFileStore(final Path path) throws IOException { return new ESFileStore(Files.getFileStore(path)); }
spins = IOUtils.spins(PathUtils.get(getMountPointLinux(in))); } catch (Exception e) { spins = null; final String[] fields = line.trim().split("\\s+"); final String mountPoint = fields[4]; if (mountPoint.equals(getMountPointLinux(in))) { final String[] deviceNumbers = fields[2].split(":"); majorDeviceNumber = Integer.parseInt(deviceNumbers[0]);
@SuppressForbidden(reason = "tries to determine if disk is spinning") // TODO: move PathUtils to be package-private here instead of // public+forbidden api! ESFileStore(FileStore in) { this.in = in; Boolean spins; // Lucene's IOUtils.spins only works on Linux today: if (Constants.LINUX) { try { spins = IOUtils.spins(PathUtils.get(getMountPointLinux(in))); } catch (Exception e) { spins = null; } } else { spins = null; } this.spins = spins; }