private List<TimelineStore> getTimelineStoresFromCacheIds( Set<TimelineEntityGroupId> groupIds, String entityType) throws IOException { List<TimelineStore> stores = new LinkedList<TimelineStore>(); // For now we just handle one store in a context. We return the first // non-null storage for the group ids. for (TimelineEntityGroupId groupId : groupIds) { TimelineStore storeForId = getCachedStore(groupId); if (storeForId != null) { LOG.debug("Adding {} as a store for the query", storeForId.getName()); stores.add(storeForId); } } if (stores.size() == 0) { LOG.debug("Using summary store for {}", entityType); stores.add(this.summaryStore); } return stores; }
@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 TimelineEntity getEntity(String entityId, String entityType, EnumSet<Field> fieldsToRetrieve) throws IOException { LOG.debug("getEntity type={} id={}", entityType, entityId); List<EntityCacheItem> relatedCacheItems = new ArrayList<>(); List<TimelineStore> stores = getTimelineStoresForRead(entityId, entityType, relatedCacheItems); 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; }
private List<TimelineStore> getTimelineStoresFromCacheIds( Set<TimelineEntityGroupId> groupIds, String entityType, List<EntityCacheItem> cacheItems) throws IOException { List<TimelineStore> stores = new LinkedList<TimelineStore>(); // For now we just handle one store in a context. We return the first // non-null storage for the group ids. for (TimelineEntityGroupId groupId : groupIds) { TimelineStore storeForId = getCachedStore(groupId, cacheItems); if (storeForId != null) { LOG.debug("Adding {} as a store for the query", storeForId.getName()); stores.add(storeForId); metrics.incrGetEntityToDetailOps(); } } if (stores.size() == 0) { LOG.debug("Using summary store for {}", entityType); stores.add(this.summaryStore); metrics.incrGetEntityToSummaryOps(); } return stores; }
@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; }
@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(); List<EntityCacheItem> relatedCacheItems = new ArrayList<>(); for (String entityId : entityIds) { LOG.debug("getEntityTimeline type={} id={}", entityType, entityId); List<TimelineStore> stores = getTimelineStoresForRead(entityId, entityType, relatedCacheItems); for (TimelineStore store : stores) { LOG.debug("Try timeline store {}:{} for the request", store.getName(), store.toString()); SortedSet<String> entityIdSet = new TreeSet<>(); entityIdSet.add(entityId); TimelineEvents events = store.getEntityTimelines(entityType, entityIdSet, limit, windowStart, windowEnd, eventTypes); if (events != null) { returnEvents.addEvents(events.getAllEvents()); } } } return returnEvents; }
@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 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<EntityCacheItem> relatedCacheItems = new ArrayList<>(); List<TimelineStore> stores = getTimelineStoresForRead(entityType, primaryFilter, secondaryFilters, relatedCacheItems); TimelineEntities returnEntities = new TimelineEntities(); for (TimelineStore store : stores) { LOG.debug("Try timeline store {} for the request", store.getName()); TimelineEntities entities = store.getEntities(entityType, limit, windowStart, windowEnd, fromId, fromTs, primaryFilter, secondaryFilters, fieldsToRetrieve, checkAcl); if (entities != null) { returnEntities.addEntities(entities.getEntities()); } } return returnEntities; }