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


Java NodeHeartbeatResponse.getApplicationsToCleanup方法代码示例

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


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

示例1: waitForAppCleanupMessageRecved

import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse; //导入方法依赖的package包/类
private void waitForAppCleanupMessageRecved(MockNM nm, ApplicationId appId)
    throws Exception {
  while (true) {
    NodeHeartbeatResponse response = nm.nodeHeartbeat(true);
    if (response.getApplicationsToCleanup() != null
        && response.getApplicationsToCleanup().size() == 1
        && appId.equals(response.getApplicationsToCleanup().get(0))) {
      return;
    }

    LOG.info("Haven't got application=" + appId.toString()
        + " in cleanup list from node heartbeat response, "
        + "sleep for a while before next heartbeat");
    Thread.sleep(1000);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestApplicationCleanup.java

示例2: testAppCleanup

import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse; //导入方法依赖的package包/类
@SuppressWarnings("resource")
@Test
public void testAppCleanup() throws Exception {
  Logger rootLogger = LogManager.getRootLogger();
  rootLogger.setLevel(Level.DEBUG);
  MockRM rm = new MockRM();
  rm.start();

  MockNM nm1 = rm.registerNode("127.0.0.1:1234", 5000);

  RMApp app = rm.submitApp(2000);

  //kick the scheduling
  nm1.nodeHeartbeat(true);

  RMAppAttempt attempt = app.getCurrentAppAttempt();
  MockAM am = rm.sendAMLaunched(attempt.getAppAttemptId());
  am.registerAppAttempt();
  
  //request for containers
  int request = 2;
  am.allocate("127.0.0.1" , 1000, request, 
      new ArrayList<ContainerId>());
  
  //kick the scheduler
  nm1.nodeHeartbeat(true);
  List<Container> conts = am.allocate(new ArrayList<ResourceRequest>(),
      new ArrayList<ContainerId>()).getAllocatedContainers();
  int contReceived = conts.size();
  int waitCount = 0;
  while (contReceived < request && waitCount++ < 200) {
    LOG.info("Got " + contReceived + " containers. Waiting to get "
             + request);
    Thread.sleep(100);
    conts = am.allocate(new ArrayList<ResourceRequest>(),
        new ArrayList<ContainerId>()).getAllocatedContainers();
    contReceived += conts.size();
    nm1.nodeHeartbeat(true);
  }
  Assert.assertEquals(request, contReceived);
  
  am.unregisterAppAttempt();
  NodeHeartbeatResponse resp = nm1.nodeHeartbeat(attempt.getAppAttemptId(), 1,
      ContainerState.COMPLETE);
  am.waitForState(RMAppAttemptState.FINISHED);

  //currently only containers are cleaned via this
  //AM container is cleaned via container launcher
  resp = nm1.nodeHeartbeat(true);
  List<ContainerId> containersToCleanup = resp.getContainersToCleanup();
  List<ApplicationId> appsToCleanup = resp.getApplicationsToCleanup();
  int numCleanedContainers = containersToCleanup.size();
  int numCleanedApps = appsToCleanup.size();
  waitCount = 0;
  while ((numCleanedContainers < 2 || numCleanedApps < 1)
      && waitCount++ < 200) {
    LOG.info("Waiting to get cleanup events.. cleanedConts: "
        + numCleanedContainers + " cleanedApps: " + numCleanedApps);
    Thread.sleep(100);
    resp = nm1.nodeHeartbeat(true);
    List<ContainerId> deltaContainersToCleanup =
        resp.getContainersToCleanup();
    List<ApplicationId> deltaAppsToCleanup = resp.getApplicationsToCleanup();
    // Add the deltas to the global list
    containersToCleanup.addAll(deltaContainersToCleanup);
    appsToCleanup.addAll(deltaAppsToCleanup);
    // Update counts now
    numCleanedContainers = containersToCleanup.size();
    numCleanedApps = appsToCleanup.size();
  }
  
  Assert.assertEquals(1, appsToCleanup.size());
  Assert.assertEquals(app.getApplicationId(), appsToCleanup.get(0));
  Assert.assertEquals(1, numCleanedApps);
  Assert.assertEquals(2, numCleanedContainers);

  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:79,代码来源:TestApplicationCleanup.java


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