org.apache.lucene.util.IOUtils.spins()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(165)

本文整理了Java中org.apache.lucene.util.IOUtils.spins()方法的一些代码示例,展示了IOUtils.spins()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOUtils.spins()方法的具体详情如下:
包路径:org.apache.lucene.util.IOUtils
类名称:IOUtils
方法名:spins

IOUtils.spins介绍

[英]Rough Linux-only heuristics to determine whether the provided Path is backed by spinning storage. For example, this returns false if the disk is a solid-state disk.
[中]粗略的Linux试探法,用于确定提供的路径是否由旋转存储支持。例如,如果磁盘是固态磁盘,则返回false。

代码示例

代码示例来源:origin: org.apache.lucene/lucene-core

/** 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;
 }
}

代码示例来源:origin: org.apache.lucene/lucene-core

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);
  }
 }
}

代码示例来源:origin: org.infinispan/infinispan-embedded-query

/** 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;
 }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

/** 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;
 }
}

代码示例来源:origin: harbby/presto-connectors

/** 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;
 }
}

代码示例来源:origin: harbby/presto-connectors

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);
  }
 }
}

代码示例来源:origin: org.infinispan/infinispan-embedded-query

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);
  }
 }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

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);
  }
 }
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

spins = IOUtils.spins(PathUtils.get(getMountPointLinux(in)));
} catch (Exception e) {
  spins = null;

代码示例来源:origin: harbby/presto-connectors

@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;
}

相关文章