Jagger
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
Map<MetricEntity, List<MetricPlotPointEntity> > com.griddynamics.jagger.engine.e1.services.DefaultDataService.getMetricPlotData ( Collection< MetricEntity metrics)

Return lists of points (values vs time) for selected metrics.

Parameters
metrics- metric entities
Returns
map of <metic entity, list of points (value vs time)> for selected metric
Author
Dmitry Latnikov

Preferable way to get data. Data will be fetched from database in batch in single request =>
it is faster to get batch of metrics than fetch every metric in for loop

Implements com.griddynamics.jagger.engine.e1.services.DataService.

Definition at line 377 of file DefaultDataService.java.

References com.griddynamics.jagger.engine.e1.services.data.service.MetricPlotPointEntity.setTime(), and com.griddynamics.jagger.engine.e1.services.data.service.MetricPlotPointEntity.setValue().

377  {
378  Set<MetricNameDto> metricNameDtoSet = new HashSet<MetricNameDto>();
379  Map<MetricNameDto, MetricEntity> matchMap = new HashMap<MetricNameDto, MetricEntity>();
380 
381  for (MetricEntity metric : metrics) {
382  if (metric.isPlotAvailable()) {
383  metricNameDtoSet.add(metric.getMetricNameDto());
384  matchMap.put(metric.getMetricNameDto(), metric);
385  }
386  }
387 
388  Map<MetricNameDto, List<PlotSingleDto>> resultMap = databaseService.getPlotDataByMetricNameDto(metricNameDtoSet);
389 
390  Map<MetricEntity, List<MetricPlotPointEntity>> result = new HashMap<MetricEntity, List<MetricPlotPointEntity>>();
391  for (Map.Entry<MetricNameDto, List<PlotSingleDto>> entry : resultMap.entrySet()) {
392  MetricEntity metricEntity = matchMap.get(entry.getKey());
393  List<MetricPlotPointEntity> values = new ArrayList<MetricPlotPointEntity>();
394  for (PointDto pointDto : entry.getValue().iterator().next().getPlotData()) {
395  MetricPlotPointEntity metricPlotPointEntity = new MetricPlotPointEntity();
396  metricPlotPointEntity.setTime(pointDto.getX());
397  metricPlotPointEntity.setValue(pointDto.getY());
398  values.add(metricPlotPointEntity);
399  }
400  result.put(metricEntity, values);
401  }
402 
403  return result;
404  }

Here is the call graph for this function: