YARN-912. Move client facing exceptions to yarn-api module. Contributed by Mayank Bansal.

svn merge --ignore-ancestry -c 1504032 ../../trunk/


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1504033 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Vinod Kumar Vavilapalli 2013-07-17 07:32:23 +00:00
parent a6865504d7
commit 9b3b4fe8bb
16 changed files with 159 additions and 72 deletions

View File

@ -32,6 +32,9 @@ Release 2.1.1-beta - UNRELEASED
IMPROVEMENTS
YARN-912. Move client facing exceptions to yarn-api module. (Mayank Bansal
via vinodkv)
OPTIMIZATIONS
BUG FIXES

View File

@ -53,6 +53,7 @@ import org.apache.hadoop.yarn.api.records.ApplicationReport;
import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
import org.apache.hadoop.yarn.api.records.NodeReport;
import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.api.records.ResourceRequest;
import org.apache.hadoop.yarn.api.records.Token;
import org.apache.hadoop.yarn.api.records.YarnClusterMetrics;
import org.apache.hadoop.yarn.exceptions.YarnException;
@ -113,6 +114,9 @@ public interface ApplicationClientProtocol {
* @return (empty) response on accepting the submission
* @throws YarnException
* @throws IOException
* @throws InvalidResourceRequestException
* The exception is thrown when a {@link ResourceRequest} is out of
* the range of the configured lower and upper resource boundaries.
* @see #getNewApplication(GetNewApplicationRequest)
*/
@Public

View File

@ -30,8 +30,11 @@ import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterReque
import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse;
import org.apache.hadoop.yarn.api.records.Container;
import org.apache.hadoop.yarn.api.records.ResourceRequest;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.InvalidApplicationMasterRequestException;
import org.apache.hadoop.yarn.exceptions.InvalidResourceBlacklistRequestException;
import org.apache.hadoop.yarn.exceptions.InvalidResourceRequestException;
import org.apache.hadoop.yarn.exceptions.YarnException;
/**
* <p>The protocol between a live instance of <code>ApplicationMaster</code>
@ -44,23 +47,33 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
@Public
@Stable
public interface ApplicationMasterProtocol {
/**
* <p>The interface used by a new <code>ApplicationMaster</code> to register
* with the <code>ResourceManager</code>.</p>
* <p>
* The interface used by a new <code>ApplicationMaster</code> to register with
* the <code>ResourceManager</code>.
* </p>
*
* <p>The <code>ApplicationMaster</code> needs to provide details such
* as RPC Port, HTTP tracking url etc. as specified in
* {@link RegisterApplicationMasterRequest}.</p>
* <p>
* The <code>ApplicationMaster</code> needs to provide details such as RPC
* Port, HTTP tracking url etc. as specified in
* {@link RegisterApplicationMasterRequest}.
* </p>
*
* <p>The <code>ResourceManager</code> responds with critical details such
* as maximum resource capabilities in the cluster as specified in
* {@link RegisterApplicationMasterResponse}.</p>
*
* @param request registration request
* <p>
* The <code>ResourceManager</code> responds with critical details such as
* maximum resource capabilities in the cluster as specified in
* {@link RegisterApplicationMasterResponse}.
* </p>
*
* @param request
* registration request
* @return registration respose
* @throws YarnException
* @throws IOException
* @throws InvalidApplicationMasterRequestException
* The exception is thrown when an ApplicationMaster tries to
* register more then once.
* @see RegisterApplicationMasterRequest
* @see RegisterApplicationMasterResponse
*/
@ -93,36 +106,57 @@ public interface ApplicationMasterProtocol {
public FinishApplicationMasterResponse finishApplicationMaster(
FinishApplicationMasterRequest request)
throws YarnException, IOException;
/**
* <p>The main interface between an <code>ApplicationMaster</code>
* and the <code>ResourceManager</code>.</p>
* <p>
* The main interface between an <code>ApplicationMaster</code> and the
* <code>ResourceManager</code>.
* </p>
*
* <p>The <code>ApplicationMaster</code> uses this interface to provide a list
* of {@link ResourceRequest} and returns unused {@link Container} allocated
* to it via {@link AllocateRequest}. Optionally, the
* <code>ApplicationMaster</code> can also <em>blacklist</em> resources
* which it doesn't want to use.</p>
* <p>
* The <code>ApplicationMaster</code> uses this interface to provide a list of
* {@link ResourceRequest} and returns unused {@link Container} allocated to
* it via {@link AllocateRequest}. Optionally, the
* <code>ApplicationMaster</code> can also <em>blacklist</em> resources which
* it doesn't want to use.
* </p>
*
* <p>This also doubles up as a <em>heartbeat</em> to let the
* <p>
* This also doubles up as a <em>heartbeat</em> to let the
* <code>ResourceManager</code> know that the <code>ApplicationMaster</code>
* is alive. Thus, applications should periodically make this call to be kept
* alive. The frequency depends on
* alive. The frequency depends on
* {@link YarnConfiguration#RM_AM_EXPIRY_INTERVAL_MS} which defaults to
* {@link YarnConfiguration#DEFAULT_RM_AM_EXPIRY_INTERVAL_MS}.</p>
* {@link YarnConfiguration#DEFAULT_RM_AM_EXPIRY_INTERVAL_MS}.
* </p>
*
* <p>The <code>ResourceManager</code> responds with list of allocated
* {@link Container}, status of completed containers and headroom information
* for the application.</p>
* <p>
* The <code>ResourceManager</code> responds with list of allocated
* {@link Container}, status of completed containers and headroom information
* for the application.
* </p>
*
* <p>The <code>ApplicationMaster</code> can use the available headroom
* (resources) to decide how to utilized allocated resources and make
* informed decisions about future resource requests.</p>
* <p>
* The <code>ApplicationMaster</code> can use the available headroom
* (resources) to decide how to utilized allocated resources and make informed
* decisions about future resource requests.
* </p>
*
* @param request allocation request
* @param request
* allocation request
* @return allocation response
* @throws YarnException
* @throws IOException
* @throws InvalidApplicationMasterRequestException
* This exception is thrown when an ApplicationMaster calls allocate
* without registering first.
* @throws InvalidResourceBlacklistRequestException
* This exception is thrown when an application provides an invalid
* specification for blacklist of resources.
* @throws InvalidResourceRequestException
* This exception is thrown when a {@link ResourceRequest} is out of
* the range of the configured lower and upper limits on the
* resources.
* @see AllocateRequest
* @see AllocateResponse
*/

View File

@ -32,6 +32,8 @@ import org.apache.hadoop.yarn.api.records.Container;
import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
import org.apache.hadoop.yarn.api.records.ContainerStatus;
import org.apache.hadoop.yarn.exceptions.InvalidContainerException;
import org.apache.hadoop.yarn.exceptions.NMNotYetReadyException;
import org.apache.hadoop.yarn.exceptions.YarnException;
/**
@ -49,28 +51,40 @@ import org.apache.hadoop.yarn.exceptions.YarnException;
@Stable
public interface ContainerManagementProtocol {
/**
* <p>The <code>ApplicationMaster</code> requests a <code>NodeManager</code>
* to <em>start</em> a {@link Container} allocated to it using this interface.
* <p>
* The <code>ApplicationMaster</code> requests a <code>NodeManager</code> to
* <em>start</em> a {@link Container} allocated to it using this interface.
* </p>
*
* <p>The <code>ApplicationMaster</code> has to provide details such as
* allocated resource capability, security tokens (if enabled), command
* to be executed to start the container, environment for the process,
* necessary binaries/jar/shared-objects etc. via the
* {@link ContainerLaunchContext} in the {@link StartContainerRequest}.</p>
* <p>
* The <code>ApplicationMaster</code> has to provide details such as allocated
* resource capability, security tokens (if enabled), command to be executed
* to start the container, environment for the process, necessary
* binaries/jar/shared-objects etc. via the {@link ContainerLaunchContext} in
* the {@link StartContainerRequest}.
* </p>
*
* <p>Currently the <code>NodeManager</code> sends an immediate, empty
* response via {@link StartContainerResponse} to signify acceptance of the
* request and throws an exception in case of errors. The
* <code>ApplicationMaster</code> can use
* {@link #getContainerStatus(GetContainerStatusRequest)} to get updated
* status of the to-be-launched or launched container.</p>
* <p>
* Currently the <code>NodeManager</code> sends an immediate, empty response
* via {@link StartContainerResponse} to signify acceptance of the request and
* throws an exception in case of errors. The <code>ApplicationMaster</code>
* can use {@link #getContainerStatus(GetContainerStatusRequest)} to get
* updated status of the to-be-launched or launched container.
* </p>
*
* @param request request to start a container
* @return empty response to indicate acceptance of the request
* or an exception
* @param request
* request to start a container
* @return empty response to indicate acceptance of the request or an
* exception
* @throws YarnException
* @throws IOException
* @throws NMNotYetReadyException
* This exception is thrown when NM starts from scratch but has not
* yet connected with RM.
* @throws InvalidContainerException
* This exception is thrown when NM is rejecting start-container
* requests for containers allocated by a previous instance of the
* RM
*/
@Public
@Stable

View File

@ -16,13 +16,18 @@
* limitations under the License.
*/
package org.apache.hadoop.yarn.server.resourcemanager;
package org.apache.hadoop.yarn.exceptions;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.api.ApplicationMasterProtocol;
import org.apache.hadoop.yarn.api.protocolrecords.AllocateRequest;
import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterRequest;
/**
* The exception is thrown when an application Master call allocate without
* calling RegisterApplicationMaster or try to register more then once.
* This exception is thrown when an ApplicationMaster asks for resources by
* calling {@link ApplicationMasterProtocol#allocate(AllocateRequest)} API
* without first registering by calling
* {@link ApplicationMasterProtocol#registerApplicationMaster(RegisterApplicationMasterRequest)}
* or if it tries to register more then once.
*/
public class InvalidApplicationMasterRequestException extends YarnException {

View File

@ -16,12 +16,16 @@
* limitations under the License.
*/
package org.apache.hadoop.yarn.server.nodemanager.containermanager;
package org.apache.hadoop.yarn.exceptions;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.api.ContainerManagementProtocol;
import org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest;
/**
* This Exception happens when NM is rejecting container requests from RM
* This exception is thrown by a NodeManager that is rejecting start-container
* requests via
* {@link ContainerManagementProtocol#startContainer(StartContainerRequest)}
* for containers allocated by a previous instance of the RM.
*/
public class InvalidContainerException extends YarnException {

View File

@ -16,17 +16,20 @@
* limitations under the License.
*/
package org.apache.hadoop.yarn.server.resourcemanager.scheduler;
package org.apache.hadoop.yarn.exceptions;
import org.apache.hadoop.yarn.api.ApplicationMasterProtocol;
import org.apache.hadoop.yarn.api.protocolrecords.AllocateRequest;
import org.apache.hadoop.yarn.api.records.ResourceBlacklistRequest;
import org.apache.hadoop.yarn.api.records.ResourceRequest;
import org.apache.hadoop.yarn.exceptions.YarnException;
/**
* The exception is thrown when an application provides an invalid
* specification for the blacklist.
* This exception is thrown when an application provides an invalid
* {@link ResourceBlacklistRequest} specification for blacklisting of resources
* in {@link ApplicationMasterProtocol#allocate(AllocateRequest)} API.
*
* As an e.g., currently this exceptions is thrown when an application
* tries to blacklist {@link ResourceRequest#ANY}.
* Currently this exceptions is thrown when an application tries to
* blacklist {@link ResourceRequest#ANY}.
*/
public class InvalidResourceBlacklistRequestException extends YarnException {

View File

@ -16,15 +16,18 @@
* limitations under the License.
*/
package org.apache.hadoop.yarn.server.resourcemanager.scheduler;
package org.apache.hadoop.yarn.exceptions;
import org.apache.hadoop.yarn.api.ApplicationMasterProtocol;
import org.apache.hadoop.yarn.api.protocolrecords.AllocateRequest;
import org.apache.hadoop.yarn.api.records.ResourceRequest;
import org.apache.hadoop.yarn.exceptions.YarnException;
/**
* The exception is thrown when a {@link ResourceRequest} is out of the range
* of the configured lower and upper resource boundaries.
*
* This exception is thrown when a resource requested via
* {@link ResourceRequest} in the
* {@link ApplicationMasterProtocol#allocate(AllocateRequest)} API is out of the
* range of the configured lower and upper limits on resources.
*
*/
public class InvalidResourceRequestException extends YarnException {

View File

@ -16,13 +16,15 @@
* limitations under the License.
*/
package org.apache.hadoop.yarn.server.nodemanager.containermanager;
package org.apache.hadoop.yarn.exceptions;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.api.ContainerManagementProtocol;
import org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest;
/**
* This exception happens when NM starts from scratch but has not yet connected
* with RM.
* This exception is thrown on
* {@link ContainerManagementProtocol#startContainer(StartContainerRequest)} API
* when an NM starts from scratch but has not yet connected with RM.
*/
public class NMNotYetReadyException extends YarnException {

View File

@ -64,6 +64,8 @@ import org.apache.hadoop.yarn.api.records.NodeId;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.event.AsyncDispatcher;
import org.apache.hadoop.yarn.event.EventHandler;
import org.apache.hadoop.yarn.exceptions.InvalidContainerException;
import org.apache.hadoop.yarn.exceptions.NMNotYetReadyException;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.factories.RecordFactory;
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;

View File

@ -35,11 +35,11 @@ import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.event.Dispatcher;
import org.apache.hadoop.yarn.exceptions.NMNotYetReadyException;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.factories.RecordFactory;
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
import org.apache.hadoop.yarn.server.nodemanager.containermanager.ContainerManagerImpl;
import org.apache.hadoop.yarn.server.nodemanager.containermanager.NMNotYetReadyException;
import org.apache.hadoop.yarn.server.nodemanager.metrics.NodeManagerMetrics;
import org.apache.hadoop.yarn.server.security.ApplicationACLsManager;
import org.junit.After;

View File

@ -53,6 +53,7 @@ import org.apache.hadoop.yarn.api.records.NodeId;
import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.api.records.Token;
import org.apache.hadoop.yarn.api.records.URL;
import org.apache.hadoop.yarn.exceptions.InvalidContainerException;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.security.ContainerTokenIdentifier;
import org.apache.hadoop.yarn.security.NMTokenIdentifier;

View File

@ -58,6 +58,9 @@ import org.apache.hadoop.yarn.api.records.ResourceBlacklistRequest;
import org.apache.hadoop.yarn.api.records.ResourceRequest;
import org.apache.hadoop.yarn.api.records.StrictPreemptionContract;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.InvalidApplicationMasterRequestException;
import org.apache.hadoop.yarn.exceptions.InvalidResourceBlacklistRequestException;
import org.apache.hadoop.yarn.exceptions.InvalidResourceRequestException;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.factories.RecordFactory;
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
@ -72,8 +75,6 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAt
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.event.RMAppAttemptUnregistrationEvent;
import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.InvalidResourceBlacklistRequestException;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.InvalidResourceRequestException;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNodeReport;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerUtils;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.YarnScheduler;

View File

@ -34,6 +34,7 @@ import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
import org.apache.hadoop.yarn.api.records.ResourceRequest;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.event.EventHandler;
import org.apache.hadoop.yarn.exceptions.InvalidResourceRequestException;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.ipc.RPCUtil;
import org.apache.hadoop.yarn.server.resourcemanager.RMAuditLogger.AuditConstants;
@ -48,7 +49,6 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppImpl;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppRejectedEvent;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptImpl;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.InvalidResourceRequestException;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerUtils;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.YarnScheduler;
import org.apache.hadoop.yarn.server.security.ApplicationACLsManager;

View File

@ -28,6 +28,8 @@ import org.apache.hadoop.yarn.api.records.ContainerState;
import org.apache.hadoop.yarn.api.records.ContainerStatus;
import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.api.records.ResourceRequest;
import org.apache.hadoop.yarn.exceptions.InvalidResourceBlacklistRequestException;
import org.apache.hadoop.yarn.exceptions.InvalidResourceRequestException;
import org.apache.hadoop.yarn.factories.RecordFactory;
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
import org.apache.hadoop.yarn.util.resource.ResourceCalculator;
@ -155,6 +157,9 @@ public class SchedulerUtils {
/**
* Utility method to validate a resource request, by insuring that the
* requested memory/vcore is non-negative and not greater than max
*
* @throws <code>InvalidResourceRequestException</code> when there is invalid
* request
*/
public static void validateResourceRequest(ResourceRequest resReq,
Resource maximumResource) throws InvalidResourceRequestException {
@ -189,6 +194,10 @@ public class SchedulerUtils {
}
}
/*
* @throw <code>InvalidResourceBlacklistRequestException </code> if the
* resource is not able to be added to the blacklist.
*/
public static void validateBlacklistRequest(ResourceBlacklistRequest blacklistRequest)
throws InvalidResourceBlacklistRequestException {
if (blacklistRequest != null) {

View File

@ -42,6 +42,8 @@ import org.apache.hadoop.yarn.api.records.ResourceBlacklistRequest;
import org.apache.hadoop.yarn.api.records.ResourceRequest;
import org.apache.hadoop.yarn.api.records.impl.pb.ResourceRequestPBImpl;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.InvalidResourceBlacklistRequestException;
import org.apache.hadoop.yarn.exceptions.InvalidResourceRequestException;
import org.apache.hadoop.yarn.ipc.YarnRPC;
import org.apache.hadoop.yarn.server.resourcemanager.MockNM;
import org.apache.hadoop.yarn.server.resourcemanager.MockRM;