當前位置: 首頁>>代碼示例>>Java>>正文


Java StopContainerRequest類代碼示例

本文整理匯總了Java中org.apache.hadoop.yarn.api.protocolrecords.StopContainerRequest的典型用法代碼示例。如果您正苦於以下問題:Java StopContainerRequest類的具體用法?Java StopContainerRequest怎麽用?Java StopContainerRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


StopContainerRequest類屬於org.apache.hadoop.yarn.api.protocolrecords包,在下文中一共展示了StopContainerRequest類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: cancel

import org.apache.hadoop.yarn.api.protocolrecords.StopContainerRequest; //導入依賴的package包/類
@Override
public void cancel() {
  LOG.info("Request to stop container {}.", container.getId());
  StopContainerRequest stopRequest = Records.newRecord(StopContainerRequest.class);
  stopRequest.setContainerId(container.getId());
  try {
    manager.stopContainer(stopRequest);
    while (true) {
      GetContainerStatusRequest statusRequest = Records.newRecord(GetContainerStatusRequest.class);
      statusRequest.setContainerId(container.getId());
      GetContainerStatusResponse statusResponse = manager.getContainerStatus(statusRequest);
      LOG.trace("Container status: {} {}", statusResponse.getStatus(), statusResponse.getStatus().getDiagnostics());

      if (statusResponse.getStatus().getState() == ContainerState.COMPLETE) {
        break;
      }
      Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS);
    }
    LOG.info("Container {} stopped.", container.getId());
  } catch (YarnRemoteException e) {
    LOG.error("Fail to stop container {}", container.getId(), e);
    throw Throwables.propagate(e);
  }
}
 
開發者ID:apache,項目名稱:twill,代碼行數:25,代碼來源:Hadoop20YarnNMClient.java

示例2: cancel

import org.apache.hadoop.yarn.api.protocolrecords.StopContainerRequest; //導入依賴的package包/類
@Override
public void cancel() {
  LOG.info("Request to stop container {}.", container.getId());
  StopContainerRequest stopRequest = Records.newRecord(StopContainerRequest.class);
  stopRequest.setContainerId(container.getId());
  try {
    manager.stopContainer(stopRequest);
    boolean completed = false;
    while (!completed) {
      GetContainerStatusRequest statusRequest = Records.newRecord(GetContainerStatusRequest.class);
      statusRequest.setContainerId(container.getId());
      GetContainerStatusResponse statusResponse = manager.getContainerStatus(statusRequest);
      LOG.info("Container status: {} {}", statusResponse.getStatus(), statusResponse.getStatus().getDiagnostics());

      completed = (statusResponse.getStatus().getState() == ContainerState.COMPLETE);
    }
    LOG.info("Container {} stopped.", container.getId());
  } catch (YarnRemoteException e) {
    LOG.error("Fail to stop container {}", container.getId(), e);
    throw Throwables.propagate(e);
  }
}
 
開發者ID:chtyim,項目名稱:incubator-twill,代碼行數:23,代碼來源:Hadoop20YarnNMClient.java

示例3: stopContainer

import org.apache.hadoop.yarn.api.protocolrecords.StopContainerRequest; //導入依賴的package包/類
@Override
  public synchronized void stopContainer() {

    if(isCompletelyDone()) {
      return;
    }
    if(this.state == ContainerState.PREP) {
      this.state = ContainerState.KILLED_BEFORE_LAUNCH;
    } else {
      LOG.info("KILLING " + containerID);

      ContainerManager proxy = null;
      try {
        proxy = getCMProxy(this.containerID, this.containerMgrAddress,
            this.containerToken);

        // kill the remote container if already launched
        StopContainerRequest stopRequest = Records
            .newRecord(StopContainerRequest.class);
        stopRequest.setContainerId(this.containerID);
        proxy.stopContainer(stopRequest);
        // If stopContainer returns without an error, assuming the stop made
        // it over to the NodeManager.
//          context.getEventHandler().handle(
//              new AMContainerEvent(containerID, AMContainerEventType.C_NM_STOP_SENT));
        context.getResourceAllocator().removeContainer(containerID);
      } catch (Throwable t) {

        // ignore the cleanup failure
        String message = "cleanup failed for container "
            + this.containerID + " : "
            + StringUtils.stringifyException(t);
//          context.getEventHandler().handle(
//              new AMContainerEventStopFailed(containerID, message));
        LOG.warn(message);
        this.state = ContainerState.DONE;
        return;
      } finally {
        if (proxy != null) {
          yarnRPC.stopProxy(proxy, conf);
        }
      }
      this.state = ContainerState.DONE;
    }
  }
 
開發者ID:gruter,項目名稱:tajo-cdh,代碼行數:46,代碼來源:YarnContainerProxy.java


注:本文中的org.apache.hadoop.yarn.api.protocolrecords.StopContainerRequest類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。