hadoop – Windows上的Spark – winutils究竟是什么?为什么我们需要它?

我很好奇!据我所知,HDFS需要运行datanode进程,这就是为什么它只能在服务器上运行. Spark可以在本地运行,但需要winutils.exe这是Hadoop的一个组件.但究竟是做什么的呢?怎么样,我不能在Windows上运行Hadoop,但我可以运行基于Hadoop构建的Spark?
最佳答案
我知道至少有一种用法,它用于在Windows操作系统上运行shell命令.你可以在org.apache.hadoop.util.Shell中找到它,其他模块依赖于这个类并使用它的方法,例如getGetPermissionCommand()方法:

static final String WINUTILS_EXE = "winutils.exe";
...
static {
  IOException ioe = null;
  String path = null;
  File file = null;
  // invariant: either there's a valid file and path,
  // or there is a cached IO exception.
  if (WINDOWS) {
    try {
      file = getQualifiedBin(WINUTILS_EXE);
      path = file.getCanonicalPath();
      ioe = null;
    } catch (IOException e) {
      LOG.warn("Did not find {}: {}", WINUTILS_EXE, e);
      // stack trace comes at debug level
      LOG.debug("Failed to find " + WINUTILS_EXE, e);
      file = null;
      path = null;
      ioe = e;
    }
  } else {
    // on a non-windows system, the invariant is kept
    // by adding an explicit exception.
    ioe = new FileNotFoundException(E_NOT_A_WINDOWS_SYSTEM);
  }
  WINUTILS_PATH = path;
  WINUTILS_FILE = file;

  WINUTILS = path;
  WINUTILS_FAILURE = ioe;
}
...
public static String getWinUtilsPath() {
  if (WINUTILS_FAILURE == null) {
    return WINUTILS_PATH;
  } else {
    throw new RuntimeException(WINUTILS_FAILURE.toString(),
        WINUTILS_FAILURE);
  }
}
...
public static String[] getGetPermissionCommand() {
  return (WINDOWS) ? new String[] { getWinUtilsPath(), "ls", "-F" }
                   : new String[] { "/bin/ls", "-ld" };
}

转载注明原文:hadoop – Windows上的Spark – winutils究竟是什么?为什么我们需要它? - 代码日志