use of com.continuuity.weave.internal.appmaster.ApplicationSubmitter 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);
}
use of com.continuuity.weave.internal.appmaster.ApplicationSubmitter in project weave by continuuity.
the class Hadoop21YarnAppClient method createLauncher.
@Override
public ProcessLauncher<ApplicationId> createLauncher(WeaveSpecification weaveSpec) throws Exception {
// Request for new application
YarnClientApplication application = yarnClient.createApplication();
final GetNewApplicationResponse response = application.getNewApplicationResponse();
final ApplicationId appId = response.getApplicationId();
// Setup the context for application submission
final ApplicationSubmissionContext appSubmissionContext = application.getApplicationSubmissionContext();
appSubmissionContext.setApplicationId(appId);
appSubmissionContext.setApplicationName(weaveSpec.getName());
ApplicationSubmitter submitter = new ApplicationSubmitter() {
@Override
public ProcessController<YarnApplicationReport> submit(YarnLaunchContext context, Resource capability) {
ContainerLaunchContext launchContext = context.getLaunchContext();
addRMToken(launchContext);
appSubmissionContext.setAMContainerSpec(launchContext);
appSubmissionContext.setResource(adjustMemory(response, capability));
appSubmissionContext.setMaxAppAttempts(2);
try {
yarnClient.submitApplication(appSubmissionContext);
return new ProcessControllerImpl(yarnClient, appId);
} catch (Exception e) {
LOG.error("Failed to submit application {}", appId, e);
throw Throwables.propagate(e);
}
}
};
return new ApplicationMasterProcessLauncher(appId, submitter);
}
Aggregations