org.apache.hadoop.yarn.server.nodemanager.NodeManager.getNMContext()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(160)

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

NodeManager.getNMContext介绍

暂无

代码示例

代码示例来源:origin: apache/flink

public static int getRunningContainers() {
  int count = 0;
  for (int nmId = 0; nmId < NUM_NODEMANAGERS; nmId++) {
    NodeManager nm = yarnCluster.getNodeManager(nmId);
    ConcurrentMap<ContainerId, Container> containers = nm.getNMContext().getContainers();
    count += containers.size();
  }
  return count;
}

代码示例来源:origin: apache/flink

ConcurrentMap<ContainerId, Container> containers = nm.getNMContext().getContainers();
  for (Map.Entry<ContainerId, Container> entry : containers.entrySet()) {
    String command = StringUtils.join(entry.getValue().getLaunchContext().getCommands(), " ");
nodeManager.getNMContext().getContainerManager().stopContainers(scr);

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-tests

protected void waitForNMToReceiveNMTokenKey(
  NMTokenSecretManagerInNM nmTokenSecretManagerNM, NodeManager nm)
  throws InterruptedException {
 int attempt = 60;
 ContainerManagerImpl cm =
   ((ContainerManagerImpl) nm.getNMContext().getContainerManager());
 while ((cm.getBlockNewContainerRequestsStatus() || nmTokenSecretManagerNM
   .getNodeId() == null) && attempt-- > 0) {
  Thread.sleep(2000);
 }
}

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-tests

private void waitForContainerToFinishOnNM(ContainerId containerId) {
 Context nmContet = yarnCluster.getNodeManager(0).getNMContext();
 int interval = 4 * 60; // Max time for container token to expire.
 Assert.assertNotNull(nmContet.getContainers().containsKey(containerId));
 while ((interval-- > 0)
   && !nmContet.getContainers().get(containerId)
    .cloneAndGetContainerStatus().getState()
    .equals(ContainerState.COMPLETE)) {
  try {
   LOG.info("Waiting for " + containerId + " to complete.");
   Thread.sleep(1000);
  } catch (InterruptedException e) {
  }
 }
 // Normally, Containers will be removed from NM context after they are
 // explicitly acked by RM. Now, manually remove it for testing.
 yarnCluster.getNodeManager(0).getNodeStatusUpdater()
  .addCompletedContainer(containerId);
 nmContet.getContainers().remove(containerId);
}

代码示例来源:origin: linkedin/dynamometer

nodeLabelManager.addToCluserNodeLabels(Sets.newHashSet(NAMENODE_NODELABEL, DATANODE_NODELABEL));
Map<NodeId, Set<String>> nodeLabels = new HashMap<>();
nodeLabels.put(miniYARNCluster.getNodeManager(0).getNMContext().getNodeId(), Sets.newHashSet(NAMENODE_NODELABEL));
nodeLabels.put(miniYARNCluster.getNodeManager(1).getNMContext().getNodeId(), Sets.newHashSet(DATANODE_NODELABEL));
nodeLabelManager.addLabelsToNode(nodeLabels);

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

private void waitForContainerToFinishOnNM(ContainerId containerId)
  throws InterruptedException {
 Context nmContext = yarnCluster.getNodeManager(0).getNMContext();
 // Max time for container token to expire.
 final int timeout = 4 * 60 * 1000;
 // If the container is null, then it has already completed and been removed
 // from the Context by asynchronous calls.
 Container waitContainer = nmContext.getContainers().get(containerId);
 if (waitContainer != null) {
  try {
   LOG.info("Waiting for " + containerId + " to get to state " +
     ContainerState.COMPLETE);
   GenericTestUtils.waitFor(() -> ContainerState.COMPLETE.equals(
     waitContainer.cloneAndGetContainerStatus().getState()),
     500, timeout);
  } catch (TimeoutException te) {
   LOG.error("TimeoutException", te);
   fail("Was waiting for " + containerId + " to get to state " +
     ContainerState.COMPLETE + " but was in state " +
     waitContainer.cloneAndGetContainerStatus().getState() +
     " after the timeout");
  }
 }
 // Normally, Containers will be removed from NM context after they are
 // explicitly acked by RM. Now, manually remove it for testing.
 yarnCluster.getNodeManager(0).getNodeStatusUpdater()
  .addCompletedContainer(containerId);
 LOG.info("Removing container from NMContext, containerID = " + containerId);
 nmContext.getContainers().remove(containerId);
}

代码示例来源:origin: linkedin/dynamometer

Map<ContainerId, Container> namenodeContainers = miniYARNCluster.getNodeManager(0).getNMContext().getContainers();
Map<ContainerId, Container> datanodeContainers = miniYARNCluster.getNodeManager(1).getNMContext().getContainers();
Map<ContainerId, Container> amContainers = miniYARNCluster.getNodeManager(2).getNMContext().getContainers();
assertEquals(1, namenodeContainers.size());
assertEquals(2, namenodeContainers.keySet().iterator().next().getContainerId());

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

.getNMTokenSecretManager();
NMTokenSecretManagerInNM nmTokenSecretManagerNM =
  yarnCluster.getNodeManager(0).getNMContext().getNMTokenSecretManager();
RMContainerTokenSecretManager containerTokenSecretManager =
  yarnCluster.getResourceManager().getRMContext().
  ContainerId.newContainerId(validAppAttemptId, 0);
NodeId validNode = yarnCluster.getNodeManager(0).getNMContext().getNodeId();
NodeId invalidNode = NodeId.newInstance("InvalidHost", 1234);

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-tests

.getNMTokenSecretManager();
NMTokenSecretManagerInNM nmTokenSecretManagerNM =
  yarnCluster.getNodeManager(0).getNMContext().getNMTokenSecretManager();
RMContainerTokenSecretManager containerTokenSecretManager =
  yarnCluster.getResourceManager().getRMContext().
  ContainerId.newContainerId(validAppAttemptId, 0);
NodeId validNode = yarnCluster.getNodeManager(0).getNMContext().getNodeId();
NodeId invalidNode = NodeId.newInstance("InvalidHost", 1234);

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-tests

NodeManager nm = yarnCluster.getNodeManager(0);
NMTokenSecretManagerInNM nmTokenSecretManagerInNM =
  nm.getNMContext().getNMTokenSecretManager();
String user = "test";
NodeId nodeId = nm.getNMContext().getNodeId();

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

NodeManager nm = yarnCluster.getNodeManager(0);
NMTokenSecretManagerInNM nmTokenSecretManagerInNM =
  nm.getNMContext().getNMTokenSecretManager();
String user = "test";
NodeId nodeId = nm.getNMContext().getNodeId();

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

NodeManager nm = yarnCluster.getNodeManager(0);
NMTokenSecretManagerInNM nmTokenSecretManagerInNM =
  nm.getNMContext().getNMTokenSecretManager();
String user = "test";
NodeId nodeId = nm.getNMContext().getNodeId();

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-tests

NodeManager nm = yarnCluster.getNodeManager(0);
NMTokenSecretManagerInNM nmTokenSecretManagerInNM =
  nm.getNMContext().getNMTokenSecretManager();
String user = "test";
NodeId nodeId = nm.getNMContext().getNodeId();

相关文章