Search in sources :

Example 26 with TimelineDomain

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

the class TestTimelineWebServices method testGetDomain.

@Test
public void testGetDomain() throws Exception {
    WebResource r = resource();
    ClientResponse response = r.path("ws").path("v1").path("timeline").path("domain").path("domain_id_1").accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, response.getType().toString());
    TimelineDomain domain = response.getEntity(TimelineDomain.class);
    verifyDomain(domain, "domain_id_1");
}
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 27 with TimelineDomain

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

the class TestTimelineWebServices method testGetDomainYarnACLsEnabled.

@Test
public void testGetDomainYarnACLsEnabled() {
    AdminACLsManager oldAdminACLsManager = timelineACLsManager.setAdminACLsManager(adminACLsManager);
    try {
        WebResource r = resource();
        ClientResponse response = r.path("ws").path("v1").path("timeline").path("domain").path("domain_id_1").queryParam("user.name", "owner_1").accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
        assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, response.getType().toString());
        TimelineDomain domain = response.getEntity(TimelineDomain.class);
        verifyDomain(domain, "domain_id_1");
        response = r.path("ws").path("v1").path("timeline").path("domain").path("domain_id_1").queryParam("user.name", "tester").accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
        assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, response.getType().toString());
        assertResponseStatusCode(Status.NOT_FOUND, 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 28 with TimelineDomain

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

the class DomainLogInfo method doParse.

protected long doParse(TimelineDataManager tdm, JsonParser parser, ObjectMapper objMapper, UserGroupInformation ugi, boolean appCompleted) throws IOException {
    long count = 0;
    long bytesParsed;
    long bytesParsedLastBatch = 0;
    boolean putError = false;
    try {
        MappingIterator<TimelineDomain> iter = objMapper.readValues(parser, TimelineDomain.class);
        while (iter.hasNext()) {
            TimelineDomain domain = iter.next();
            domain.setOwner(ugi.getShortUserName());
            LOG.trace("Read domain {}", domain.getId());
            ++count;
            bytesParsed = parser.getCurrentLocation().getCharOffset() + 1;
            LOG.trace("Parser now at offset {}", bytesParsed);
            try {
                tdm.putDomain(domain, ugi);
                setOffset(getOffset() + bytesParsed - bytesParsedLastBatch);
                bytesParsedLastBatch = bytesParsed;
            } catch (YarnException e) {
                putError = true;
                throw new IOException("Error posting domain", e);
            } catch (IOException e) {
                putError = true;
                throw new IOException("Error posting domain", e);
            }
        }
    } catch (IOException e) {
        // incomplete file which are treated as EOF until app completes
        if (appCompleted || putError) {
            throw e;
        }
    } catch (RuntimeException e) {
        if (appCompleted || !(e.getCause() instanceof JsonParseException)) {
            throw e;
        }
    }
    return count;
}
Also used : TimelineDomain(org.apache.hadoop.yarn.api.records.timeline.TimelineDomain) IOException(java.io.IOException) JsonParseException(com.fasterxml.jackson.core.JsonParseException) 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