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


Java StopContainersRequest.newInstance方法代码示例

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


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

示例1: stopContainer

import org.apache.hadoop.yarn.api.protocolrecords.StopContainersRequest; //导入方法依赖的package包/类
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);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestContainerManagerSecurity.java

示例2: finishTask

import org.apache.hadoop.yarn.api.protocolrecords.StopContainersRequest; //导入方法依赖的package包/类
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");
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:Application.java

示例3: cleanup

import org.apache.hadoop.yarn.api.protocolrecords.StopContainersRequest; //导入方法依赖的package包/类
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);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:AMLauncher.java

示例4: cleanup

import org.apache.hadoop.yarn.api.protocolrecords.StopContainersRequest; //导入方法依赖的package包/类
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);
  
  // The application is cleaned-up when completes successfully or killed
  // If the application failed more times than allowed, the cryptograhic
  // material is cleaned by RMAppImpl#AttemptFailedTransition
  if (conf.getBoolean(CommonConfigurationKeysPublic.IPC_SERVER_SSL_ENABLED,
      CommonConfigurationKeysPublic.IPC_SERVER_SSL_ENABLED_DEFAULT)) {
    // Remove the cryptographic material only if the application is
    // finished or killed
    RMApp app = rmContext.getRMApps().get(application.getAppAttemptId()
        .getApplicationId());
    if (appFinalStates.contains(app.getState())) {
      String user = rmContext.getRMApps().get(containerId
          .getApplicationAttemptId().getApplicationId()).getUser();
      try {
        rmContext.getCertificateLocalizationService().removeMaterial(user);
      } catch (InterruptedException | ExecutionException e) {
        throw new IOException(e);
      }
    }
  }
  
  if (response.getFailedRequests() != null
      && response.getFailedRequests().containsKey(containerId)) {
    Throwable t = response.getFailedRequests().get(containerId).deSerialize();
    parseAndThrowException(t);
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:37,代码来源:AMLauncher.java

示例5: kill

import org.apache.hadoop.yarn.api.protocolrecords.StopContainersRequest; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public synchronized void kill() {

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

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

      // kill the remote container if already launched
      List<ContainerId> ids = new ArrayList<ContainerId>();
      ids.add(this.containerID);
      StopContainersRequest request = StopContainersRequest.newInstance(ids);
      StopContainersResponse response =
          proxy.getContainerManagementProtocol().stopContainers(request);
      if (response.getFailedRequests() != null
          && response.getFailedRequests().containsKey(this.containerID)) {
        throw response.getFailedRequests().get(this.containerID)
          .deSerialize();
      }
    } catch (Throwable t) {
      // ignore the cleanup failure
      String message = "cleanup failed for container "
          + this.containerID + " : "
          + StringUtils.stringifyException(t);
      context.getEventHandler()
          .handle(
              new TaskAttemptDiagnosticsUpdateEvent(this.taskAttemptID,
                  message));
      LOG.warn(message);
    } finally {
      if (proxy != null) {
        cmProxy.mayBeCloseProxy(proxy);
      }
    }
    this.state = ContainerState.DONE;
  }
  // after killing, send killed event to task attempt
  context.getEventHandler().handle(
      new TaskAttemptEvent(this.taskAttemptID,
          TaskAttemptEventType.TA_CONTAINER_CLEANED));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:46,代码来源:ContainerLauncherImpl.java

示例6: kill

import org.apache.hadoop.yarn.api.protocolrecords.StopContainersRequest; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public synchronized void kill() {

  if(this.state == ContainerState.PREP) {
	LOG.info("final state for killed container"+"KILLED BEFORE LAUNCH");
    this.state = ContainerState.KILLED_BEFORE_LAUNCH;
  } else if (!isCompletelyDone()) {
    LOG.info("KILLING " + taskAttemptID);

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

      // kill the remote container if already launched
      List<ContainerId> ids = new ArrayList<ContainerId>();
      ids.add(this.containerID);
      StopContainersRequest request = StopContainersRequest.newInstance(ids);
      StopContainersResponse response =
          proxy.getContainerManagementProtocol().stopContainers(request);
      if (response.getFailedRequests() != null
          && response.getFailedRequests().containsKey(this.containerID)) {
        throw response.getFailedRequests().get(this.containerID)
          .deSerialize();
      }
    } catch (Throwable t) {
      // ignore the cleanup failure
      String message = "cleanup failed for container "
          + this.containerID + " : "
          + StringUtils.stringifyException(t);
      context.getEventHandler()
          .handle(
              new TaskAttemptDiagnosticsUpdateEvent(this.taskAttemptID,
                  message));
      LOG.warn(message);
    } finally {
      if (proxy != null) {
        cmProxy.mayBeCloseProxy(proxy);
      }
    }
    LOG.info("final state for killed container"+"DONE");
    this.state = ContainerState.DONE;
  }
  // after killing, send killed event to task attempt
  context.getEventHandler().handle(
      new TaskAttemptEvent(this.taskAttemptID,
          TaskAttemptEventType.TA_CONTAINER_CLEANED));
}
 
开发者ID:yncxcw,项目名称:FlexMap,代码行数:48,代码来源:ContainerLauncherImpl.java

示例7: testUnauthorizedRequests

import org.apache.hadoop.yarn.api.protocolrecords.StopContainersRequest; //导入方法依赖的package包/类
@Test
public void testUnauthorizedRequests() throws IOException, YarnException {
  containerManager.start();

  // Create a containerId that belongs to an unauthorized appId
  ContainerId cId = createContainerId(0, 1);

  // startContainers()
  ContainerLaunchContext containerLaunchContext =
      recordFactory.newRecordInstance(ContainerLaunchContext.class);
  StartContainerRequest scRequest =
      StartContainerRequest.newInstance(containerLaunchContext,
          createContainerToken(cId, DUMMY_RM_IDENTIFIER, context.getNodeId(),
              user, context.getContainerTokenSecretManager(), userFolder));
  List<StartContainerRequest> list = new ArrayList<>();
  list.add(scRequest);
  StartContainersRequest allRequests =
      StartContainersRequest.newInstance(list);
  StartContainersResponse startResponse =
      containerManager.startContainers(allRequests);

  Assert.assertFalse("Should not be authorized to start container",
      startResponse.getSuccessfullyStartedContainers().contains(cId));
  Assert.assertTrue("Start container request should fail",
      startResponse.getFailedRequests().containsKey(cId));

  // Insert the containerId into context, make it as if it is running
  ContainerTokenIdentifier containerTokenIdentifier =
      BuilderUtils.newContainerTokenIdentifier(scRequest.getContainerToken());
  Container container = new ContainerImpl(conf, null, containerLaunchContext,
      null, metrics, containerTokenIdentifier, context);
  context.getContainers().put(cId, container);

  // stopContainers()
  List<ContainerId> containerIds = new ArrayList<>();
  containerIds.add(cId);
  StopContainersRequest stopRequest =
      StopContainersRequest.newInstance(containerIds);
  StopContainersResponse stopResponse =
      containerManager.stopContainers(stopRequest);

  Assert.assertFalse("Should not be authorized to stop container",
      stopResponse.getSuccessfullyStoppedContainers().contains(cId));
  Assert.assertTrue("Stop container request should fail",
      stopResponse.getFailedRequests().containsKey(cId));

  // getContainerStatuses()
  containerIds = new ArrayList<>();
  containerIds.add(cId);
  GetContainerStatusesRequest request =
      GetContainerStatusesRequest.newInstance(containerIds);
  GetContainerStatusesResponse response =
      containerManager.getContainerStatuses(request);

  Assert.assertEquals("Should not be authorized to get container status",
      response.getContainerStatuses().size(), 0);
  Assert.assertTrue("Get status request should fail",
      response.getFailedRequests().containsKey(cId));
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:60,代码来源:TestContainerManager.java


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