All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse Maven / Gradle / Ivy

There is a newer version: 3.4.0
Show newest version
/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.hadoop.yarn.api.protocolrecords;

import java.util.List;

import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Evolving;
import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.api.ApplicationMasterProtocol;
import org.apache.hadoop.yarn.api.records.AMCommand;
import org.apache.hadoop.yarn.api.records.Container;
import org.apache.hadoop.yarn.api.records.ContainerResourceDecrease;
import org.apache.hadoop.yarn.api.records.ContainerResourceIncrease;
import org.apache.hadoop.yarn.api.records.ContainerStatus;
import org.apache.hadoop.yarn.api.records.NMToken;
import org.apache.hadoop.yarn.api.records.NodeReport;
import org.apache.hadoop.yarn.api.records.PreemptionMessage;
import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.util.Records;

/**
 * 

The response sent by the ResourceManager the * ApplicationMaster during resource negotiation.

* *

The response, includes: *

    *
  • Response ID to track duplicate responses.
  • *
  • * An AMCommand sent by ResourceManager to let the ApplicationMaster * take some actions (resync, shutdown etc.). *
  • A list of newly allocated {@link Container}.
  • *
  • A list of completed {@link Container}s' statuses.
  • *
  • * The available headroom for resources in the cluster for the * application. *
  • *
  • A list of nodes whose status has been updated.
  • *
  • The number of available nodes in a cluster.
  • *
  • A description of resources requested back by the cluster
  • *
*

* * @see ApplicationMasterProtocol#allocate(AllocateRequest) */ @Public @Stable public abstract class AllocateResponse { @Public @Stable public static AllocateResponse newInstance(int responseId, List completedContainers, List allocatedContainers, List updatedNodes, Resource availResources, AMCommand command, int numClusterNodes, PreemptionMessage preempt, List nmTokens) { AllocateResponse response = Records.newRecord(AllocateResponse.class); response.setNumClusterNodes(numClusterNodes); response.setResponseId(responseId); response.setCompletedContainersStatuses(completedContainers); response.setAllocatedContainers(allocatedContainers); response.setUpdatedNodes(updatedNodes); response.setAvailableResources(availResources); response.setAMCommand(command); response.setPreemptionMessage(preempt); response.setNMTokens(nmTokens); return response; } @Public @Stable public static AllocateResponse newInstance(int responseId, List completedContainers, List allocatedContainers, List updatedNodes, Resource availResources, AMCommand command, int numClusterNodes, PreemptionMessage preempt, List nmTokens, List increasedContainers, List decreasedContainers) { AllocateResponse response = newInstance(responseId, completedContainers, allocatedContainers, updatedNodes, availResources, command, numClusterNodes, preempt, nmTokens); response.setIncreasedContainers(increasedContainers); response.setDecreasedContainers(decreasedContainers); return response; } /** * If the ResourceManager needs the * ApplicationMaster to take some action then it will send an * AMCommand to the ApplicationMaster. See AMCommand * for details on commands and actions for them. * @return AMCommand if the ApplicationMaster should * take action, null otherwise * @see AMCommand */ @Public @Stable public abstract AMCommand getAMCommand(); @Private @Unstable public abstract void setAMCommand(AMCommand command); /** * Get the last response id. * @return last response id */ @Public @Stable public abstract int getResponseId(); @Private @Unstable public abstract void setResponseId(int responseId); /** * Get the list of newly allocated Container by the * ResourceManager. * @return list of newly allocated Container */ @Public @Stable public abstract List getAllocatedContainers(); /** * Set the list of newly allocated Container by the * ResourceManager. * @param containers list of newly allocated Container */ @Private @Unstable public abstract void setAllocatedContainers(List containers); /** * Get the available headroom for resources in the cluster for the * application. * @return limit of available headroom for resources in the cluster for the * application */ @Public @Stable public abstract Resource getAvailableResources(); @Private @Unstable public abstract void setAvailableResources(Resource limit); /** * Get the list of completed containers' statuses. * @return the list of completed containers' statuses */ @Public @Stable public abstract List getCompletedContainersStatuses(); @Private @Unstable public abstract void setCompletedContainersStatuses(List containers); /** * Get the list of updated NodeReports. Updates could * be changes in health, availability etc of the nodes. * @return The delta of updated nodes since the last response */ @Public @Stable public abstract List getUpdatedNodes(); @Private @Unstable public abstract void setUpdatedNodes(final List updatedNodes); /** * Get the number of hosts available on the cluster. * @return the available host count. */ @Public @Stable public abstract int getNumClusterNodes(); @Private @Unstable public abstract void setNumClusterNodes(int numNodes); /** *

Get the description of containers owned by the AM, but requested back by * the cluster. Note that the RM may have an inconsistent view of the * resources owned by the AM. These messages are advisory, and the AM may * elect to ignore them.

* *

The message is a snapshot of the resources the RM wants back from the AM. * While demand persists, the RM will repeat its request; applications should * not interpret each message as a request for additional * resources on top of previous messages. Resources requested consistently * over some duration may be forcibly killed by the RM.

* * @return A specification of the resources to reclaim from this AM. */ @Public @Evolving public abstract PreemptionMessage getPreemptionMessage(); @Private @Unstable public abstract void setPreemptionMessage(PreemptionMessage request); /** *

Get the list of NMTokens required for communicating with NM. New NMTokens * issued only if

*

1) AM is receiving first container on underlying NodeManager.
* OR
* 2) NMToken master key rolled over in ResourceManager and AM is getting new * container on the same underlying NodeManager.

*

AM will receive one NMToken per NM irrespective of the number of containers * issued on same NM. AM is expected to store these tokens until issued a * new token for the same NM.

*/ @Public @Stable public abstract List getNMTokens(); @Private @Unstable public abstract void setNMTokens(List nmTokens); /** * Get the list of newly increased containers by ResourceManager */ @Public @Stable public abstract List getIncreasedContainers(); /** * Set the list of newly increased containers by ResourceManager */ @Private @Unstable public abstract void setIncreasedContainers( List increasedContainers); /** * Get the list of newly decreased containers by NodeManager */ @Public @Stable public abstract List getDecreasedContainers(); /** * Set the list of newly decreased containers by NodeManager */ @Private @Unstable public abstract void setDecreasedContainers( List decreasedContainers); }