Java 类org.apache.hadoop.yarn.api.records.timeline.TimelineDomains 实例源码

项目:hadoop    文件:TimelineDataManager.java   
/**
 * Get all the domains that belong to the given owner. If callerUGI is not
 * the owner or the admin of the domain, empty list is going to be returned.
 */
public TimelineDomains getDomains(String owner,
    UserGroupInformation callerUGI) throws YarnException, IOException {
  TimelineDomains domains = store.getDomains(owner);
  boolean hasAccess = true;
  if (domains.getDomains().size() > 0) {
    // The owner for each domain is the same, just need to check one
    hasAccess = timelineACLsManager.checkAccess(
        callerUGI, domains.getDomains().get(0));
  }
  if (hasAccess) {
    return domains;
  } else {
    return new TimelineDomains();
  }
}
项目:hadoop    文件:TestTimelineWebServices.java   
@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);
  Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  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");
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestTimelineWebServices.java   
@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);
  Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  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");
  }
}
项目:big-c    文件:TimelineDataManager.java   
/**
 * Get all the domains that belong to the given owner. If callerUGI is not
 * the owner or the admin of the domain, empty list is going to be returned.
 */
public TimelineDomains getDomains(String owner,
    UserGroupInformation callerUGI) throws YarnException, IOException {
  TimelineDomains domains = store.getDomains(owner);
  boolean hasAccess = true;
  if (domains.getDomains().size() > 0) {
    // The owner for each domain is the same, just need to check one
    hasAccess = timelineACLsManager.checkAccess(
        callerUGI, domains.getDomains().get(0));
  }
  if (hasAccess) {
    return domains;
  } else {
    return new TimelineDomains();
  }
}
项目:big-c    文件:TestTimelineWebServices.java   
@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);
  Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  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");
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TimelineDataManager.java   
/**
 * Get all the domains that belong to the given owner. If callerUGI is not
 * the owner or the admin of the domain, empty list is going to be returned.
 */
public TimelineDomains getDomains(String owner,
    UserGroupInformation callerUGI) throws YarnException, IOException {
  TimelineDomains domains = store.getDomains(owner);
  boolean hasAccess = true;
  if (domains.getDomains().size() > 0) {
    // The owner for each domain is the same, just need to check one
    hasAccess = timelineACLsManager.checkAccess(
        callerUGI, domains.getDomains().get(0));
  }
  if (hasAccess) {
    return domains;
  } else {
    return new TimelineDomains();
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestTimelineWebServices.java   
@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);
  Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  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");
  }
}
项目:hops    文件:TestTimelineWebServices.java   
@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);
  Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  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");
  }
}
项目:hadoop    文件:TimelineWebServices.java   
/**
 * Return a list of domains of the given owner.
 */
@GET
@Path("/domain")
@Produces({ MediaType.APPLICATION_JSON /* , MediaType.APPLICATION_XML */})
public TimelineDomains getDomains(
    @Context HttpServletRequest req,
    @Context HttpServletResponse res,
    @QueryParam("owner") String owner) {
  init(res);
  owner = parseStr(owner);
  UserGroupInformation callerUGI = getUser(req);
  if (owner == null || owner.length() == 0) {
    if (callerUGI == null) {
      throw new BadRequestException("Domain owner is not specified.");
    } else {
      // By default it's going to list the caller's domains
      owner = callerUGI.getShortUserName();
    }
  }
  try {
    return timelineDataManager.getDomains(owner, callerUGI);
  } catch (Exception e) {
    LOG.error("Error getting domains", e);
    throw new WebApplicationException(e,
        Response.Status.INTERNAL_SERVER_ERROR);
  }
}
项目:hadoop    文件:MemoryTimelineStore.java   
@Override
public TimelineDomains getDomains(String owner)
    throws IOException {
  List<TimelineDomain> domains = new ArrayList<TimelineDomain>();
  Set<TimelineDomain> domainsOfOneOwner = domainsByOwner.get(owner);
  if (domainsOfOneOwner == null) {
    return new TimelineDomains();
  }
  for (TimelineDomain domain : domainsByOwner.get(owner)) {
    TimelineDomain domainToReturn = createTimelineDomain(
        domain.getId(),
        domain.getDescription(),
        domain.getOwner(),
        domain.getReaders(),
        domain.getWriters(),
        domain.getCreatedTime(),
        domain.getModifiedTime());
    domains.add(domainToReturn);
  }
  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;
}
项目:hadoop    文件:TestTimelineWebServices.java   
@Test
public void testGetDomainsYarnACLsEnabled() throws Exception {
  AdminACLsManager oldAdminACLsManager =
      timelineACLsManager.setAdminACLsManager(adminACLsManager);
  try {
    WebResource r = resource();
    ClientResponse response = r.path("ws").path("v1").path("timeline")
        .path("domain")
        .queryParam("user.name", "owner_1")
        .accept(MediaType.APPLICATION_JSON)
        .get(ClientResponse.class);
    Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    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");
    }

    response = r.path("ws").path("v1").path("timeline")
        .path("domain")
        .queryParam("owner", "owner_1")
        .queryParam("user.name", "tester")
        .accept(MediaType.APPLICATION_JSON)
        .get(ClientResponse.class);
    Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    domains = response.getEntity(TimelineDomains.class);
    Assert.assertEquals(0, domains.getDomains().size());
  } finally {
    timelineACLsManager.setAdminACLsManager(oldAdminACLsManager);
  }
}
项目:hadoop    文件:TimelineStoreTestUtils.java   
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());
}
项目:aliyun-oss-hadoop-fs    文件:TimelineWebServices.java   
/**
 * Return a list of domains of the given owner.
 */
@GET
@Path("/domain")
@Produces({ MediaType.APPLICATION_JSON /* , MediaType.APPLICATION_XML */})
public TimelineDomains getDomains(
    @Context HttpServletRequest req,
    @Context HttpServletResponse res,
    @QueryParam("owner") String owner) {
  init(res);
  owner = parseStr(owner);
  UserGroupInformation callerUGI = getUser(req);
  if (owner == null || owner.length() == 0) {
    if (callerUGI == null) {
      throw new BadRequestException("Domain owner is not specified.");
    } else {
      // By default it's going to list the caller's domains
      owner = callerUGI.getShortUserName();
    }
  }
  try {
    return timelineDataManager.getDomains(owner, callerUGI);
  } catch (Exception e) {
    LOG.error("Error getting domains", e);
    throw new WebApplicationException(e,
        Response.Status.INTERNAL_SERVER_ERROR);
  }
}
项目:aliyun-oss-hadoop-fs    文件:MemoryTimelineStore.java   
@Override
public TimelineDomains getDomains(String owner)
    throws IOException {
  List<TimelineDomain> domains = new ArrayList<TimelineDomain>();
  Set<TimelineDomain> domainsOfOneOwner = domainsByOwner.get(owner);
  if (domainsOfOneOwner == null) {
    return new TimelineDomains();
  }
  for (TimelineDomain domain : domainsByOwner.get(owner)) {
    TimelineDomain domainToReturn = createTimelineDomain(
        domain.getId(),
        domain.getDescription(),
        domain.getOwner(),
        domain.getReaders(),
        domain.getWriters(),
        domain.getCreatedTime(),
        domain.getModifiedTime());
    domains.add(domainToReturn);
  }
  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;
}
项目:aliyun-oss-hadoop-fs    文件:TimelineDataManager.java   
/**
 * Get all the domains that belong to the given owner. If callerUGI is not
 * the owner or the admin of the domain, empty list is going to be returned.
 */
public TimelineDomains getDomains(String owner,
    UserGroupInformation callerUGI) throws YarnException, IOException {
  long startTime = Time.monotonicNow();
  metrics.incrGetDomainsOps();
  try {
    TimelineDomains domains = doGetDomains(owner, callerUGI);
    metrics.incrGetDomainsTotal(domains.getDomains().size());
    return domains;
  } finally {
    metrics.addGetDomainsTime(Time.monotonicNow() - startTime);
  }
}
项目:aliyun-oss-hadoop-fs    文件:TimelineDataManager.java   
private TimelineDomains doGetDomains(String owner,
    UserGroupInformation callerUGI) throws YarnException, IOException {
  TimelineDomains domains = store.getDomains(owner);
  boolean hasAccess = true;
  if (domains.getDomains().size() > 0) {
    // The owner for each domain is the same, just need to check one
    hasAccess = timelineACLsManager.checkAccess(
        callerUGI, domains.getDomains().get(0));
  }
  if (hasAccess) {
    return domains;
  } else {
    return new TimelineDomains();
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestTimelineWebServices.java   
@Test
public void testGetDomainsYarnACLsEnabled() throws Exception {
  AdminACLsManager oldAdminACLsManager =
      timelineACLsManager.setAdminACLsManager(adminACLsManager);
  try {
    WebResource r = resource();
    ClientResponse response = r.path("ws").path("v1").path("timeline")
        .path("domain")
        .queryParam("user.name", "owner_1")
        .accept(MediaType.APPLICATION_JSON)
        .get(ClientResponse.class);
    Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    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");
    }

    response = r.path("ws").path("v1").path("timeline")
        .path("domain")
        .queryParam("owner", "owner_1")
        .queryParam("user.name", "tester")
        .accept(MediaType.APPLICATION_JSON)
        .get(ClientResponse.class);
    Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    domains = response.getEntity(TimelineDomains.class);
    Assert.assertEquals(0, domains.getDomains().size());
  } finally {
    timelineACLsManager.setAdminACLsManager(oldAdminACLsManager);
  }
}
项目:aliyun-oss-hadoop-fs    文件:TimelineStoreTestUtils.java   
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());
}
项目:big-c    文件:TimelineWebServices.java   
/**
 * Return a list of domains of the given owner.
 */
@GET
@Path("/domain")
@Produces({ MediaType.APPLICATION_JSON /* , MediaType.APPLICATION_XML */})
public TimelineDomains getDomains(
    @Context HttpServletRequest req,
    @Context HttpServletResponse res,
    @QueryParam("owner") String owner) {
  init(res);
  owner = parseStr(owner);
  UserGroupInformation callerUGI = getUser(req);
  if (owner == null || owner.length() == 0) {
    if (callerUGI == null) {
      throw new BadRequestException("Domain owner is not specified.");
    } else {
      // By default it's going to list the caller's domains
      owner = callerUGI.getShortUserName();
    }
  }
  try {
    return timelineDataManager.getDomains(owner, callerUGI);
  } catch (Exception e) {
    LOG.error("Error getting domains", e);
    throw new WebApplicationException(e,
        Response.Status.INTERNAL_SERVER_ERROR);
  }
}
项目:big-c    文件:MemoryTimelineStore.java   
@Override
public TimelineDomains getDomains(String owner)
    throws IOException {
  List<TimelineDomain> domains = new ArrayList<TimelineDomain>();
  Set<TimelineDomain> domainsOfOneOwner = domainsByOwner.get(owner);
  if (domainsOfOneOwner == null) {
    return new TimelineDomains();
  }
  for (TimelineDomain domain : domainsByOwner.get(owner)) {
    TimelineDomain domainToReturn = createTimelineDomain(
        domain.getId(),
        domain.getDescription(),
        domain.getOwner(),
        domain.getReaders(),
        domain.getWriters(),
        domain.getCreatedTime(),
        domain.getModifiedTime());
    domains.add(domainToReturn);
  }
  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;
}
项目:big-c    文件:TestTimelineWebServices.java   
@Test
public void testGetDomainsYarnACLsEnabled() throws Exception {
  AdminACLsManager oldAdminACLsManager =
      timelineACLsManager.setAdminACLsManager(adminACLsManager);
  try {
    WebResource r = resource();
    ClientResponse response = r.path("ws").path("v1").path("timeline")
        .path("domain")
        .queryParam("user.name", "owner_1")
        .accept(MediaType.APPLICATION_JSON)
        .get(ClientResponse.class);
    Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    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");
    }

    response = r.path("ws").path("v1").path("timeline")
        .path("domain")
        .queryParam("owner", "owner_1")
        .queryParam("user.name", "tester")
        .accept(MediaType.APPLICATION_JSON)
        .get(ClientResponse.class);
    Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    domains = response.getEntity(TimelineDomains.class);
    Assert.assertEquals(0, domains.getDomains().size());
  } finally {
    timelineACLsManager.setAdminACLsManager(oldAdminACLsManager);
  }
}
项目:big-c    文件:TimelineStoreTestUtils.java   
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());
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TimelineWebServices.java   
/**
 * Return a list of domains of the given owner.
 */
@GET
@Path("/domain")
@Produces({ MediaType.APPLICATION_JSON /* , MediaType.APPLICATION_XML */})
public TimelineDomains getDomains(
    @Context HttpServletRequest req,
    @Context HttpServletResponse res,
    @QueryParam("owner") String owner) {
  init(res);
  owner = parseStr(owner);
  UserGroupInformation callerUGI = getUser(req);
  if (owner == null || owner.length() == 0) {
    if (callerUGI == null) {
      throw new BadRequestException("Domain owner is not specified.");
    } else {
      // By default it's going to list the caller's domains
      owner = callerUGI.getShortUserName();
    }
  }
  try {
    return timelineDataManager.getDomains(owner, callerUGI);
  } catch (Exception e) {
    LOG.error("Error getting domains", e);
    throw new WebApplicationException(e,
        Response.Status.INTERNAL_SERVER_ERROR);
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:MemoryTimelineStore.java   
@Override
public TimelineDomains getDomains(String owner)
    throws IOException {
  List<TimelineDomain> domains = new ArrayList<TimelineDomain>();
  Set<TimelineDomain> domainsOfOneOwner = domainsByOwner.get(owner);
  if (domainsOfOneOwner == null) {
    return new TimelineDomains();
  }
  for (TimelineDomain domain : domainsByOwner.get(owner)) {
    TimelineDomain domainToReturn = createTimelineDomain(
        domain.getId(),
        domain.getDescription(),
        domain.getOwner(),
        domain.getReaders(),
        domain.getWriters(),
        domain.getCreatedTime(),
        domain.getModifiedTime());
    domains.add(domainToReturn);
  }
  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;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestTimelineWebServices.java   
@Test
public void testGetDomainsYarnACLsEnabled() throws Exception {
  AdminACLsManager oldAdminACLsManager =
      timelineACLsManager.setAdminACLsManager(adminACLsManager);
  try {
    WebResource r = resource();
    ClientResponse response = r.path("ws").path("v1").path("timeline")
        .path("domain")
        .queryParam("user.name", "owner_1")
        .accept(MediaType.APPLICATION_JSON)
        .get(ClientResponse.class);
    Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    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");
    }

    response = r.path("ws").path("v1").path("timeline")
        .path("domain")
        .queryParam("owner", "owner_1")
        .queryParam("user.name", "tester")
        .accept(MediaType.APPLICATION_JSON)
        .get(ClientResponse.class);
    Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    domains = response.getEntity(TimelineDomains.class);
    Assert.assertEquals(0, domains.getDomains().size());
  } finally {
    timelineACLsManager.setAdminACLsManager(oldAdminACLsManager);
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TimelineStoreTestUtils.java   
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());
}
项目:hops    文件:TimelineWebServices.java   
/**
 * Return a list of domains of the given owner.
 */
@GET
@Path("/domain")
@Produces({ MediaType.APPLICATION_JSON /* , MediaType.APPLICATION_XML */})
public TimelineDomains getDomains(
    @Context HttpServletRequest req,
    @Context HttpServletResponse res,
    @QueryParam("owner") String owner) {
  init(res);
  owner = parseStr(owner);
  UserGroupInformation callerUGI = getUser(req);
  if (owner == null || owner.length() == 0) {
    if (callerUGI == null) {
      throw new BadRequestException("Domain owner is not specified.");
    } else {
      // By default it's going to list the caller's domains
      owner = callerUGI.getShortUserName();
    }
  }
  try {
    return timelineDataManager.getDomains(owner, callerUGI);
  } catch (Exception e) {
    LOG.error("Error getting domains", e);
    throw new WebApplicationException(e,
        Response.Status.INTERNAL_SERVER_ERROR);
  }
}
项目:hops    文件:TimelineDataManager.java   
/**
 * Get all the domains that belong to the given owner. If callerUGI is not
 * the owner or the admin of the domain, empty list is going to be returned.
 */
public TimelineDomains getDomains(String owner,
    UserGroupInformation callerUGI) throws YarnException, IOException {
  long startTime = Time.monotonicNow();
  metrics.incrGetDomainsOps();
  try {
    TimelineDomains domains = doGetDomains(owner, callerUGI);
    metrics.incrGetDomainsTotal(domains.getDomains().size());
    return domains;
  } finally {
    metrics.addGetDomainsTime(Time.monotonicNow() - startTime);
  }
}
项目:hops    文件:TimelineDataManager.java   
private TimelineDomains doGetDomains(String owner,
    UserGroupInformation callerUGI) throws YarnException, IOException {
  TimelineDomains domains = store.getDomains(owner);
  boolean hasAccess = true;
  if (domains.getDomains().size() > 0) {
    // The owner for each domain is the same, just need to check one
    hasAccess = timelineACLsManager.checkAccess(
        callerUGI, domains.getDomains().get(0));
  }
  if (hasAccess) {
    return domains;
  } else {
    return new TimelineDomains();
  }
}
项目:hops    文件:TestTimelineWebServices.java   
@Test
public void testGetDomainsYarnACLsEnabled() throws Exception {
  AdminACLsManager oldAdminACLsManager =
      timelineACLsManager.setAdminACLsManager(adminACLsManager);
  try {
    WebResource r = resource();
    ClientResponse response = r.path("ws").path("v1").path("timeline")
        .path("domain")
        .queryParam("user.name", "owner_1")
        .accept(MediaType.APPLICATION_JSON)
        .get(ClientResponse.class);
    Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    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");
    }

    response = r.path("ws").path("v1").path("timeline")
        .path("domain")
        .queryParam("owner", "owner_1")
        .queryParam("user.name", "tester")
        .accept(MediaType.APPLICATION_JSON)
        .get(ClientResponse.class);
    Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    domains = response.getEntity(TimelineDomains.class);
    Assert.assertEquals(0, domains.getDomains().size());
  } finally {
    timelineACLsManager.setAdminACLsManager(oldAdminACLsManager);
  }
}
项目:hops    文件:TimelineStoreTestUtils.java   
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());
}
项目:aliyun-oss-hadoop-fs    文件:RollingLevelDBTimelineStore.java   
@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);
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:LeveldbTimelineStore.java   
@Override
public TimelineDomains getDomains(String owner)
    throws IOException {
  DBIterator iterator = null;
  try {
    byte[] prefix = KeyBuilder.newInstance()
        .add(OWNER_LOOKUP_PREFIX).add(owner).getBytesForLookup();
    List<TimelineDomain> domains = new ArrayList<TimelineDomain>();
    for (iterator = db.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_LOOKUP_PREFIX)
          .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);
  }
}
项目:hops    文件:EntityGroupFSTimelineStore.java   
@Override
public TimelineDomains getDomains(String owner) throws IOException {
  return summaryStore.getDomains(owner);
}
项目:hops    文件:RollingLevelDBTimelineStore.java   
@Override
public TimelineDomains getDomains(String owner) throws IOException {
  try (DBIterator iterator = ownerdb.iterator()) {
    byte[] prefix = KeyBuilder.newInstance().add(owner).getBytesForLookup();
    iterator.seek(prefix);
    List<TimelineDomain> domains = new ArrayList<TimelineDomain>();
    while (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;
  }
}
项目:hops    文件:KeyValueBasedTimelineStore.java   
@Override
public TimelineDomains getDomains(String owner)
    throws IOException {
  if (getServiceStopped()) {
    LOG.info("Service stopped, return null for the storage");
    return null;
  }
  List<TimelineDomain> domains = new ArrayList<TimelineDomain>();
  Set<TimelineDomain> domainsOfOneOwner = domainsByOwner.get(owner);
  if (domainsOfOneOwner == null) {
    return new TimelineDomains();
  }
  for (TimelineDomain domain : domainsByOwner.get(owner)) {
    TimelineDomain domainToReturn = KeyValueBasedTimelineStoreUtils
        .createTimelineDomain(
            domain.getId(),
            domain.getDescription(),
            domain.getOwner(),
            domain.getReaders(),
            domain.getWriters(),
            domain.getCreatedTime(),
            domain.getModifiedTime());
    domains.add(domainToReturn);
  }
  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;
}
项目:hadoop    文件:TimelineReader.java   
/**
 * This method retrieves all the domains that belong to a given owner.
 * The domains are sorted according to the created time firstly and the
 * modified time secondly in descending order.
 * 
 * @param owner
 *          the domain owner
 * @return an {@link TimelineDomains} object.
 * @throws IOException
 */
TimelineDomains getDomains(String owner) throws IOException;
项目:aliyun-oss-hadoop-fs    文件:TimelineReader.java   
/**
 * This method retrieves all the domains that belong to a given owner.
 * The domains are sorted according to the created time firstly and the
 * modified time secondly in descending order.
 * 
 * @param owner
 *          the domain owner
 * @return an {@link TimelineDomains} object.
 * @throws IOException
 */
TimelineDomains getDomains(String owner) throws IOException;
项目:big-c    文件:TimelineReader.java   
/**
 * This method retrieves all the domains that belong to a given owner.
 * The domains are sorted according to the created time firstly and the
 * modified time secondly in descending order.
 * 
 * @param owner
 *          the domain owner
 * @return an {@link TimelineDomains} object.
 * @throws IOException
 */
TimelineDomains getDomains(String owner) throws IOException;
项目:hadoop-2.6.0-cdh5.4.3    文件:TimelineReader.java   
/**
 * This method retrieves all the domains that belong to a given owner.
 * The domains are sorted according to the created time firstly and the
 * modified time secondly in descending order.
 * 
 * @param owner
 *          the domain owner
 * @return an {@link TimelineDomains} object.
 * @throws IOException
 */
TimelineDomains getDomains(String owner) throws IOException;