@Override public int compare(SummarySingleDto metricDto, SummarySingleDto metricDto2) { String displayName1 = metricDto.getMetricName().getMetricDisplayName(); String displayName2 = metricDto2.getMetricName().getMetricDisplayName(); if (!displayName1.equals(displayName2)) { return MetricRankingProvider.compare(metricDto.getMetricName().getMetricDisplayName(), metricDto2.getMetricName() .getMetricDisplayName()); } else { return metricDto2.getMetricName().getOrigin().ordinal() - metricDto.getMetricName().getOrigin().ordinal(); } } });
private Map<String, Set<String>> getAgentNamesForMonitoringParameters(Set<? extends MetricNode> nodeList) { Map<String, Set<String>> agentNames = new HashMap<>(); for (MetricNode node : nodeList) { node.getMetricNameDtoList().stream() .filter(metricNameDto -> metricNameDto.getOrigin() == TEST_GROUP_METRIC) .map(metricNameDto -> MonitoringIdUtils.splitMonitoringMetricId(metricNameDto.getMetricName())) .filter(Objects::nonNull) .forEach(monitoringId -> defaultMonitoringParams.keySet().stream() .filter(key -> defaultMonitoringParams.get(key).contains(monitoringId.getMonitoringName())) .forEach(key -> { agentNames.putIfAbsent(key, new HashSet<>()); agentNames.get(key).add(monitoringId.getAgentName()); })); } return agentNames; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; MetricEntity that = (MetricEntity) o; if (plotAvailable != that.plotAvailable) return false; if (summaryAvailable != that.summaryAvailable) return false; if (!metricNameDto.equals(that.metricNameDto)) return false; return true; }
/** * Map Collection of MetricNameDto first of all by TaskDataDto id, after all by metric name (metric id) * * @param metricNameDtos collection of MetricNameDto to be mapped * @return Map <TaskDataDto.id, Map<metricName, MetricDto>> */ public static Map<Long, Map<String, MetricNameDto>> getMappedMetricDtos(Collection<MetricNameDto> metricNameDtos) { Map<Long, Map<String, MetricNameDto>> taskIdMap = new HashMap<>(); for (MetricNameDto metricName : metricNameDtos) { Set<Long> ids = metricName.getTaskIds(); for (Long id : ids) { if (!taskIdMap.containsKey(id)) { taskIdMap.put(id, new HashMap<>()); } Map<String, MetricNameDto> metricIdMap = taskIdMap.get(id); if (!metricIdMap.containsKey(metricName.getMetricName())) { metricIdMap.put(metricName.getMetricName(), metricName); } else { throw new IllegalStateException(metricName.toString() + " already in Map"); } } } return taskIdMap; }
if (!metricNameList.contains(metricNameDto.getMetricName())) { metricNameList.add(metricNameDto.getMetricName()); PlotNode ssPlotNode = new PlotNode(); taskDataDto.getDescription()); MetricNameDto tempMetricNameDto = new MetricNameDto(tempTaskDataDto, metricNameDto.getMetricName(), metricNameDto.getMetricDisplayName(), metricNameDto.getOrigin()); ssPlotNode.init(NameTokens.SESSION_SCOPE_PREFIX + metricNameDto.getMetricName(), plotNode.getDisplayName(), Collections.singletonList(tempMetricNameDto)); if (!nameId.containsKey(metricNameDto.getMetricName())) nameId.put(metricNameDto.getMetricName(), new ArrayList<>()); nameId.get(metricNameDto.getMetricName()).addAll(metricNameDto.getTaskIds()); for (Long taskId : nameId.get(metricNameDto.getMetricName())) metricNameDto.getTest().getIdToSessionId().put(taskId, sessionId);
metric = metricNameDto.getMetricDisplayName(); } else { metric = metricNameDto.getMetricName();
private Map<TaskDataDto, List<PlotNode>> getTestPlotsMap(Set<String> sessionIds, List<TaskDataDto> taskList) { Map<TaskDataDto, List<PlotNode>> result = new HashMap<>(); List<MetricNameDto> metricNameDtoList = new ArrayList<>(); try { metricNameDtoList.addAll(customMetricPlotNameProvider.getPlotNames(taskList)); log.debug("For sessions {} are available these plots: {}", sessionIds, metricNameDtoList); for (MetricNameDto pnd : metricNameDtoList) { if ((pnd.getMetricName() == null) || (pnd.getMetricName().equals(""))) { log.warn("Metric with undefined id detected. It will be ignored. Details: " + pnd); } else { for (TaskDataDto tdd : taskList) { if (!result.containsKey(tdd)) { result.put(tdd, new ArrayList<>()); } if (tdd.getIds().containsAll(pnd.getTaskIds())) { PlotNode pn = new PlotNode(); String id = NameTokens.METRICS_PREFIX + tdd.hashCode() + pnd.getMetricName() + pnd.getOrigin(); pn.init(id, pnd.getMetricDisplayName(), Collections.singletonList(pnd)); result.get(tdd).add(pn); break; } } } } } catch (Exception e) { log.error("Error was occurred during task scope plots data getting for session IDs " + sessionIds + ", tasks : " + taskList, e); throw new RuntimeException(e); } return result; }
for (TaskDataDto td : tests) { if (td.getIds().contains(((BigInteger) name[1]).longValue())) { MetricNameDto metric = new MetricNameDto(); metric.setTest(td); metric.setMetricName((String) name[0]); metric.setMetricDisplayName((String) name[2]); metric.setOrigin(MetricNameDto.Origin.VALIDATOR); validators.add(metric); break;
protected Set<Pair<MetricNameDto, List<PlotSingleDto>>> getResult(Collection<AbstractMetricPlotFetcher.MetricRawData> allRawData, List<MetricNameDto> metricNames) { Set<Long> taskIds = new HashSet<>(); for (MetricNameDto metricName : metricNames) { taskIds.addAll(metricName.getTaskIds()); } Multimap<String, AbstractMetricPlotFetcher.MetricRawData> metricIdRawMap = getMetricIdRawMap(allRawData, taskIds); Multimap<MetricNameDto, PlotSingleDto> metricNamePlotMap = ArrayListMultimap.create(); for (MetricNameDto metricName : metricNames) { Collection<AbstractMetricPlotFetcher.MetricRawData> rawDatas; if (metricIdRawMap.isEmpty()) continue; rawDatas = metricIdRawMap.get(metricName.getMetricName()); if (rawDatas == null || rawDatas.isEmpty()) { continue; } metricNamePlotMap.put(metricName, abstractMetricPlotFetcher.assemble(metricName, rawDatas)); } Set<Pair<MetricNameDto, List<PlotSingleDto>>> resultSet = new HashSet<>(metricNames.size()); for (MetricNameDto metricName : metricNamePlotMap.keySet()) { List<PlotSingleDto> plotDatasetDtoList = new ArrayList<>(metricNamePlotMap.get(metricName)); resultSet.add(Pair.of(metricName, plotDatasetDtoList)); } return resultSet; }
if ((mnd.getMetricName() == null) || (mnd.getMetricName().equals(""))) { log.warn("Metric with undefined id detected. It will be ignored. Details: " + mnd); } else { for (TaskDataDto tdd : dtos) { if (tdd.getIds().containsAll(mnd.getTaskIds())) { if (!result.containsKey(tdd)) { result.put(tdd, new ArrayList<>()); String id = NameTokens.SUMMARY_PREFIX + tdd.hashCode() + mnd.getMetricName(); mn.init(id, mnd.getMetricDisplayName(), Collections.singletonList(mnd)); result.get(tdd).add(mn); break;
metricIds.add(metricName.getMetricName()); taskIds.addAll(metricName.getTaskIds()); if (metricName.getOrigin().equals(TEST_GROUP_METRIC)) { taskIdsWhereParentIdIsRequired.addAll(metricName.getTaskIds());
/** Get metric id */ public String getMetricId() { return metricNameDto.getMetricName(); }
private boolean isSessionScopeMetric(MetricNameDto metricNameDto) { return metricNameDto.getOrigin() == MetricNameDto.Origin.SESSION_SCOPE_TG; } }
/** Get metric display name - label displayed in reports */ public String getDisplayName() { return metricNameDto.getMetricDisplayName(); }
private Set<MetricNameDto> getCustomMetricsNamesNewModel(List<TaskDataDto> tests) { try { Set<Long> taskIds = CommonUtils.getTestsIds(tests); List<Object[]> metricDescriptionEntities = getMetricNames(taskIds); if (metricDescriptionEntities.isEmpty()) { return Collections.emptySet(); } Set<MetricNameDto> metrics = new HashSet<>(metricDescriptionEntities.size()); for (Object[] mde : metricDescriptionEntities) { for (TaskDataDto td : tests) { if (td.getIds().contains((Long) mde[2])) { String metricName = (String) mde[0]; MetricNameDto metricNameDto = new MetricNameDto(td, metricName, (String) mde[1], MetricNameDto.Origin.METRIC); metrics.add(metricNameDto); break; } } } return metrics; } catch (PersistenceException e) { log.debug("Could not fetch data from MetricSummaryEntity: {}", DataProcessingUtil.getMessageFromLastCause(e)); return Collections.emptySet(); } }
/** * Map Collection of MetricNameDto first of all by TaskDataDto id, after all by metric name (metric id) * * @param metricNameDtos collection of MetricNameDto to be mapped * @return Map <TaskDataDto.id, MetricNameDto> */ public static Map<Long, MetricNameDto> getMappedMetricDtosByTaskIds(Collection<MetricNameDto> metricNameDtos) { Map<Long, MetricNameDto> taskIdMap = new HashMap<>(); for (MetricNameDto metricName : metricNameDtos) { Set<Long> ids = metricName.getTaskIds(); ids.stream().filter(id -> !taskIdMap.containsKey(id)).forEach(id -> taskIdMap.put(id, metricName)); } return taskIdMap; }
@Override public int hashCode() { int result = metricNameDto.hashCode(); result = 31 * result + (summaryAvailable ? 1 : 0); result = 31 * result + (plotAvailable ? 1 : 0); return result; }
/** * Creates plot for given MetricNode and lines referred to it * * @param metricNode metric node for witch plot should be created * @param curves lines of plot * @param xAxisLabel x axis label * @return plot for given MetricNode */ private PlotIntegratedDto createPlotIntegratedDto(MetricNode metricNode, List<PlotSingleDto> curves, String xAxisLabel) { String taskName = metricNode.getMetricNameDtoList().get(0).getTest().getTaskName(); MetricNameDto firstMetricNameDto = metricNode.getMetricNameDtoList().get(0); String plotHeader; if (isSessionScopeMetric(firstMetricNameDto)) plotHeader = legendProvider.generateSessionScopePlotHeader(metricNode.getDisplayName()); else plotHeader = legendProvider.generatePlotHeader(taskName, metricNode.getDisplayName()); return new PlotIntegratedDto(createLegendTree(metricNode, curves), xAxisLabel, "", plotHeader); }
protected PlotSingleDto assemble(MetricNameDto metricNameDto, Collection<MetricRawData> rawDatas) { List<PointDto> points = new ArrayList<>(rawDatas.size()); String sessionId = null; for (MetricRawData metricRawData : rawDatas) { if (sessionId == null) sessionId = metricRawData.getSessionId(); points.add(new PointDto(metricRawData.getTime() / 1000D, metricRawData.getValue())); } return new PlotSingleDto( points, legendProvider.generatePlotLegend( sessionId, metricNameDto.getMetricDisplayName(), true), getHexColorCode(metricNameDto.getMetricName(), sessionId), generatePointShape(metricNameDto.getMetricName(), sessionId)); }
for (TaskDataDto td : tests) { if (td.getIds().contains(((BigInteger) name[1]).longValue())) { MetricNameDto metric = new MetricNameDto(); metric.setTest(td); metric.setMetricName((String) name[0]); metric.setOrigin(MetricNameDto.Origin.VALIDATOR); validators.add(metric); break;