@Override public TimelineEntities getEntities(String entityType, Long limit, Long windowStart, Long windowEnd, String fromId, Long fromTs, NameValuePair primaryFilter, Collection<NameValuePair> secondaryFilters, EnumSet<Field> fieldsToRetrieve, CheckAcl checkAcl) throws IOException { LOG.debug("getEntities type={} primary={}", entityType, primaryFilter); Object arg = (primaryFilter == null) ? null : primaryFilter.getValue(); TimelineStore store = getTimelineStoreForRead(entityType, arg); return store.getEntities(entityType, limit, windowStart, windowEnd, fromId, fromTs, primaryFilter, secondaryFilters, fieldsToRetrieve, checkAcl); }
@Override public TimelineEntity getEntity(String entityId, String entityType, EnumSet<Field> fieldsToRetrieve) throws IOException { LOG.debug("getEntity type={} id={}", entityType, entityId); TimelineStore store = getTimelineStoreForRead(entityType, entityId); return store.getEntity(entityId, entityType, fieldsToRetrieve); }
@Override public TimelineDomain getDomain(String domainId) throws IOException { return summaryStore.getDomain(domainId); }
@Override public TimelineEntity getEntity(String entityId, String entityType, EnumSet<Field> fieldsToRetrieve) throws IOException { LOG.debug("getEntity type={} id={}", entityType, entityId); List<TimelineStore> stores = getTimelineStoresForRead(entityId, entityType); for (TimelineStore store : stores) { LOG.debug("Try timeline store {}:{} for the request", store.getName(), store.toString()); TimelineEntity e = store.getEntity(entityId, entityType, fieldsToRetrieve); if (e != null) { return e; } } LOG.debug("getEntity: Found nothing"); return null; }
@Override public TimelineEvents getEntityTimelines(String entityType, SortedSet<String> entityIds, Long limit, Long windowStart, Long windowEnd, Set<String> eventTypes) throws IOException { LOG.debug("getEntityTimelines type={} ids={}", entityType, entityIds); TimelineEvents returnEvents = new TimelineEvents(); for (String entityId : entityIds) { LOG.debug("getEntityTimeline type={} id={}", entityType, entityId); List<TimelineStore> stores = getTimelineStoresForRead(entityId, entityType); for (TimelineStore store : stores) { LOG.debug("Try timeline store {}:{} for the request", store.getName(), store.toString()); SortedSet<String> entityIdSet = new TreeSet<String>(); entityIdSet.add(entityId); TimelineEvents events = store.getEntityTimelines(entityType, entityIdSet, limit, windowStart, windowEnd, eventTypes); returnEvents.addEvents(events.getAllEvents()); } } return returnEvents; }
@Test public void testRelatingToNonExistingEntity() throws IOException { TimelineEntity entityToStore = new TimelineEntity(); entityToStore.setEntityType("TEST_ENTITY_TYPE_1"); entityToStore.setEntityId("TEST_ENTITY_ID_1"); entityToStore.setDomainId(TimelineDataManager.DEFAULT_DOMAIN_ID); entityToStore.addRelatedEntity("TEST_ENTITY_TYPE_2", "TEST_ENTITY_ID_2"); TimelineEntities entities = new TimelineEntities(); entities.addEntity(entityToStore); store.put(entities); TimelineEntity entityToGet = store.getEntity("TEST_ENTITY_ID_2", "TEST_ENTITY_TYPE_2", null); Assert.assertNotNull(entityToGet); Assert.assertEquals("DEFAULT", 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()); }
@Override protected void serviceInit(Configuration conf) throws Exception { TimelineDomain domain = store.getDomain("DEFAULT"); // it is okay to reuse an existing domain even if it was created by another // user of the timeline server before, because it allows everybody to access. if (domain == null) { // create a default domain, which allows everybody to access and modify // the entities in it. domain = new TimelineDomain(); domain.setId(DEFAULT_DOMAIN_ID); domain.setDescription("System Default Domain"); domain.setOwner( UserGroupInformation.getCurrentUser().getShortUserName()); domain.setReaders("*"); domain.setWriters("*"); store.put(domain); } super.serviceInit(conf); }
UserGroupInformation callerUGI) throws YarnException, IOException { TimelineEvents events = null; events = store.getEntityTimelines( entityType, entityIds, TimelineEvents.EventsOfOneEntity eventsOfOneEntity = eventsItr.next(); try { TimelineEntity entity = store.getEntity( eventsOfOneEntity.getEntityId(), eventsOfOneEntity.getEntityType(),
@Before public void setup() throws Exception { fsContext = FileContext.getLocalFSFileContext(); fsPath = new File("target", this.getClass().getSimpleName() + "-tmpDir").getAbsoluteFile(); fsContext.delete(new Path(fsPath.getAbsolutePath()), true); config.set(YarnConfiguration.TIMELINE_SERVICE_LEVELDB_PATH, fsPath.getAbsolutePath()); config.setBoolean(YarnConfiguration.TIMELINE_SERVICE_TTL_ENABLE, false); store = new LeveldbTimelineStore(); store.init(config); store.start(); loadTestEntityData(); loadVerificationEntityData(); loadTestDomainData(); }
@Override public void put(TimelineDomain domain) throws IOException { summaryStore.put(domain); } }
@Override public TimelineDomains getDomains(String owner) throws IOException { return summaryStore.getDomains(owner); }
@Override public TimelineEntities getEntities(String entityType, Long limit, Long windowStart, Long windowEnd, String fromId, Long fromTs, NameValuePair primaryFilter, Collection<NameValuePair> secondaryFilters, EnumSet<Field> fieldsToRetrieve, CheckAcl checkAcl) throws IOException { LOG.debug("getEntities type={} primary={}", entityType, primaryFilter); List<TimelineStore> stores = getTimelineStoresForRead(entityType, primaryFilter, secondaryFilters); TimelineEntities returnEntities = new TimelineEntities(); for (TimelineStore store : stores) { LOG.debug("Try timeline store {} for the request", store.getName()); returnEntities.addEntities( store.getEntities(entityType, limit, windowStart, windowEnd, fromId, fromTs, primaryFilter, secondaryFilters, fieldsToRetrieve, checkAcl).getEntities()); } return returnEntities; }
@Override public TimelineEvents getEntityTimelines(String entityType, SortedSet<String> entityIds, Long limit, Long windowStart, Long windowEnd, Set<String> eventTypes) throws IOException { // TODO: This should coalesce lookups from multiple cache stores LOG.debug("getEntityTimelines type={} ids={}", entityType, entityIds); return summaryStore.getEntityTimelines(entityType, entityIds, limit, windowStart, windowEnd, eventTypes); }
@After public void tearDown() throws Exception { store.stop(); }
LOG.info("Starting {}",getName()); yarnClient.start(); summaryStore.start();
yarnClient.init(conf); summaryStore = createSummaryStore(); summaryStore.init(conf); long logRetainSecs = conf.getLong( TIMELINE_SERVICE_ENTITYFILE_RETAIN_SECONDS,
public synchronized void releaseCache() { try { if (cacheStore != null) { cacheStore.close(); } } catch (IOException e) { LOG.warn("Error closing datamanager", e); } cacheStore = null; cacheRefreshTime = 0; cacheCompleted = false; // reset offsets so next time logs are re-parsed for (LogInfo log : detailLogs) { log.offset = 0; } }
@Test public void testRelatingToNonExistingEntity() throws IOException { TimelineEntity entityToStore = new TimelineEntity(); entityToStore.setEntityType("TEST_ENTITY_TYPE_1"); entityToStore.setEntityId("TEST_ENTITY_ID_1"); entityToStore.setDomainId(TimelineDataManager.DEFAULT_DOMAIN_ID); entityToStore.addRelatedEntity("TEST_ENTITY_TYPE_2", "TEST_ENTITY_ID_2"); TimelineEntities entities = new TimelineEntities(); entities.addEntity(entityToStore); store.put(entities); TimelineEntity entityToGet = store.getEntity("TEST_ENTITY_ID_2", "TEST_ENTITY_TYPE_2", null); Assert.assertNotNull(entityToGet); Assert.assertEquals("DEFAULT", 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()); }
@Override protected void serviceInit(Configuration conf) throws Exception { TimelineDomain domain = store.getDomain("DEFAULT"); // it is okay to reuse an existing domain even if it was created by another // user of the timeline server before, because it allows everybody to access. if (domain == null) { // create a default domain, which allows everybody to access and modify // the entities in it. domain = new TimelineDomain(); domain.setId(DEFAULT_DOMAIN_ID); domain.setDescription("System Default Domain"); domain.setOwner( UserGroupInformation.getCurrentUser().getShortUserName()); domain.setReaders("*"); domain.setWriters("*"); store.put(domain); } super.serviceInit(conf); }