当前位置: 首页>>代码示例>>Java>>正文


Java ApplicationSubmissionContextInfo.setApplicationId方法代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationSubmissionContextInfo.setApplicationId方法的典型用法代码示例。如果您正苦于以下问题:Java ApplicationSubmissionContextInfo.setApplicationId方法的具体用法?Java ApplicationSubmissionContextInfo.setApplicationId怎么用?Java ApplicationSubmissionContextInfo.setApplicationId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationSubmissionContextInfo的用法示例。


在下文中一共展示了ApplicationSubmissionContextInfo.setApplicationId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCancelledDelegationToken

import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationSubmissionContextInfo; //导入方法依赖的package包/类
@Test
public void testCancelledDelegationToken() throws Exception {
  String token = getDelegationToken("client");
  cancelDelegationToken(token);
  ApplicationSubmissionContextInfo app =
      new ApplicationSubmissionContextInfo();
  String appid = "application_123_0";
  app.setApplicationId(appid);
  String requestBody = getMarshalledAppInfo(app);

  URL url = new URL("http://localhost:8088/ws/v1/cluster/apps");
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  conn.setRequestProperty(delegationTokenHeader, token);
  setupConn(conn, "POST", MediaType.APPLICATION_XML, requestBody);

  // this should fail with unauthorized because only
  // auth is kerberos or delegation token
  try {
    conn.getInputStream();
    fail("Authentication should fail with expired delegation tokens");
  } catch (IOException e) {
    assertEquals(Status.FORBIDDEN.getStatusCode(), conn.getResponseCode());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestRMWebServicesDelegationTokenAuthentication.java

示例2: testAppSubmitErrors

import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationSubmissionContextInfo; //导入方法依赖的package包/类
public void testAppSubmitErrors(String acceptMedia, String contentMedia)
    throws Exception {

  // submit a bunch of bad requests(correct format but bad values) via the
  // REST API and make sure we get the right error response codes

  String urlPath = "apps";
  ApplicationSubmissionContextInfo appInfo = new ApplicationSubmissionContextInfo();
  ClientResponse response =
      this.constructWebResource(urlPath).accept(acceptMedia)
        .entity(appInfo, contentMedia).post(ClientResponse.class);
  validateResponseStatus(response, Status.BAD_REQUEST);

  String appId = "random";
  appInfo.setApplicationId(appId);
  response =
      this.constructWebResource(urlPath).accept(acceptMedia)
        .entity(appInfo, contentMedia).post(ClientResponse.class);
  validateResponseStatus(response, Status.BAD_REQUEST);

  appId = "random_junk";
  appInfo.setApplicationId(appId);
  response =
      this.constructWebResource(urlPath).accept(acceptMedia)
        .entity(appInfo, contentMedia).post(ClientResponse.class);
  validateResponseStatus(response, Status.BAD_REQUEST);

  // bad resource info
  appInfo.getResource().setMemory(
    rm.getConfig().getInt(
      YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
      YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB) + 1);
  appInfo.getResource().setvCores(1);
  appInfo.getResource().setgCores(1);
  response =
      this.constructWebResource(urlPath).accept(acceptMedia)
        .entity(appInfo, contentMedia).post(ClientResponse.class);

  validateResponseStatus(response, Status.BAD_REQUEST);

  appInfo.getResource().setvCores(
    rm.getConfig().getInt(
      YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
      YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES) + 1);
  appInfo.getResource().setgCores(
    rm.getConfig().getInt(
      YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_GCORES,
      YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_GCORES) + 1);
  appInfo.getResource().setMemory(CONTAINER_MB);
  response =
      this.constructWebResource(urlPath).accept(acceptMedia)
        .entity(appInfo, contentMedia).post(ClientResponse.class);
  validateResponseStatus(response, Status.BAD_REQUEST);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:55,代码来源:TestRMWebServicesAppsModification.java

示例3: testDelegationTokenAuth

import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationSubmissionContextInfo; //导入方法依赖的package包/类
@Test
public void testDelegationTokenAuth() throws Exception {
  final String token = getDelegationToken("test");

  ApplicationSubmissionContextInfo app =
      new ApplicationSubmissionContextInfo();
  String appid = "application_123_0";
  app.setApplicationId(appid);
  String requestBody = getMarshalledAppInfo(app);

  URL url = new URL("http://localhost:8088/ws/v1/cluster/apps");
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  setupConn(conn, "POST", "application/xml", requestBody);

  // this should fail with unauthorized because only
  // auth is kerberos or delegation token
  try {
    conn.getInputStream();
    fail("we should not be here");
  } catch (IOException e) {
    assertEquals(Status.UNAUTHORIZED.getStatusCode(), conn.getResponseCode());
  }

  conn = (HttpURLConnection) url.openConnection();
  conn.setRequestProperty(delegationTokenHeader, token);
  setupConn(conn, "POST", MediaType.APPLICATION_XML, requestBody);

  // this should not fail
  try {
    conn.getInputStream();
  }
  catch(IOException ie) {
    InputStream errorStream = conn.getErrorStream();
    String error = "";
    BufferedReader reader = null;
    reader = new BufferedReader(new InputStreamReader(errorStream, "UTF8"));
    for (String line; (line = reader.readLine()) != null;) {
      error += line;
    }
    reader.close();
    errorStream.close();
    fail("Response " + conn.getResponseCode() + "; " + error);
  }

  boolean appExists =
      rm.getRMContext().getRMApps()
        .containsKey(ConverterUtils.toApplicationId(appid));
  assertTrue(appExists);
  RMApp actualApp =
      rm.getRMContext().getRMApps()
        .get(ConverterUtils.toApplicationId(appid));
  String owner = actualApp.getUser();
  assertEquals("client", owner);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:55,代码来源:TestRMWebServicesDelegationTokenAuthentication.java

示例4: testAnonymousSimpleUser

import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationSubmissionContextInfo; //导入方法依赖的package包/类
private void testAnonymousSimpleUser() throws Exception {

    ApplicationSubmissionContextInfo app =
        new ApplicationSubmissionContextInfo();
    String appid = "application_123_0";
    app.setApplicationId(appid);
    String requestBody =
        TestRMWebServicesDelegationTokenAuthentication
          .getMarshalledAppInfo(app);

    URL url = new URL("http://localhost:8088/ws/v1/cluster/apps");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    TestRMWebServicesDelegationTokenAuthentication.setupConn(conn, "POST",
      "application/xml", requestBody);

    conn.getInputStream();
    assertEquals(Status.ACCEPTED.getStatusCode(), conn.getResponseCode());
    boolean appExists =
        rm.getRMContext().getRMApps()
          .containsKey(ConverterUtils.toApplicationId(appid));
    assertTrue(appExists);
    RMApp actualApp =
        rm.getRMContext().getRMApps()
          .get(ConverterUtils.toApplicationId(appid));
    String owner = actualApp.getUser();
    assertEquals(
      rm.getConfig().get(CommonConfigurationKeys.HADOOP_HTTP_STATIC_USER,
        CommonConfigurationKeys.DEFAULT_HADOOP_HTTP_STATIC_USER), owner);

    appid = "application_123_1";
    app.setApplicationId(appid);
    requestBody =
        TestRMWebServicesDelegationTokenAuthentication
          .getMarshalledAppInfo(app);
    url = new URL("http://localhost:8088/ws/v1/cluster/apps?user.name=client");
    conn = (HttpURLConnection) url.openConnection();
    TestRMWebServicesDelegationTokenAuthentication.setupConn(conn, "POST",
      MediaType.APPLICATION_XML, requestBody);

    conn.getInputStream();
    appExists =
        rm.getRMContext().getRMApps()
          .containsKey(ConverterUtils.toApplicationId(appid));
    assertTrue(appExists);
    actualApp =
        rm.getRMContext().getRMApps()
          .get(ConverterUtils.toApplicationId(appid));
    owner = actualApp.getUser();
    assertEquals("client", owner);

  }
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:52,代码来源:TestRMWebappAuthentication.java

示例5: testAppSubmitErrors

import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationSubmissionContextInfo; //导入方法依赖的package包/类
public void testAppSubmitErrors(String acceptMedia, String contentMedia)
    throws Exception {

  // submit a bunch of bad requests(correct format but bad values) via the
  // REST API and make sure we get the right error response codes

  String urlPath = "apps";
  ApplicationSubmissionContextInfo appInfo = new ApplicationSubmissionContextInfo();
  ClientResponse response =
      this.constructWebResource(urlPath).accept(acceptMedia)
        .entity(appInfo, contentMedia).post(ClientResponse.class);
  validateResponseStatus(response, Status.BAD_REQUEST);

  String appId = "random";
  appInfo.setApplicationId(appId);
  response =
      this.constructWebResource(urlPath).accept(acceptMedia)
        .entity(appInfo, contentMedia).post(ClientResponse.class);
  validateResponseStatus(response, Status.BAD_REQUEST);

  appId = "random_junk";
  appInfo.setApplicationId(appId);
  response =
      this.constructWebResource(urlPath).accept(acceptMedia)
        .entity(appInfo, contentMedia).post(ClientResponse.class);
  validateResponseStatus(response, Status.BAD_REQUEST);

  // bad resource info
  appInfo.getResource().setMemory(
    rm.getConfig().getInt(
      YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
      YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB) + 1);
  appInfo.getResource().setvCores(1);
  response =
      this.constructWebResource(urlPath).accept(acceptMedia)
        .entity(appInfo, contentMedia).post(ClientResponse.class);

  validateResponseStatus(response, Status.BAD_REQUEST);

  appInfo.getResource().setvCores(
    rm.getConfig().getInt(
      YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
      YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES) + 1);
  appInfo.getResource().setMemory(CONTAINER_MB);
  response =
      this.constructWebResource(urlPath).accept(acceptMedia)
        .entity(appInfo, contentMedia).post(ClientResponse.class);
  validateResponseStatus(response, Status.BAD_REQUEST);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:50,代码来源:TestRMWebServicesAppsModification.java

示例6: testDelegationTokenAuth

import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationSubmissionContextInfo; //导入方法依赖的package包/类
@Test
public void testDelegationTokenAuth() throws Exception {
  final String token = getDelegationToken("test");

  ApplicationSubmissionContextInfo app =
      new ApplicationSubmissionContextInfo();
  String appid = "application_123_0";
  app.setApplicationId(appid);
  String requestBody = getMarshalledAppInfo(app);

  URL url = new URL("http://localhost:8088/ws/v1/cluster/apps");
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  setupConn(conn, "POST", "application/xml", requestBody);

  // this should fail with unauthorized because only
  // auth is kerberos or delegation token
  try {
    conn.getInputStream();
    fail("we should not be here");
  } catch (IOException e) {
    assertEquals(Status.UNAUTHORIZED.getStatusCode(), conn.getResponseCode());
  }

  conn = (HttpURLConnection) url.openConnection();
  conn.setRequestProperty(delegationTokenHeader, token);
  setupConn(conn, "POST", MediaType.APPLICATION_XML, requestBody);

  // this should not fail
  try {
    conn.getInputStream();
  }
  catch(IOException ie) {
    InputStream errorStream = conn.getErrorStream();
    String error = "";
    BufferedReader reader = null;
    reader = new BufferedReader(new InputStreamReader(errorStream, "UTF8"));
    for (String line; (line = reader.readLine()) != null;) {
      error += line;
    }
    reader.close();
    errorStream.close();
    fail("Response " + conn.getResponseCode() + "; " + error);
  }

  boolean appExists =
      rm.getRMContext().getRMApps()
        .containsKey(ApplicationId.fromString(appid));
  assertTrue(appExists);
  RMApp actualApp =
      rm.getRMContext().getRMApps()
        .get(ApplicationId.fromString(appid));
  String owner = actualApp.getUser();
  assertEquals("client", owner);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:55,代码来源:TestRMWebServicesDelegationTokenAuthentication.java

示例7: testAnonymousSimpleUser

import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationSubmissionContextInfo; //导入方法依赖的package包/类
private void testAnonymousSimpleUser() throws Exception {

    ApplicationSubmissionContextInfo app =
        new ApplicationSubmissionContextInfo();
    String appid = "application_123_0";
    app.setApplicationId(appid);
    String requestBody =
        TestRMWebServicesDelegationTokenAuthentication
          .getMarshalledAppInfo(app);

    URL url = new URL("http://localhost:8088/ws/v1/cluster/apps");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    TestRMWebServicesDelegationTokenAuthentication.setupConn(conn, "POST",
      "application/xml", requestBody);

    conn.getInputStream();
    assertEquals(Status.ACCEPTED.getStatusCode(), conn.getResponseCode());
    boolean appExists =
        rm.getRMContext().getRMApps()
          .containsKey(ApplicationId.fromString(appid));
    assertTrue(appExists);
    RMApp actualApp =
        rm.getRMContext().getRMApps()
          .get(ApplicationId.fromString(appid));
    String owner = actualApp.getUser();
    assertEquals(
      rm.getConfig().get(CommonConfigurationKeys.HADOOP_HTTP_STATIC_USER,
        CommonConfigurationKeys.DEFAULT_HADOOP_HTTP_STATIC_USER), owner);

    appid = "application_123_1";
    app.setApplicationId(appid);
    requestBody =
        TestRMWebServicesDelegationTokenAuthentication
          .getMarshalledAppInfo(app);
    url = new URL("http://localhost:8088/ws/v1/cluster/apps?user.name=client");
    conn = (HttpURLConnection) url.openConnection();
    TestRMWebServicesDelegationTokenAuthentication.setupConn(conn, "POST",
      MediaType.APPLICATION_XML, requestBody);

    conn.getInputStream();
    appExists =
        rm.getRMContext().getRMApps()
          .containsKey(ApplicationId.fromString(appid));
    assertTrue(appExists);
    actualApp =
        rm.getRMContext().getRMApps()
          .get(ApplicationId.fromString(appid));
    owner = actualApp.getUser();
    assertEquals("client", owner);

  }
 
开发者ID:hopshadoop,项目名称:hops,代码行数:52,代码来源:TestRMWebappAuthentication.java


注:本文中的org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationSubmissionContextInfo.setApplicationId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。