Search in sources :

Example 11 with TimelineDomain

use of org.apache.hadoop.yarn.api.records.timeline.TimelineDomain in project hadoop by apache.

the class TestTimelineACLsManager method testYarnACLsNotEnabledForDomain.

@Test
public void testYarnACLsNotEnabledForDomain() throws Exception {
    Configuration conf = new YarnConfiguration();
    conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, false);
    TimelineACLsManager timelineACLsManager = new TimelineACLsManager(conf);
    TimelineDomain domain = new TimelineDomain();
    domain.setOwner("owner");
    Assert.assertTrue("Always true when ACLs are not enabled", timelineACLsManager.checkAccess(UserGroupInformation.createRemoteUser("user"), domain));
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) TimelineDomain(org.apache.hadoop.yarn.api.records.timeline.TimelineDomain) Test(org.junit.Test)

Example 12 with TimelineDomain

use of org.apache.hadoop.yarn.api.records.timeline.TimelineDomain in project hadoop by apache.

the class TestTimelineWebServices method testPutDomainYarnACLsEnabled.

@Test
public void testPutDomainYarnACLsEnabled() throws Exception {
    AdminACLsManager oldAdminACLsManager = timelineACLsManager.setAdminACLsManager(adminACLsManager);
    try {
        TimelineDomain domain = new TimelineDomain();
        domain.setId("test_domain_id_acl");
        WebResource r = resource();
        ClientResponse response = r.path("ws").path("v1").path("timeline").path("domain").queryParam("user.name", "tester").accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).put(ClientResponse.class, domain);
        assertResponseStatusCode(Status.OK, response.getStatusInfo());
        // Update the domain by another user
        response = r.path("ws").path("v1").path("timeline").path("domain").queryParam("user.name", "other").accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).put(ClientResponse.class, domain);
        assertResponseStatusCode(Status.FORBIDDEN, response.getStatusInfo());
    } finally {
        timelineACLsManager.setAdminACLsManager(oldAdminACLsManager);
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) AdminACLsManager(org.apache.hadoop.yarn.security.AdminACLsManager) WebResource(com.sun.jersey.api.client.WebResource) TimelineDomain(org.apache.hadoop.yarn.api.records.timeline.TimelineDomain) Test(org.junit.Test)

Example 13 with TimelineDomain

use of org.apache.hadoop.yarn.api.records.timeline.TimelineDomain in project hadoop by apache.

the class TestTimelineWebServices method testPutDomain.

@Test
public void testPutDomain() throws Exception {
    TimelineDomain domain = new TimelineDomain();
    domain.setId("test_domain_id");
    WebResource r = resource();
    // No owner, will be rejected
    ClientResponse response = r.path("ws").path("v1").path("timeline").path("domain").accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).put(ClientResponse.class, domain);
    assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, response.getType().toString());
    assertResponseStatusCode(Status.FORBIDDEN, response.getStatusInfo());
    response = r.path("ws").path("v1").path("timeline").path("domain").queryParam("user.name", "tester").accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).put(ClientResponse.class, domain);
    assertResponseStatusCode(Status.OK, response.getStatusInfo());
    // Verify the domain exists
    response = r.path("ws").path("v1").path("timeline").path("domain").path("test_domain_id").accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, response.getType().toString());
    domain = response.getEntity(TimelineDomain.class);
    Assert.assertNotNull(domain);
    Assert.assertEquals("test_domain_id", domain.getId());
    Assert.assertEquals("tester", domain.getOwner());
    Assert.assertEquals(null, domain.getDescription());
    // Update the domain
    domain.setDescription("test_description");
    response = r.path("ws").path("v1").path("timeline").path("domain").queryParam("user.name", "tester").accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).put(ClientResponse.class, domain);
    assertResponseStatusCode(Status.OK, response.getStatusInfo());
    // Verify the domain is updated
    response = r.path("ws").path("v1").path("timeline").path("domain").path("test_domain_id").accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, response.getType().toString());
    domain = response.getEntity(TimelineDomain.class);
    Assert.assertNotNull(domain);
    Assert.assertEquals("test_domain_id", domain.getId());
    Assert.assertEquals("test_description", domain.getDescription());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) WebResource(com.sun.jersey.api.client.WebResource) TimelineDomain(org.apache.hadoop.yarn.api.records.timeline.TimelineDomain) Test(org.junit.Test)

Example 14 with TimelineDomain

use of org.apache.hadoop.yarn.api.records.timeline.TimelineDomain in project hadoop by apache.

the class TestLogInfo method testParseDomain.

@Test
public void testParseDomain() throws Exception {
    // Load test data
    TimelineDataManager tdm = PluginStoreTestUtils.getTdmWithMemStore(config);
    DomainLogInfo domainLogInfo = new DomainLogInfo(TEST_ATTEMPT_DIR_NAME, TEST_DOMAIN_FILE_NAME, UserGroupInformation.getLoginUser().getUserName());
    domainLogInfo.parseForStore(tdm, getTestRootPath(), true, jsonFactory, objMapper, fs);
    // Verify domain data
    TimelineDomain resultDomain = tdm.getDomain("domain_1", UserGroupInformation.getLoginUser());
    assertNotNull(resultDomain);
    assertEquals(testDomain.getReaders(), resultDomain.getReaders());
    assertEquals(testDomain.getOwner(), resultDomain.getOwner());
    assertEquals(testDomain.getDescription(), resultDomain.getDescription());
}
Also used : TimelineDomain(org.apache.hadoop.yarn.api.records.timeline.TimelineDomain) Test(org.junit.Test)

Example 15 with TimelineDomain

use of org.apache.hadoop.yarn.api.records.timeline.TimelineDomain in project jstorm by alibaba.

the class JstormOnYarn method prepareTimelineDomain.

private void prepareTimelineDomain() {
    TimelineClient timelineClient = null;
    if (jstormClientContext.conf.getBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, YarnConfiguration.DEFAULT_TIMELINE_SERVICE_ENABLED)) {
        timelineClient = TimelineClient.createTimelineClient();
        timelineClient.init(jstormClientContext.conf);
        timelineClient.start();
    } else {
        LOG.warn("Cannot put the domain " + jstormClientContext.domainId + " because the timeline service is not enabled");
        return;
    }
    try {
        TimelineDomain domain = new TimelineDomain();
        domain.setId(jstormClientContext.domainId);
        domain.setReaders(jstormClientContext.viewACLs != null && jstormClientContext.viewACLs.length() > 0 ? jstormClientContext.viewACLs : JOYConstants.BLANK);
        domain.setWriters(jstormClientContext.modifyACLs != null && jstormClientContext.modifyACLs.length() > 0 ? jstormClientContext.modifyACLs : JOYConstants.BLANK);
        timelineClient.putDomain(domain);
        LOG.info("Put the timeline domain: " + TimelineUtils.dumpTimelineRecordtoJSON(domain));
    } catch (Exception e) {
        LOG.error("Error when putting the timeline domain", e);
    } finally {
        timelineClient.stop();
    }
}
Also used : TimelineClient(org.apache.hadoop.yarn.client.api.TimelineClient) TimelineDomain(org.apache.hadoop.yarn.api.records.timeline.TimelineDomain) ParseException(org.apache.commons.cli.ParseException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException)

Aggregations

TimelineDomain (org.apache.hadoop.yarn.api.records.timeline.TimelineDomain)28 Test (org.junit.Test)9 IOException (java.io.IOException)7 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)7 Configuration (org.apache.hadoop.conf.Configuration)5 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)5 ClientResponse (com.sun.jersey.api.client.ClientResponse)4 WebResource (com.sun.jersey.api.client.WebResource)4 TimelineEntities (org.apache.hadoop.yarn.api.records.timeline.TimelineEntities)4 Path (org.apache.hadoop.fs.Path)3 TimelineDomains (org.apache.hadoop.yarn.api.records.timeline.TimelineDomains)3 TimelineClient (org.apache.hadoop.yarn.client.api.TimelineClient)3 ArrayList (java.util.ArrayList)2 ParseException (org.apache.commons.cli.ParseException)2 HdfsConfiguration (org.apache.hadoop.hdfs.HdfsConfiguration)2 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)2 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)2 AdminACLsManager (org.apache.hadoop.yarn.security.AdminACLsManager)2 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 File (java.io.File)1