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


Java BuilderUtils.newContainerToken方法代码示例

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


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

示例1: createContainerToken

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
public static Token createContainerToken(ContainerId cId, long rmIdentifier,
    NodeId nodeId, String user,
    NMContainerTokenSecretManager containerTokenSecretManager,
    LogAggregationContext logAggregationContext)
    throws IOException {
  Resource r = BuilderUtils.newResource(1024, 1);
  ContainerTokenIdentifier containerTokenIdentifier =
      new ContainerTokenIdentifier(cId, nodeId.toString(), user, r,
        System.currentTimeMillis() + 100000L, 123, rmIdentifier,
        Priority.newInstance(0), 0, logAggregationContext);
  Token containerToken =
      BuilderUtils
        .newContainerToken(nodeId, containerTokenSecretManager
          .retrievePassword(containerTokenIdentifier),
          containerTokenIdentifier);
  return containerToken;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestContainerManager.java

示例2: createContainerTokenId

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
private static ContainerTokenIdentifier createContainerTokenId(
    ContainerId cid, NodeId nodeId, String user,
    NMContainerTokenSecretManager secretMgr) throws IOException {
  long rmid = cid.getApplicationAttemptId().getApplicationId()
      .getClusterTimestamp();
  ContainerTokenIdentifier ctid = new ContainerTokenIdentifier(cid,
      nodeId.toString(), user, BuilderUtils.newResource(1024, 1),
      System.currentTimeMillis() + 100000L,
      secretMgr.getCurrentKey().getKeyId(), rmid,
      Priority.newInstance(0), 0);
  Token token = BuilderUtils.newContainerToken(nodeId,
      secretMgr.createPassword(ctid), ctid);
  return BuilderUtils.newContainerTokenIdentifier(token);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:TestNMContainerTokenSecretManager.java

示例3: createContainerToken

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
protected Token createContainerToken(ContainerId cId, Priority priority,
    long createTime) throws InvalidToken {
  Resource r = BuilderUtils.newResource(1024, 1);
  ContainerTokenIdentifier containerTokenIdentifier =
      new ContainerTokenIdentifier(cId, context.getNodeId().toString(), user,
        r, System.currentTimeMillis() + 10000L, 123, DUMMY_RM_IDENTIFIER,
        priority, createTime);
  Token containerToken =
      BuilderUtils.newContainerToken(
        context.getNodeId(),
        context.getContainerTokenSecretManager().retrievePassword(
          containerTokenIdentifier), containerTokenIdentifier);
  return containerToken;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:TestContainerLaunch.java

示例4: testRemovePreviousCompletedContainersFromContext

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
@Test(timeout = 90000)
public void testRemovePreviousCompletedContainersFromContext() throws Exception {
  NodeManager nm = new NodeManager();
  YarnConfiguration conf = new YarnConfiguration();
  conf.set(
      NodeStatusUpdaterImpl
          .YARN_NODEMANAGER_DURATION_TO_TRACK_STOPPED_CONTAINERS,
      "10000");
  nm.init(conf);
  NodeStatusUpdaterImpl nodeStatusUpdater =
      (NodeStatusUpdaterImpl) nm.getNodeStatusUpdater();
  ApplicationId appId = ApplicationId.newInstance(0, 0);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(appId, 0);

  ContainerId cId = ContainerId.newContainerId(appAttemptId, 1);
  Token containerToken =
      BuilderUtils.newContainerToken(cId, "anyHost", 1234, "anyUser",
          BuilderUtils.newResource(1024, 1), 0, 123,
          "password".getBytes(), 0);
  Container anyCompletedContainer = new ContainerImpl(conf, null,
      null, null, null, null,
      BuilderUtils.newContainerTokenIdentifier(containerToken)) {

    @Override
    public ContainerState getCurrentState() {
      return ContainerState.COMPLETE;
    }

    @Override
    public org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState getContainerState() {
      return org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState.DONE;
    }
  };

  ContainerId runningContainerId =
      ContainerId.newContainerId(appAttemptId, 3);
  Token runningContainerToken =
      BuilderUtils.newContainerToken(runningContainerId, "anyHost",
        1234, "anyUser", BuilderUtils.newResource(1024, 1), 0, 123,
        "password".getBytes(), 0);
  Container runningContainer =
      new ContainerImpl(conf, null, null, null, null, null,
        BuilderUtils.newContainerTokenIdentifier(runningContainerToken)) {
        @Override
        public ContainerState getCurrentState() {
          return ContainerState.RUNNING;
        }

        @Override
        public org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState getContainerState() {
          return org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState.RUNNING;
        }
      };

  nm.getNMContext().getApplications().putIfAbsent(appId,
      mock(Application.class));
  nm.getNMContext().getContainers().put(cId, anyCompletedContainer);
  nm.getNMContext().getContainers()
    .put(runningContainerId, runningContainer);

  Assert.assertEquals(2, nodeStatusUpdater.getContainerStatuses().size());

  List<ContainerId> ackedContainers = new ArrayList<ContainerId>();
  ackedContainers.add(cId);
  ackedContainers.add(runningContainerId);

  nodeStatusUpdater.removeOrTrackCompletedContainersFromContext(ackedContainers);

  Set<ContainerId> containerIdSet = new HashSet<ContainerId>();
  List<ContainerStatus> containerStatuses = nodeStatusUpdater.getContainerStatuses();
  for (ContainerStatus status : containerStatuses) {
    containerIdSet.add(status.getContainerId());
  }

  Assert.assertEquals(1, containerStatuses.size());
  // completed container is removed;
  Assert.assertFalse(containerIdSet.contains(cId));
  // running container is not removed;
  Assert.assertTrue(containerIdSet.contains(runningContainerId));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:82,代码来源:TestNodeStatusUpdater.java

示例5: testCleanedupApplicationContainerCleanup

import org.apache.hadoop.yarn.server.utils.BuilderUtils; //导入方法依赖的package包/类
@Test
public void testCleanedupApplicationContainerCleanup() throws IOException {
  NodeManager nm = new NodeManager();
  YarnConfiguration conf = new YarnConfiguration();
  conf.set(NodeStatusUpdaterImpl
          .YARN_NODEMANAGER_DURATION_TO_TRACK_STOPPED_CONTAINERS,
      "1000000");
  nm.init(conf);

  NodeStatusUpdaterImpl nodeStatusUpdater =
      (NodeStatusUpdaterImpl) nm.getNodeStatusUpdater();
  ApplicationId appId = ApplicationId.newInstance(0, 0);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(appId, 0);

  ContainerId cId = ContainerId.newContainerId(appAttemptId, 1);
  Token containerToken =
      BuilderUtils.newContainerToken(cId, "anyHost", 1234, "anyUser",
          BuilderUtils.newResource(1024, 1), 0, 123,
          "password".getBytes(), 0);
  Container anyCompletedContainer = new ContainerImpl(conf, null,
      null, null, null, null,
      BuilderUtils.newContainerTokenIdentifier(containerToken)) {

    @Override
    public ContainerState getCurrentState() {
      return ContainerState.COMPLETE;
    }
  };

  Application application = mock(Application.class);
  when(application.getApplicationState()).thenReturn(ApplicationState.RUNNING);
  nm.getNMContext().getApplications().putIfAbsent(appId, application);
  nm.getNMContext().getContainers().put(cId, anyCompletedContainer);

  Assert.assertEquals(1, nodeStatusUpdater.getContainerStatuses().size());

  when(application.getApplicationState()).thenReturn(
      ApplicationState.FINISHING_CONTAINERS_WAIT);
  // The completed container will be saved in case of lost heartbeat.
  Assert.assertEquals(1, nodeStatusUpdater.getContainerStatuses().size());
  Assert.assertEquals(1, nodeStatusUpdater.getContainerStatuses().size());

  nm.getNMContext().getContainers().put(cId, anyCompletedContainer);
  nm.getNMContext().getApplications().remove(appId);
  // The completed container will be saved in case of lost heartbeat.
  Assert.assertEquals(1, nodeStatusUpdater.getContainerStatuses().size());
  Assert.assertEquals(1, nodeStatusUpdater.getContainerStatuses().size());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:50,代码来源:TestNodeStatusUpdater.java


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