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


Java ContainerState类代码示例

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


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

示例1: startContainers

import org.apache.hadoop.yarn.api.records.ContainerState; //导入依赖的package包/类
@Override
public StartContainersResponse startContainers(
    StartContainersRequest requests) throws YarnException {
  StartContainersResponse response =
      recordFactory.newRecordInstance(StartContainersResponse.class);
  for (StartContainerRequest request : requests.getStartContainerRequests()) {
    Token containerToken = request.getContainerToken();
    ContainerTokenIdentifier tokenId = null;

    try {
      tokenId = newContainerTokenIdentifier(containerToken);
    } catch (IOException e) {
      throw RPCUtil.getRemoteException(e);
    }
    ContainerStatus status =
        recordFactory.newRecordInstance(ContainerStatus.class);
    status.setState(ContainerState.RUNNING);
    status.setContainerId(tokenId.getContainerID());
    status.setExitStatus(0);
    statuses.add(status);

  }
  return response;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestRPC.java

示例2: testGetContainerStatus

import org.apache.hadoop.yarn.api.records.ContainerState; //导入依赖的package包/类
private void testGetContainerStatus(Container container, int index,
    ContainerState state, String diagnostics, List<Integer> exitStatuses)
        throws YarnException, IOException {
  while (true) {
    try {
      ContainerStatus status = nmClient.getContainerStatus(
          container.getId(), container.getNodeId());
      // NodeManager may still need some time to get the stable
      // container status
      if (status.getState() == state) {
        assertEquals(container.getId(), status.getContainerId());
        assertTrue("" + index + ": " + status.getDiagnostics(),
            status.getDiagnostics().contains(diagnostics));
        
        assertTrue("Exit Statuses are supposed to be in: " + exitStatuses +
            ", but the actual exit status code is: " + status.getExitStatus(),
            exitStatuses.contains(status.getExitStatus()));
        break;
      }
      Thread.sleep(100);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:TestNMClient.java

示例3: waitForRecoveredContainers

import org.apache.hadoop.yarn.api.records.ContainerState; //导入依赖的package包/类
private void waitForRecoveredContainers() throws InterruptedException {
  final int sleepMsec = 100;
  int waitIterations = 100;
  List<ContainerId> newContainers = new ArrayList<ContainerId>();
  while (--waitIterations >= 0) {
    newContainers.clear();
    for (Container container : context.getContainers().values()) {
      if (container.getContainerState() == org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState.NEW) {
        newContainers.add(container.getContainerId());
      }
    }
    if (newContainers.isEmpty()) {
      break;
    }
    LOG.info("Waiting for containers: " + newContainers);
    Thread.sleep(sleepMsec);
  }
  if (waitIterations < 0) {
    LOG.warn("Timeout waiting for recovered containers");
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:ContainerManagerImpl.java

示例4: getNMContainerStatuses

import org.apache.hadoop.yarn.api.records.ContainerState; //导入依赖的package包/类
private List<NMContainerStatus> getNMContainerStatuses() throws IOException {
  List<NMContainerStatus> containerStatuses =
      new ArrayList<NMContainerStatus>();
  for (Container container : this.context.getContainers().values()) {
    ContainerId containerId = container.getContainerId();
    ApplicationId applicationId = containerId.getApplicationAttemptId()
        .getApplicationId();
    if (!this.context.getApplications().containsKey(applicationId)) {
      context.getContainers().remove(containerId);
      continue;
    }
    NMContainerStatus status =
        container.getNMContainerStatus();
    containerStatuses.add(status);
    if (status.getContainerState() == ContainerState.COMPLETE) {
      // Adding to finished containers cache. Cache will keep it around at
      // least for #durationToTrackStoppedContainers duration. In the
      // subsequent call to stop container it will get removed from cache.
      addCompletedContainer(containerId);
    }
  }
  LOG.info("Sending out " + containerStatuses.size()
    + " NM container statuses: " + containerStatuses);
  return containerStatuses;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:NodeStatusUpdaterImpl.java

示例5: waitForContainerState

import org.apache.hadoop.yarn.api.records.ContainerState; //导入依赖的package包/类
public static void waitForContainerState(ContainerManagementProtocol containerManager,
      ContainerId containerID, ContainerState finalState, int timeOutMax)
      throws InterruptedException, YarnException, IOException {
List<ContainerId> list = new ArrayList<ContainerId>();
list.add(containerID);
GetContainerStatusesRequest request =
    GetContainerStatusesRequest.newInstance(list);
ContainerStatus containerStatus =
    containerManager.getContainerStatuses(request).getContainerStatuses()
      .get(0);
int timeoutSecs = 0;
  while (!containerStatus.getState().equals(finalState)
      && timeoutSecs++ < timeOutMax) {
      Thread.sleep(1000);
      LOG.info("Waiting for container to get into state " + finalState
          + ". Current state is " + containerStatus.getState());
      containerStatus = containerManager.getContainerStatuses(request).getContainerStatuses().get(0);
    }
    LOG.info("Container state is " + containerStatus.getState());
    Assert.assertEquals("ContainerState is not correct (timedout)",
        finalState, containerStatus.getState());
  }
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:BaseContainerManagerTest.java

示例6: getContainers

import org.apache.hadoop.yarn.api.records.ContainerState; //导入依赖的package包/类
@Override
public ConcurrentMap<ContainerId, Container> getContainers() {
  if (heartBeatID == 0) {
    return containers;
  } else if (heartBeatID == 1) {
    ContainerStatus containerStatus2 =
        createContainerStatus(2, ContainerState.RUNNING);
    putMockContainer(containerStatus2);

    ContainerStatus containerStatus3 =
        createContainerStatus(3, ContainerState.COMPLETE);
    putMockContainer(containerStatus3);
    return containers;
  } else if (heartBeatID == 2) {
    ContainerStatus containerStatus4 =
        createContainerStatus(4, ContainerState.RUNNING);
    putMockContainer(containerStatus4);

    ContainerStatus containerStatus5 =
        createContainerStatus(5, ContainerState.COMPLETE);
    putMockContainer(containerStatus5);
    return containers;
  } else if (heartBeatID == 3 || heartBeatID == 4) {
    return containers;
  } else {
    containers.clear();
    return containers;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:30,代码来源:TestNodeStatusUpdater.java

示例7: createRMContainer

import org.apache.hadoop.yarn.api.records.ContainerState; //导入依赖的package包/类
private static RMContainer createRMContainer(ContainerId containerId) {
  RMContainer container = mock(RMContainer.class);
  when(container.getContainerId()).thenReturn(containerId);
  when(container.getAllocatedNode()).thenReturn(
      NodeId.newInstance("test host", -100));
  when(container.getAllocatedResource()).thenReturn(
      Resource.newInstance(-1, -1, -1));
  when(container.getAllocatedPriority()).thenReturn(Priority.UNDEFINED);
  when(container.getCreationTime()).thenReturn(Integer.MAX_VALUE + 1L);
  when(container.getFinishTime()).thenReturn(Integer.MAX_VALUE + 2L);
  when(container.getDiagnosticsInfo()).thenReturn("test diagnostics info");
  when(container.getContainerExitStatus()).thenReturn(-1);
  when(container.getContainerState()).thenReturn(ContainerState.COMPLETE);
  Container mockContainer = mock(Container.class);
  when(container.getContainer()).thenReturn(mockContainer);
  when(mockContainer.getNodeHttpAddress())
    .thenReturn("http://localhost:1234");
  return container;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestSystemMetricsPublisher.java

示例8: testAppWithNoContainers

import org.apache.hadoop.yarn.api.records.ContainerState; //导入依赖的package包/类
@Test (timeout = 30000)
public void testAppWithNoContainers() throws Exception {
  Logger rootLogger = LogManager.getRootLogger();
  rootLogger.setLevel(Level.DEBUG);
  MockRM rm = new MockRM(conf);
  rm.start();
  MockNM nm1 = rm.registerNode("h1:1234", 5120);
  
  RMApp app = rm.submitApp(2000);

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

  RMAppAttempt attempt = app.getCurrentAppAttempt();
  MockAM am = rm.sendAMLaunched(attempt.getAppAttemptId());
  am.registerAppAttempt();
  am.unregisterAppAttempt();
  nm1.nodeHeartbeat(attempt.getAppAttemptId(), 1, ContainerState.COMPLETE);
  am.waitForState(RMAppAttemptState.FINISHED);
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:TestRM.java

示例9: testInvalidatedAMHostPortOnAMRestart

import org.apache.hadoop.yarn.api.records.ContainerState; //导入依赖的package包/类
@Test (timeout = 60000)
public void testInvalidatedAMHostPortOnAMRestart() throws Exception {
  MockRM rm1 = new MockRM(conf);
  rm1.start();
  MockNM nm1 =
      new MockNM("127.0.0.1:1234", 15120, rm1.getResourceTrackerService());
  nm1.registerNode();

  // a failed app
  RMApp app2 = rm1.submitApp(200);
  MockAM am2 = MockRM.launchAndRegisterAM(app2, rm1, nm1);
  nm1
    .nodeHeartbeat(am2.getApplicationAttemptId(), 1, ContainerState.COMPLETE);
  am2.waitForState(RMAppAttemptState.FAILED);
  rm1.waitForState(app2.getApplicationId(), RMAppState.ACCEPTED);

  // before new attempt is launched, the app report returns the invalid AM
  // host and port.
  GetApplicationReportRequest request1 =
      GetApplicationReportRequest.newInstance(app2.getApplicationId());
  ApplicationReport report1 =
      rm1.getClientRMService().getApplicationReport(request1)
        .getApplicationReport();
  Assert.assertEquals("N/A", report1.getHost());
  Assert.assertEquals(-1, report1.getRpcPort());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:TestRM.java

示例10: createRMContainer

import org.apache.hadoop.yarn.api.records.ContainerState; //导入依赖的package包/类
private static RMContainer createRMContainer(ContainerId containerId) {
  RMContainer container = mock(RMContainer.class);
  when(container.getContainerId()).thenReturn(containerId);
  when(container.getAllocatedNode()).thenReturn(
    NodeId.newInstance("test host", -100));
  when(container.getAllocatedResource()).thenReturn(
    Resource.newInstance(-1, -1, -1));
  when(container.getAllocatedPriority()).thenReturn(Priority.UNDEFINED);
  when(container.getCreationTime()).thenReturn(0L);
  when(container.getFinishTime()).thenReturn(1L);
  when(container.getDiagnosticsInfo()).thenReturn("test diagnostics info");
  when(container.getLogURL()).thenReturn("test log url");
  when(container.getContainerExitStatus()).thenReturn(-1);
  when(container.getContainerState()).thenReturn(ContainerState.COMPLETE);
  return container;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestRMApplicationHistoryWriter.java

示例11: testSuccessfulFinishingToFinished

import org.apache.hadoop.yarn.api.records.ContainerState; //导入依赖的package包/类
@Test
public void testSuccessfulFinishingToFinished() {
  Container amContainer = allocateApplicationAttempt();
  launchApplicationAttempt(amContainer);
  runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl", false);
  FinalApplicationStatus finalStatus = FinalApplicationStatus.SUCCEEDED;
  String trackingUrl = "mytrackingurl";
  String diagnostics = "Successful";
  unregisterApplicationAttempt(amContainer, finalStatus, trackingUrl,
      diagnostics);
  NodeId anyNodeId = NodeId.newInstance("host", 1234);
  applicationAttempt.handle(
      new RMAppAttemptContainerFinishedEvent(
          applicationAttempt.getAppAttemptId(),
          BuilderUtils.newContainerStatus(amContainer.getId(),
              ContainerState.COMPLETE, "", 0), anyNodeId));
  testAppAttemptFinishedState(amContainer, finalStatus, trackingUrl,
      diagnostics, 0, false);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestRMAppAttemptTransitions.java

示例12: createNMContainerStatusForApp

import org.apache.hadoop.yarn.api.records.ContainerState; //导入依赖的package包/类
public static List<NMContainerStatus>
    createNMContainerStatusForApp(MockAM am) {
  List<NMContainerStatus> list =
      new ArrayList<NMContainerStatus>();
  NMContainerStatus amContainer =
      TestRMRestart.createNMContainerStatus(am.getApplicationAttemptId(), 1,
        ContainerState.RUNNING);
  NMContainerStatus runningContainer =
      TestRMRestart.createNMContainerStatus(am.getApplicationAttemptId(), 2,
        ContainerState.RUNNING);
  NMContainerStatus completedContainer =
      TestRMRestart.createNMContainerStatus(am.getApplicationAttemptId(), 3,
        ContainerState.COMPLETE);
  list.add(amContainer);
  list.add(runningContainer);
  list.add(completedContainer);
  return list;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestWorkPreservingRMRestart.java

示例13: getContainerState

import org.apache.hadoop.yarn.api.records.ContainerState; //导入依赖的package包/类
@Override
public ContainerState getContainerState() {
  ContainerReportProtoOrBuilder p = viaProto ? proto : builder;
  if (!p.hasContainerState()) {
    return null;
  }
  return convertFromProtoFormat(p.getContainerState());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:ContainerReportPBImpl.java

示例14: setContainerState

import org.apache.hadoop.yarn.api.records.ContainerState; //导入依赖的package包/类
@Override
public void setContainerState(ContainerState containerState) {
  maybeInitBuilder();
  if (containerState == null) {
    builder.clearContainerState();
    return;
  }
  builder.setContainerState(convertToProtoFormat(containerState));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:ContainerReportPBImpl.java

示例15: getState

import org.apache.hadoop.yarn.api.records.ContainerState; //导入依赖的package包/类
@Override
public synchronized ContainerState getState() {
  ContainerStatusProtoOrBuilder p = viaProto ? proto : builder;
  if (!p.hasState()) {
    return null;
  }
  return convertFromProtoFormat(p.getState());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:ContainerStatusPBImpl.java


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