Search in sources :

Example 6 with TimelineDomains

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

the class RollingLevelDBTimelineStore method getDomains.

@Override
public TimelineDomains getDomains(String owner) throws IOException {
    DBIterator iterator = null;
    try {
        byte[] prefix = KeyBuilder.newInstance().add(owner).getBytesForLookup();
        List<TimelineDomain> domains = new ArrayList<TimelineDomain>();
        for (iterator = ownerdb.iterator(), iterator.seek(prefix); iterator.hasNext(); ) {
            byte[] key = iterator.peekNext().getKey();
            if (!prefixMatches(prefix, prefix.length, key)) {
                break;
            }
            // Iterator to parse the rows of an individual domain
            KeyParser kp = new KeyParser(key, prefix.length);
            String domainId = kp.getNextString();
            byte[] prefixExt = KeyBuilder.newInstance().add(owner).add(domainId).getBytesForLookup();
            TimelineDomain domainToReturn = getTimelineDomain(iterator, domainId, prefixExt);
            if (domainToReturn != null) {
                domains.add(domainToReturn);
            }
        }
        // Sort the domains to return
        Collections.sort(domains, new Comparator<TimelineDomain>() {

            @Override
            public int compare(TimelineDomain domain1, TimelineDomain domain2) {
                int result = domain2.getCreatedTime().compareTo(domain1.getCreatedTime());
                if (result == 0) {
                    return domain2.getModifiedTime().compareTo(domain1.getModifiedTime());
                } else {
                    return result;
                }
            }
        });
        TimelineDomains domainsToReturn = new TimelineDomains();
        domainsToReturn.addDomains(domains);
        return domainsToReturn;
    } finally {
        IOUtils.cleanup(LOG, iterator);
    }
}
Also used : DBIterator(org.iq80.leveldb.DBIterator) TimelineDomains(org.apache.hadoop.yarn.api.records.timeline.TimelineDomains) ArrayList(java.util.ArrayList) TimelineDomain(org.apache.hadoop.yarn.api.records.timeline.TimelineDomain) KeyParser(org.apache.hadoop.yarn.server.timeline.util.LeveldbUtils.KeyParser)

Example 7 with TimelineDomains

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

the class TimelineStoreTestUtils method testGetDomains.

public void testGetDomains() throws IOException {
    TimelineDomains actualDomains = store.getDomains("owner_1");
    assertEquals(2, actualDomains.getDomains().size());
    verifyDomainInfo(domain3, actualDomains.getDomains().get(0));
    verifyDomainInfo(domain1, actualDomains.getDomains().get(1));
    // owner without any domain
    actualDomains = store.getDomains("owner_4");
    assertEquals(0, actualDomains.getDomains().size());
}
Also used : TimelineDomains(org.apache.hadoop.yarn.api.records.timeline.TimelineDomains)

Example 8 with TimelineDomains

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

the class TestTimelineWebServices method testGetDomains.

@Test
public void testGetDomains() throws Exception {
    WebResource r = resource();
    ClientResponse response = r.path("ws").path("v1").path("timeline").path("domain").queryParam("owner", "owner_1").accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, response.getType().toString());
    TimelineDomains domains = response.getEntity(TimelineDomains.class);
    Assert.assertEquals(2, domains.getDomains().size());
    for (int i = 0; i < domains.getDomains().size(); ++i) {
        verifyDomain(domains.getDomains().get(i), i == 0 ? "domain_id_4" : "domain_id_1");
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) TimelineDomains(org.apache.hadoop.yarn.api.records.timeline.TimelineDomains) WebResource(com.sun.jersey.api.client.WebResource) Test(org.junit.Test)

Aggregations

TimelineDomains (org.apache.hadoop.yarn.api.records.timeline.TimelineDomains)8 TimelineDomain (org.apache.hadoop.yarn.api.records.timeline.TimelineDomain)3 ClientResponse (com.sun.jersey.api.client.ClientResponse)2 WebResource (com.sun.jersey.api.client.WebResource)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 File (java.io.File)1 IOException (java.io.IOException)1 Configuration (org.apache.hadoop.conf.Configuration)1 TimelineEntities (org.apache.hadoop.yarn.api.records.timeline.TimelineEntities)1 TimelineEntity (org.apache.hadoop.yarn.api.records.timeline.TimelineEntity)1 TimelinePutResponse (org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse)1 TimelineClient (org.apache.hadoop.yarn.client.api.TimelineClient)1 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)1 AdminACLsManager (org.apache.hadoop.yarn.security.AdminACLsManager)1 TimelineDelegationTokenIdentifier (org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier)1 KeyParser (org.apache.hadoop.yarn.server.timeline.util.LeveldbUtils.KeyParser)1 DBIterator (org.iq80.leveldb.DBIterator)1