Java Code Examples for org.apache.hadoop.yarn.api.records.timeline.TimelineDomain

The following examples show how to use org.apache.hadoop.yarn.api.records.timeline.TimelineDomain. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: hadoop   Source File: TimelineACLsManager.java    License: Apache License 2.0 6 votes vote down vote up
public boolean checkAccess(UserGroupInformation callerUGI,
    TimelineDomain domain) throws YarnException, IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Verifying the access of "
        + (callerUGI == null ? null : callerUGI.getShortUserName())
        + " on the timeline domain " + domain);
  }

  if (!adminAclsManager.areACLsEnabled()) {
    return true;
  }

  String owner = domain.getOwner();
  if (owner == null || owner.length() == 0) {
    throw new YarnException("Owner information of the timeline domain "
        + domain.getId() + " is corrupted.");
  }
  if (callerUGI != null
      && (adminAclsManager.isAdmin(callerUGI) ||
          callerUGI.getShortUserName().equals(owner))) {
    return true;
  }
  return false;
}
 
Example 2
Source Project: hadoop   Source File: MemoryTimelineStore.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public TimelineDomain getDomain(String domainId)
    throws IOException {
  TimelineDomain domain = domainsById.get(domainId);
  if (domain == null) {
    return null;
  } else {
    return createTimelineDomain(
        domain.getId(),
        domain.getDescription(),
        domain.getOwner(),
        domain.getReaders(),
        domain.getWriters(),
        domain.getCreatedTime(),
        domain.getModifiedTime());
  }
}
 
Example 3
Source Project: hadoop   Source File: MemoryTimelineStore.java    License: Apache License 2.0 6 votes vote down vote up
public void put(TimelineDomain domain) throws IOException {
  TimelineDomain domainToReplace =
      domainsById.get(domain.getId());
  Long currentTimestamp = System.currentTimeMillis();
  TimelineDomain domainToStore = createTimelineDomain(
      domain.getId(), domain.getDescription(), domain.getOwner(),
      domain.getReaders(), domain.getWriters(),
      (domainToReplace == null ?
          currentTimestamp : domainToReplace.getCreatedTime()),
      currentTimestamp);
  domainsById.put(domainToStore.getId(), domainToStore);
  Set<TimelineDomain> domainsByOneOwner =
      domainsByOwner.get(domainToStore.getOwner());
  if (domainsByOneOwner == null) {
    domainsByOneOwner = new HashSet<TimelineDomain>();
    domainsByOwner.put(domainToStore.getOwner(), domainsByOneOwner);
  }
  if (domainToReplace != null) {
    domainsByOneOwner.remove(domainToReplace);
  }
  domainsByOneOwner.add(domainToStore);
}
 
Example 4
Source Project: hadoop   Source File: TimelineDataManager.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Add or update an domain. If the domain already exists, only the owner
 * and the admin can update it.
 */
public void putDomain(TimelineDomain domain,
    UserGroupInformation callerUGI) throws YarnException, IOException {
  TimelineDomain existingDomain =
      store.getDomain(domain.getId());
  if (existingDomain != null) {
    if (!timelineACLsManager.checkAccess(callerUGI, existingDomain)) {
      throw new YarnException(callerUGI.getShortUserName() +
          " is not allowed to override an existing domain " +
          existingDomain.getId());
    }
    // Set it again in case ACLs are not enabled: The domain can be
    // modified by every body, but the owner is not changed.
    domain.setOwner(existingDomain.getOwner());
  }
  store.put(domain);
  // If the domain exists already, it is likely to be in the cache.
  // We need to invalidate it.
  if (existingDomain != null) {
    timelineACLsManager.replaceIfExist(domain);
  }
}
 
Example 5
Source Project: hadoop   Source File: TestTimelineAuthenticationFilter.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testPutDomains() throws Exception {
  KerberosTestUtils.doAs(HTTP_USER + "/localhost", new Callable<Void>() {
    @Override
    public Void call() throws Exception {
      TimelineClient client = createTimelineClientForUGI();
      TimelineDomain domainToStore = new TimelineDomain();
      domainToStore.setId(TestTimelineAuthenticationFilter.class.getName());
      domainToStore.setReaders("*");
      domainToStore.setWriters("*");
      client.putDomain(domainToStore);
      TimelineDomain domainToRead =
          testTimelineServer.getTimelineStore().getDomain(
              TestTimelineAuthenticationFilter.class.getName());
      Assert.assertNotNull(domainToRead);
      return null;
    }
  });
}
 
Example 6
Source Project: hadoop   Source File: TestTimelineACLsManager.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testYarnACLsEnabledForDomain() throws Exception {
  Configuration conf = new YarnConfiguration();
  conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
  conf.set(YarnConfiguration.YARN_ADMIN_ACL, "admin");
  TimelineACLsManager timelineACLsManager =
      new TimelineACLsManager(conf);
  TimelineDomain domain = new TimelineDomain();
  domain.setOwner("owner");
  Assert.assertTrue(
      "Owner should be allowed to access",
      timelineACLsManager.checkAccess(
          UserGroupInformation.createRemoteUser("owner"), domain));
  Assert.assertFalse(
      "Other shouldn't be allowed to access",
      timelineACLsManager.checkAccess(
          UserGroupInformation.createRemoteUser("other"), domain));
  Assert.assertTrue(
      "Admin should be allowed to access",
      timelineACLsManager.checkAccess(
          UserGroupInformation.createRemoteUser("admin"), domain));
}
 
Example 7
Source Project: hadoop   Source File: TestTimelineACLsManager.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCorruptedOwnerInfoForDomain() throws Exception {
  Configuration conf = new YarnConfiguration();
  conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
  conf.set(YarnConfiguration.YARN_ADMIN_ACL, "owner");
  TimelineACLsManager timelineACLsManager =
      new TimelineACLsManager(conf);
  TimelineDomain domain = new TimelineDomain();
  try {
    timelineACLsManager.checkAccess(
        UserGroupInformation.createRemoteUser("owner"), domain);
    Assert.fail("Exception is expected");
  } catch (YarnException e) {
    Assert.assertTrue("It's not the exact expected exception", e.getMessage()
        .contains("is corrupted."));
  }
}
 
Example 8
Source Project: hadoop   Source File: TimelineStoreTestUtils.java    License: Apache License 2.0 6 votes vote down vote up
public void testGetDomain() throws IOException {
  TimelineDomain actualDomain1 =
      store.getDomain(domain1.getId());
  verifyDomainInfo(domain1, actualDomain1);
  assertTrue(actualDomain1.getCreatedTime() > 0);
  assertTrue(actualDomain1.getModifiedTime() > 0);
  assertEquals(
      actualDomain1.getCreatedTime(), actualDomain1.getModifiedTime());

  TimelineDomain actualDomain2 =
      store.getDomain(domain2.getId());
  verifyDomainInfo(domain2, actualDomain2);
  assertEquals("domain_id_2", actualDomain2.getId());
  assertTrue(actualDomain2.getCreatedTime() > 0);
  assertTrue(actualDomain2.getModifiedTime() > 0);
  assertTrue(
      actualDomain2.getCreatedTime() < actualDomain2.getModifiedTime());
}
 
Example 9
Source Project: big-c   Source File: TimelineACLsManager.java    License: Apache License 2.0 6 votes vote down vote up
public boolean checkAccess(UserGroupInformation callerUGI,
    TimelineDomain domain) throws YarnException, IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Verifying the access of "
        + (callerUGI == null ? null : callerUGI.getShortUserName())
        + " on the timeline domain " + domain);
  }

  if (!adminAclsManager.areACLsEnabled()) {
    return true;
  }

  String owner = domain.getOwner();
  if (owner == null || owner.length() == 0) {
    throw new YarnException("Owner information of the timeline domain "
        + domain.getId() + " is corrupted.");
  }
  if (callerUGI != null
      && (adminAclsManager.isAdmin(callerUGI) ||
          callerUGI.getShortUserName().equals(owner))) {
    return true;
  }
  return false;
}
 
Example 10
Source Project: big-c   Source File: MemoryTimelineStore.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public TimelineDomain getDomain(String domainId)
    throws IOException {
  TimelineDomain domain = domainsById.get(domainId);
  if (domain == null) {
    return null;
  } else {
    return createTimelineDomain(
        domain.getId(),
        domain.getDescription(),
        domain.getOwner(),
        domain.getReaders(),
        domain.getWriters(),
        domain.getCreatedTime(),
        domain.getModifiedTime());
  }
}
 
Example 11
Source Project: big-c   Source File: MemoryTimelineStore.java    License: Apache License 2.0 6 votes vote down vote up
public void put(TimelineDomain domain) throws IOException {
  TimelineDomain domainToReplace =
      domainsById.get(domain.getId());
  Long currentTimestamp = System.currentTimeMillis();
  TimelineDomain domainToStore = createTimelineDomain(
      domain.getId(), domain.getDescription(), domain.getOwner(),
      domain.getReaders(), domain.getWriters(),
      (domainToReplace == null ?
          currentTimestamp : domainToReplace.getCreatedTime()),
      currentTimestamp);
  domainsById.put(domainToStore.getId(), domainToStore);
  Set<TimelineDomain> domainsByOneOwner =
      domainsByOwner.get(domainToStore.getOwner());
  if (domainsByOneOwner == null) {
    domainsByOneOwner = new HashSet<TimelineDomain>();
    domainsByOwner.put(domainToStore.getOwner(), domainsByOneOwner);
  }
  if (domainToReplace != null) {
    domainsByOneOwner.remove(domainToReplace);
  }
  domainsByOneOwner.add(domainToStore);
}
 
Example 12
Source Project: big-c   Source File: TimelineDataManager.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Add or update an domain. If the domain already exists, only the owner
 * and the admin can update it.
 */
public void putDomain(TimelineDomain domain,
    UserGroupInformation callerUGI) throws YarnException, IOException {
  TimelineDomain existingDomain =
      store.getDomain(domain.getId());
  if (existingDomain != null) {
    if (!timelineACLsManager.checkAccess(callerUGI, existingDomain)) {
      throw new YarnException(callerUGI.getShortUserName() +
          " is not allowed to override an existing domain " +
          existingDomain.getId());
    }
    // Set it again in case ACLs are not enabled: The domain can be
    // modified by every body, but the owner is not changed.
    domain.setOwner(existingDomain.getOwner());
  }
  store.put(domain);
  // If the domain exists already, it is likely to be in the cache.
  // We need to invalidate it.
  if (existingDomain != null) {
    timelineACLsManager.replaceIfExist(domain);
  }
}
 
Example 13
Source Project: big-c   Source File: TestTimelineAuthenticationFilter.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testPutDomains() throws Exception {
  KerberosTestUtils.doAs(HTTP_USER + "/localhost", new Callable<Void>() {
    @Override
    public Void call() throws Exception {
      TimelineClient client = createTimelineClientForUGI();
      TimelineDomain domainToStore = new TimelineDomain();
      domainToStore.setId(TestTimelineAuthenticationFilter.class.getName());
      domainToStore.setReaders("*");
      domainToStore.setWriters("*");
      client.putDomain(domainToStore);
      TimelineDomain domainToRead =
          testTimelineServer.getTimelineStore().getDomain(
              TestTimelineAuthenticationFilter.class.getName());
      Assert.assertNotNull(domainToRead);
      return null;
    }
  });
}
 
Example 14
Source Project: big-c   Source File: TestTimelineACLsManager.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testYarnACLsEnabledForDomain() throws Exception {
  Configuration conf = new YarnConfiguration();
  conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
  conf.set(YarnConfiguration.YARN_ADMIN_ACL, "admin");
  TimelineACLsManager timelineACLsManager =
      new TimelineACLsManager(conf);
  TimelineDomain domain = new TimelineDomain();
  domain.setOwner("owner");
  Assert.assertTrue(
      "Owner should be allowed to access",
      timelineACLsManager.checkAccess(
          UserGroupInformation.createRemoteUser("owner"), domain));
  Assert.assertFalse(
      "Other shouldn't be allowed to access",
      timelineACLsManager.checkAccess(
          UserGroupInformation.createRemoteUser("other"), domain));
  Assert.assertTrue(
      "Admin should be allowed to access",
      timelineACLsManager.checkAccess(
          UserGroupInformation.createRemoteUser("admin"), domain));
}
 
Example 15
Source Project: big-c   Source File: TestTimelineACLsManager.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCorruptedOwnerInfoForDomain() throws Exception {
  Configuration conf = new YarnConfiguration();
  conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
  conf.set(YarnConfiguration.YARN_ADMIN_ACL, "owner");
  TimelineACLsManager timelineACLsManager =
      new TimelineACLsManager(conf);
  TimelineDomain domain = new TimelineDomain();
  try {
    timelineACLsManager.checkAccess(
        UserGroupInformation.createRemoteUser("owner"), domain);
    Assert.fail("Exception is expected");
  } catch (YarnException e) {
    Assert.assertTrue("It's not the exact expected exception", e.getMessage()
        .contains("is corrupted."));
  }
}
 
Example 16
Source Project: big-c   Source File: TimelineStoreTestUtils.java    License: Apache License 2.0 6 votes vote down vote up
public void testGetDomain() throws IOException {
  TimelineDomain actualDomain1 =
      store.getDomain(domain1.getId());
  verifyDomainInfo(domain1, actualDomain1);
  assertTrue(actualDomain1.getCreatedTime() > 0);
  assertTrue(actualDomain1.getModifiedTime() > 0);
  assertEquals(
      actualDomain1.getCreatedTime(), actualDomain1.getModifiedTime());

  TimelineDomain actualDomain2 =
      store.getDomain(domain2.getId());
  verifyDomainInfo(domain2, actualDomain2);
  assertEquals("domain_id_2", actualDomain2.getId());
  assertTrue(actualDomain2.getCreatedTime() > 0);
  assertTrue(actualDomain2.getModifiedTime() > 0);
  assertTrue(
      actualDomain2.getCreatedTime() < actualDomain2.getModifiedTime());
}
 
Example 17
Source Project: tez   Source File: ATSV15HistoryACLPolicyManager.java    License: Apache License 2.0 6 votes vote down vote up
private void createTimelineDomain(ApplicationId applicationId,
    String domainId, Configuration tezConf, DAGAccessControls dagAccessControls)
    throws IOException, HistoryACLPolicyException {
  TimelineDomain timelineDomain = new TimelineDomain();
  timelineDomain.setId(domainId);

  ACLConfigurationParser parser = new ACLConfigurationParser(tezConf, false);
  timelineDomain.setReaders(getMergedViewACLs(parser, dagAccessControls));
  timelineDomain.setWriters(user);

  // Use dummy app attempt id
  ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(applicationId, 1);
  try {
    if (timelineClient != null) {
      timelineClient.putDomain(appAttemptId, timelineDomain);
    }
  } catch (Exception e) {
    LOG.warn("Could not post timeline domain", e);
    throw new
      HistoryACLPolicyException("Fail to create ACL-related domain in Timeline", e);
  }
}
 
Example 18
Source Project: tez   Source File: ATSHistoryACLPolicyManager.java    License: Apache License 2.0 6 votes vote down vote up
private void createTimelineDomain(String domainId, Configuration tezConf,
    DAGAccessControls dagAccessControls) throws IOException, HistoryACLPolicyException {
  TimelineDomain timelineDomain = new TimelineDomain();
  timelineDomain.setId(domainId);

  ACLConfigurationParser parser = new ACLConfigurationParser(tezConf, false);
  timelineDomain.setReaders(getMergedViewACLs(parser, dagAccessControls));
  timelineDomain.setWriters(user);

  try {
    if (timelineClient != null) {
      timelineClient.putDomain(timelineDomain);
    }
  } catch (Exception e) {
    LOG.warn("Could not post timeline domain", e);
    throw new
      HistoryACLPolicyException("Fail to create ACL-related domain in Timeline", e);
  }
}
 
Example 19
Source Project: hadoop   Source File: TestTimelineClient.java    License: Apache License 2.0 5 votes vote down vote up
private static ClientResponse mockDomainClientResponse(
    TimelineClientImpl client, ClientResponse.Status status,
    boolean hasRuntimeError) {
  ClientResponse response = mock(ClientResponse.class);
  if (hasRuntimeError) {
    doThrow(new ClientHandlerException(new ConnectException())).when(client)
        .doPostingObject(any(TimelineDomain.class), any(String.class));
    return response;
  }
  doReturn(response).when(client)
      .doPostingObject(any(TimelineDomain.class), any(String.class));
  when(response.getClientResponseStatus()).thenReturn(status);
  return response;
}
 
Example 20
Source Project: hadoop   Source File: TestTimelineClient.java    License: Apache License 2.0 5 votes vote down vote up
public static TimelineDomain generateDomain() {
  TimelineDomain domain = new TimelineDomain();
  domain.setId("namesapce id");
  domain.setDescription("domain description");
  domain.setOwner("domain owner");
  domain.setReaders("domain_reader");
  domain.setWriters("domain_writer");
  domain.setCreatedTime(0L);
  domain.setModifiedTime(1L);
  return domain;
}
 
Example 21
Source Project: hadoop   Source File: TimelineACLsManager.java    License: Apache License 2.0 5 votes vote down vote up
private AccessControlListExt loadDomainFromTimelineStore(
    String domainId) throws IOException {
  if (store == null) {
    return null;
  }
  TimelineDomain domain = store.getDomain(domainId);
  if (domain == null) {
    return null;
  } else {
    return putDomainIntoCache(domain);
  }
}
 
Example 22
Source Project: hadoop   Source File: TimelineACLsManager.java    License: Apache License 2.0 5 votes vote down vote up
private AccessControlListExt putDomainIntoCache(
    TimelineDomain domain) {
  Map<ApplicationAccessType, AccessControlList> acls
  = new HashMap<ApplicationAccessType, AccessControlList>(2);
  acls.put(ApplicationAccessType.VIEW_APP,
      new AccessControlList(StringHelper.cjoin(domain.getReaders())));
  acls.put(ApplicationAccessType.MODIFY_APP,
      new AccessControlList(StringHelper.cjoin(domain.getWriters())));
  AccessControlListExt aclExt =
      new AccessControlListExt(domain.getOwner(), acls);
  aclExts.put(domain.getId(), aclExt);
  return aclExt;
}
 
Example 23
Source Project: hadoop   Source File: TimelineWebServices.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Return a single domain of the given domain Id.
 */
@GET
@Path("/domain/{domainId}")
@Produces({ MediaType.APPLICATION_JSON /* , MediaType.APPLICATION_XML */})
public TimelineDomain getDomain(
    @Context HttpServletRequest req,
    @Context HttpServletResponse res,
    @PathParam("domainId") String domainId) {
  init(res);
  domainId = parseStr(domainId);
  if (domainId == null || domainId.length() == 0) {
    throw new BadRequestException("Domain ID is not specified.");
  }
  TimelineDomain domain = null;
  try {
    domain = timelineDataManager.getDomain(
        parseStr(domainId), getUser(req));
  } catch (Exception e) {
    LOG.error("Error getting domain", e);
    throw new WebApplicationException(e,
        Response.Status.INTERNAL_SERVER_ERROR);
  }
  if (domain == null) {
    throw new NotFoundException("Timeline domain ["
        + domainId + "] is not found");
  }
  return domain;
}
 
Example 24
Source Project: hadoop   Source File: MemoryTimelineStore.java    License: Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 25
Source Project: hadoop   Source File: MemoryTimelineStore.java    License: Apache License 2.0 5 votes vote down vote up
private static TimelineDomain createTimelineDomain(
    String id, String description, String owner,
    String readers, String writers,
    Long createdTime, Long modifiedTime) {
  TimelineDomain domainToStore = new TimelineDomain();
  domainToStore.setId(id);
  domainToStore.setDescription(description);
  domainToStore.setOwner(owner);
  domainToStore.setReaders(readers);
  domainToStore.setWriters(writers);
  domainToStore.setCreatedTime(createdTime);
  domainToStore.setModifiedTime(modifiedTime);
  return domainToStore;
}
 
Example 26
Source Project: hadoop   Source File: TimelineDataManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get a single domain of the particular ID. If callerUGI is not the owner
 * or the admin of the domain, null will be returned.
 */
public TimelineDomain getDomain(String domainId,
    UserGroupInformation callerUGI) throws YarnException, IOException {
  TimelineDomain domain = store.getDomain(domainId);
  if (domain != null) {
    if (timelineACLsManager.checkAccess(callerUGI, domain)) {
      return domain;
    }
  }
  return null;
}
 
Example 27
Source Project: hadoop   Source File: TestTimelineACLsManager.java    License: Apache License 2.0 5 votes vote down vote up
@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));
}
 
Example 28
Source Project: hadoop   Source File: TestTimelineACLsManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public TimelineDomain getDomain(
    String domainId) throws IOException {
  if (domainId == null) {
    return null;
  } else {
    return domain;
  }
}
 
Example 29
Source Project: hadoop   Source File: TestTimelineWebServices.java    License: Apache License 2.0 5 votes vote down vote up
@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);
  Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  TimelineDomain domain = response.getEntity(TimelineDomain.class);
  verifyDomain(domain, "domain_id_1");
}
 
Example 30
Source Project: hadoop   Source File: TestTimelineWebServices.java    License: Apache License 2.0 5 votes vote down vote up
@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);
    Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    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);
    Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    Assert.assertEquals(ClientResponse.Status.NOT_FOUND,
        response.getClientResponseStatus());
  } finally {
    timelineACLsManager.setAdminACLsManager(oldAdminACLsManager);
  }
}