use of org.apache.hadoop.yarn.api.records.timeline.TimelineEntities in project hadoop by apache.
the class TestRollingLevelDBTimelineStore method testRelatingToEntityInSamePut.
@Test
public void testRelatingToEntityInSamePut() throws IOException {
TimelineEntity entityToRelate = new TimelineEntity();
entityToRelate.setEntityType("TEST_ENTITY_TYPE_2");
entityToRelate.setEntityId("TEST_ENTITY_ID_2");
entityToRelate.setDomainId("TEST_DOMAIN");
TimelineEntity entityToStore = new TimelineEntity();
entityToStore.setEntityType("TEST_ENTITY_TYPE_1");
entityToStore.setEntityId("TEST_ENTITY_ID_1");
entityToStore.setDomainId("TEST_DOMAIN");
entityToStore.addRelatedEntity("TEST_ENTITY_TYPE_2", "TEST_ENTITY_ID_2");
TimelineEntities entities = new TimelineEntities();
entities.addEntity(entityToStore);
entities.addEntity(entityToRelate);
store.put(entities);
TimelineEntity entityToGet = store.getEntity("TEST_ENTITY_ID_2", "TEST_ENTITY_TYPE_2", null);
Assert.assertNotNull(entityToGet);
Assert.assertEquals("TEST_DOMAIN", entityToGet.getDomainId());
Assert.assertEquals("TEST_ENTITY_TYPE_1", entityToGet.getRelatedEntities().keySet().iterator().next());
Assert.assertEquals("TEST_ENTITY_ID_1", entityToGet.getRelatedEntities().values().iterator().next().iterator().next());
}
use of org.apache.hadoop.yarn.api.records.timeline.TimelineEntities in project hadoop by apache.
the class TestTimelineDataManager method testGetOldEntitiesWithOutDomainId.
@Test
public void testGetOldEntitiesWithOutDomainId() throws Exception {
TimelineEntities entities = dataManaer.getEntities("OLD_ENTITY_TYPE_1", null, null, null, null, null, null, null, null, UserGroupInformation.getCurrentUser());
Assert.assertEquals(2, entities.getEntities().size());
Assert.assertEquals("OLD_ENTITY_ID_2", entities.getEntities().get(0).getEntityId());
Assert.assertEquals("OLD_ENTITY_TYPE_1", entities.getEntities().get(0).getEntityType());
Assert.assertEquals(TimelineDataManager.DEFAULT_DOMAIN_ID, entities.getEntities().get(0).getDomainId());
Assert.assertEquals("OLD_ENTITY_ID_1", entities.getEntities().get(1).getEntityId());
Assert.assertEquals("OLD_ENTITY_TYPE_1", entities.getEntities().get(1).getEntityType());
Assert.assertEquals(TimelineDataManager.DEFAULT_DOMAIN_ID, entities.getEntities().get(1).getDomainId());
}
use of org.apache.hadoop.yarn.api.records.timeline.TimelineEntities in project hadoop by apache.
the class TestTimelineDataManager method testUpdatingOldEntityWithoutDomainId.
@Test
public void testUpdatingOldEntityWithoutDomainId() throws Exception {
// Set the domain to the default domain when updating
TimelineEntity entity = new TimelineEntity();
entity.setEntityType("OLD_ENTITY_TYPE_1");
entity.setEntityId("OLD_ENTITY_ID_1");
entity.setDomainId(TimelineDataManager.DEFAULT_DOMAIN_ID);
entity.addOtherInfo("NEW_OTHER_INFO_KEY", "NEW_OTHER_INFO_VALUE");
TimelineEntities entities = new TimelineEntities();
entities.addEntity(entity);
TimelinePutResponse response = dataManaer.postEntities(entities, UserGroupInformation.getCurrentUser());
Assert.assertEquals(0, response.getErrors().size());
entity = store.getEntity("OLD_ENTITY_ID_1", "OLD_ENTITY_TYPE_1", null);
Assert.assertNotNull(entity);
// Even in leveldb, the domain is updated to the default domain Id
Assert.assertEquals(TimelineDataManager.DEFAULT_DOMAIN_ID, entity.getDomainId());
Assert.assertEquals(1, entity.getOtherInfo().size());
Assert.assertEquals("NEW_OTHER_INFO_KEY", entity.getOtherInfo().keySet().iterator().next());
Assert.assertEquals("NEW_OTHER_INFO_VALUE", entity.getOtherInfo().values().iterator().next());
// Set the domain to the non-default domain when updating
entity = new TimelineEntity();
entity.setEntityType("OLD_ENTITY_TYPE_1");
entity.setEntityId("OLD_ENTITY_ID_2");
entity.setDomainId("NON_DEFAULT");
entity.addOtherInfo("NEW_OTHER_INFO_KEY", "NEW_OTHER_INFO_VALUE");
entities = new TimelineEntities();
entities.addEntity(entity);
response = dataManaer.postEntities(entities, UserGroupInformation.getCurrentUser());
Assert.assertEquals(1, response.getErrors().size());
Assert.assertEquals(TimelinePutResponse.TimelinePutError.ACCESS_DENIED, response.getErrors().get(0).getErrorCode());
entity = store.getEntity("OLD_ENTITY_ID_2", "OLD_ENTITY_TYPE_1", null);
Assert.assertNotNull(entity);
// In leveldb, the domain Id is still null
Assert.assertNull(entity.getDomainId());
// Updating is not executed
Assert.assertEquals(0, entity.getOtherInfo().size());
}
use of org.apache.hadoop.yarn.api.records.timeline.TimelineEntities in project hadoop by apache.
the class TestTimelineDataManager method testGetEntitiesAclEnabled.
@Test
public void testGetEntitiesAclEnabled() throws Exception {
AdminACLsManager oldAdminACLsManager = aclsManager.setAdminACLsManager(adminACLsManager);
try {
TimelineEntities entities = dataManaer.getEntities("ACL_ENTITY_TYPE_1", null, null, null, null, null, null, 1l, null, UserGroupInformation.createUserForTesting("owner_1", new String[] { "group1" }));
Assert.assertEquals(1, entities.getEntities().size());
Assert.assertEquals("ACL_ENTITY_ID_11", entities.getEntities().get(0).getEntityId());
} finally {
aclsManager.setAdminACLsManager(oldAdminACLsManager);
}
}
use of org.apache.hadoop.yarn.api.records.timeline.TimelineEntities in project hadoop by apache.
the class TimelineStoreTestUtils method loadTestDomainData.
protected void loadTestDomainData() throws IOException {
domain1 = new TimelineDomain();
domain1.setId("domain_id_1");
domain1.setDescription("description_1");
domain1.setOwner("owner_1");
domain1.setReaders("reader_user_1 reader_group_1");
domain1.setWriters("writer_user_1 writer_group_1");
store.put(domain1);
domain2 = new TimelineDomain();
domain2.setId("domain_id_2");
domain2.setDescription("description_2");
domain2.setOwner("owner_2");
domain2.setReaders("reader_user_2 reader_group_2");
domain2.setWriters("writer_user_2 writer_group_2");
store.put(domain2);
// Wait a second before updating the domain information
elapsedTime = 1000;
try {
Thread.sleep(elapsedTime);
} catch (InterruptedException e) {
throw new IOException(e);
}
domain2.setDescription("description_3");
domain2.setOwner("owner_3");
domain2.setReaders("reader_user_3 reader_group_3");
domain2.setWriters("writer_user_3 writer_group_3");
store.put(domain2);
domain3 = new TimelineDomain();
domain3.setId("domain_id_4");
domain3.setDescription("description_4");
domain3.setOwner("owner_1");
domain3.setReaders("reader_user_4 reader_group_4");
domain3.setWriters("writer_user_4 writer_group_4");
store.put(domain3);
TimelineEntities entities = new TimelineEntities();
if (store instanceof LeveldbTimelineStore) {
LeveldbTimelineStore leveldb = (LeveldbTimelineStore) store;
entities.setEntities(Collections.singletonList(createEntity("ACL_ENTITY_ID_11", "ACL_ENTITY_TYPE_1", 63l, null, null, null, null, "domain_id_4")));
leveldb.put(entities);
entities.setEntities(Collections.singletonList(createEntity("ACL_ENTITY_ID_22", "ACL_ENTITY_TYPE_1", 64l, null, null, null, null, "domain_id_2")));
leveldb.put(entities);
}
}
Aggregations