MemoryTimelineStore extends AbstractService implements TimelineStore { @Override public synchronized TimelineEntities getEntities(String entityType, Long limit, Long windowStart, Long windowEnd, String fromId, Long fromTs, NameValuePair primaryFilter, Collection<NameValuePair> secondaryFilters, EnumSet<Field> fields, CheckAcl checkAcl) throws IOException { if (limit == null) { limit = DEFAULT_LIMIT; } if (windowStart == null) { windowStart = Long.MIN_VALUE; } if (windowEnd == null) { windowEnd = Long.MAX_VALUE; } if (fields == null) { fields = EnumSet.allOf(Field.class); } Iterator<TimelineEntity> entityIterator = null; if (fromId != null) { TimelineEntity firstEntity = entities.get(new EntityIdentifier(fromId, entityType)); if (firstEntity == null) { return new TimelineEntities(); } else { entityIterator = new TreeSet<TimelineEntity>(entities.values()) .tailSet(firstEntity, true).iterator(); } } if (entityIterator == null) { entityIterator = new PriorityQueue<TimelineEntity>(entities.values()) .iterator(); } List<TimelineEntity> entitiesSelected = new ArrayList<TimelineEntity>(); while (entityIterator.hasNext()) { TimelineEntity entity = entityIterator.next(); if (entitiesSelected.size() >= limit) { break; } if (!entity.getEntityType().equals(entityType)) { continue; } if (entity.getStartTime() <= windowStart) { continue; } if (entity.getStartTime() > windowEnd) { continue; } if (fromTs != null && entityInsertTimes.get(new EntityIdentifier( entity.getEntityId(), entity.getEntityType())) > fromTs) { continue; } if (primaryFilter != null && !matchPrimaryFilter(entity.getPrimaryFilters(), primaryFilter)) { continue; } if (secondaryFilters != null) { boolean flag = true; for (NameValuePair secondaryFilter : secondaryFilters) { if (secondaryFilter != null && !matchPrimaryFilter( entity.getPrimaryFilters(), secondaryFilter) && !matchFilter(entity.getOtherInfo(), secondaryFilter)) { flag = false; break; } } if (!flag) { continue; } } if (entity.getDomainId() == null) { entity.setDomainId(DEFAULT_DOMAIN_ID); } if (checkAcl == null || checkAcl.check(entity)) { entitiesSelected.add(entity); } } List<TimelineEntity> entitiesToReturn = new ArrayList<TimelineEntity>(); for (TimelineEntity entitySelected : entitiesSelected) { entitiesToReturn.add(maskFields(entitySelected, fields)); } Collections.sort(entitiesToReturn); TimelineEntities entitiesWrapper = new TimelineEntities(); entitiesWrapper.setEntities(entitiesToReturn); return entitiesWrapper; } MemoryTimelineStore(); @Override synchronized TimelineEntities getEntities(String entityType, Long limit,
      Long windowStart, Long windowEnd, String fromId, Long fromTs,
      NameValuePair primaryFilter, Collection<NameValuePair> secondaryFilters,
      EnumSet<Field> fields, CheckAcl checkAcl); @Override synchronized TimelineEntity getEntity(String entityId, String entityType,
      EnumSet<Field> fieldsToRetrieve); @Override synchronized TimelineEvents getEntityTimelines(String entityType,
      SortedSet<String> entityIds, Long limit, Long windowStart,
      Long windowEnd,
      Set<String> eventTypes); @Override TimelineDomain getDomain(String domainId); @Override TimelineDomains getDomains(String owner); @Override synchronized TimelinePutResponse put(TimelineEntities data); void put(TimelineDomain domain);  }
@Test public void testGetEntities() throws IOException { super.testGetEntities(); }