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

项目:hadoop    文件:TestContainerManagerSecurity.java   
private void stopContainer(YarnRPC rpc, Token nmToken,
    List<ContainerId> containerId, ApplicationAttemptId appAttemptId,
    NodeId nodeId) throws Exception {
  StopContainersRequest request =
      StopContainersRequest.newInstance(containerId);
  ContainerManagementProtocol proxy = null;
  try {
    proxy =
        getContainerManagementProtocolProxy(rpc, nmToken, nodeId,
            appAttemptId.toString());
    StopContainersResponse response = proxy.stopContainers(request);
    if (response.getFailedRequests() != null &&
        response.getFailedRequests().containsKey(containerId)) {
      parseAndThrowException(response.getFailedRequests().get(containerId)
          .deSerialize());
    }
  } catch (Exception e) {
    if (proxy != null) {
      rpc.stopProxy(proxy, conf);
    }
  }
}
项目:hadoop    文件:ContainerManagerImpl.java   
/**
 * Stop a list of containers running on this NodeManager.
 */
@Override
public StopContainersResponse stopContainers(StopContainersRequest requests)
    throws YarnException, IOException {

  List<ContainerId> succeededRequests = new ArrayList<ContainerId>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  for (ContainerId id : requests.getContainerIds()) {
    try {
      stopContainerInternal(identifier, id);
      succeededRequests.add(id);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return StopContainersResponse
    .newInstance(succeededRequests, failedRequests);
}
项目:hadoop    文件:Application.java   
public synchronized void finishTask(Task task) throws IOException,
    YarnException {
  Set<Task> tasks = this.tasks.get(task.getPriority());
  if (!tasks.remove(task)) {
    throw new IllegalStateException(
        "Finishing unknown task " + task.getTaskId() + 
        " from application " + applicationId);
  }

  NodeManager nodeManager = task.getNodeManager();
  ContainerId containerId = task.getContainerId();
  task.stop();
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  StopContainersRequest stopRequest =
      StopContainersRequest.newInstance(containerIds);
  nodeManager.stopContainers(stopRequest);

  Resources.subtractFrom(used, requestSpec.get(task.getPriority()));

  LOG.info("Finished task " + task.getTaskId() + 
      " of application " + applicationId + 
      " on node " + nodeManager.getHostName() + 
      ", currently using " + used + " resources");
}
项目:hadoop    文件:NMClientImpl.java   
private void stopContainerInternal(ContainerId containerId, NodeId nodeId)
    throws IOException, YarnException {
  ContainerManagementProtocolProxyData proxy = null;
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  try {
    proxy = cmProxy.getProxy(nodeId.toString(), containerId);
    StopContainersResponse response =
        proxy.getContainerManagementProtocol().stopContainers(
          StopContainersRequest.newInstance(containerIds));
    if (response.getFailedRequests() != null
        && response.getFailedRequests().containsKey(containerId)) {
      Throwable t = response.getFailedRequests().get(containerId)
        .deSerialize();
      parseAndThrowException(t);
    }
  } finally {
    if (proxy != null) {
      cmProxy.mayBeCloseProxy(proxy);
    }
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestContainerManagerSecurity.java   
private void stopContainer(YarnRPC rpc, Token nmToken,
    List<ContainerId> containerId, ApplicationAttemptId appAttemptId,
    NodeId nodeId) throws Exception {
  StopContainersRequest request =
      StopContainersRequest.newInstance(containerId);
  ContainerManagementProtocol proxy = null;
  try {
    proxy =
        getContainerManagementProtocolProxy(rpc, nmToken, nodeId,
            appAttemptId.toString());
    StopContainersResponse response = proxy.stopContainers(request);
    if (response.getFailedRequests() != null &&
        response.getFailedRequests().containsKey(containerId)) {
      parseAndThrowException(response.getFailedRequests().get(containerId)
          .deSerialize());
    }
  } catch (Exception e) {
    if (proxy != null) {
      rpc.stopProxy(proxy, conf);
    }
  }
}
项目:aliyun-oss-hadoop-fs    文件:ContainerManagerImpl.java   
/**
 * Stop a list of containers running on this NodeManager.
 */
@Override
public StopContainersResponse stopContainers(StopContainersRequest requests)
    throws YarnException, IOException {

  List<ContainerId> succeededRequests = new ArrayList<ContainerId>();
  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 : requests.getContainerIds()) {
    try {
      stopContainerInternal(identifier, id);
      succeededRequests.add(id);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return StopContainersResponse
    .newInstance(succeededRequests, failedRequests);
}
项目:aliyun-oss-hadoop-fs    文件:Application.java   
public synchronized void finishTask(Task task) throws IOException,
    YarnException {
  Set<Task> tasks = this.tasks.get(task.getPriority());
  if (!tasks.remove(task)) {
    throw new IllegalStateException(
        "Finishing unknown task " + task.getTaskId() + 
        " from application " + applicationId);
  }

  NodeManager nodeManager = task.getNodeManager();
  ContainerId containerId = task.getContainerId();
  task.stop();
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  StopContainersRequest stopRequest =
      StopContainersRequest.newInstance(containerIds);
  nodeManager.stopContainers(stopRequest);

  Resources.subtractFrom(used, requestSpec.get(task.getPriority()));

  LOG.info("Finished task " + task.getTaskId() + 
      " of application " + applicationId + 
      " on node " + nodeManager.getHostName() + 
      ", currently using " + used + " resources");
}
项目:aliyun-oss-hadoop-fs    文件:NMClientImpl.java   
private void stopContainerInternal(ContainerId containerId, NodeId nodeId)
    throws IOException, YarnException {
  ContainerManagementProtocolProxyData proxy = null;
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  try {
    proxy = cmProxy.getProxy(nodeId.toString(), containerId);
    StopContainersResponse response =
        proxy.getContainerManagementProtocol().stopContainers(
          StopContainersRequest.newInstance(containerIds));
    if (response.getFailedRequests() != null
        && response.getFailedRequests().containsKey(containerId)) {
      Throwable t = response.getFailedRequests().get(containerId)
        .deSerialize();
      parseAndThrowException(t);
    }
  } finally {
    if (proxy != null) {
      cmProxy.mayBeCloseProxy(proxy);
    }
  }
}
项目:big-c    文件:TestContainerManagerSecurity.java   
private void stopContainer(YarnRPC rpc, Token nmToken,
    List<ContainerId> containerId, ApplicationAttemptId appAttemptId,
    NodeId nodeId) throws Exception {
  StopContainersRequest request =
      StopContainersRequest.newInstance(containerId);
  ContainerManagementProtocol proxy = null;
  try {
    proxy =
        getContainerManagementProtocolProxy(rpc, nmToken, nodeId,
            appAttemptId.toString());
    StopContainersResponse response = proxy.stopContainers(request);
    if (response.getFailedRequests() != null &&
        response.getFailedRequests().containsKey(containerId)) {
      parseAndThrowException(response.getFailedRequests().get(containerId)
          .deSerialize());
    }
  } catch (Exception e) {
    if (proxy != null) {
      rpc.stopProxy(proxy, conf);
    }
  }
}
项目:big-c    文件:ContainerManagerImpl.java   
/**
 * Stop a list of containers running on this NodeManager.
 */
@Override
public StopContainersResponse stopContainers(StopContainersRequest requests)
    throws YarnException, IOException {

  List<ContainerId> succeededRequests = new ArrayList<ContainerId>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  for (ContainerId id : requests.getContainerIds()) {
    try {
      stopContainerInternal(identifier, id);
      succeededRequests.add(id);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return StopContainersResponse
    .newInstance(succeededRequests, failedRequests);
}
项目:big-c    文件:Application.java   
public synchronized void finishTask(Task task) throws IOException,
    YarnException {
  Set<Task> tasks = this.tasks.get(task.getPriority());
  if (!tasks.remove(task)) {
    throw new IllegalStateException(
        "Finishing unknown task " + task.getTaskId() + 
        " from application " + applicationId);
  }

  NodeManager nodeManager = task.getNodeManager();
  ContainerId containerId = task.getContainerId();
  task.stop();
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  StopContainersRequest stopRequest =
      StopContainersRequest.newInstance(containerIds);
  nodeManager.stopContainers(stopRequest);

  Resources.subtractFrom(used, requestSpec.get(task.getPriority()));

  LOG.info("Finished task " + task.getTaskId() + 
      " of application " + applicationId + 
      " on node " + nodeManager.getHostName() + 
      ", currently using " + used + " resources");
}
项目:big-c    文件:NMClientImpl.java   
private void stopContainerInternal(ContainerId containerId, NodeId nodeId)
    throws IOException, YarnException {
  ContainerManagementProtocolProxyData proxy = null;
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  try {
    proxy = cmProxy.getProxy(nodeId.toString(), containerId);
    StopContainersResponse response =
        proxy.getContainerManagementProtocol().stopContainers(
          StopContainersRequest.newInstance(containerIds));
    if (response.getFailedRequests() != null
        && response.getFailedRequests().containsKey(containerId)) {
      Throwable t = response.getFailedRequests().get(containerId)
        .deSerialize();
      parseAndThrowException(t);
    }
  } finally {
    if (proxy != null) {
      cmProxy.mayBeCloseProxy(proxy);
    }
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestContainerManagerSecurity.java   
private void stopContainer(YarnRPC rpc, Token nmToken,
    List<ContainerId> containerId, ApplicationAttemptId appAttemptId,
    NodeId nodeId) throws Exception {
  StopContainersRequest request =
      StopContainersRequest.newInstance(containerId);
  ContainerManagementProtocol proxy = null;
  try {
    proxy =
        getContainerManagementProtocolProxy(rpc, nmToken, nodeId,
            appAttemptId.toString());
    StopContainersResponse response = proxy.stopContainers(request);
    if (response.getFailedRequests() != null &&
        response.getFailedRequests().containsKey(containerId)) {
      parseAndThrowException(response.getFailedRequests().get(containerId)
          .deSerialize());
    }
  } catch (Exception e) {
    if (proxy != null) {
      rpc.stopProxy(proxy, conf);
    }
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ContainerManagerImpl.java   
/**
 * Stop a list of containers running on this NodeManager.
 */
@Override
public StopContainersResponse stopContainers(StopContainersRequest requests)
    throws YarnException, IOException {

  List<ContainerId> succeededRequests = new ArrayList<ContainerId>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  for (ContainerId id : requests.getContainerIds()) {
    try {
      stopContainerInternal(identifier, id);
      succeededRequests.add(id);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return StopContainersResponse
    .newInstance(succeededRequests, failedRequests);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:Application.java   
public synchronized void finishTask(Task task) throws IOException,
    YarnException {
  Set<Task> tasks = this.tasks.get(task.getPriority());
  if (!tasks.remove(task)) {
    throw new IllegalStateException(
        "Finishing unknown task " + task.getTaskId() + 
        " from application " + applicationId);
  }

  NodeManager nodeManager = task.getNodeManager();
  ContainerId containerId = task.getContainerId();
  task.stop();
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  StopContainersRequest stopRequest =
      StopContainersRequest.newInstance(containerIds);
  nodeManager.stopContainers(stopRequest);

  Resources.subtractFrom(used, requestSpec.get(task.getPriority()));

  LOG.info("Finished task " + task.getTaskId() + 
      " of application " + applicationId + 
      " on node " + nodeManager.getHostName() + 
      ", currently using " + used + " resources");
}
项目:hadoop-2.6.0-cdh5.4.3    文件:NMClientImpl.java   
private void stopContainerInternal(ContainerId containerId, NodeId nodeId)
    throws IOException, YarnException {
  ContainerManagementProtocolProxyData proxy = null;
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  try {
    proxy = cmProxy.getProxy(nodeId.toString(), containerId);
    StopContainersResponse response =
        proxy.getContainerManagementProtocol().stopContainers(
          StopContainersRequest.newInstance(containerIds));
    if (response.getFailedRequests() != null
        && response.getFailedRequests().containsKey(containerId)) {
      Throwable t = response.getFailedRequests().get(containerId)
        .deSerialize();
      parseAndThrowException(t);
    }
  } finally {
    if (proxy != null) {
      cmProxy.mayBeCloseProxy(proxy);
    }
  }
}
项目:hadoop-plus    文件:ContainerManagerImpl.java   
/**
 * Stop a list of containers running on this NodeManager.
 */
@Override
public StopContainersResponse stopContainers(StopContainersRequest requests)
    throws YarnException, IOException {

  List<ContainerId> succeededRequests = new ArrayList<ContainerId>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  for (ContainerId id : requests.getContainerIds()) {
    try {
      stopContainerInternal(identifier, id);
      succeededRequests.add(id);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return StopContainersResponse
    .newInstance(succeededRequests, failedRequests);
}
项目:hadoop-plus    文件:Application.java   
public synchronized void finishTask(Task task) throws IOException,
    YarnException {
  Set<Task> tasks = this.tasks.get(task.getPriority());
  if (!tasks.remove(task)) {
    throw new IllegalStateException(
        "Finishing unknown task " + task.getTaskId() + 
        " from application " + applicationId);
  }

  NodeManager nodeManager = task.getNodeManager();
  ContainerId containerId = task.getContainerId();
  task.stop();
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  StopContainersRequest stopRequest =
      StopContainersRequest.newInstance(containerIds);
  nodeManager.stopContainers(stopRequest);

  Resources.subtractFrom(used, requestSpec.get(task.getPriority()));

  LOG.info("Finished task " + task.getTaskId() + 
      " of application " + applicationId + 
      " on node " + nodeManager.getHostName() + 
      ", currently using " + used + " resources");
}
项目:hadoop-plus    文件:NMClientImpl.java   
private void stopContainerInternal(ContainerId containerId, NodeId nodeId)
    throws IOException, YarnException {
  ContainerManagementProtocolProxyData proxy = null;
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  try {
    proxy = cmProxy.getProxy(nodeId.toString(), containerId);
    StopContainersResponse response =
        proxy.getContainerManagementProtocol().stopContainers(
          StopContainersRequest.newInstance(containerIds));
    if (response.getFailedRequests() != null
        && response.getFailedRequests().containsKey(containerId)) {
      Throwable t = response.getFailedRequests().get(containerId)
        .deSerialize();
      parseAndThrowException(t);
    }
  } finally {
    if (proxy != null) {
      cmProxy.mayBeCloseProxy(proxy);
    }
  }
}
项目:hops    文件:TestContainerManagerSecurity.java   
private void stopContainer(YarnRPC rpc, Token nmToken,
    List<ContainerId> containerId, ApplicationAttemptId appAttemptId,
    NodeId nodeId) throws Exception {
  StopContainersRequest request =
      StopContainersRequest.newInstance(containerId);
  ContainerManagementProtocol proxy = null;
  try {
    proxy =
        getContainerManagementProtocolProxy(rpc, nmToken, nodeId,
            appAttemptId.toString());
    StopContainersResponse response = proxy.stopContainers(request);
    if (response.getFailedRequests() != null &&
        response.getFailedRequests().containsKey(containerId)) {
      parseAndThrowException(response.getFailedRequests().get(containerId)
          .deSerialize());
    }
  } catch (Exception e) {
    if (proxy != null) {
      rpc.stopProxy(proxy, conf);
    }
  }
}
项目:hops    文件:ContainerManagerImpl.java   
/**
 * Stop a list of containers running on this NodeManager.
 */
@Override
public StopContainersResponse stopContainers(StopContainersRequest requests)
    throws YarnException, IOException {

  List<ContainerId> succeededRequests = new ArrayList<ContainerId>();
  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 : requests.getContainerIds()) {
    try {
      stopContainerInternal(identifier, id);
      succeededRequests.add(id);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return StopContainersResponse
    .newInstance(succeededRequests, failedRequests);
}
项目:hops    文件:Application.java   
public synchronized void finishTask(Task task) throws IOException,
    YarnException {
  Set<Task> tasks = this.tasks.get(task.getPriority());
  if (!tasks.remove(task)) {
    throw new IllegalStateException(
        "Finishing unknown task " + task.getTaskId() + 
        " from application " + applicationId);
  }

  NodeManager nodeManager = task.getNodeManager();
  ContainerId containerId = task.getContainerId();
  task.stop();
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  StopContainersRequest stopRequest =
      StopContainersRequest.newInstance(containerIds);
  nodeManager.stopContainers(stopRequest);

  Resources.subtractFrom(used, requestSpec.get(task.getPriority()));

  LOG.info("Finished task " + task.getTaskId() + 
      " of application " + applicationId + 
      " on node " + nodeManager.getHostName() + 
      ", currently using " + used + " resources");
}
项目:hops    文件:NMClientImpl.java   
private void stopContainerInternal(ContainerId containerId, NodeId nodeId)
    throws IOException, YarnException {
  ContainerManagementProtocolProxyData proxy = null;
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  try {
    proxy = cmProxy.getProxy(nodeId.toString(), containerId);
    StopContainersResponse response =
        proxy.getContainerManagementProtocol().stopContainers(
          StopContainersRequest.newInstance(containerIds));
    if (response.getFailedRequests() != null
        && response.getFailedRequests().containsKey(containerId)) {
      Throwable t = response.getFailedRequests().get(containerId)
        .deSerialize();
      parseAndThrowException(t);
    }
  } finally {
    if (proxy != null) {
      cmProxy.mayBeCloseProxy(proxy);
    }
  }
}
项目:hadoop-TCP    文件:TestContainerManagerSecurity.java   
private void stopContainer(YarnRPC rpc, Token nmToken,
    List<ContainerId> containerId, ApplicationAttemptId appAttemptId,
    NodeId nodeId) throws Exception {
  StopContainersRequest request =
      StopContainersRequest.newInstance(containerId);
  ContainerManagementProtocol proxy = null;
  try {
    proxy =
        getContainerManagementProtocolProxy(rpc, nmToken, nodeId,
            appAttemptId.toString());
    StopContainersResponse response = proxy.stopContainers(request);
    if (response.getFailedRequests() != null &&
        response.getFailedRequests().containsKey(containerId)) {
      parseAndThrowException(response.getFailedRequests().get(containerId)
          .deSerialize());
    }
  } catch (Exception e) {
    if (proxy != null) {
      rpc.stopProxy(proxy, conf);
    }
  }
}
项目:hadoop-TCP    文件:ContainerManagerImpl.java   
/**
 * Stop a list of containers running on this NodeManager.
 */
@Override
public StopContainersResponse stopContainers(StopContainersRequest requests)
    throws YarnException, IOException {

  List<ContainerId> succeededRequests = new ArrayList<ContainerId>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  for (ContainerId id : requests.getContainerIds()) {
    try {
      stopContainerInternal(identifier, id);
      succeededRequests.add(id);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return StopContainersResponse
    .newInstance(succeededRequests, failedRequests);
}
项目:hadoop-TCP    文件:Application.java   
public synchronized void finishTask(Task task) throws IOException,
    YarnException {
  Set<Task> tasks = this.tasks.get(task.getPriority());
  if (!tasks.remove(task)) {
    throw new IllegalStateException(
        "Finishing unknown task " + task.getTaskId() + 
        " from application " + applicationId);
  }

  NodeManager nodeManager = task.getNodeManager();
  ContainerId containerId = task.getContainerId();
  task.stop();
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  StopContainersRequest stopRequest =
      StopContainersRequest.newInstance(containerIds);
  nodeManager.stopContainers(stopRequest);

  Resources.subtractFrom(used, requestSpec.get(task.getPriority()));

  LOG.info("Finished task " + task.getTaskId() + 
      " of application " + applicationId + 
      " on node " + nodeManager.getHostName() + 
      ", currently using " + used + " resources");
}
项目:hadoop-TCP    文件:NMClientImpl.java   
private void stopContainerInternal(ContainerId containerId, NodeId nodeId)
    throws IOException, YarnException {
  ContainerManagementProtocolProxyData proxy = null;
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  try {
    proxy = cmProxy.getProxy(nodeId.toString(), containerId);
    StopContainersResponse response =
        proxy.getContainerManagementProtocol().stopContainers(
          StopContainersRequest.newInstance(containerIds));
    if (response.getFailedRequests() != null
        && response.getFailedRequests().containsKey(containerId)) {
      Throwable t = response.getFailedRequests().get(containerId)
        .deSerialize();
      parseAndThrowException(t);
    }
  } finally {
    if (proxy != null) {
      cmProxy.mayBeCloseProxy(proxy);
    }
  }
}
项目:hardfs    文件:TestContainerManagerSecurity.java   
private void stopContainer(YarnRPC rpc, Token nmToken,
    List<ContainerId> containerId, ApplicationAttemptId appAttemptId,
    NodeId nodeId) throws Exception {
  StopContainersRequest request =
      StopContainersRequest.newInstance(containerId);
  ContainerManagementProtocol proxy = null;
  try {
    proxy =
        getContainerManagementProtocolProxy(rpc, nmToken, nodeId,
            appAttemptId.toString());
    StopContainersResponse response = proxy.stopContainers(request);
    if (response.getFailedRequests() != null &&
        response.getFailedRequests().containsKey(containerId)) {
      parseAndThrowException(response.getFailedRequests().get(containerId)
          .deSerialize());
    }
  } catch (Exception e) {
    if (proxy != null) {
      rpc.stopProxy(proxy, conf);
    }
  }
}
项目:hardfs    文件:ContainerManagerImpl.java   
/**
 * Stop a list of containers running on this NodeManager.
 */
@Override
public StopContainersResponse stopContainers(StopContainersRequest requests)
    throws YarnException, IOException {

  List<ContainerId> succeededRequests = new ArrayList<ContainerId>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  for (ContainerId id : requests.getContainerIds()) {
    try {
      stopContainerInternal(identifier, id);
      succeededRequests.add(id);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return StopContainersResponse
    .newInstance(succeededRequests, failedRequests);
}
项目:hardfs    文件:Application.java   
public synchronized void finishTask(Task task) throws IOException,
    YarnException {
  Set<Task> tasks = this.tasks.get(task.getPriority());
  if (!tasks.remove(task)) {
    throw new IllegalStateException(
        "Finishing unknown task " + task.getTaskId() + 
        " from application " + applicationId);
  }

  NodeManager nodeManager = task.getNodeManager();
  ContainerId containerId = task.getContainerId();
  task.stop();
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  StopContainersRequest stopRequest =
      StopContainersRequest.newInstance(containerIds);
  nodeManager.stopContainers(stopRequest);

  Resources.subtractFrom(used, requestSpec.get(task.getPriority()));

  LOG.info("Finished task " + task.getTaskId() + 
      " of application " + applicationId + 
      " on node " + nodeManager.getHostName() + 
      ", currently using " + used + " resources");
}
项目:hardfs    文件:NMClientImpl.java   
private void stopContainerInternal(ContainerId containerId, NodeId nodeId)
    throws IOException, YarnException {
  ContainerManagementProtocolProxyData proxy = null;
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  try {
    proxy = cmProxy.getProxy(nodeId.toString(), containerId);
    StopContainersResponse response =
        proxy.getContainerManagementProtocol().stopContainers(
          StopContainersRequest.newInstance(containerIds));
    if (response.getFailedRequests() != null
        && response.getFailedRequests().containsKey(containerId)) {
      Throwable t = response.getFailedRequests().get(containerId)
        .deSerialize();
      parseAndThrowException(t);
    }
  } finally {
    if (proxy != null) {
      cmProxy.mayBeCloseProxy(proxy);
    }
  }
}
项目:hadoop-on-lustre2    文件:TestContainerManagerSecurity.java   
private void stopContainer(YarnRPC rpc, Token nmToken,
    List<ContainerId> containerId, ApplicationAttemptId appAttemptId,
    NodeId nodeId) throws Exception {
  StopContainersRequest request =
      StopContainersRequest.newInstance(containerId);
  ContainerManagementProtocol proxy = null;
  try {
    proxy =
        getContainerManagementProtocolProxy(rpc, nmToken, nodeId,
            appAttemptId.toString());
    StopContainersResponse response = proxy.stopContainers(request);
    if (response.getFailedRequests() != null &&
        response.getFailedRequests().containsKey(containerId)) {
      parseAndThrowException(response.getFailedRequests().get(containerId)
          .deSerialize());
    }
  } catch (Exception e) {
    if (proxy != null) {
      rpc.stopProxy(proxy, conf);
    }
  }
}
项目:hadoop-on-lustre2    文件:ContainerManagerImpl.java   
/**
 * Stop a list of containers running on this NodeManager.
 */
@Override
public StopContainersResponse stopContainers(StopContainersRequest requests)
    throws YarnException, IOException {

  List<ContainerId> succeededRequests = new ArrayList<ContainerId>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  for (ContainerId id : requests.getContainerIds()) {
    try {
      stopContainerInternal(identifier, id);
      succeededRequests.add(id);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return StopContainersResponse
    .newInstance(succeededRequests, failedRequests);
}
项目:hadoop-on-lustre2    文件:Application.java   
public synchronized void finishTask(Task task) throws IOException,
    YarnException {
  Set<Task> tasks = this.tasks.get(task.getPriority());
  if (!tasks.remove(task)) {
    throw new IllegalStateException(
        "Finishing unknown task " + task.getTaskId() + 
        " from application " + applicationId);
  }

  NodeManager nodeManager = task.getNodeManager();
  ContainerId containerId = task.getContainerId();
  task.stop();
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  StopContainersRequest stopRequest =
      StopContainersRequest.newInstance(containerIds);
  nodeManager.stopContainers(stopRequest);

  Resources.subtractFrom(used, requestSpec.get(task.getPriority()));

  LOG.info("Finished task " + task.getTaskId() + 
      " of application " + applicationId + 
      " on node " + nodeManager.getHostName() + 
      ", currently using " + used + " resources");
}
项目:hadoop-on-lustre2    文件:NMClientImpl.java   
private void stopContainerInternal(ContainerId containerId, NodeId nodeId)
    throws IOException, YarnException {
  ContainerManagementProtocolProxyData proxy = null;
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  try {
    proxy = cmProxy.getProxy(nodeId.toString(), containerId);
    StopContainersResponse response =
        proxy.getContainerManagementProtocol().stopContainers(
          StopContainersRequest.newInstance(containerIds));
    if (response.getFailedRequests() != null
        && response.getFailedRequests().containsKey(containerId)) {
      Throwable t = response.getFailedRequests().get(containerId)
        .deSerialize();
      parseAndThrowException(t);
    }
  } finally {
    if (proxy != null) {
      cmProxy.mayBeCloseProxy(proxy);
    }
  }
}
项目:hadoop    文件:ContainerManagementProtocolPBClientImpl.java   
@Override
public StopContainersResponse stopContainers(StopContainersRequest requests)
    throws YarnException, IOException {
  StopContainersRequestProto requestProto =
      ((StopContainersRequestPBImpl) requests).getProto();
  try {
    return new StopContainersResponsePBImpl(proxy.stopContainers(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hadoop    文件:TestRPC.java   
@Override
public StopContainersResponse stopContainers(StopContainersRequest request) 
throws YarnException {
  Exception e = new Exception(EXCEPTION_MSG, 
      new Exception(EXCEPTION_CAUSE));
  throw new YarnException(e);
}
项目:hadoop    文件:TestContainerLaunchRPC.java   
@Override
public StopContainersResponse
    stopContainers(StopContainersRequest requests) throws YarnException,
        IOException {
  Exception e = new Exception("Dummy function", new Exception(
      "Dummy function cause"));
  throw new YarnException(e);
}
项目:hadoop    文件:AMLauncher.java   
private void cleanup() throws IOException, YarnException {
  connect();
  ContainerId containerId = masterContainer.getId();
  List<ContainerId> containerIds = new ArrayList<ContainerId>();
  containerIds.add(containerId);
  StopContainersRequest stopRequest =
      StopContainersRequest.newInstance(containerIds);
  StopContainersResponse response =
      containerMgrProxy.stopContainers(stopRequest);
  if (response.getFailedRequests() != null
      && response.getFailedRequests().containsKey(containerId)) {
    Throwable t = response.getFailedRequests().get(containerId).deSerialize();
    parseAndThrowException(t);
  }
}
项目:hadoop    文件:TestApplicationMasterLauncher.java   
@Override
public StopContainersResponse stopContainers(StopContainersRequest request)
    throws YarnException {
  LOG.info("Container cleaned up by MyContainerManager");
  cleanedup = true;
  return null;
}