Search in sources :

Example 1 with YarnRemoteException

use of org.apache.hadoop.yarn.exceptions.YarnRemoteException in project weave by continuuity.

the class Hadoop20YarnNMClient method start.

@Override
public Cancellable start(YarnContainerInfo containerInfo, YarnLaunchContext launchContext) {
    ContainerLaunchContext context = launchContext.getLaunchContext();
    context.setUser(System.getProperty("user.name"));
    Container container = containerInfo.getContainer();
    context.setContainerId(container.getId());
    context.setResource(container.getResource());
    StartContainerRequest startRequest = Records.newRecord(StartContainerRequest.class);
    startRequest.setContainerLaunchContext(context);
    ContainerManager manager = connectContainerManager(container);
    try {
        manager.startContainer(startRequest);
        return new ContainerTerminator(container, manager);
    } catch (YarnRemoteException e) {
        LOG.error("Error in launching process", e);
        throw Throwables.propagate(e);
    }
}
Also used : Container(org.apache.hadoop.yarn.api.records.Container) ContainerManager(org.apache.hadoop.yarn.api.ContainerManager) ContainerLaunchContext(org.apache.hadoop.yarn.api.records.ContainerLaunchContext) StartContainerRequest(org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest) YarnRemoteException(org.apache.hadoop.yarn.exceptions.YarnRemoteException)

Example 2 with YarnRemoteException

use of org.apache.hadoop.yarn.exceptions.YarnRemoteException in project weave by continuuity.

the class Hadoop20YarnAppClient method createLauncher.

@Override
public ProcessLauncher<ApplicationId> createLauncher(WeaveSpecification weaveSpec) throws Exception {
    // Request for new application
    final GetNewApplicationResponse response = yarnClient.getNewApplication();
    final ApplicationId appId = response.getApplicationId();
    // Setup the context for application submission
    final ApplicationSubmissionContext appSubmissionContext = Records.newRecord(ApplicationSubmissionContext.class);
    appSubmissionContext.setApplicationId(appId);
    appSubmissionContext.setApplicationName(weaveSpec.getName());
    appSubmissionContext.setUser(user);
    ApplicationSubmitter submitter = new ApplicationSubmitter() {

        @Override
        public ProcessController<YarnApplicationReport> submit(YarnLaunchContext launchContext, Resource capability) {
            ContainerLaunchContext context = launchContext.getLaunchContext();
            addRMToken(context);
            context.setUser(appSubmissionContext.getUser());
            context.setResource(adjustMemory(response, capability));
            appSubmissionContext.setAMContainerSpec(context);
            try {
                yarnClient.submitApplication(appSubmissionContext);
                return new ProcessControllerImpl(yarnClient, appId);
            } catch (YarnRemoteException e) {
                LOG.error("Failed to submit application {}", appId, e);
                throw Throwables.propagate(e);
            }
        }
    };
    return new ApplicationMasterProcessLauncher(appId, submitter);
}
Also used : ApplicationMasterProcessLauncher(com.continuuity.weave.internal.appmaster.ApplicationMasterProcessLauncher) GetNewApplicationResponse(org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationResponse) ApplicationSubmissionContext(org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext) Resource(org.apache.hadoop.yarn.api.records.Resource) ContainerLaunchContext(org.apache.hadoop.yarn.api.records.ContainerLaunchContext) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) ApplicationSubmitter(com.continuuity.weave.internal.appmaster.ApplicationSubmitter) YarnRemoteException(org.apache.hadoop.yarn.exceptions.YarnRemoteException)

Aggregations

ContainerLaunchContext (org.apache.hadoop.yarn.api.records.ContainerLaunchContext)2 YarnRemoteException (org.apache.hadoop.yarn.exceptions.YarnRemoteException)2 ApplicationMasterProcessLauncher (com.continuuity.weave.internal.appmaster.ApplicationMasterProcessLauncher)1 ApplicationSubmitter (com.continuuity.weave.internal.appmaster.ApplicationSubmitter)1 ContainerManager (org.apache.hadoop.yarn.api.ContainerManager)1 GetNewApplicationResponse (org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationResponse)1 StartContainerRequest (org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest)1 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)1 ApplicationSubmissionContext (org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext)1 Container (org.apache.hadoop.yarn.api.records.Container)1 Resource (org.apache.hadoop.yarn.api.records.Resource)1