/// <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);
        }