org.apache.hadoop.util.Shell.getWinUtilsPath()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(215)

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

Shell.getWinUtilsPath介绍

[英]Locate the winutils binary, or fail with a meaningful exception and stack trace as an RTE. This method is for use in methods which don't explicitly throw an IOException.
[中]找到winutils二进制文件,或因有意义的异常而失败,并将跟踪堆栈为RTE。此方法用于不显式抛出IOException的方法。

代码示例

代码示例来源:origin: org.apache.hadoop/hadoop-common

/** Return a command to read the target of the a symbolic link. */
public static String[] getReadlinkCommand(String link) {
 return WINDOWS ?
   new String[] { getWinUtilsPath(), "readlink", link }
   : new String[] { "readlink", link };
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

/** Return a command to get permission information. */
public static String[] getGetPermissionCommand() {
 return (WINDOWS) ? new String[] { getWinUtilsPath(), "ls", "-F" }
          : new String[] { "ls", "-ld" };
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

/** Return a command to set owner. */
public static String[] getSetOwnerCommand(String owner) {
 return (WINDOWS) ?
   new String[] { getWinUtilsPath(), "chown", "\"" + owner + "\"" }
   : new String[] { "chown", owner };
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

/** Return a command to create symbolic links. */
public static String[] getSymlinkCommand(String target, String link) {
 return WINDOWS ?
   new String[] { getWinUtilsPath(), "symlink", link, target }
   : new String[] { "ln", "-s", target, link };
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

/** Return a command to set permission. */
public static String[] getSetPermissionCommand(String perm, boolean recursive) {
 if (recursive) {
  return (WINDOWS) ?
    new String[] { getWinUtilsPath(), "chmod", "-R", perm }
    : new String[] { "chmod", "-R", perm };
 } else {
  return (WINDOWS) ?
    new String[] { getWinUtilsPath(), "chmod", perm }
    : new String[] { "chmod", perm };
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

/** Return a command to send a signal to a given pid. */
public static String[] getSignalKillCommand(int code, String pid) {
 // Code == 0 means check alive
 if (Shell.WINDOWS) {
  if (0 == code) {
   return new String[] {Shell.getWinUtilsPath(), "task", "isAlive", pid };
  } else {
   return new String[] {Shell.getWinUtilsPath(), "task", "kill", pid };
  }
 }
 // Use the bash-builtin instead of the Unix kill command (usually
 // /bin/kill) as the bash-builtin supports "--" in all Hadoop supported
 // OSes.
 final String quotedPid = bashQuote(pid);
 if (isSetsidAvailable) {
  return new String[] { "bash", "-c", "kill -" + code + " -- -" +
    quotedPid };
 } else {
  return new String[] { "bash", "-c", "kill -" + code + " " +
    quotedPid };
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
 * A command to get a given user's group id list.
 * The command will get the user's primary group
 * first and finally get the groups list which includes the primary group.
 * i.e. the user's primary group will be included twice.
 * This command does not support Windows and will only return group names.
 */
public static String[] getGroupsIDForUserCommand(final String user) {
 //'groups username' command return is inconsistent across different unixes
 if (WINDOWS) {
  return new String[]{getWinUtilsPath(), "groups", "-F", "\"" + user +
             "\""};
 } else {
  String quotedUser = bashQuote(user);
  return new String[] {"bash", "-c", "id -g " + quotedUser + "; id -G " +
             quotedUser};
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
 * A command to get a given user's groups list.
 * If the OS is not WINDOWS, the command will get the user's primary group
 * first and finally get the groups list which includes the primary group.
 * i.e. the user's primary group will be included twice.
 */
public static String[] getGroupsForUserCommand(final String user) {
 //'groups username' command return is inconsistent across different unixes
 if (WINDOWS) {
  return new String[]
    {getWinUtilsPath(), "groups", "-F", "\"" + user + "\""};
 } else {
  String quotedUser = bashQuote(user);
  return new String[] {"bash", "-c", "id -gn " + quotedUser +
             "; id -Gn " + quotedUser};
 }
}

代码示例来源:origin: io.hops/hadoop-common

/** Return a command to create symbolic links. */
public static String[] getSymlinkCommand(String target, String link) {
 return WINDOWS ?
   new String[] { getWinUtilsPath(), "symlink", link, target }
   : new String[] { "ln", "-s", target, link };
}

代码示例来源:origin: io.hops/hadoop-common

/** Return a command to read the target of the a symbolic link. */
public static String[] getReadlinkCommand(String link) {
 return WINDOWS ?
   new String[] { getWinUtilsPath(), "readlink", link }
   : new String[] { "readlink", link };
}

代码示例来源:origin: io.hops/hadoop-common

/** Return a command to get permission information. */
public static String[] getGetPermissionCommand() {
 return (WINDOWS) ? new String[] { getWinUtilsPath(), "ls", "-F" }
          : new String[] { "ls", "-ld" };
}

代码示例来源:origin: io.hops/hadoop-common

/** Return a command to set permission. */
public static String[] getSetPermissionCommand(String perm, boolean recursive) {
 if (recursive) {
  return (WINDOWS) ?
    new String[] { getWinUtilsPath(), "chmod", "-R", perm }
    : new String[] { "chmod", "-R", perm };
 } else {
  return (WINDOWS) ?
    new String[] { getWinUtilsPath(), "chmod", perm }
    : new String[] { "chmod", perm };
 }
}

代码示例来源:origin: io.hops/hadoop-common

/** Return a command to set owner. */
public static String[] getSetOwnerCommand(String owner) {
 return (WINDOWS) ?
   new String[] { getWinUtilsPath(), "chown", "\"" + owner + "\"" }
   : new String[] { "chown", owner };
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-nodemanager

@Override
protected String[] getRunCommand(String command, String groupId,
  String userName, Path pidFile, Configuration conf) {
 File f = new File(command);
 if (LOG.isDebugEnabled()) {
  LOG.debug(String.format("getRunCommand: %s exists:%b", 
    command, f.exists()));
 }
 return new String[] { Shell.getWinUtilsPath(), "task",
   "createAsUser", groupId,
   userName, pidFile.toString(), "cmd /c " + command };
}

代码示例来源:origin: io.hops/hadoop-yarn-server-nodemanager

@Override
protected String[] getRunCommand(String command, String groupId,
  String userName, Path pidFile, Configuration conf) {
 File f = new File(command);
 if (LOG.isDebugEnabled()) {
  LOG.debug(String.format("getRunCommand: %s exists:%b", 
    command, f.exists()));
 }
 return new String[] { Shell.getWinUtilsPath(), "task",
   "createAsUser", groupId,
   userName, pidFile.toString(), "cmd /c " + command };
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-nodemanager

@Override
protected void link(Path src, Path dst) throws IOException {
 File srcFile = new File(src.toUri().getPath());
 String srcFileStr = srcFile.getPath();
 String dstFileStr = new File(dst.toString()).getPath();
 lineWithLenCheck(String.format("@%s symlink \"%s\" \"%s\"",
   Shell.getWinUtilsPath(), dstFileStr, srcFileStr));
 errorCheck();
}

代码示例来源:origin: io.hops/hadoop-yarn-server-nodemanager

@Override
protected void link(Path src, Path dst) throws IOException {
 File srcFile = new File(src.toUri().getPath());
 String srcFileStr = srcFile.getPath();
 String dstFileStr = new File(dst.toString()).getPath();
 lineWithLenCheck(String.format("@%s symlink \"%s\" \"%s\"",
   Shell.getWinUtilsPath(), dstFileStr, srcFileStr));
 errorCheck();
}

代码示例来源:origin: io.hops/hadoop-common

/**
 * A command to get a given user's groups list.
 * If the OS is not WINDOWS, the command will get the user's primary group
 * first and finally get the groups list which includes the primary group.
 * i.e. the user's primary group will be included twice.
 */
public static String[] getGroupsForUserCommand(final String user) {
 //'groups username' command return is inconsistent across different unixes
 if (WINDOWS) {
  return new String[]
    {getWinUtilsPath(), "groups", "-F", "\"" + user + "\""};
 } else {
  String quotedUser = bashQuote(user);
  return new String[] {"bash", "-c", "id -gn " + quotedUser +
             "; id -Gn " + quotedUser};
 }
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

/**
 * a Unix command to get a given user's groups list.
 * If the OS is not WINDOWS, the command will get the user's primary group
 * first and finally get the groups list which includes the primary group.
 * i.e. the user's primary group will be included twice.
 */
public static String[] getGroupsForUserCommand(final String user) {
 //'groups username' command return is inconsistent across different unixes
 if (WINDOWS) {
  return new String[]
    {getWinUtilsPath(), "groups", "-F", "\"" + user + "\""};
 } else {
  String quotedUser = bashQuote(user);
  return new String[] {"bash", "-c", "id -gn " + quotedUser +
             "; id -Gn " + quotedUser};
 }
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

/**
 * a Unix command to get a given user's groups list.
 * If the OS is not WINDOWS, the command will get the user's primary group
 * first and finally get the groups list which includes the primary group.
 * i.e. the user's primary group will be included twice.
 */
public static String[] getGroupsForUserCommand(final String user) {
 //'groups username' command return is inconsistent across different unixes
 if (WINDOWS) {
  return new String[]
    {getWinUtilsPath(), "groups", "-F", "\"" + user + "\""};
 } else {
  String quotedUser = bashQuote(user);
  return new String[] {"bash", "-c", "id -gn " + quotedUser +
             "; id -Gn " + quotedUser};
 }
}

相关文章