本文整理汇总了Java中org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest.newInstance方法的典型用法代码示例。如果您正苦于以下问题:Java SubmitApplicationRequest.newInstance方法的具体用法?Java SubmitApplicationRequest.newInstance怎么用?Java SubmitApplicationRequest.newInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest
的用法示例。
在下文中一共展示了SubmitApplicationRequest.newInstance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: submitAppAndGetAppId
import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest; //导入方法依赖的package包/类
private ApplicationId submitAppAndGetAppId(String submitter,
String queueName, boolean setupACLs) throws Exception {
GetNewApplicationRequest newAppRequest =
GetNewApplicationRequest.newInstance();
ApplicationClientProtocol submitterClient = getRMClientForUser(submitter);
ApplicationId applicationId =
submitterClient.getNewApplication(newAppRequest).getApplicationId();
Resource resource = BuilderUtils.newResource(1024, 1);
Map<ApplicationAccessType, String> acls = createACLs(submitter, setupACLs);
ContainerLaunchContext amContainerSpec =
ContainerLaunchContext.newInstance(null, null, null, null, null, acls);
ApplicationSubmissionContext appSubmissionContext =
ApplicationSubmissionContext.newInstance(applicationId,
"applicationName", queueName, null, amContainerSpec, false, true, 1,
resource, "applicationType");
appSubmissionContext.setApplicationId(applicationId);
appSubmissionContext.setQueue(queueName);
SubmitApplicationRequest submitRequest =
SubmitApplicationRequest.newInstance(appSubmissionContext);
submitterClient.submitApplication(submitRequest);
resourceManager.waitForState(applicationId, RMAppState.ACCEPTED);
return applicationId;
}
示例2: testAppSubmissionWithInvalidDelegationToken
import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest; //导入方法依赖的package包/类
@Test(timeout=20000)
public void testAppSubmissionWithInvalidDelegationToken() throws Exception {
Configuration conf = new Configuration();
conf.set(
CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION,
"kerberos");
UserGroupInformation.setConfiguration(conf);
MockRM rm = new MockRM(conf) {
@Override
protected void doSecureLogin() throws IOException {
// Skip the login.
}
};
ByteBuffer tokens = ByteBuffer.wrap("BOGUS".getBytes());
ContainerLaunchContext amContainer =
ContainerLaunchContext.newInstance(
new HashMap<String, LocalResource>(), new HashMap<String, String>(),
new ArrayList<String>(), new HashMap<String, ByteBuffer>(), tokens,
new HashMap<ApplicationAccessType, String>());
ApplicationSubmissionContext appSubContext =
ApplicationSubmissionContext.newInstance(
ApplicationId.newInstance(1234121, 0),
"BOGUS", "default", Priority.UNDEFINED, amContainer, false,
true, 1, Resource.newInstance(1024, 1, 1), "BOGUS");
SubmitApplicationRequest request =
SubmitApplicationRequest.newInstance(appSubContext);
try {
rm.getClientRMService().submitApplication(request);
fail("Error was excepted.");
} catch (YarnException e) {
Assert.assertTrue(e.getMessage().contains(
"Bad header found in token storage"));
}
}
示例3: testAppSubmissionWithInvalidDelegationToken
import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest; //导入方法依赖的package包/类
@Test(timeout=20000)
public void testAppSubmissionWithInvalidDelegationToken() throws Exception {
Configuration conf = new Configuration();
conf.set(
CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION,
"kerberos");
UserGroupInformation.setConfiguration(conf);
MockRM rm = new MockRM(conf) {
@Override
protected void doSecureLogin() throws IOException {
// Skip the login.
}
};
ByteBuffer tokens = ByteBuffer.wrap("BOGUS".getBytes());
ContainerLaunchContext amContainer =
ContainerLaunchContext.newInstance(
new HashMap<String, LocalResource>(), new HashMap<String, String>(),
new ArrayList<String>(), new HashMap<String, ByteBuffer>(), tokens,
new HashMap<ApplicationAccessType, String>());
ApplicationSubmissionContext appSubContext =
ApplicationSubmissionContext.newInstance(
ApplicationId.newInstance(1234121, 0),
"BOGUS", "default", Priority.UNDEFINED, amContainer, false,
true, 1, Resource.newInstance(1024, 1), "BOGUS");
SubmitApplicationRequest request =
SubmitApplicationRequest.newInstance(appSubContext);
try {
rm.getClientRMService().submitApplication(request);
fail("Error was excepted.");
} catch (YarnException e) {
Assert.assertTrue(e.getMessage().contains(
"Bad header found in token storage"));
}
}
示例4: testAppSubmissionWithInvalidDelegationToken
import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest; //导入方法依赖的package包/类
@Test(timeout=20000)
public void testAppSubmissionWithInvalidDelegationToken() throws Exception {
Configuration conf = new Configuration();
conf.set(
CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION,
"kerberos");
UserGroupInformation.setConfiguration(conf);
MockRM rm = new MockRM(conf);
ByteBuffer tokens = ByteBuffer.wrap("BOGUS".getBytes());
ContainerLaunchContext amContainer =
ContainerLaunchContext.newInstance(
new HashMap<String, LocalResource>(), new HashMap<String, String>(),
new ArrayList<String>(), new HashMap<String, ByteBuffer>(), tokens,
new HashMap<ApplicationAccessType, String>());
ApplicationSubmissionContext appSubContext =
ApplicationSubmissionContext.newInstance(
ApplicationId.newInstance(1234121, 0),
"BOGUS", "default", Priority.UNDEFINED, amContainer, false,
true, 1, Resource.newInstance(1024, 1), "BOGUS");
SubmitApplicationRequest request =
SubmitApplicationRequest.newInstance(appSubContext);
try {
rm.getClientRMService().submitApplication(request);
fail("Error was excepted.");
} catch (YarnException e) {
Assert.assertTrue(e.getMessage().contains(
"Bad header found in token storage"));
}
}
示例5: submitApplication
import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest; //导入方法依赖的package包/类
/**
* Function to submit an app to the RM
*
* @param newApp
* structure containing information to construct the
* ApplicationSubmissionContext
* @param hsr
* the servlet request
* @return Response containing the status code
* @throws AuthorizationException
* @throws IOException
* @throws InterruptedException
*/
@POST
@Path("/apps")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response submitApplication(ApplicationSubmissionContextInfo newApp,
@Context HttpServletRequest hsr) throws AuthorizationException,
IOException, InterruptedException {
init();
UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true);
if (callerUGI == null) {
throw new AuthorizationException("Unable to obtain user name, "
+ "user not authenticated");
}
if (UserGroupInformation.isSecurityEnabled() && isStaticUser(callerUGI)) {
String msg = "The default static user cannot carry out this operation.";
return Response.status(Status.FORBIDDEN).entity(msg).build();
}
ApplicationSubmissionContext appContext =
createAppSubmissionContext(newApp);
final SubmitApplicationRequest req =
SubmitApplicationRequest.newInstance(appContext);
try {
callerUGI
.doAs(new PrivilegedExceptionAction<SubmitApplicationResponse>() {
@Override
public SubmitApplicationResponse run() throws IOException,
YarnException {
return rm.getClientRMService().submitApplication(req);
}
});
} catch (UndeclaredThrowableException ue) {
if (ue.getCause() instanceof YarnException) {
throw new BadRequestException(ue.getCause().getMessage());
}
LOG.info("Submit app request failed", ue);
throw ue;
}
String url = hsr.getRequestURL() + "/" + newApp.getApplicationId();
return Response.status(Status.ACCEPTED).header(HttpHeaders.LOCATION, url)
.build();
}
示例6: testSubmitApplication
import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest; //导入方法依赖的package包/类
@Test
public void testSubmitApplication() throws Exception {
GetNewApplicationRequest newAppReq = GetNewApplicationRequest
.newInstance();
GetNewApplicationResponse newAppRes = acClient.getNewApplication
(newAppReq);
ApplicationSubmissionContext appCtx = Records.newRecord
(ApplicationSubmissionContext.class);
//appCtx.setApplicationId(ApplicationId.newInstance(0L, 1));
appCtx.setApplicationId(newAppRes.getApplicationId());
appCtx.setApplicationName("RandomApplication");
appCtx.setApplicationType("SomeType");
Map<String, LocalResource> localResources = new HashMap<>();
LocalResource lr = LocalResource.newInstance(URL.newInstance
("hdfs://", "localhost", 8020, "aFile"),
LocalResourceType.FILE, LocalResourceVisibility.PUBLIC, 100L, 100L);
localResources.put("aFile", lr);
Map<String, String> env = new HashMap<>();
env.put("env0", "someValue");
List<String> amCommnads = new ArrayList<>();
amCommnads.add("someRandom --command");
ContainerLaunchContext amCtx = ContainerLaunchContext.newInstance
(localResources, env, amCommnads, null, null, null);
appCtx.setAMContainerSpec(amCtx);
appCtx.setResource(Resource.newInstance(2048, 2));
appCtx.setQueue("default");
//ByteBuffer[] material = getCryptoMaterial();
ByteBuffer kstore = ByteBuffer.allocate(5000);
ByteBuffer tstore = ByteBuffer.allocate(5000);
String pass = "password";
appCtx.setKeyStore(kstore);
appCtx.setKeyStorePassword(pass);
appCtx.setTrustStore(tstore);
appCtx.setTrustStorePassword(pass);
ApplicationClientProtocol client = ClientRMProxy.createRMProxy(conf,
ApplicationClientProtocol.class, true);
Thread invoker = new Thread(new Invoker(client));
invoker.setName("AnotherClient");
invoker.start();
SubmitApplicationRequest appReq = SubmitApplicationRequest
.newInstance(appCtx);
LOG.debug("Submitting the application");
acClient.submitApplication(appReq);
LOG.debug("Submitted the application");
LOG.debug("Getting new application");
newAppRes = acClient.getNewApplication(newAppReq);
assertNotNull(newAppRes);
LOG.debug("I have gotten the new application");
List<ApplicationReport> appsReport = acClient.getApplications(
GetApplicationsRequest.newInstance()).getApplicationList();
boolean found = false;
for (ApplicationReport appRep : appsReport) {
if (appRep.getApplicationId().equals(appCtx.getApplicationId())) {
found = true;
break;
}
}
assertTrue(found);
TimeUnit.SECONDS.sleep(10);
}