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


Java PrivilegedOperationException类代码示例

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


PrivilegedOperationException类属于org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged包,在下文中一共展示了PrivilegedOperationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initializeState

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入依赖的package包/类
private void initializeState() throws ResourceHandlerException {
  LOG.info("Initializing tc state.");

  BatchBuilder builder = new BatchBuilder(PrivilegedOperation.
      OperationType.TC_MODIFY_STATE)
      .addRootQDisc()
      .addCGroupFilter()
      .addClassToRootQDisc(rootBandwidthMbit)
      .addDefaultClass(defaultClassBandwidthMbit, rootBandwidthMbit)
          //yarn bandwidth is capped with rate = ceil
      .addYARNRootClass(yarnBandwidthMbit, yarnBandwidthMbit);
  PrivilegedOperation op = builder.commitBatchToTempFile();

  try {
    privilegedOperationExecutor.executePrivilegedOperation(op, false);
  } catch (PrivilegedOperationException e) {
    LOG.warn("Failed to bootstrap outbound bandwidth configuration");

    throw new ResourceHandlerException(
        "Failed to bootstrap outbound bandwidth configuration", e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TrafficController.java

示例2: recoverAcquireContainerClasses

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入依赖的package包/类
private void recoverAcquireContainerClasses(int containerBandwidthMbit, boolean strictMode) throws ResourceHandlerException {
  LOG.info("Recovering acquired container's tc state.");

  BatchBuilder builder = new BatchBuilder(PrivilegedOperation.
      OperationType.TC_MODIFY_STATE);

  for (int i = this.classIdSet.nextSetBit(0); i >= 0; i = this.classIdSet.nextSetBit(i+1)) {
    int classId = i + MIN_CONTAINER_CLASS_ID;
    builder.addContainerClass(classId, containerBandwidthMbit, strictMode);
    LOG.info("Recovered container classid: " + classId);
  }

  PrivilegedOperation op = builder.commitBatchToTempFile();

  try {
    privilegedOperationExecutor.executePrivilegedOperation(op, false);
  } catch (PrivilegedOperationException e) {
    LOG.warn("Failed to bootstrap outbound bandwidth configuration");

    throw new ResourceHandlerException(
        "Failed to bootstrap outbound bandwidth configuration", e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TrafficController.java

示例3: wipeState

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入依赖的package包/类
private void wipeState() throws ResourceHandlerException {
  BatchBuilder builder = new BatchBuilder(PrivilegedOperation.
      OperationType.TC_MODIFY_STATE)
      .wipeState();
  PrivilegedOperation op = builder.commitBatchToTempFile();

  try {
    LOG.info("Wiping tc state.");
    privilegedOperationExecutor.executePrivilegedOperation(op, false);
  } catch (PrivilegedOperationException e) {
    LOG.warn("Failed to wipe tc state. This could happen if the interface" +
        " is already in its default state. Ignoring.");
    //Ignoring this exception. This could happen if the interface is already
    //in its default state. For this reason we don't throw a
    //ResourceHandlerException here.
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TrafficController.java

示例4: readStats

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入依赖的package包/类
public Map<Integer, Integer> readStats() throws ResourceHandlerException {
  BatchBuilder builder = new BatchBuilder(PrivilegedOperation.
      OperationType.TC_READ_STATS)
      .readClasses();
  PrivilegedOperation op = builder.commitBatchToTempFile();

  try {
    String output =
        privilegedOperationExecutor.executePrivilegedOperation(op, true);

    if (LOG.isDebugEnabled()) {
      LOG.debug("TC stats output:" + output);
    }

    Map<Integer, Integer> classIdBytesStats = parseStatsString(output);

    if (LOG.isDebugEnabled()) {
      LOG.debug("classId -> bytes sent %n" + classIdBytesStats);
    }

    return classIdBytesStats;
  } catch (PrivilegedOperationException e) {
    LOG.warn("Failed to get tc stats");
    throw new ResourceHandlerException("Failed to get tc stats", e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:TrafficController.java

示例5: 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

示例6: 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

示例7: capturePrivilegedOperation

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private PrivilegedOperation capturePrivilegedOperation()
    throws PrivilegedOperationException {
  ArgumentCaptor<PrivilegedOperation> opCaptor = ArgumentCaptor.forClass(
      PrivilegedOperation.class);

  //single invocation expected
  //due to type erasure + mocking, this verification requires a suppress
  // warning annotation on the entire method
  verify(mockExecutor, times(1))
      .executePrivilegedOperation(anyList(), opCaptor.capture(), any(
          File.class), any(Map.class), eq(false));

  //verification completed. we need to isolate specific invications.
  // hence, reset mock here
  Mockito.reset(mockExecutor);

  return opCaptor.getValue();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestDockerContainerRuntime.java

示例8: captureDockerLoadPrivilegedOperationAndVerifyArgs

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private PrivilegedOperation captureDockerLoadPrivilegedOperationAndVerifyArgs()
    throws PrivilegedOperationException {
  ArgumentCaptor<PrivilegedOperation> opCaptor = ArgumentCaptor.forClass(
      PrivilegedOperation.class);
  verify(mockExecutor, times(1))
      .executePrivilegedOperation(anyList(), opCaptor.capture(), any(
          File.class), any(Map.class), eq(false));

  PrivilegedOperation op = opCaptor.getValue();

  Assert.assertEquals(PrivilegedOperation.OperationType
      .RUN_DOCKER_CMD, op.getOperationType());
  List<String> args = op.getArguments();
  Assert.assertEquals(1, args.size());
  return op;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestDockerContainerRuntime.java

示例9: testDockerContainerPrepare

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入依赖的package包/类
@Test
public void testDockerContainerPrepare()
    throws ContainerExecutionException, PrivilegedOperationException, IOException {
  String validImageFileRegex = "busybox.*";
  DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
      mockExecutor, mockCGroupsHandler);
  runtime.initialize(conf);
  Map<Path, List<String>> localizedResources = new HashMap<Path,List<String>>();
  localizedResources.put(new Path(containerWorkDir+ "/busybox.tar"),null);
  env.put(DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_IMAGE_FILE, validImageFileRegex);
  builder.setExecutionAttribute(LOCALIZED_RESOURCES, localizedResources);
  runtime.prepareContainer(builder.build());
  PrivilegedOperation op = captureDockerLoadPrivilegedOperationAndVerifyArgs();
  List<String> args = op.getArguments();
  String dockerCommandFile = args.get(0);
  String expectedCommand = "load --input " + containerWorkDir+ "/busybox.tar";
  List<String> dockerCommands = Files.readAllLines(Paths.get
      (dockerCommandFile), Charset.forName("UTF-8"));
  Assert.assertEquals(expectedCommand, dockerCommands.get(0));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestDockerContainerRuntime.java

示例10: testLaunchPrivilegedContainersWithDisabledSetting

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入依赖的package包/类
@Test
public void testLaunchPrivilegedContainersWithDisabledSetting()
    throws ContainerExecutionException, PrivilegedOperationException,
    IOException{
  DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
      mockExecutor, mockCGroupsHandler);
  runtime.initialize(conf);

  env.put("YARN_CONTAINER_RUNTIME_DOCKER_RUN_PRIVILEGED_CONTAINER",
      "true");

  try {
    runtime.launchContainer(builder.build());
    Assert.fail("Expected a privileged launch container failure.");
  } catch (ContainerExecutionException e) {
    LOG.info("Caught expected exception : " + e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestDockerContainerRuntime.java

示例11: testLaunchPrivilegedContainersWithEnabledSettingAndDefaultACL

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入依赖的package包/类
@Test
public void testLaunchPrivilegedContainersWithEnabledSettingAndDefaultACL()
    throws ContainerExecutionException, PrivilegedOperationException,
    IOException{
  //Enable privileged containers.
  conf.setBoolean(YarnConfiguration.NM_DOCKER_ALLOW_PRIVILEGED_CONTAINERS,
      true);

  DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
      mockExecutor, mockCGroupsHandler);
  runtime.initialize(conf);

  env.put("YARN_CONTAINER_RUNTIME_DOCKER_RUN_PRIVILEGED_CONTAINER",
      "true");
  //By default
  // yarn.nodemanager.runtime.linux.docker.privileged-containers.acl
  // is empty. So we expect this launch to fail.

  try {
    runtime.launchContainer(builder.build());
    Assert.fail("Expected a privileged launch container failure.");
  } catch (ContainerExecutionException e) {
    LOG.info("Caught expected exception : " + e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:TestDockerContainerRuntime.java

示例12: testLaunchPrivilegedContainersEnabledAndUserNotInWhitelist

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入依赖的package包/类
@Test
public void
testLaunchPrivilegedContainersEnabledAndUserNotInWhitelist()
    throws ContainerExecutionException, PrivilegedOperationException,
    IOException{
  //Enable privileged containers.
  conf.setBoolean(YarnConfiguration.NM_DOCKER_ALLOW_PRIVILEGED_CONTAINERS,
      true);
  //set whitelist of users.
  conf.set(YarnConfiguration.NM_DOCKER_PRIVILEGED_CONTAINERS_ACL,
      whitelistedUser);

  DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
      mockExecutor, mockCGroupsHandler);
  runtime.initialize(conf);

  env.put("YARN_CONTAINER_RUNTIME_DOCKER_RUN_PRIVILEGED_CONTAINER",
      "true");

  try {
    runtime.launchContainer(builder.build());
    Assert.fail("Expected a privileged launch container failure.");
  } catch (ContainerExecutionException e) {
    LOG.info("Caught expected exception : " + e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:TestDockerContainerRuntime.java

示例13: testMountSourceOnly

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入依赖的package包/类
@Test
public void testMountSourceOnly()
    throws ContainerExecutionException, PrivilegedOperationException,
    IOException{
  DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
      mockExecutor, mockCGroupsHandler);
    runtime.initialize(conf);

    env.put(
            DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_LOCAL_RESOURCE_MOUNTS,
      "source");

  try {
    runtime.launchContainer(builder.build());
    Assert.fail("Expected a launch container failure due to invalid mount.");
  } catch (ContainerExecutionException e) {
    LOG.info("Caught expected exception : " + e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestDockerContainerRuntime.java

示例14: testMountInvalid

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入依赖的package包/类
@Test
public void testMountInvalid()
    throws ContainerExecutionException, PrivilegedOperationException,
    IOException{
  DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
      mockExecutor, mockCGroupsHandler);
  runtime.initialize(conf);

  env.put(
      DockerLinuxContainerRuntime.ENV_DOCKER_CONTAINER_LOCAL_RESOURCE_MOUNTS,
      "source:target:other");

  try {
    runtime.launchContainer(builder.build());
    Assert.fail("Expected a launch container failure due to invalid mount.");
  } catch (ContainerExecutionException e) {
    LOG.info("Caught expected exception : " + e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestDockerContainerRuntime.java

示例15: testContainerLivelinessCheck

import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException; //导入依赖的package包/类
@Test
public void testContainerLivelinessCheck()
    throws ContainerExecutionException, PrivilegedOperationException {

  DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
      mockExecutor, mockCGroupsHandler);
  builder.setExecutionAttribute(RUN_AS_USER, runAsUser)
      .setExecutionAttribute(USER, user)
      .setExecutionAttribute(PID, signalPid)
          .setExecutionAttribute(SIGNAL, ContainerExecutor.Signal.NULL);
    runtime.initialize(getConfigurationWithMockContainerExecutor());
    runtime.signalContainer(builder.build());

  PrivilegedOperation op = capturePrivilegedOperation();
  Assert.assertEquals(op.getOperationType(),
      PrivilegedOperation.OperationType.SIGNAL_CONTAINER);
  Assert.assertEquals("run_as_user", op.getArguments().get(0));
  Assert.assertEquals("user", op.getArguments().get(1));
  Assert.assertEquals("2", op.getArguments().get(2));
  Assert.assertEquals("1234", op.getArguments().get(3));
    Assert.assertEquals("0", op.getArguments().get(4));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestDockerContainerRuntime.java


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