org.apache.hadoop.yarn.api.ApplicationClientProtocol.getNewApplication()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(13.3k)|赞(0)|评价(0)|浏览(231)

本文整理了Java中org.apache.hadoop.yarn.api.ApplicationClientProtocol.getNewApplication()方法的一些代码示例,展示了ApplicationClientProtocol.getNewApplication()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ApplicationClientProtocol.getNewApplication()方法的具体详情如下:
包路径:org.apache.hadoop.yarn.api.ApplicationClientProtocol
类名称:ApplicationClientProtocol
方法名:getNewApplication

ApplicationClientProtocol.getNewApplication介绍

[英]The interface used by clients to obtain a new ApplicationId for submitting new applications.

The ResourceManager responds with a new, monotonically increasing, ApplicationId which is used by the client to submit a new application.

The ResourceManager also responds with details such as maximum resource capabilities in the cluster as specified in GetNewApplicationResponse.
[中]客户端用于获取用于提交新应用程序的新ApplicationId的接口。
ResourceManager以一个新的、单调递增的ApplicationId响应,客户端使用该ID提交新的应用程序。
ResourceManager也会以GetNewApplicationResponse中指定的集群中的最大资源能力等详细信息进行响应。

代码示例

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-router

@Override
public GetNewApplicationResponse getNewApplication(
  GetNewApplicationRequest request) throws YarnException, IOException {
 return clientRMProxy.getNewApplication(request);
}

代码示例来源:origin: io.hops/hadoop-yarn-client

private GetNewApplicationResponse getNewApplication()
  throws YarnException, IOException {
 GetNewApplicationRequest request =
   Records.newRecord(GetNewApplicationRequest.class);
 return rmClient.getNewApplication(request);
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-client

private GetNewApplicationResponse getNewApplication()
  throws YarnException, IOException {
 GetNewApplicationRequest request =
   Records.newRecord(GetNewApplicationRequest.class);
 return rmClient.getNewApplication(request);
}

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-client

private GetNewApplicationResponse getNewApplication()
  throws YarnException, IOException {
 GetNewApplicationRequest request =
   Records.newRecord(GetNewApplicationRequest.class);
 return rmClient.getNewApplication(request);
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-yarn-client

private GetNewApplicationResponse getNewApplication()
  throws YarnException, IOException {
 GetNewApplicationRequest request =
   Records.newRecord(GetNewApplicationRequest.class);
 return rmClient.getNewApplication(request);
}

代码示例来源:origin: org.springframework.data/spring-yarn-core

@Override
  public GetNewApplicationResponse doInYarn(ApplicationClientProtocol proxy) throws YarnException, IOException {
    GetNewApplicationRequest request = Records.newRecord(GetNewApplicationRequest.class);
    return proxy.getNewApplication(request);
  }
});

代码示例来源:origin: alibaba/mpich2-yarn

/**
 * Get a new application from the ASM
 *
 * @return New Application
 * @throws IOException
 *           , YarnException
 */
private GetNewApplicationResponse getApplication() throws IOException,
YarnException {
 GetNewApplicationRequest request = Records
   .newRecord(GetNewApplicationRequest.class);
 GetNewApplicationResponse response = applicationsManager
   .getNewApplication(request);
 LOG.info("Got new application id=" + response.getApplicationId());
 return response;
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-common

@Override
public GetNewApplicationResponseProto getNewApplication(
  RpcController arg0, GetNewApplicationRequestProto proto)
  throws ServiceException {
 GetNewApplicationRequestPBImpl request = new GetNewApplicationRequestPBImpl(proto);
 try {
  GetNewApplicationResponse response = real.getNewApplication(request);
  return ((GetNewApplicationResponsePBImpl)response).getProto();
 } catch (YarnException e) {
  throw new ServiceException(e);
 } catch (IOException e) {
  throw new ServiceException(e);
 }
}

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-common

@Override
public GetNewApplicationResponseProto getNewApplication(
  RpcController arg0, GetNewApplicationRequestProto proto)
  throws ServiceException {
 GetNewApplicationRequestPBImpl request = new GetNewApplicationRequestPBImpl(proto);
 try {
  GetNewApplicationResponse response = real.getNewApplication(request);
  return ((GetNewApplicationResponsePBImpl)response).getProto();
 } catch (YarnException e) {
  throw new ServiceException(e);
 } catch (IOException e) {
  throw new ServiceException(e);
 }
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-yarn-common

@Override
public GetNewApplicationResponseProto getNewApplication(
  RpcController arg0, GetNewApplicationRequestProto proto)
  throws ServiceException {
 GetNewApplicationRequestPBImpl request = new GetNewApplicationRequestPBImpl(proto);
 try {
  GetNewApplicationResponse response = real.getNewApplication(request);
  return ((GetNewApplicationResponsePBImpl)response).getProto();
 } catch (YarnException e) {
  throw new ServiceException(e);
 } catch (IOException e) {
  throw new ServiceException(e);
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

public GetNewApplicationResponse getNewAppId() throws Exception {
 ApplicationClientProtocol client = getClientRMService();
 return client.getNewApplication(Records
   .newRecord(GetNewApplicationRequest.class));
}

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-resourcemanager

public GetNewApplicationResponse getNewAppId() throws Exception {
 ApplicationClientProtocol client = getClientRMService();
 return client.getNewApplication(Records
   .newRecord(GetNewApplicationRequest.class));
}

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-common

@Test
public void testUnknownCall() {
 Configuration conf = new Configuration();
 conf.set(YarnConfiguration.IPC_RPC_IMPL, HadoopYarnProtoRPC.class
   .getName());
 YarnRPC rpc = YarnRPC.create(conf);
 String bindAddr = "localhost:0";
 InetSocketAddress addr = NetUtils.createSocketAddr(bindAddr);
 Server server = rpc.getServer(ContainerManagementProtocol.class,
   new DummyContainerManager(), addr, conf, null, 1);
 server.start();
 // Any unrelated protocol would do
 ApplicationClientProtocol proxy = (ApplicationClientProtocol) rpc.getProxy(
   ApplicationClientProtocol.class, NetUtils.getConnectAddress(server), conf);
 try {
  proxy.getNewApplication(Records
    .newRecord(GetNewApplicationRequest.class));
  Assert.fail("Excepted RPC call to fail with unknown method.");
 } catch (YarnException e) {
  Assert.assertTrue(e.getMessage().matches(
    "Unknown method getNewApplication called on.*"
      + "org.apache.hadoop.yarn.proto.ApplicationClientProtocol"
      + "\\$ApplicationClientProtocolService\\$BlockingInterface protocol."));
 } catch (Exception e) {
  e.printStackTrace();
 }
}

代码示例来源:origin: io.hops/hadoop-yarn-common

@Test
public void testUnknownCall() {
 Configuration conf = new Configuration();
 conf.set(YarnConfiguration.IPC_RPC_IMPL, HadoopYarnProtoRPC.class
   .getName());
 YarnRPC rpc = YarnRPC.create(conf);
 String bindAddr = "localhost:0";
 InetSocketAddress addr = NetUtils.createSocketAddr(bindAddr);
 Server server = rpc.getServer(ContainerManagementProtocol.class,
   new DummyContainerManager(), addr, conf, null, 1);
 server.start();
 // Any unrelated protocol would do
 ApplicationClientProtocol proxy = (ApplicationClientProtocol) rpc.getProxy(
   ApplicationClientProtocol.class, NetUtils.getConnectAddress(server), conf);
 try {
  proxy.getNewApplication(Records
    .newRecord(GetNewApplicationRequest.class));
  Assert.fail("Excepted RPC call to fail with unknown method.");
 } catch (YarnException e) {
  Assert.assertTrue(e.getMessage().matches(
    "Unknown method getNewApplication called on.*"
      + "org.apache.hadoop.yarn.proto.ApplicationClientProtocol"
      + "\\$ApplicationClientProtocolService\\$BlockingInterface protocol."));
 } catch (Exception e) {
  e.printStackTrace();
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-common

proxy.getNewApplication(Records
  .newRecord(GetNewApplicationRequest.class));
Assert.fail("Excepted RPC call to fail with unknown method.");

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

@SuppressWarnings("deprecation")
private ApplicationId submitAppAndGetAppId(AccessControlList viewACL,
  AccessControlList modifyACL) throws Exception {
 SubmitApplicationRequest submitRequest = recordFactory
   .newRecordInstance(SubmitApplicationRequest.class);
 ApplicationSubmissionContext context = recordFactory
   .newRecordInstance(ApplicationSubmissionContext.class);
 ApplicationId applicationId = rmClient.getNewApplication(
   recordFactory.newRecordInstance(GetNewApplicationRequest.class))
   .getApplicationId();
 context.setApplicationId(applicationId);
 Map<ApplicationAccessType, String> acls
   = new HashMap<ApplicationAccessType, String>();
 acls.put(ApplicationAccessType.VIEW_APP, viewACL.getAclString());
 acls.put(ApplicationAccessType.MODIFY_APP, modifyACL.getAclString());
 ContainerLaunchContext amContainer = recordFactory
   .newRecordInstance(ContainerLaunchContext.class);
 Resource resource = BuilderUtils.newResource(1024, 1);
 context.setResource(resource);
 amContainer.setApplicationACLs(acls);
 if (conf.get(YarnConfiguration.RM_SCHEDULER)
   .equals(FairScheduler.class.getName())) {
  context.setQueue("root.default");
 }
 context.setAMContainerSpec(amContainer);
 submitRequest.setApplicationSubmissionContext(context);
 rmClient.submitApplication(submitRequest);
 resourceManager.waitForState(applicationId, RMAppState.ACCEPTED);
 return applicationId;
}

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-resourcemanager

@SuppressWarnings("deprecation")
private ApplicationId submitAppAndGetAppId(AccessControlList viewACL,
  AccessControlList modifyACL) throws Exception {
 SubmitApplicationRequest submitRequest = recordFactory
   .newRecordInstance(SubmitApplicationRequest.class);
 ApplicationSubmissionContext context = recordFactory
   .newRecordInstance(ApplicationSubmissionContext.class);
 ApplicationId applicationId = rmClient.getNewApplication(
   recordFactory.newRecordInstance(GetNewApplicationRequest.class))
   .getApplicationId();
 context.setApplicationId(applicationId);
 Map<ApplicationAccessType, String> acls
   = new HashMap<ApplicationAccessType, String>();
 acls.put(ApplicationAccessType.VIEW_APP, viewACL.getAclString());
 acls.put(ApplicationAccessType.MODIFY_APP, modifyACL.getAclString());
 ContainerLaunchContext amContainer = recordFactory
   .newRecordInstance(ContainerLaunchContext.class);
 Resource resource = BuilderUtils.newResource(1024, 1);
 context.setResource(resource);
 amContainer.setApplicationACLs(acls);
 context.setAMContainerSpec(amContainer);
 submitRequest.setApplicationSubmissionContext(context);
 rmClient.submitApplication(submitRequest);
 resourceManager.waitForState(applicationId, RMAppState.ACCEPTED);
 return applicationId;
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

private ApplicationSubmissionContext prepareForAppSubmission(String submitter,
  String queueName, Priority priority) throws Exception {
 GetNewApplicationRequest newAppRequest = GetNewApplicationRequest
   .newInstance();
 ApplicationClientProtocol submitterClient = getRMClientForUser(submitter);
 ApplicationId applicationId = submitterClient
   .getNewApplication(newAppRequest).getApplicationId();
 Resource resource = BuilderUtils.newResource(1024, 1);
 ContainerLaunchContext amContainerSpec = ContainerLaunchContext
   .newInstance(null, null, null, null, null, null);
 ApplicationSubmissionContext appSubmissionContext = ApplicationSubmissionContext
   .newInstance(applicationId, "applicationName", queueName, null,
     amContainerSpec, false, true, 1, resource, "applicationType");
 appSubmissionContext.setApplicationId(applicationId);
 appSubmissionContext.setQueue(queueName);
 if (null != priority) {
  appSubmissionContext.setPriority(priority);
 }
 return appSubmissionContext;
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

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;
}

代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-resourcemanager

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;
}

相关文章

微信公众号

最新文章

更多

ApplicationClientProtocol类方法