org.apache.hadoop.yarn.api.records.Container.getVersion()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(86)

本文整理了Java中org.apache.hadoop.yarn.api.records.Container.getVersion()方法的一些代码示例,展示了Container.getVersion()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Container.getVersion()方法的具体详情如下:
包路径:org.apache.hadoop.yarn.api.records.Container
类名称:Container
方法名:getVersion

Container.getVersion介绍

[英]Get the version of this container. The version will be incremented when a container is updated.
[中]获取此容器的版本。更新容器时,版本将增加。

代码示例

代码示例来源:origin: io.hops/hadoop-yarn-client

private List<UpdateContainerRequest> createUpdateList() {
 List<UpdateContainerRequest> updateList = new ArrayList<>();
 for (Map.Entry<ContainerId, SimpleEntry<Container, Resource>> entry :
   change.entrySet()) {
  Resource targetCapability = entry.getValue().getValue();
  Resource currCapability = entry.getValue().getKey().getResource();
  int version = entry.getValue().getKey().getVersion();
  ContainerUpdateType updateType =
    ContainerUpdateType.INCREASE_RESOURCE;
  if (Resources.fitsIn(targetCapability, currCapability)) {
   updateType = ContainerUpdateType.DECREASE_RESOURCE;
  }
  updateList.add(
    UpdateContainerRequest.newInstance(version, entry.getKey(),
      updateType, targetCapability));
 }
 return updateList;
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-client

private List<UpdateContainerRequest> createUpdateList() {
 List<UpdateContainerRequest> updateList = new ArrayList<>();
 for (Map.Entry<ContainerId, SimpleEntry<Container,
   UpdateContainerRequest>> entry : change.entrySet()) {
  Resource targetCapability = entry.getValue().getValue().getCapability();
  ExecutionType targetExecType =
    entry.getValue().getValue().getExecutionType();
  ContainerUpdateType updateType =
    entry.getValue().getValue().getContainerUpdateType();
  int version = entry.getValue().getKey().getVersion();
  updateList.add(
    UpdateContainerRequest.newInstance(version, entry.getKey(),
      updateType, targetCapability, targetExecType));
 }
 return updateList;
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

private static String validateContainerIdAndVersion(
  Set<ContainerId> outstandingUpdate, UpdateContainerRequest updateReq,
  RMContainer rmContainer) {
 String msg = null;
 if (rmContainer == null) {
  msg = INVALID_CONTAINER_ID;
 }
 // Only allow updates if the requested version matches the current
 // version
 if (msg == null && updateReq.getContainerVersion() !=
   rmContainer.getContainer().getVersion()) {
  msg = INCORRECT_CONTAINER_VERSION_ERROR;
 }
 // No more than 1 container update per request.
 if (msg == null &&
   outstandingUpdate.contains(updateReq.getContainerId())) {
  msg = UPDATE_OUTSTANDING_ERROR;
 }
 return msg;
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-client

"UpdateContainerRequest cannot be null!!");
requestContainerUpdate(container, UpdateContainerRequest.newInstance(
  container.getVersion(), container.getId(),
  Resources.fitsIn(capability, container.getResource()) ?
    ContainerUpdateType.DECREASE_RESOURCE :

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-client

"UpdateContainerRequest cannot be null!!");
requestContainerUpdate(container, UpdateContainerRequest.newInstance(
  container.getVersion(), container.getId(),
  Resources.fitsIn(capability, container.getResource()) ?
    ContainerUpdateType.DECREASE_RESOURCE :

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-applications-distributedshell

@Override
public void onContainerStatusReceived(ContainerId containerId,
  ContainerStatus containerStatus) {
 if (LOG.isDebugEnabled()) {
  LOG.debug("Container Status: id=" + containerId + ", status=" +
    containerStatus);
 }
 // If promote_opportunistic_after_start is set, automatically promote
 // opportunistic containers to guaranteed.
 if (autoPromoteContainers) {
  if (containerStatus.getState() == ContainerState.RUNNING) {
   Container container = containers.get(containerId);
   if (container.getExecutionType() == ExecutionType.OPPORTUNISTIC) {
    // Promote container
    LOG.info("Promoting container {} to {}", container.getId(),
      container.getExecutionType());
    UpdateContainerRequest updateRequest = UpdateContainerRequest
      .newInstance(container.getVersion(), container.getId(),
        ContainerUpdateType.PROMOTE_EXECUTION_TYPE, null,
        ExecutionType.GUARANTEED);
    amRMClient.requestContainerUpdate(container, updateRequest);
   }
  }
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

private static void checkAndcreateUpdateError(
  List<UpdateContainerError> errors, UpdateContainerRequest updateReq,
  RMContainer rmContainer, String msg) {
 if (msg != null) {
  UpdateContainerError updateError = RECORD_FACTORY
    .newRecordInstance(UpdateContainerError.class);
  updateError.setReason(msg);
  updateError.setUpdateContainerRequest(updateReq);
  if (rmContainer != null) {
   updateError.setCurrentContainerVersion(
     rmContainer.getContainer().getVersion());
  } else {
   updateError.setCurrentContainerVersion(-1);
  }
  errors.add(updateError);
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

/**
 * Rollback container update after expiry.
 * @param containerId ContainerId.
 */
protected void rollbackContainerUpdate(
  ContainerId containerId) {
 RMContainer rmContainer = getRMContainer(containerId);
 if (rmContainer == null) {
  LOG.info("Cannot rollback resource for container " + containerId
    + ". The container does not exist.");
  return;
 }
 T app = getCurrentAttemptForContainer(containerId);
 if (getCurrentAttemptForContainer(containerId) == null) {
  LOG.info("Cannot rollback resource for container " + containerId
    + ". The application that the container "
    + "belongs to does not exist.");
  return;
 }
 if (Resources.fitsIn(rmContainer.getLastConfirmedResource(),
   rmContainer.getContainer().getResource())) {
  LOG.info("Roll back resource for container " + containerId);
  handleDecreaseRequests(app, Arrays.asList(
    UpdateContainerRequest.newInstance(
      rmContainer.getContainer().getVersion(),
      rmContainer.getContainerId(),
      ContainerUpdateType.DECREASE_RESOURCE,
      rmContainer.getLastConfirmedResource(), null)));
 }
}

代码示例来源:origin: io.hops/hadoop-yarn-server-nodemanager

try {
 changeContainerResourceInternal(container.getId(),
   container.getVersion(), container.getResource(), false);
} catch (YarnException e) {
 LOG.error("Unable to decrease container resource", e);

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

.thenReturn(rmContainer);
Container container = Mockito.mock(Container.class);
Mockito.when(container.getVersion()).thenReturn(containerVersion);
Mockito.when(rmContainer.getContainer()).thenReturn(container);
Mockito.when(scheduler.getNormalizedResource(capabilityOk, maxAllocation))

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

ContainerType containerType = ContainerType.TASK;
if (updateType != null) {
 container.setVersion(container.getVersion() + 1);
   .createContainerToken(container.getId(), container.getVersion(),
     container.getNodeId(), getUser(), container.getResource(),
     container.getPriority(), rmContainer.getCreationTime(),

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

private RMContainer createDemotedRMContainer(
  SchedulerApplicationAttempt appAttempt,
  OpportunisticContainerContext oppCntxt,
  RMContainer rmContainer) {
 SchedulerRequestKey sk =
   SchedulerRequestKey.extractFrom(rmContainer.getContainer());
 Container demotedContainer = BuilderUtils.newContainer(
   ContainerId.newContainerId(appAttempt.getApplicationAttemptId(),
     oppCntxt.getContainerIdGenerator().generateContainerId()),
   rmContainer.getContainer().getNodeId(),
   rmContainer.getContainer().getNodeHttpAddress(),
   rmContainer.getContainer().getResource(),
   sk.getPriority(), null, ExecutionType.OPPORTUNISTIC,
   sk.getAllocationRequestId());
 demotedContainer.setVersion(rmContainer.getContainer().getVersion());
 return SchedulerUtils.createOpportunisticRmContainer(
   rmContext, demotedContainer, false);
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

Assert.assertEquals(ExecutionType.GUARANTEED, uc.getExecutionType());
Assert.assertEquals(uc.getId(), container.getId());
Assert.assertEquals(uc.getVersion(), container.getVersion() + 1);
  Arrays.asList(UpdateContainerRequest.newInstance(uc.getVersion(),
    uc.getId(), ContainerUpdateType.DEMOTE_EXECUTION_TYPE,
    null, ExecutionType.OPPORTUNISTIC)));
Assert.assertEquals(ExecutionType.OPPORTUNISTIC, uc.getExecutionType());
Assert.assertEquals(uc.getId(), container.getId());
Assert.assertEquals(uc.getVersion(), container.getVersion() + 2);

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

private RMContainer createDecreasedRMContainer(
  SchedulerApplicationAttempt appAttempt, UpdateContainerRequest uReq,
  RMContainer rmContainer) {
 SchedulerRequestKey sk =
   SchedulerRequestKey.extractFrom(rmContainer.getContainer());
 Container decreasedContainer = BuilderUtils.newContainer(
   ContainerId.newContainerId(appAttempt.getApplicationAttemptId(),
     appAttempt.getNewContainerId()),
   rmContainer.getContainer().getNodeId(),
   rmContainer.getContainer().getNodeHttpAddress(),
   Resources.none(),
   sk.getPriority(), null, rmContainer.getExecutionType(),
   sk.getAllocationRequestId());
 decreasedContainer.setVersion(rmContainer.getContainer().getVersion());
 RMContainer newRmContainer = new RMContainerImpl(decreasedContainer,
   sk, appAttempt.getApplicationAttemptId(),
   decreasedContainer.getNodeId(), appAttempt.getUser(), rmContext,
   rmContainer.isRemotelyAllocated());
 appAttempt.addRMContainer(decreasedContainer.getId(), rmContainer);
 ((AbstractYarnScheduler) rmContext.getScheduler()).getNode(
   decreasedContainer.getNodeId()).allocateContainer(newRmContainer);
 return newRmContainer;
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

newContainer.setAllocationRequestId(
  existingRMContainer.getContainer().getAllocationRequestId());
newContainer.setVersion(existingRMContainer.getContainer().getVersion());

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

Assert.assertEquals(ExecutionType.GUARANTEED, uc.getExecutionType());
Assert.assertEquals(uc.getId(), container.getId());
Assert.assertEquals(uc.getVersion(), container.getVersion() + 1);

相关文章