/** If the dir is an {@link FSDirectory} or wraps one via possibly * nested {@link FilterDirectory} or {@link FileSwitchDirectory}, * this returns {@link #spins(Path)} for the wrapped directory, * else, true. * * @throws IOException if {@code path} does not exist. * * @lucene.internal */ public static boolean spins(Directory dir) throws IOException { dir = FilterDirectory.unwrap(dir); if (dir instanceof FileSwitchDirectory) { FileSwitchDirectory fsd = (FileSwitchDirectory) dir; // Spinning is contagious: return spins(fsd.getPrimaryDir()) || spins(fsd.getSecondaryDir()); } else if (dir instanceof RAMDirectory) { return false; } else if (dir instanceof FSDirectory) { return spins(((FSDirectory) dir).getDirectory()); } else { return true; } }
private synchronized void initDynamicDefaults(IndexWriter writer) throws IOException { if (maxThreadCount == AUTO_DETECT_MERGES_AND_THREADS) { boolean spins = IOUtils.spins(writer.getDirectory()); // Let tests override this to help reproducing a failure on a machine that has a different // core count than the one where the test originally failed: try { String value = System.getProperty(DEFAULT_SPINS_PROPERTY); if (value != null) { spins = Boolean.parseBoolean(value); } } catch (Exception ignored) { // that's fine we might hit a SecurityException etc. here just continue } setDefaultMaxMergesAndThreads(spins); if (verbose()) { message("initDynamicDefaults spins=" + spins + " maxThreadCount=" + maxThreadCount + " maxMergeCount=" + maxMergeCount); } } }
/** If the dir is an {@link FSDirectory} or wraps one via possibly * nested {@link FilterDirectory} or {@link FileSwitchDirectory}, * this returns {@link #spins(Path)} for the wrapped directory, * else, true. * * @throws IOException if {@code path} does not exist. * * @lucene.internal */ public static boolean spins(Directory dir) throws IOException { dir = FilterDirectory.unwrap(dir); if (dir instanceof FileSwitchDirectory) { FileSwitchDirectory fsd = (FileSwitchDirectory) dir; // Spinning is contagious: return spins(fsd.getPrimaryDir()) || spins(fsd.getSecondaryDir()); } else if (dir instanceof RAMDirectory) { return false; } else if (dir instanceof FSDirectory) { return spins(((FSDirectory) dir).getDirectory()); } else { return true; } }
/** If the dir is an {@link FSDirectory} or wraps one via possibly * nested {@link FilterDirectory} or {@link FileSwitchDirectory}, * this returns {@link #spins(Path)} for the wrapped directory, * else, true. * * @throws IOException if {@code path} does not exist. * * @lucene.internal */ public static boolean spins(Directory dir) throws IOException { dir = FilterDirectory.unwrap(dir); if (dir instanceof FileSwitchDirectory) { FileSwitchDirectory fsd = (FileSwitchDirectory) dir; // Spinning is contagious: return spins(fsd.getPrimaryDir()) || spins(fsd.getSecondaryDir()); } else if (dir instanceof RAMDirectory) { return false; } else if (dir instanceof FSDirectory) { return spins(((FSDirectory) dir).getDirectory()); } else { return true; } }
/** If the dir is an {@link FSDirectory} or wraps one via possibly * nested {@link FilterDirectory} or {@link FileSwitchDirectory}, * this returns {@link #spins(Path)} for the wrapped directory, * else, true. * * @throws IOException if {@code path} does not exist. * * @lucene.internal */ public static boolean spins(Directory dir) throws IOException { dir = FilterDirectory.unwrap(dir); if (dir instanceof FileSwitchDirectory) { FileSwitchDirectory fsd = (FileSwitchDirectory) dir; // Spinning is contagious: return spins(fsd.getPrimaryDir()) || spins(fsd.getSecondaryDir()); } else if (dir instanceof RAMDirectory) { return false; } else if (dir instanceof FSDirectory) { return spins(((FSDirectory) dir).getDirectory()); } else { return true; } }
private synchronized void initDynamicDefaults(IndexWriter writer) throws IOException { if (maxThreadCount == AUTO_DETECT_MERGES_AND_THREADS) { boolean spins = IOUtils.spins(writer.getDirectory()); // Let tests override this to help reproducing a failure on a machine that has a different // core count than the one where the test originally failed: try { String value = System.getProperty(DEFAULT_SPINS_PROPERTY); if (value != null) { spins = Boolean.parseBoolean(value); } } catch (Throwable ignored) { } setDefaultMaxMergesAndThreads(spins); if (verbose()) { message("initDynamicDefaults spins=" + spins + " maxThreadCount=" + maxThreadCount + " maxMergeCount=" + maxMergeCount); } } }
private synchronized void initDynamicDefaults(IndexWriter writer) throws IOException { if (maxThreadCount == AUTO_DETECT_MERGES_AND_THREADS) { boolean spins = IOUtils.spins(writer.getDirectory()); // Let tests override this to help reproducing a failure on a machine that has a different // core count than the one where the test originally failed: try { String value = System.getProperty(DEFAULT_SPINS_PROPERTY); if (value != null) { spins = Boolean.parseBoolean(value); } } catch (Throwable ignored) { } setDefaultMaxMergesAndThreads(spins); if (verbose()) { message("initDynamicDefaults spins=" + spins + " maxThreadCount=" + maxThreadCount + " maxMergeCount=" + maxMergeCount); } } }
private synchronized void initDynamicDefaults(IndexWriter writer) throws IOException { if (maxThreadCount == AUTO_DETECT_MERGES_AND_THREADS) { boolean spins = IOUtils.spins(writer.getDirectory()); // Let tests override this to help reproducing a failure on a machine that has a different // core count than the one where the test originally failed: try { String value = System.getProperty(DEFAULT_SPINS_PROPERTY); if (value != null) { spins = Boolean.parseBoolean(value); } } catch (Exception ignored) { // that's fine we might hit a SecurityException etc. here just continue } setDefaultMaxMergesAndThreads(spins); if (verbose()) { message("initDynamicDefaults spins=" + spins + " maxThreadCount=" + maxThreadCount + " maxMergeCount=" + maxMergeCount); } } }
spins = IOUtils.spins(PathUtils.get(getMountPointLinux(in))); } catch (Exception e) { spins = null;
@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; }