@Override public Integer getEventCategoryId(final String eventCategory, final InternalTenantContext context) throws UnableToObtainConnectionException, CallbackFailedException { Integer result = eventCategoriesCache.inverse().get(eventCategory); if (result == null) { result = delegate.getEventCategoryId(eventCategory, context); if (result != null) { synchronized (eventCategoriesCache) { if (eventCategoriesCache.get(result) == null) { eventCategoriesCache.put(result, eventCategory); } } } } return result; }
private List<Integer> translateCategoriesAndMetricNamesToMetricIds(final Map<String, Collection<String>> metricsPerCategory) { final List<Integer> metricIds = new ArrayList<Integer>(metricsPerCategory.keySet().size()); for (final String category : metricsPerCategory.keySet()) { final Integer categoryId = timelineDao.getEventCategoryId(category, context); if (categoryId == null) { // Ignore continue; } for (final String metricName : metricsPerCategory.get(category)) { final Integer sampleKindId = timelineDao.getMetricId(categoryId, metricName, context); if (sampleKindId == null) { // Ignore continue; } metricIds.add(sampleKindId); } } return metricIds; }
@VisibleForTesting public void processSamples(final SourceSamplesForTimestamp hostSamples, final InternalTenantContext context) throws ExecutionException, IOException { final int sourceId = hostSamples.getSourceId(); final String category = hostSamples.getCategory(); final int categoryId = timelineDAO.getEventCategoryId(category, context); final DateTime timestamp = hostSamples.getTimestamp(); final TimelineSourceEventAccumulator accumulator = getOrAddSourceEventAccumulator(sourceId, categoryId, timestamp); accumulator.addSourceSamples(hostSamples); }
final int sourceId = hostSamples.getSourceId(); final String category = hostSamples.getCategory(); final int categoryId = timelineDAO.getEventCategoryId(category, context);