public virtual TimelineEvents GetEntityTimelines(string entityType, ICollection <string > entityIds, long limit, long windowStart, long windowEnd, ICollection <string> eventTypes ) { lock (this) { TimelineEvents allEvents = new TimelineEvents(); if (entityIds == null) { return(allEvents); } if (limit == null) { limit = DefaultLimit; } if (windowStart == null) { windowStart = long.MinValue; } if (windowEnd == null) { windowEnd = long.MaxValue; } foreach (string entityId in entityIds) { EntityIdentifier entityID = new EntityIdentifier(entityId, entityType); TimelineEntity entity = entities[entityID]; if (entity == null) { continue; } TimelineEvents.EventsOfOneEntity events = new TimelineEvents.EventsOfOneEntity(); events.SetEntityId(entityId); events.SetEntityType(entityType); foreach (TimelineEvent @event in entity.GetEvents()) { if (events.GetEvents().Count >= limit) { break; } if (@event.GetTimestamp() <= windowStart) { continue; } if (@event.GetTimestamp() > windowEnd) { continue; } if (eventTypes != null && !eventTypes.Contains(@event.GetEventType())) { continue; } events.AddEvent(@event); } allEvents.AddEvent(events); } return(allEvents); } }
/// <summary>Get the events whose entities the given user has access to.</summary> /// <remarks> /// Get the events whose entities the given user has access to. The meaning of /// each argument has been documented with /// <see cref="TimelineReader.GetEntityTimelines(string, System.Collections.Generic.ICollection{E}, long, long, long, System.Collections.Generic.ICollection{E}) /// "/> /// . /// </remarks> /// <seealso cref="TimelineReader.GetEntityTimelines(string, System.Collections.Generic.ICollection{E}, long, long, long, System.Collections.Generic.ICollection{E}) /// "/> /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual TimelineEvents GetEvents(string entityType, ICollection <string> entityIds , ICollection <string> eventTypes, long windowStart, long windowEnd, long limit, UserGroupInformation callerUGI) { TimelineEvents events = null; events = store.GetEntityTimelines(entityType, entityIds, limit, windowStart, windowEnd , eventTypes); if (events != null) { IEnumerator <TimelineEvents.EventsOfOneEntity> eventsItr = events.GetAllEvents().GetEnumerator (); while (eventsItr.HasNext()) { TimelineEvents.EventsOfOneEntity eventsOfOneEntity = eventsItr.Next(); try { TimelineEntity entity = store.GetEntity(eventsOfOneEntity.GetEntityId(), eventsOfOneEntity .GetEntityType(), EnumSet.Of(TimelineReader.Field.PrimaryFilters)); AddDefaultDomainIdIfAbsent(entity); // check ACLs if (!timelineACLsManager.CheckAccess(callerUGI, ApplicationAccessType.ViewApp, entity )) { eventsItr.Remove(); } } catch (Exception e) { Log.Error("Error when verifying access for user " + callerUGI + " on the events of the timeline entity " + new EntityIdentifier(eventsOfOneEntity.GetEntityId(), eventsOfOneEntity.GetEntityType ()), e); eventsItr.Remove(); } } } if (events == null) { return(new TimelineEvents()); } return(events); }