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


Java ApplicationSubmissionContextInfo类代码示例

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


ApplicationSubmissionContextInfo类属于org.apache.hadoop.yarn.server.resourcemanager.webapp.dao包,在下文中一共展示了ApplicationSubmissionContextInfo类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: createAppSubmissionContext

import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationSubmissionContextInfo; //导入依赖的package包/类
/**
 * Create the actual ApplicationSubmissionContext to be submitted to the RM
 * from the information provided by the user.
 * 
 * @param newApp
 *          the information provided by the user
 * @return returns the constructed ApplicationSubmissionContext
 * @throws IOException
 */
protected ApplicationSubmissionContext createAppSubmissionContext(
    ApplicationSubmissionContextInfo newApp) throws IOException {

  // create local resources and app submission context

  ApplicationId appid;
  String error =
      "Could not parse application id " + newApp.getApplicationId();
  try {
    appid =
        ConverterUtils.toApplicationId(recordFactory,
          newApp.getApplicationId());
  } catch (Exception e) {
    throw new BadRequestException(error);
  }
  ApplicationSubmissionContext appContext =
      ApplicationSubmissionContext.newInstance(appid,
        newApp.getApplicationName(), newApp.getQueue(),
        Priority.newInstance(newApp.getPriority()),
        createContainerLaunchContext(newApp), newApp.getUnmanagedAM(),
        newApp.getCancelTokensWhenComplete(), newApp.getMaxAppAttempts(),
        createAppSubmissionContextResource(newApp),
        newApp.getApplicationType(),
        newApp.getKeepContainersAcrossApplicationAttempts(),
        newApp.getAppNodeLabelExpression(),
        newApp.getAMContainerNodeLabelExpression());
  appContext.setApplicationTags(newApp.getApplicationTags());

  return appContext;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:40,代码来源:RMWebServices.java

示例3: getMarshalledAppInfo

import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationSubmissionContextInfo; //导入依赖的package包/类
static String getMarshalledAppInfo(ApplicationSubmissionContextInfo appInfo)
    throws Exception {

  StringWriter writer = new StringWriter();
  JAXBContext context =
      JAXBContext.newInstance(ApplicationSubmissionContextInfo.class);
  Marshaller m = context.createMarshaller();
  m.marshal(appInfo, writer);
  return writer.toString();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:TestRMWebServicesDelegationTokenAuthentication.java

示例4: createAppSubmissionContext

import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationSubmissionContextInfo; //导入依赖的package包/类
/**
 * Create the actual ApplicationSubmissionContext to be submitted to the RM
 * from the information provided by the user.
 * 
 * @param newApp
 *          the information provided by the user
 * @return returns the constructed ApplicationSubmissionContext
 * @throws IOException
 */
protected ApplicationSubmissionContext createAppSubmissionContext(
    ApplicationSubmissionContextInfo newApp) throws IOException {

  // create local resources and app submission context

  ApplicationId appid;
  String error =
      "Could not parse application id " + newApp.getApplicationId();
  try {
    appid = ApplicationId.fromString(newApp.getApplicationId());
  } catch (Exception e) {
    throw new BadRequestException(error);
  }
  ApplicationSubmissionContext appContext =
      ApplicationSubmissionContext.newInstance(appid,
        newApp.getApplicationName(), newApp.getQueue(),
        Priority.newInstance(newApp.getPriority()),
        createContainerLaunchContext(newApp), newApp.getUnmanagedAM(),
        newApp.getCancelTokensWhenComplete(), newApp.getMaxAppAttempts(),
        createAppSubmissionContextResource(newApp),
        newApp.getApplicationType(),
        newApp.getKeepContainersAcrossApplicationAttempts(),
        newApp.getAppNodeLabelExpression(),
        newApp.getAMContainerNodeLabelExpression());
  appContext.setApplicationTags(newApp.getApplicationTags());

  return appContext;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:38,代码来源:RMWebServices.java

示例5: submitApplication

import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationSubmissionContextInfo; //导入依赖的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();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:60,代码来源:RMWebServices.java

示例6: 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

示例7: testAppSubmitBadJsonAndXML

import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationSubmissionContextInfo; //导入依赖的package包/类
@Test
public void testAppSubmitBadJsonAndXML() throws Exception {

  // submit a bunch of bad XML and JSON via the
  // REST API and make sure we get error response codes

  String urlPath = "apps";
  rm.start();
  MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
  amNodeManager.nodeHeartbeat(true);

  ApplicationSubmissionContextInfo appInfo = new ApplicationSubmissionContextInfo();
  appInfo.setApplicationName("test");
  appInfo.setPriority(3);
  appInfo.setMaxAppAttempts(2);
  appInfo.setQueue("testqueue");
  appInfo.setApplicationType("test-type");
  HashMap<String, LocalResourceInfo> lr = new HashMap<>();
  LocalResourceInfo y = new LocalResourceInfo();
  y.setUrl(new URI("http://www.test.com/file.txt"));
  y.setSize(100);
  y.setTimestamp(System.currentTimeMillis());
  y.setType(LocalResourceType.FILE);
  y.setVisibility(LocalResourceVisibility.APPLICATION);
  lr.put("example", y);
  appInfo.getContainerLaunchContextInfo().setResources(lr);
  appInfo.getResource().setMemory(1024);
  appInfo.getResource().setvCores(1);
  appInfo.getResource().setgCores(1);

  String body =
      "<?xml version=\"1.0\" encoding=\"UTF-8\" "
          + "standalone=\"yes\"?><blah/>";
  ClientResponse response =
      this.constructWebResource(urlPath).accept(MediaType.APPLICATION_XML)
        .entity(body, MediaType.APPLICATION_XML).post(ClientResponse.class);
  assertEquals(Status.BAD_REQUEST, response.getClientResponseStatus());
  body = "{\"a\" : \"b\"}";
  response =
      this.constructWebResource(urlPath).accept(MediaType.APPLICATION_XML)
        .entity(body, MediaType.APPLICATION_JSON).post(ClientResponse.class);
  validateResponseStatus(response, Status.BAD_REQUEST);
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:45,代码来源:TestRMWebServicesAppsModification.java

示例8: 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

示例9: 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

示例10: 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

示例11: testAppSubmitBadJsonAndXML

import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationSubmissionContextInfo; //导入依赖的package包/类
@Test
public void testAppSubmitBadJsonAndXML() throws Exception {

  // submit a bunch of bad XML and JSON via the
  // REST API and make sure we get error response codes

  String urlPath = "apps";
  rm.start();
  MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
  amNodeManager.nodeHeartbeat(true);

  ApplicationSubmissionContextInfo appInfo = new ApplicationSubmissionContextInfo();
  appInfo.setApplicationName("test");
  appInfo.setPriority(3);
  appInfo.setMaxAppAttempts(2);
  appInfo.setQueue("testqueue");
  appInfo.setApplicationType("test-type");
  HashMap<String, LocalResourceInfo> lr = new HashMap<>();
  LocalResourceInfo y = new LocalResourceInfo();
  y.setUrl(new URI("http://www.test.com/file.txt"));
  y.setSize(100);
  y.setTimestamp(System.currentTimeMillis());
  y.setType(LocalResourceType.FILE);
  y.setVisibility(LocalResourceVisibility.APPLICATION);
  lr.put("example", y);
  appInfo.getContainerLaunchContextInfo().setResources(lr);
  appInfo.getResource().setMemory(1024);
  appInfo.getResource().setvCores(1);

  String body =
      "<?xml version=\"1.0\" encoding=\"UTF-8\" "
          + "standalone=\"yes\"?><blah/>";
  ClientResponse response =
      this.constructWebResource(urlPath).accept(MediaType.APPLICATION_XML)
        .entity(body, MediaType.APPLICATION_XML).post(ClientResponse.class);
  assertEquals(Status.BAD_REQUEST, response.getClientResponseStatus());
  body = "{\"a\" : \"b\"}";
  response =
      this.constructWebResource(urlPath).accept(MediaType.APPLICATION_XML)
        .entity(body, MediaType.APPLICATION_JSON).post(ClientResponse.class);
  validateResponseStatus(response, Status.BAD_REQUEST);
  rm.stop();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:44,代码来源:TestRMWebServicesAppsModification.java

示例12: testAppSubmitBadJsonAndXML

import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ApplicationSubmissionContextInfo; //导入依赖的package包/类
@Test
public void testAppSubmitBadJsonAndXML() throws Exception {

  // submit a bunch of bad XML and JSON via the
  // REST API and make sure we get error response codes

  String urlPath = "apps";
  rm.start();
  MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
  amNodeManager.nodeHeartbeat(true);

  ApplicationSubmissionContextInfo appInfo = new ApplicationSubmissionContextInfo();
  appInfo.setApplicationName("test");
  appInfo.setPriority(3);
  appInfo.setMaxAppAttempts(2);
  appInfo.setQueue("testqueue");
  appInfo.setApplicationType("test-type");
  HashMap<String, LocalResourceInfo> lr =
      new HashMap<String, LocalResourceInfo>();
  LocalResourceInfo y = new LocalResourceInfo();
  y.setUrl(new URI("http://www.test.com/file.txt"));
  y.setSize(100);
  y.setTimestamp(System.currentTimeMillis());
  y.setType(LocalResourceType.FILE);
  y.setVisibility(LocalResourceVisibility.APPLICATION);
  lr.put("example", y);
  appInfo.getContainerLaunchContextInfo().setResources(lr);
  appInfo.getResource().setMemory(1024);
  appInfo.getResource().setvCores(1);

  String body =
      "<?xml version=\"1.0\" encoding=\"UTF-8\" "
          + "standalone=\"yes\"?><blah/>";
  ClientResponse response =
      this.constructWebResource(urlPath).accept(MediaType.APPLICATION_XML)
        .entity(body, MediaType.APPLICATION_XML).post(ClientResponse.class);
  assertEquals(Status.BAD_REQUEST, response.getClientResponseStatus());
  body = "{\"a\" : \"b\"}";
  response =
      this.constructWebResource(urlPath).accept(MediaType.APPLICATION_XML)
        .entity(body, MediaType.APPLICATION_JSON).post(ClientResponse.class);
  validateResponseStatus(response, Status.BAD_REQUEST);
  rm.stop();
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:45,代码来源:TestRMWebServicesAppsModification.java

示例13: 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

示例14: 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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。