Java 类org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesRequest 实例源码

项目:hadoop    文件:ContainerManagerImpl.java   
/**
 * Get a list of container statuses running on this NodeManager
 */
@Override
public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException, IOException {

  List<ContainerStatus> succeededRequests = new ArrayList<ContainerStatus>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  for (ContainerId id : request.getContainerIds()) {
    try {
      ContainerStatus status = getContainerStatusInternal(id, identifier);
      succeededRequests.add(status);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return GetContainerStatusesResponse.newInstance(succeededRequests,
    failedRequests);
}
项目:hadoop    文件:BaseContainerManagerTest.java   
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());
  }
项目:hadoop    文件:NodeManager.java   
@Override
synchronized public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException {
  List<ContainerStatus> statuses = new ArrayList<ContainerStatus>();
  for (ContainerId containerId : request.getContainerIds()) {
    List<Container> appContainers =
        containers.get(containerId.getApplicationAttemptId()
          .getApplicationId());
    Container container = null;
    for (Container c : appContainers) {
      if (c.getId().equals(containerId)) {
        container = c;
      }
    }
    if (container != null
        && containerStatusMap.get(container).getState() != null) {
      statuses.add(containerStatusMap.get(container));
    }
  }
  return GetContainerStatusesResponse.newInstance(statuses, null);
}
项目:hadoop    文件:NMClientImpl.java   
@Override
public ContainerStatus getContainerStatus(ContainerId containerId,
    NodeId nodeId) throws YarnException, IOException {

  ContainerManagementProtocolProxyData proxy = null;
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  try {
    proxy = cmProxy.getProxy(nodeId.toString(), containerId);
    GetContainerStatusesResponse response =
        proxy.getContainerManagementProtocol().getContainerStatuses(
            GetContainerStatusesRequest.newInstance(containerIds));
    if (response.getFailedRequests() != null
        && response.getFailedRequests().containsKey(containerId)) {
      Throwable t =
          response.getFailedRequests().get(containerId).deSerialize();
      parseAndThrowException(t);
    }
    ContainerStatus containerStatus = response.getContainerStatuses().get(0);
    return containerStatus;
  } finally {
    if (proxy != null) {
      cmProxy.mayBeCloseProxy(proxy);
    }
  }
}
项目:aliyun-oss-hadoop-fs    文件:ContainerManagerImpl.java   
/**
 * Get a list of container statuses running on this NodeManager
 */
@Override
public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException, IOException {

  List<ContainerStatus> succeededRequests = new ArrayList<ContainerStatus>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  if (identifier == null) {
    throw RPCUtil.getRemoteException(INVALID_NMTOKEN_MSG);
  }
  for (ContainerId id : request.getContainerIds()) {
    try {
      ContainerStatus status = getContainerStatusInternal(id, identifier);
      succeededRequests.add(status);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return GetContainerStatusesResponse.newInstance(succeededRequests,
    failedRequests);
}
项目:aliyun-oss-hadoop-fs    文件:BaseContainerManagerTest.java   
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());
  }
项目:aliyun-oss-hadoop-fs    文件:TestContainerManagerRecovery.java   
private ContainerStatus getContainerStatus(
    Context context, final ContainerManagerImpl cm, ContainerId cid)
    throws  Exception {
  UserGroupInformation user = UserGroupInformation.createRemoteUser(
      cid.getApplicationAttemptId().toString());
  NMTokenIdentifier nmToken = new NMTokenIdentifier(
      cid.getApplicationAttemptId(), context.getNodeId(),
      user.getShortUserName(),
      context.getNMTokenSecretManager().getCurrentKey().getKeyId());
  user.addTokenIdentifier(nmToken);
  List<ContainerId> containerIds = new ArrayList<>();
  containerIds.add(cid);
  final GetContainerStatusesRequest gcsRequest =
      GetContainerStatusesRequest.newInstance(containerIds);
  return user.doAs(
      new PrivilegedExceptionAction<ContainerStatus>() {
        @Override
        public ContainerStatus run() throws Exception {
          return cm.getContainerStatuses(gcsRequest)
              .getContainerStatuses().get(0);
        }
      });
}
项目:aliyun-oss-hadoop-fs    文件:NodeManager.java   
@Override
synchronized public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException {
  List<ContainerStatus> statuses = new ArrayList<ContainerStatus>();
  for (ContainerId containerId : request.getContainerIds()) {
    List<Container> appContainers =
        containers.get(containerId.getApplicationAttemptId()
          .getApplicationId());
    Container container = null;
    for (Container c : appContainers) {
      if (c.getId().equals(containerId)) {
        container = c;
      }
    }
    if (container != null
        && containerStatusMap.get(container).getState() != null) {
      statuses.add(containerStatusMap.get(container));
    }
  }
  return GetContainerStatusesResponse.newInstance(statuses, null);
}
项目:aliyun-oss-hadoop-fs    文件:NMClientImpl.java   
@Override
public ContainerStatus getContainerStatus(ContainerId containerId,
    NodeId nodeId) throws YarnException, IOException {

  ContainerManagementProtocolProxyData proxy = null;
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  try {
    proxy = cmProxy.getProxy(nodeId.toString(), containerId);
    GetContainerStatusesResponse response =
        proxy.getContainerManagementProtocol().getContainerStatuses(
            GetContainerStatusesRequest.newInstance(containerIds));
    if (response.getFailedRequests() != null
        && response.getFailedRequests().containsKey(containerId)) {
      Throwable t =
          response.getFailedRequests().get(containerId).deSerialize();
      parseAndThrowException(t);
    }
    ContainerStatus containerStatus = response.getContainerStatuses().get(0);
    return containerStatus;
  } finally {
    if (proxy != null) {
      cmProxy.mayBeCloseProxy(proxy);
    }
  }
}
项目:big-c    文件:ContainerManagerImpl.java   
/**
 * Get a list of container statuses running on this NodeManager
 */
@Override
public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException, IOException {

  List<ContainerStatus> succeededRequests = new ArrayList<ContainerStatus>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  for (ContainerId id : request.getContainerIds()) {
    try {
      ContainerStatus status = getContainerStatusInternal(id, identifier);
      succeededRequests.add(status);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return GetContainerStatusesResponse.newInstance(succeededRequests,
    failedRequests);
}
项目:big-c    文件:BaseContainerManagerTest.java   
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());
  }
项目:big-c    文件:NodeManager.java   
@Override
synchronized public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException {
  List<ContainerStatus> statuses = new ArrayList<ContainerStatus>();
  for (ContainerId containerId : request.getContainerIds()) {
    List<Container> appContainers =
        containers.get(containerId.getApplicationAttemptId()
          .getApplicationId());
    Container container = null;
    for (Container c : appContainers) {
      if (c.getId().equals(containerId)) {
        container = c;
      }
    }
    if (container != null
        && containerStatusMap.get(container).getState() != null) {
      statuses.add(containerStatusMap.get(container));
    }
  }
  return GetContainerStatusesResponse.newInstance(statuses, null);
}
项目:big-c    文件:NMClientImpl.java   
@Override
public ContainerStatus getContainerStatus(ContainerId containerId,
    NodeId nodeId) throws YarnException, IOException {

  ContainerManagementProtocolProxyData proxy = null;
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  try {
    proxy = cmProxy.getProxy(nodeId.toString(), containerId);
    GetContainerStatusesResponse response =
        proxy.getContainerManagementProtocol().getContainerStatuses(
            GetContainerStatusesRequest.newInstance(containerIds));
    if (response.getFailedRequests() != null
        && response.getFailedRequests().containsKey(containerId)) {
      Throwable t =
          response.getFailedRequests().get(containerId).deSerialize();
      parseAndThrowException(t);
    }
    ContainerStatus containerStatus = response.getContainerStatuses().get(0);
    return containerStatus;
  } finally {
    if (proxy != null) {
      cmProxy.mayBeCloseProxy(proxy);
    }
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ContainerManagerImpl.java   
/**
 * Get a list of container statuses running on this NodeManager
 */
@Override
public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException, IOException {

  List<ContainerStatus> succeededRequests = new ArrayList<ContainerStatus>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  for (ContainerId id : request.getContainerIds()) {
    try {
      ContainerStatus status = getContainerStatusInternal(id, identifier);
      succeededRequests.add(status);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return GetContainerStatusesResponse.newInstance(succeededRequests,
    failedRequests);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:BaseContainerManagerTest.java   
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());
  }
项目:hadoop-2.6.0-cdh5.4.3    文件:NodeManager.java   
@Override
synchronized public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException {
  List<ContainerStatus> statuses = new ArrayList<ContainerStatus>();
  for (ContainerId containerId : request.getContainerIds()) {
    List<Container> appContainers =
        containers.get(containerId.getApplicationAttemptId()
          .getApplicationId());
    Container container = null;
    for (Container c : appContainers) {
      if (c.getId().equals(containerId)) {
        container = c;
      }
    }
    if (container != null
        && containerStatusMap.get(container).getState() != null) {
      statuses.add(containerStatusMap.get(container));
    }
  }
  return GetContainerStatusesResponse.newInstance(statuses, null);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:NMClientImpl.java   
@Override
public ContainerStatus getContainerStatus(ContainerId containerId,
    NodeId nodeId) throws YarnException, IOException {

  ContainerManagementProtocolProxyData proxy = null;
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  try {
    proxy = cmProxy.getProxy(nodeId.toString(), containerId);
    GetContainerStatusesResponse response =
        proxy.getContainerManagementProtocol().getContainerStatuses(
            GetContainerStatusesRequest.newInstance(containerIds));
    if (response.getFailedRequests() != null
        && response.getFailedRequests().containsKey(containerId)) {
      Throwable t =
          response.getFailedRequests().get(containerId).deSerialize();
      parseAndThrowException(t);
    }
    ContainerStatus containerStatus = response.getContainerStatuses().get(0);
    return containerStatus;
  } finally {
    if (proxy != null) {
      cmProxy.mayBeCloseProxy(proxy);
    }
  }
}
项目:hadoop-plus    文件:ContainerManagerImpl.java   
/**
 * Get a list of container statuses running on this NodeManager
 */
@Override
public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException, IOException {

  List<ContainerStatus> succeededRequests = new ArrayList<ContainerStatus>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  for (ContainerId id : request.getContainerIds()) {
    try {
      ContainerStatus status = getContainerStatusInternal(id, identifier);
      succeededRequests.add(status);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return GetContainerStatusesResponse.newInstance(succeededRequests,
    failedRequests);
}
项目:hadoop-plus    文件:BaseContainerManagerTest.java   
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());
  }
项目:hadoop-plus    文件:NodeManager.java   
@Override
synchronized public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException {
  List<ContainerStatus> statuses = new ArrayList<ContainerStatus>();
  for (ContainerId containerId : request.getContainerIds()) {
    List<Container> appContainers =
        containers.get(containerId.getApplicationAttemptId()
          .getApplicationId());
    Container container = null;
    for (Container c : appContainers) {
      if (c.getId().equals(containerId)) {
        container = c;
      }
    }
    if (container != null
        && containerStatusMap.get(container).getState() != null) {
      statuses.add(containerStatusMap.get(container));
    }
  }
  return GetContainerStatusesResponse.newInstance(statuses, null);
}
项目:hadoop-plus    文件:NMClientImpl.java   
@Override
public ContainerStatus getContainerStatus(ContainerId containerId,
    NodeId nodeId) throws YarnException, IOException {

  ContainerManagementProtocolProxyData proxy = null;
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  try {
    proxy = cmProxy.getProxy(nodeId.toString(), containerId);
    GetContainerStatusesResponse response =
        proxy.getContainerManagementProtocol().getContainerStatuses(
            GetContainerStatusesRequest.newInstance(containerIds));
    if (response.getFailedRequests() != null
        && response.getFailedRequests().containsKey(containerId)) {
      Throwable t =
          response.getFailedRequests().get(containerId).deSerialize();
      parseAndThrowException(t);
    }
    ContainerStatus containerStatus = response.getContainerStatuses().get(0);
    return containerStatus;
  } finally {
    if (proxy != null) {
      cmProxy.mayBeCloseProxy(proxy);
    }
  }
}
项目:hops    文件:ContainerManagerImpl.java   
/**
 * Get a list of container statuses running on this NodeManager
 */
@Override
public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException, IOException {

  List<ContainerStatus> succeededRequests = new ArrayList<ContainerStatus>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  if (identifier == null) {
    throw RPCUtil.getRemoteException(INVALID_NMTOKEN_MSG);
  }
  for (ContainerId id : request.getContainerIds()) {
    try {
      ContainerStatus status = getContainerStatusInternal(id, identifier);
      succeededRequests.add(status);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return GetContainerStatusesResponse.newInstance(succeededRequests,
    failedRequests);
}
项目:hops    文件:BaseContainerManagerTest.java   
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());
  }
项目:hops    文件:TestContainerManagerRecovery.java   
private ContainerStatus getContainerStatus(
    Context context, final ContainerManagerImpl cm, ContainerId cid)
    throws  Exception {
  UserGroupInformation user = UserGroupInformation.createRemoteUser(
      cid.getApplicationAttemptId().toString());
  NMTokenIdentifier nmToken = new NMTokenIdentifier(
      cid.getApplicationAttemptId(), context.getNodeId(),
      user.getShortUserName(),
      context.getNMTokenSecretManager().getCurrentKey().getKeyId());
  user.addTokenIdentifier(nmToken);
  List<ContainerId> containerIds = new ArrayList<>();
  containerIds.add(cid);
  final GetContainerStatusesRequest gcsRequest =
      GetContainerStatusesRequest.newInstance(containerIds);
  return user.doAs(
      new PrivilegedExceptionAction<ContainerStatus>() {
        @Override
        public ContainerStatus run() throws Exception {
          return cm.getContainerStatuses(gcsRequest)
              .getContainerStatuses().get(0);
        }
      });
}
项目:hops    文件:NodeManager.java   
@Override
synchronized public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException {
  List<ContainerStatus> statuses = new ArrayList<ContainerStatus>();
  for (ContainerId containerId : request.getContainerIds()) {
    List<Container> appContainers =
        containers.get(containerId.getApplicationAttemptId()
          .getApplicationId());
    Container container = null;
    for (Container c : appContainers) {
      if (c.getId().equals(containerId)) {
        container = c;
      }
    }
    if (container != null
        && containerStatusMap.get(container).getState() != null) {
      statuses.add(containerStatusMap.get(container));
    }
  }
  return GetContainerStatusesResponse.newInstance(statuses, null);
}
项目:hops    文件:NMClientImpl.java   
@Override
public ContainerStatus getContainerStatus(ContainerId containerId,
    NodeId nodeId) throws YarnException, IOException {

  ContainerManagementProtocolProxyData proxy = null;
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  try {
    proxy = cmProxy.getProxy(nodeId.toString(), containerId);
    GetContainerStatusesResponse response =
        proxy.getContainerManagementProtocol().getContainerStatuses(
            GetContainerStatusesRequest.newInstance(containerIds));
    if (response.getFailedRequests() != null
        && response.getFailedRequests().containsKey(containerId)) {
      Throwable t =
          response.getFailedRequests().get(containerId).deSerialize();
      parseAndThrowException(t);
    }
    ContainerStatus containerStatus = response.getContainerStatuses().get(0);
    return containerStatus;
  } finally {
    if (proxy != null) {
      cmProxy.mayBeCloseProxy(proxy);
    }
  }
}
项目:hadoop-TCP    文件:ContainerManagerImpl.java   
/**
 * Get a list of container statuses running on this NodeManager
 */
@Override
public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException, IOException {

  List<ContainerStatus> succeededRequests = new ArrayList<ContainerStatus>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  for (ContainerId id : request.getContainerIds()) {
    try {
      ContainerStatus status = getContainerStatusInternal(id, identifier);
      succeededRequests.add(status);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return GetContainerStatusesResponse.newInstance(succeededRequests,
    failedRequests);
}
项目:hadoop-TCP    文件:BaseContainerManagerTest.java   
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());
  }
项目:hadoop-TCP    文件:NodeManager.java   
@Override
synchronized public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException {
  List<ContainerStatus> statuses = new ArrayList<ContainerStatus>();
  for (ContainerId containerId : request.getContainerIds()) {
    List<Container> appContainers =
        containers.get(containerId.getApplicationAttemptId()
          .getApplicationId());
    Container container = null;
    for (Container c : appContainers) {
      if (c.getId().equals(containerId)) {
        container = c;
      }
    }
    if (container != null
        && containerStatusMap.get(container).getState() != null) {
      statuses.add(containerStatusMap.get(container));
    }
  }
  return GetContainerStatusesResponse.newInstance(statuses, null);
}
项目:hadoop-TCP    文件:NMClientImpl.java   
@Override
public ContainerStatus getContainerStatus(ContainerId containerId,
    NodeId nodeId) throws YarnException, IOException {

  ContainerManagementProtocolProxyData proxy = null;
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  try {
    proxy = cmProxy.getProxy(nodeId.toString(), containerId);
    GetContainerStatusesResponse response =
        proxy.getContainerManagementProtocol().getContainerStatuses(
            GetContainerStatusesRequest.newInstance(containerIds));
    if (response.getFailedRequests() != null
        && response.getFailedRequests().containsKey(containerId)) {
      Throwable t =
          response.getFailedRequests().get(containerId).deSerialize();
      parseAndThrowException(t);
    }
    ContainerStatus containerStatus = response.getContainerStatuses().get(0);
    return containerStatus;
  } finally {
    if (proxy != null) {
      cmProxy.mayBeCloseProxy(proxy);
    }
  }
}
项目:hardfs    文件:ContainerManagerImpl.java   
/**
 * Get a list of container statuses running on this NodeManager
 */
@Override
public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException, IOException {

  List<ContainerStatus> succeededRequests = new ArrayList<ContainerStatus>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  for (ContainerId id : request.getContainerIds()) {
    try {
      ContainerStatus status = getContainerStatusInternal(id, identifier);
      succeededRequests.add(status);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return GetContainerStatusesResponse.newInstance(succeededRequests,
    failedRequests);
}
项目:hardfs    文件:BaseContainerManagerTest.java   
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());
  }
项目:hardfs    文件:NodeManager.java   
@Override
synchronized public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException {
  List<ContainerStatus> statuses = new ArrayList<ContainerStatus>();
  for (ContainerId containerId : request.getContainerIds()) {
    List<Container> appContainers =
        containers.get(containerId.getApplicationAttemptId()
          .getApplicationId());
    Container container = null;
    for (Container c : appContainers) {
      if (c.getId().equals(containerId)) {
        container = c;
      }
    }
    if (container != null
        && containerStatusMap.get(container).getState() != null) {
      statuses.add(containerStatusMap.get(container));
    }
  }
  return GetContainerStatusesResponse.newInstance(statuses, null);
}
项目:hardfs    文件:NMClientImpl.java   
@Override
public ContainerStatus getContainerStatus(ContainerId containerId,
    NodeId nodeId) throws YarnException, IOException {

  ContainerManagementProtocolProxyData proxy = null;
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  try {
    proxy = cmProxy.getProxy(nodeId.toString(), containerId);
    GetContainerStatusesResponse response =
        proxy.getContainerManagementProtocol().getContainerStatuses(
            GetContainerStatusesRequest.newInstance(containerIds));
    if (response.getFailedRequests() != null
        && response.getFailedRequests().containsKey(containerId)) {
      Throwable t =
          response.getFailedRequests().get(containerId).deSerialize();
      parseAndThrowException(t);
    }
    ContainerStatus containerStatus = response.getContainerStatuses().get(0);
    return containerStatus;
  } finally {
    if (proxy != null) {
      cmProxy.mayBeCloseProxy(proxy);
    }
  }
}
项目:hadoop-on-lustre2    文件:ContainerManagerImpl.java   
/**
 * Get a list of container statuses running on this NodeManager
 */
@Override
public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException, IOException {

  List<ContainerStatus> succeededRequests = new ArrayList<ContainerStatus>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  for (ContainerId id : request.getContainerIds()) {
    try {
      ContainerStatus status = getContainerStatusInternal(id, identifier);
      succeededRequests.add(status);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return GetContainerStatusesResponse.newInstance(succeededRequests,
    failedRequests);
}
项目:hadoop-on-lustre2    文件:BaseContainerManagerTest.java   
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());
  }
项目:hadoop-on-lustre2    文件:NodeManager.java   
@Override
synchronized public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException {
  List<ContainerStatus> statuses = new ArrayList<ContainerStatus>();
  for (ContainerId containerId : request.getContainerIds()) {
    List<Container> appContainers =
        containers.get(containerId.getApplicationAttemptId()
          .getApplicationId());
    Container container = null;
    for (Container c : appContainers) {
      if (c.getId().equals(containerId)) {
        container = c;
      }
    }
    if (container != null
        && containerStatusMap.get(container).getState() != null) {
      statuses.add(containerStatusMap.get(container));
    }
  }
  return GetContainerStatusesResponse.newInstance(statuses, null);
}
项目:hadoop-on-lustre2    文件:NMClientImpl.java   
@Override
public ContainerStatus getContainerStatus(ContainerId containerId,
    NodeId nodeId) throws YarnException, IOException {

  ContainerManagementProtocolProxyData proxy = null;
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  try {
    proxy = cmProxy.getProxy(nodeId.toString(), containerId);
    GetContainerStatusesResponse response =
        proxy.getContainerManagementProtocol().getContainerStatuses(
            GetContainerStatusesRequest.newInstance(containerIds));
    if (response.getFailedRequests() != null
        && response.getFailedRequests().containsKey(containerId)) {
      Throwable t =
          response.getFailedRequests().get(containerId).deSerialize();
      parseAndThrowException(t);
    }
    ContainerStatus containerStatus = response.getContainerStatuses().get(0);
    return containerStatus;
  } finally {
    if (proxy != null) {
      cmProxy.mayBeCloseProxy(proxy);
    }
  }
}
项目:hadoop    文件:ContainerManagementProtocolPBClientImpl.java   
@Override
public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException, IOException {
  GetContainerStatusesRequestProto requestProto =
      ((GetContainerStatusesRequestPBImpl) request).getProto();
  try {
    return new GetContainerStatusesResponsePBImpl(proxy.getContainerStatuses(
      null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hadoop    文件:TestRPC.java   
@Override
public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request)
throws YarnException {
  GetContainerStatusesResponse response = 
      recordFactory.newRecordInstance(GetContainerStatusesResponse.class);
  response.setContainerStatuses(statuses);
  return response;
}