/** Rough Linux-only heuristics to determine whether the provided * {@code Path} is backed by spinning storage. For example, this * returns false if the disk is a solid-state disk. * * @param path a location to check which must exist. the mount point will be determined from this location. * @return false if the storage is non-rotational (e.g. an SSD), or true if it is spinning or could not be determined * @throws IOException if {@code path} does not exist. * * @lucene.internal */ public static boolean spins(Path path) throws IOException { // resolve symlinks (this will throw exception if the path does not exist) path = path.toRealPath(); // Super cowboy approach, but seems to work! if (!Constants.LINUX) { return true; // no detection } try { return spinsLinux(path); } catch (Exception exc) { // our crazy heuristics can easily trigger SecurityException, AIOOBE, etc ... return true; } }
/** Rough Linux-only heuristics to determine whether the provided * {@code Path} is backed by spinning storage. For example, this * returns false if the disk is a solid-state disk. * * @param path a location to check which must exist. the mount point will be determined from this location. * @return false if the storage is non-rotational (e.g. an SSD), or true if it is spinning or could not be determined * @throws IOException if {@code path} does not exist. * * @lucene.internal */ public static boolean spins(Path path) throws IOException { // resolve symlinks (this will throw exception if the path does not exist) path = path.toRealPath(); // Super cowboy approach, but seems to work! if (!Constants.LINUX) { return true; // no detection } try { return spinsLinux(path); } catch (Exception exc) { // our crazy heuristics can easily trigger SecurityException, AIOOBE, etc ... return true; } }
/** Rough Linux-only heuristics to determine whether the provided * {@code Path} is backed by spinning storage. For example, this * returns false if the disk is a solid-state disk. * * @param path a location to check which must exist. the mount point will be determined from this location. * @return false if the storage is non-rotational (e.g. an SSD), or true if it is spinning or could not be determined * @throws IOException if {@code path} does not exist. * * @lucene.internal */ public static boolean spins(Path path) throws IOException { // resolve symlinks (this will throw exception if the path does not exist) path = path.toRealPath(); // Super cowboy approach, but seems to work! if (!Constants.LINUX) { return true; // no detection } try { return spinsLinux(path); } catch (Exception exc) { // our crazy heuristics can easily trigger SecurityException, AIOOBE, etc ... return true; } }
/** Rough Linux-only heuristics to determine whether the provided * {@code Path} is backed by spinning storage. For example, this * returns false if the disk is a solid-state disk. * * @param path a location to check which must exist. the mount point will be determined from this location. * @return false if the storage is non-rotational (e.g. an SSD), or true if it is spinning or could not be determined * @throws IOException if {@code path} does not exist. * * @lucene.internal */ public static boolean spins(Path path) throws IOException { // resolve symlinks (this will throw exception if the path does not exist) path = path.toRealPath(); // Super cowboy approach, but seems to work! if (!Constants.LINUX) { return true; // no detection } try { return spinsLinux(path); } catch (Exception exc) { // our crazy heuristics can easily trigger SecurityException, AIOOBE, etc ... return true; } }