/// <exception cref="System.IO.IOException"/> public virtual TimelineEntities GetEntities(string entityType, long limit, long windowStart , long windowEnd, string fromId, long fromTs, NameValuePair primaryFilter, ICollection <NameValuePair> secondaryFilters, EnumSet <TimelineReader.Field> fields, TimelineDataManager.CheckAcl checkAcl) { lock (this) { if (limit == null) { limit = DefaultLimit; } if (windowStart == null) { windowStart = long.MinValue; } if (windowEnd == null) { windowEnd = long.MaxValue; } if (fields == null) { fields = EnumSet.AllOf <TimelineReader.Field>(); } IEnumerator <TimelineEntity> entityIterator = null; if (fromId != null) { TimelineEntity firstEntity = entities[new EntityIdentifier(fromId, entityType)]; if (firstEntity == null) { return(new TimelineEntities()); } else { entityIterator = new TreeSet <TimelineEntity>(entities.Values).TailSet(firstEntity , true).GetEnumerator(); } } if (entityIterator == null) { entityIterator = new PriorityQueue <TimelineEntity>(entities.Values).GetEnumerator (); } IList <TimelineEntity> entitiesSelected = new AList <TimelineEntity>(); while (entityIterator.HasNext()) { TimelineEntity entity = entityIterator.Next(); if (entitiesSelected.Count >= limit) { break; } if (!entity.GetEntityType().Equals(entityType)) { continue; } if (entity.GetStartTime() <= windowStart) { continue; } if (entity.GetStartTime() > windowEnd) { continue; } if (fromTs != null && entityInsertTimes[new EntityIdentifier(entity.GetEntityId() , entity.GetEntityType())] > fromTs) { continue; } if (primaryFilter != null && !MatchPrimaryFilter(entity.GetPrimaryFilters(), primaryFilter )) { continue; } if (secondaryFilters != null) { // AND logic bool flag = true; foreach (NameValuePair secondaryFilter in secondaryFilters) { if (secondaryFilter != null && !MatchPrimaryFilter(entity.GetPrimaryFilters(), secondaryFilter ) && !MatchFilter(entity.GetOtherInfo(), secondaryFilter)) { flag = false; break; } } if (!flag) { continue; } } if (entity.GetDomainId() == null) { entity.SetDomainId(TimelineDataManager.DefaultDomainId); } if (checkAcl == null || checkAcl.Check(entity)) { entitiesSelected.AddItem(entity); } } IList <TimelineEntity> entitiesToReturn = new AList <TimelineEntity>(); foreach (TimelineEntity entitySelected in entitiesSelected) { entitiesToReturn.AddItem(MaskFields(entitySelected, fields)); } entitiesToReturn.Sort(); TimelineEntities entitiesWrapper = new TimelineEntities(); entitiesWrapper.SetEntities(entitiesToReturn); return(entitiesWrapper); } }
/// <summary> /// This method retrieves a list of entity information, /// <see cref="Org.Apache.Hadoop.Yarn.Api.Records.Timeline.TimelineEntity"/> /// , /// sorted by the starting timestamp for the entity, descending. The starting /// timestamp of an entity is a timestamp specified by the client. If it is not /// explicitly specified, it will be chosen by the store to be the earliest /// timestamp of the events received in the first put for the entity. /// </summary> /// <param name="entityType">The type of entities to return (required).</param> /// <param name="limit"> /// A limit on the number of entities to return. If null, defaults to /// <see cref="DefaultLimit"/> /// . /// </param> /// <param name="windowStart"> /// The earliest start timestamp to retrieve (exclusive). If null, /// defaults to retrieving all entities until the limit is reached. /// </param> /// <param name="windowEnd"> /// The latest start timestamp to retrieve (inclusive). If null, /// defaults to /// <see cref="long.MaxValue"/> /// </param> /// <param name="fromId"> /// If fromId is not null, retrieve entities earlier than and /// including the specified ID. If no start time is found for the /// specified ID, an empty list of entities will be returned. The /// windowEnd parameter will take precedence if the start time of this /// entity falls later than windowEnd. /// </param> /// <param name="fromTs"> /// If fromTs is not null, ignore entities that were inserted into the /// store after the given timestamp. The entity's insert timestamp /// used for this comparison is the store's system time when the first /// put for the entity was received (not the entity's start time). /// </param> /// <param name="primaryFilter"> /// Retrieves only entities that have the specified primary filter. If /// null, retrieves all entities. This is an indexed retrieval, and no /// entities that do not match the filter are scanned. /// </param> /// <param name="secondaryFilters"> /// Retrieves only entities that have exact matches for all the /// specified filters in their primary filters or other info. This is /// not an indexed retrieval, so all entities are scanned but only /// those matching the filters are returned. /// </param> /// <param name="fieldsToRetrieve"> /// Specifies which fields of the entity object to retrieve (see /// <see cref="Field"/> /// ). If the set of fields contains /// <see cref="Field.LastEventOnly"/> /// and not /// <see cref="Field.Events"/> /// , the /// most recent event for each entity is retrieved. If null, retrieves /// all fields. /// </param> /// <returns> /// An /// <see cref="Org.Apache.Hadoop.Yarn.Api.Records.Timeline.TimelineEntities"/> /// object. /// </returns> /// <exception cref="System.IO.IOException"/> public abstract TimelineEntities GetEntities(string entityType, long limit, long windowStart, long windowEnd, string fromId, long fromTs, NameValuePair primaryFilter , ICollection <NameValuePair> secondaryFilters, EnumSet <TimelineReader.Field> fieldsToRetrieve , TimelineDataManager.CheckAcl checkAcl);