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));
}
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);
}
}
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());
}
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());
}
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();
}
}
Aggregations