当前位置: 首页>>代码示例>>Java>>正文


Java PrivilegedOperationException.getExitCode方法代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException.getExitCode方法的典型用法代码示例。如果您正苦于以下问题:Java PrivilegedOperationException.getExitCode方法的具体用法?Java PrivilegedOperationException.getExitCode怎么用?Java PrivilegedOperationException.getExitCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException的用法示例。


在下文中一共展示了PrivilegedOperationException.getExitCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeDockerLoadCommand

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入方法依赖的package包/类
private void executeDockerLoadCommand(DockerLoadCommand cmd,
    ContainerRuntimeContext ctx)
    throws ContainerExecutionException {
  Container container = ctx.getContainer();
  String containerIdStr = container.getContainerId().toString();
  String commandFile = dockerClient.writeCommandToTempFile(cmd,
      containerIdStr);
  PrivilegedOperation launchOp = new PrivilegedOperation(
      PrivilegedOperation.OperationType.RUN_DOCKER_CMD);

  launchOp.appendArgs(commandFile);

  try {
    privilegedOperationExecutor.executePrivilegedOperation(null,
        launchOp, null, container.getLaunchContext().getEnvironment(),
        false);
  } catch (PrivilegedOperationException e) {
    LOG.warn("Docker load operation failed. Exception: ", e);
    throw new ContainerExecutionException("Docker load operation failed", e
        .getExitCode(), e.getOutput(), e.getErrorOutput());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:DockerLinuxContainerRuntime.java

示例2: mountCgroups

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入方法依赖的package包/类
public void mountCgroups(List<String> cgroupKVs, String hierarchy)
    throws IOException {
  try {
    PrivilegedOperation mountCGroupsOp = new PrivilegedOperation(
        PrivilegedOperation.OperationType.MOUNT_CGROUPS, hierarchy);
    Configuration conf = super.getConf();

    mountCGroupsOp.appendArgs(cgroupKVs);
    PrivilegedOperationExecutor privilegedOperationExecutor =
        PrivilegedOperationExecutor.getInstance(conf);

    privilegedOperationExecutor.executePrivilegedOperation(mountCGroupsOp,
        false);
  } catch (PrivilegedOperationException e) {
    int exitCode = e.getExitCode();
    LOG.warn("Exception in LinuxContainerExecutor mountCgroups ", e);

    throw new IOException("Problem mounting cgroups " + cgroupKVs +
        "; exit code = " + exitCode + " and output: " + e.getOutput(),
        e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:LinuxContainerExecutor.java

示例3: mountCgroups

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入方法依赖的package包/类
public void mountCgroups(List<String> cgroupKVs, String hierarchy)
    throws IOException {
  try {
    PrivilegedOperation mountCGroupsOp = new PrivilegedOperation(
        PrivilegedOperation.OperationType.MOUNT_CGROUPS, hierarchy);
    Configuration conf = super.getConf();

    mountCGroupsOp.appendArgs(cgroupKVs);
    PrivilegedOperationExecutor privilegedOperationExecutor =
        getPrivilegedOperationExecutor();

    privilegedOperationExecutor.executePrivilegedOperation(mountCGroupsOp,
        false);
  } catch (PrivilegedOperationException e) {
    int exitCode = e.getExitCode();
    LOG.warn("Exception in LinuxContainerExecutor mountCgroups ", e);

    throw new IOException("Problem mounting cgroups " + cgroupKVs +
        "; exit code = " + exitCode + " and output: " + e.getOutput(),
        e);
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:23,代码来源:LinuxContainerExecutor.java

示例4: signalContainer

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入方法依赖的package包/类
@Override
public void signalContainer(ContainerRuntimeContext ctx)
    throws ContainerExecutionException {
  Container container = ctx.getContainer();
  PrivilegedOperation signalOp = new PrivilegedOperation(
      PrivilegedOperation.OperationType.SIGNAL_CONTAINER, (String) null);

  signalOp.appendArgs(ctx.getExecutionAttribute(RUN_AS_USER),
      ctx.getExecutionAttribute(USER),
      Integer.toString(PrivilegedOperation.RunAsUserCommand
          .SIGNAL_CONTAINER.getValue()),
      ctx.getExecutionAttribute(PID),
      Integer.toString(ctx.getExecutionAttribute(SIGNAL).getValue()));

  try {
    PrivilegedOperationExecutor executor = PrivilegedOperationExecutor
        .getInstance(conf);

    executor.executePrivilegedOperation(null,
        signalOp, null, container.getLaunchContext().getEnvironment(),
        false);
  } catch (PrivilegedOperationException e) {
    LOG.warn("Signal container failed. Exception: ", e);

    throw new ContainerExecutionException("Signal container failed", e
        .getExitCode(), e.getOutput(), e.getErrorOutput());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:ProcessContainerRuntime.java

示例5: signalContainer

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入方法依赖的package包/类
@Override
public void signalContainer(ContainerRuntimeContext ctx)
    throws ContainerExecutionException {
  Container container = ctx.getContainer();
  PrivilegedOperation signalOp = new PrivilegedOperation(
      PrivilegedOperation.OperationType.SIGNAL_CONTAINER);

  signalOp.appendArgs(ctx.getExecutionAttribute(RUN_AS_USER),
      ctx.getExecutionAttribute(USER),
      Integer.toString(PrivilegedOperation.RunAsUserCommand
          .SIGNAL_CONTAINER.getValue()),
      ctx.getExecutionAttribute(PID),
      Integer.toString(ctx.getExecutionAttribute(SIGNAL).getValue()));

  //Some failures here are acceptable. Let the calling executor decide.
  signalOp.disableFailureLogging();

  try {
    PrivilegedOperationExecutor executor = PrivilegedOperationExecutor
        .getInstance(conf);

    executor.executePrivilegedOperation(null,
        signalOp, null, container.getLaunchContext().getEnvironment(),
        false);
  } catch (PrivilegedOperationException e) {
    //Don't log the failure here. Some kinds of signaling failures are
    // acceptable. Let the calling executor decide what to do.
    throw new ContainerExecutionException("Signal container failed", e
        .getExitCode(), e.getOutput(), e.getErrorOutput());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:32,代码来源:DefaultLinuxContainerRuntime.java

示例6: signalContainer

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入方法依赖的package包/类
@Override
public void signalContainer(ContainerRuntimeContext ctx)
    throws ContainerExecutionException {
  Container container = ctx.getContainer();
  PrivilegedOperation signalOp = new PrivilegedOperation(
      PrivilegedOperation.OperationType.SIGNAL_CONTAINER, (String) null);

  signalOp.appendArgs(ctx.getExecutionAttribute(RUN_AS_USER),
      ctx.getExecutionAttribute(USER),
      Integer.toString(PrivilegedOperation
          .RunAsUserCommand.SIGNAL_CONTAINER.getValue()),
      ctx.getExecutionAttribute(PID),
      Integer.toString(ctx.getExecutionAttribute(SIGNAL).getValue()));

  try {
    PrivilegedOperationExecutor executor = PrivilegedOperationExecutor
        .getInstance(conf);

    executor.executePrivilegedOperation(null,
        signalOp, null, container.getLaunchContext().getEnvironment(),
        false);
  } catch (PrivilegedOperationException e) {
    LOG.warn("Signal container failed. Exception: ", e);

    throw new ContainerExecutionException("Signal container failed", e
        .getExitCode(), e.getOutput(), e.getErrorOutput());
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:29,代码来源:DockerLinuxContainerRuntime.java

示例7: signalContainer

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入方法依赖的package包/类
@Override
public void signalContainer(ContainerRuntimeContext ctx)
    throws ContainerExecutionException {
  Container container = ctx.getContainer();
  PrivilegedOperation signalOp = new PrivilegedOperation(
      PrivilegedOperation.OperationType.SIGNAL_CONTAINER);

  signalOp.appendArgs(ctx.getExecutionAttribute(RUN_AS_USER),
      ctx.getExecutionAttribute(USER),
      Integer.toString(PrivilegedOperation
          .RunAsUserCommand.SIGNAL_CONTAINER.getValue()),
      ctx.getExecutionAttribute(PID),
      Integer.toString(ctx.getExecutionAttribute(SIGNAL).getValue()));

  try {
    PrivilegedOperationExecutor executor = PrivilegedOperationExecutor
        .getInstance(conf);

    executor.executePrivilegedOperation(null,
        signalOp, null, container.getLaunchContext().getEnvironment(),
        false, true);
  } catch (PrivilegedOperationException e) {
    LOG.warn("Signal container failed. Exception: ", e);

    throw new ContainerExecutionException("Signal container failed", e
        .getExitCode(), e.getOutput(), e.getErrorOutput());
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:29,代码来源:DockerLinuxContainerRuntime.java

示例8: signalContainer

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入方法依赖的package包/类
@Override
public void signalContainer(ContainerRuntimeContext ctx)
    throws ContainerExecutionException {
  Container container = ctx.getContainer();
  PrivilegedOperation signalOp = new PrivilegedOperation(
      PrivilegedOperation.OperationType.SIGNAL_CONTAINER);

  signalOp.appendArgs(ctx.getExecutionAttribute(RUN_AS_USER),
      ctx.getExecutionAttribute(USER),
      Integer.toString(PrivilegedOperation.RunAsUserCommand
          .SIGNAL_CONTAINER.getValue()),
      ctx.getExecutionAttribute(PID),
      Integer.toString(ctx.getExecutionAttribute(SIGNAL).getValue()));

  //Some failures here are acceptable. Let the calling executor decide.
  signalOp.disableFailureLogging();

  try {
    PrivilegedOperationExecutor executor = PrivilegedOperationExecutor
        .getInstance(conf);

    executor.executePrivilegedOperation(null,
        signalOp, null, container.getLaunchContext().getEnvironment(),
        false, true);
  } catch (PrivilegedOperationException e) {
    //Don't log the failure here. Some kinds of signaling failures are
    // acceptable. Let the calling executor decide what to do.
    throw new ContainerExecutionException("Signal container failed", e
        .getExitCode(), e.getOutput(), e.getErrorOutput());
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:32,代码来源:DefaultLinuxContainerRuntime.java

示例9: launchContainer

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入方法依赖的package包/类
@Override
public void launchContainer(ContainerRuntimeContext ctx)
    throws ContainerExecutionException {
  Container container = ctx.getContainer();
  PrivilegedOperation launchOp = new PrivilegedOperation(
      PrivilegedOperation.OperationType.LAUNCH_CONTAINER, (String) null);

  //All of these arguments are expected to be available in the runtime context
  launchOp.appendArgs(ctx.getExecutionAttribute(RUN_AS_USER),
      ctx.getExecutionAttribute(USER),
      Integer.toString(PrivilegedOperation.
          RunAsUserCommand.LAUNCH_CONTAINER.getValue()),
      ctx.getExecutionAttribute(APPID),
      ctx.getExecutionAttribute(CONTAINER_ID_STR),
      ctx.getExecutionAttribute(CONTAINER_WORK_DIR).toString(),
      ctx.getExecutionAttribute(NM_PRIVATE_CONTAINER_SCRIPT_PATH).toUri()
          .getPath(),
      ctx.getExecutionAttribute(NM_PRIVATE_TOKENS_PATH).toUri().getPath(),
      ctx.getExecutionAttribute(PID_FILE_PATH).toString(),
      StringUtils.join(PrivilegedOperation.LINUX_FILE_PATH_SEPARATOR,
          ctx.getExecutionAttribute(LOCAL_DIRS)),
      StringUtils.join(PrivilegedOperation.LINUX_FILE_PATH_SEPARATOR,
          ctx.getExecutionAttribute(LOG_DIRS)),
      ctx.getExecutionAttribute(RESOURCES_OPTIONS));

  String tcCommandFile = ctx.getExecutionAttribute(TC_COMMAND_FILE);

  if (tcCommandFile != null) {
    launchOp.appendArgs(tcCommandFile);
  }

  //List<String> -> stored as List -> fetched/converted to List<String>
  //we can't do better here thanks to type-erasure
  @SuppressWarnings("unchecked")
  List<String> prefixCommands = (List<String>) ctx.getExecutionAttribute(
      CONTAINER_LAUNCH_PREFIX_COMMANDS);

  try {
    privilegedOperationExecutor.executePrivilegedOperation(prefixCommands,
          launchOp, null, container.getLaunchContext().getEnvironment(),
          false);
  } catch (PrivilegedOperationException e) {
    LOG.warn("Launch container failed. Exception: ", e);

    throw new ContainerExecutionException("Launch container failed", e
        .getExitCode(), e.getOutput(), e.getErrorOutput());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:49,代码来源:ProcessContainerRuntime.java

示例10: launchContainer

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入方法依赖的package包/类
@Override
public void launchContainer(ContainerRuntimeContext ctx)
    throws ContainerExecutionException {
  Container container = ctx.getContainer();
  PrivilegedOperation launchOp = new PrivilegedOperation(
      PrivilegedOperation.OperationType.LAUNCH_CONTAINER);

  //All of these arguments are expected to be available in the runtime context
  launchOp.appendArgs(ctx.getExecutionAttribute(RUN_AS_USER),
      ctx.getExecutionAttribute(USER),
      Integer.toString(PrivilegedOperation.
          RunAsUserCommand.LAUNCH_CONTAINER.getValue()),
      ctx.getExecutionAttribute(APPID),
      ctx.getExecutionAttribute(CONTAINER_ID_STR),
      ctx.getExecutionAttribute(CONTAINER_WORK_DIR).toString(),
      ctx.getExecutionAttribute(NM_PRIVATE_CONTAINER_SCRIPT_PATH).toUri()
          .getPath(),
      ctx.getExecutionAttribute(NM_PRIVATE_TOKENS_PATH).toUri().getPath(),
      ctx.getExecutionAttribute(PID_FILE_PATH).toString(),
      StringUtils.join(PrivilegedOperation.LINUX_FILE_PATH_SEPARATOR,
          ctx.getExecutionAttribute(LOCAL_DIRS)),
      StringUtils.join(PrivilegedOperation.LINUX_FILE_PATH_SEPARATOR,
          ctx.getExecutionAttribute(LOG_DIRS)),
      ctx.getExecutionAttribute(RESOURCES_OPTIONS));

  String tcCommandFile = ctx.getExecutionAttribute(TC_COMMAND_FILE);

  if (tcCommandFile != null) {
    launchOp.appendArgs(tcCommandFile);
  }

  //List<String> -> stored as List -> fetched/converted to List<String>
  //we can't do better here thanks to type-erasure
  @SuppressWarnings("unchecked")
  List<String> prefixCommands = (List<String>) ctx.getExecutionAttribute(
      CONTAINER_LAUNCH_PREFIX_COMMANDS);

  try {
    privilegedOperationExecutor.executePrivilegedOperation(prefixCommands,
          launchOp, null, container.getLaunchContext().getEnvironment(),
          false);
  } catch (PrivilegedOperationException e) {
    LOG.warn("Launch container failed. Exception: ", e);

    throw new ContainerExecutionException("Launch container failed", e
        .getExitCode(), e.getOutput(), e.getErrorOutput());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:49,代码来源:DefaultLinuxContainerRuntime.java

示例11: startLocalizer

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入方法依赖的package包/类
@Override
public void startLocalizer(LocalizerStartContext ctx)
    throws IOException, InterruptedException {
  Path nmPrivateContainerTokensPath = ctx.getNmPrivateContainerTokens();
  InetSocketAddress nmAddr = ctx.getNmAddr();
  String user = ctx.getUser();
  String appId = ctx.getAppId();
  String locId = ctx.getLocId();
  LocalDirsHandlerService dirsHandler = ctx.getDirsHandler();
  List<String> localDirs = dirsHandler.getLocalDirs();
  List<String> logDirs = dirsHandler.getLogDirs();
  
  verifyUsernamePattern(user);
  String runAsUser = getRunAsUser(user);
  PrivilegedOperation initializeContainerOp = new PrivilegedOperation(
      PrivilegedOperation.OperationType.INITIALIZE_CONTAINER);
  List<String> prefixCommands = new ArrayList<>();

  addSchedPriorityCommand(prefixCommands);
  initializeContainerOp.appendArgs(
      runAsUser,
      user,
      Integer.toString(
          PrivilegedOperation.RunAsUserCommand.INITIALIZE_CONTAINER
              .getValue()),
      appId,
      nmPrivateContainerTokensPath.toUri().getPath().toString(),
      StringUtils.join(PrivilegedOperation.LINUX_FILE_PATH_SEPARATOR,
          localDirs),
      StringUtils.join(PrivilegedOperation.LINUX_FILE_PATH_SEPARATOR,
          logDirs));

    File jvm =                                  // use same jvm as parent
      new File(new File(System.getProperty("java.home"), "bin"), "java");
  initializeContainerOp.appendArgs(jvm.toString());
  initializeContainerOp.appendArgs("-classpath");
  initializeContainerOp.appendArgs(System.getProperty("java.class.path"));
    String javaLibPath = System.getProperty("java.library.path");
    if (javaLibPath != null) {
    initializeContainerOp.appendArgs("-Djava.library.path=" + javaLibPath);
    }

  initializeContainerOp.appendArgs(ContainerLocalizer.getJavaOpts(getConf()));

  List<String> localizerArgs = new ArrayList<>();

  buildMainArgs(localizerArgs, user, appId, locId, nmAddr, localDirs);
  initializeContainerOp.appendArgs(localizerArgs);

    try {
    Configuration conf = super.getConf();
    PrivilegedOperationExecutor privilegedOperationExecutor =
        PrivilegedOperationExecutor.getInstance(conf);

    privilegedOperationExecutor.executePrivilegedOperation(prefixCommands,
        initializeContainerOp, null, null, false);

  } catch (PrivilegedOperationException e) {
    int exitCode = e.getExitCode();
      LOG.warn("Exit code from container " + locId + " startLocalizer is : "
          + exitCode, e);

      throw new IOException("Application " + appId + " initialization failed" +
        " (exitCode=" + exitCode + ") with output: " + e.getOutput(), e);
    }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:67,代码来源:LinuxContainerExecutor.java

示例12: deleteAsUser

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入方法依赖的package包/类
@Override
public void deleteAsUser(DeletionAsUserContext ctx) {
  String user = ctx.getUser();
  Path dir = ctx.getSubDir();
  List<Path> baseDirs = ctx.getBasedirs();

  verifyUsernamePattern(user);

  String runAsUser = getRunAsUser(user);
  String dirString = dir == null ? "" : dir.toUri().getPath();

  PrivilegedOperation deleteAsUserOp = new PrivilegedOperation(
      PrivilegedOperation.OperationType.DELETE_AS_USER, (String) null);

  deleteAsUserOp.appendArgs(
      runAsUser,
      user,
      Integer.toString(PrivilegedOperation.
          RunAsUserCommand.DELETE_AS_USER.getValue()),
      dirString);

  List<String> pathsToDelete = new ArrayList<String>();
  if (baseDirs == null || baseDirs.size() == 0) {
    LOG.info("Deleting absolute path : " + dir);
    pathsToDelete.add(dirString);
  } else {
    for (Path baseDir : baseDirs) {
      Path del = dir == null ? baseDir : new Path(baseDir, dir);
      LOG.info("Deleting path : " + del);
      pathsToDelete.add(del.toString());
      deleteAsUserOp.appendArgs(baseDir.toUri().getPath());
    }
  }

  try {
    Configuration conf = super.getConf();
    PrivilegedOperationExecutor privilegedOperationExecutor =
        PrivilegedOperationExecutor.getInstance(conf);

    privilegedOperationExecutor.executePrivilegedOperation(deleteAsUserOp,
        false);
  }   catch (PrivilegedOperationException e) {
    int exitCode = e.getExitCode();
    LOG.error("DeleteAsUser for " + StringUtils.join(" ", pathsToDelete)
        + " returned with exit code: " + exitCode, e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:48,代码来源:LinuxContainerExecutor.java

示例13: startLocalizer

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入方法依赖的package包/类
@Override
public void startLocalizer(LocalizerStartContext ctx)
    throws IOException, InterruptedException {
  Path nmPrivateContainerTokensPath = ctx.getNmPrivateContainerTokens();
  InetSocketAddress nmAddr = ctx.getNmAddr();
  String user = ctx.getUser();
  String appId = ctx.getAppId();
  String locId = ctx.getLocId();
  LocalDirsHandlerService dirsHandler = ctx.getDirsHandler();
  List<String> localDirs = dirsHandler.getLocalDirs();
  List<String> logDirs = dirsHandler.getLogDirs();

  verifyUsernamePattern(user);
  String runAsUser = getRunAsUser(user);
  PrivilegedOperation initializeContainerOp = new PrivilegedOperation(
      PrivilegedOperation.OperationType.INITIALIZE_CONTAINER, (String) null);
  List<String> prefixCommands = new ArrayList<>();

  addSchedPriorityCommand(prefixCommands);
  initializeContainerOp.appendArgs(
      runAsUser,
      user,
      Integer.toString(
          PrivilegedOperation.RunAsUserCommand.INITIALIZE_CONTAINER
              .getValue()),
      appId,
      nmPrivateContainerTokensPath.toUri().getPath().toString(),
      StringUtils.join(PrivilegedOperation.LINUX_FILE_PATH_SEPARATOR,
          localDirs),
      StringUtils.join(PrivilegedOperation.LINUX_FILE_PATH_SEPARATOR,
          logDirs));

  File jvm =                                  // use same jvm as parent
      new File(new File(System.getProperty("java.home"), "bin"), "java");
  initializeContainerOp.appendArgs(jvm.toString());
  initializeContainerOp.appendArgs("-classpath");
  initializeContainerOp.appendArgs(System.getProperty("java.class.path"));
  String javaLibPath = System.getProperty("java.library.path");
  if (javaLibPath != null) {
    initializeContainerOp.appendArgs("-Djava.library.path=" + javaLibPath);
  }

  initializeContainerOp.appendArgs(ContainerLocalizer.getJavaOpts(getConf()));

  List<String> localizerArgs = new ArrayList<>();

  buildMainArgs(localizerArgs, user, appId, locId, nmAddr, localDirs);
  initializeContainerOp.appendArgs(localizerArgs);

  try {
    Configuration conf = super.getConf();
    PrivilegedOperationExecutor privilegedOperationExecutor =
        PrivilegedOperationExecutor.getInstance(conf);

    privilegedOperationExecutor.executePrivilegedOperation(prefixCommands,
        initializeContainerOp, null, null, false);

  } catch (PrivilegedOperationException e) {
    int exitCode = e.getExitCode();
    LOG.warn("Exit code from container " + locId + " startLocalizer is : "
        + exitCode, e);

    throw new IOException("Application " + appId + " initialization failed" +
        " (exitCode=" + exitCode + ") with output: " + e.getOutput(), e);
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:67,代码来源:LinuxContainerExecutor.java

示例14: launchContainer

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入方法依赖的package包/类
@Override
public void launchContainer(ContainerRuntimeContext ctx)
    throws ContainerExecutionException {
  Container container = ctx.getContainer();
  PrivilegedOperation launchOp = new PrivilegedOperation(
      PrivilegedOperation.OperationType.LAUNCH_CONTAINER);

  //All of these arguments are expected to be available in the runtime context
  launchOp.appendArgs(ctx.getExecutionAttribute(RUN_AS_USER),
      ctx.getExecutionAttribute(USER),
      Integer.toString(PrivilegedOperation.
          RunAsUserCommand.LAUNCH_CONTAINER.getValue()),
      ctx.getExecutionAttribute(APPID),
      ctx.getExecutionAttribute(CONTAINER_ID_STR),
      ctx.getExecutionAttribute(CONTAINER_WORK_DIR).toString(),
      ctx.getExecutionAttribute(NM_PRIVATE_CONTAINER_SCRIPT_PATH).toUri()
          .getPath(),
      ctx.getExecutionAttribute(NM_PRIVATE_TOKENS_PATH).toUri().getPath(),
      ctx.getExecutionAttribute(PID_FILE_PATH).toString(),
      StringUtils.join(PrivilegedOperation.LINUX_FILE_PATH_SEPARATOR,
          ctx.getExecutionAttribute(LOCAL_DIRS)),
      StringUtils.join(PrivilegedOperation.LINUX_FILE_PATH_SEPARATOR,
          ctx.getExecutionAttribute(LOG_DIRS)),
      ctx.getExecutionAttribute(RESOURCES_OPTIONS));

  String tcCommandFile = ctx.getExecutionAttribute(TC_COMMAND_FILE);

  if (tcCommandFile != null) {
    launchOp.appendArgs(tcCommandFile);
  }

  //List<String> -> stored as List -> fetched/converted to List<String>
  //we can't do better here thanks to type-erasure
  @SuppressWarnings("unchecked")
  List<String> prefixCommands = (List<String>) ctx.getExecutionAttribute(
      CONTAINER_LAUNCH_PREFIX_COMMANDS);

  try {
    privilegedOperationExecutor.executePrivilegedOperation(prefixCommands,
          launchOp, null, container.getLaunchContext().getEnvironment(),
          false, false);
  } catch (PrivilegedOperationException e) {
    LOG.warn("Launch container failed. Exception: ", e);

    throw new ContainerExecutionException("Launch container failed", e
        .getExitCode(), e.getOutput(), e.getErrorOutput());
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:49,代码来源:DefaultLinuxContainerRuntime.java

示例15: startLocalizer

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入方法依赖的package包/类
@Override
public void startLocalizer(LocalizerStartContext ctx)
    throws IOException, InterruptedException {
  Path nmPrivateContainerTokensPath = ctx.getNmPrivateContainerTokens();
  InetSocketAddress nmAddr = ctx.getNmAddr();
  String user = ctx.getUser();
  String appId = ctx.getAppId();
  String locId = ctx.getLocId();
  String userFolder = ctx.getUserFolder();
  LocalDirsHandlerService dirsHandler = ctx.getDirsHandler();
  List<String> localDirs = dirsHandler.getLocalDirs();
  List<String> logDirs = dirsHandler.getLogDirs();

  verifyUsernamePattern(user);
  String runAsUser = getRunAsUser(user);
  PrivilegedOperation initializeContainerOp = new PrivilegedOperation(
      PrivilegedOperation.OperationType.INITIALIZE_CONTAINER);
  List<String> prefixCommands = new ArrayList<>();

  addSchedPriorityCommand(prefixCommands);
  initializeContainerOp.appendArgs(
      runAsUser,
      userFolder,
      Integer.toString(
          PrivilegedOperation.RunAsUserCommand.INITIALIZE_CONTAINER
              .getValue()),
      appId,
      nmPrivateContainerTokensPath.toUri().getPath().toString(),
      StringUtils.join(PrivilegedOperation.LINUX_FILE_PATH_SEPARATOR,
          localDirs),
      StringUtils.join(PrivilegedOperation.LINUX_FILE_PATH_SEPARATOR,
          logDirs));

  File jvm =                                  // use same jvm as parent
      new File(new File(System.getProperty("java.home"), "bin"), "java");
  initializeContainerOp.appendArgs(jvm.toString());
  initializeContainerOp.appendArgs("-classpath");
  initializeContainerOp.appendArgs(System.getProperty("java.class.path"));
  String javaLibPath = System.getProperty("java.library.path");
  if (javaLibPath != null) {
    initializeContainerOp.appendArgs("-Djava.library.path=" + javaLibPath);
  }

  initializeContainerOp.appendArgs(ContainerLocalizer.getJavaOpts(getConf()));

  List<String> localizerArgs = new ArrayList<>();

  buildMainArgs(localizerArgs, user, appId, locId, nmAddr, localDirs, userFolder);
  initializeContainerOp.appendArgs(localizerArgs);

  try {
    Configuration conf = super.getConf();
    PrivilegedOperationExecutor privilegedOperationExecutor =
        getPrivilegedOperationExecutor();

    privilegedOperationExecutor.executePrivilegedOperation(prefixCommands,
        initializeContainerOp, null, null, false, true);

  } catch (PrivilegedOperationException e) {
    int exitCode = e.getExitCode();
    LOG.warn("Exit code from container " + locId + " startLocalizer is : "
        + exitCode, e);

    throw new IOException("Application " + appId + " initialization failed" +
        " (exitCode=" + exitCode + ") with output: " + e.getOutput(), e);
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:68,代码来源:LinuxContainerExecutor.java


注:本文中的org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException.getExitCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。