use of org.xdi.model.metric.MetricType in project oxTrust by GluuFederation.
the class MetricService method findAuthenticationMetrics.
private Map<MetricType, List<? extends MetricEntry>> findAuthenticationMetrics(int countDays) {
List<MetricType> metricTypes = new ArrayList<MetricType>();
metricTypes.add(MetricType.OXAUTH_USER_AUTHENTICATION_FAILURES);
metricTypes.add(MetricType.OXAUTH_USER_AUTHENTICATION_SUCCESS);
Date endDate = new Date();
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, countDays);
Date startDate = calendar.getTime();
Map<MetricType, List<? extends MetricEntry>> entries = findMetricEntry(ApplicationType.OX_AUTH, appConfiguration.getApplianceInum(), metricTypes, startDate, endDate);
return entries;
}
use of org.xdi.model.metric.MetricType in project oxTrust by GluuFederation.
the class MetricService method genereateAuthenticationChartDto.
public AuthenticationChartDto genereateAuthenticationChartDto(int countDays) {
String key = OxTrustConstants.CACHE_METRICS_KEY + "#home";
AuthenticationChartDto authenticationChartDto = (AuthenticationChartDto) cacheService.get(OxTrustConstants.CACHE_METRICS_NAME, key);
if (authenticationChartDto != null) {
return authenticationChartDto;
}
Map<MetricType, List<? extends MetricEntry>> entries = findAuthenticationMetrics(-countDays);
String[] labels = new String[countDays];
Map<String, Long> successStats = calculateCounterStatistics(countDays, (List<CounterMetricEntry>) entries.get(MetricType.OXAUTH_USER_AUTHENTICATION_SUCCESS));
labels = successStats.keySet().toArray(labels);
Long[] values = new Long[countDays];
values = successStats.values().toArray(values);
authenticationChartDto = new AuthenticationChartDto();
authenticationChartDto.setLabels(labels);
authenticationChartDto.setSuccess(values);
Map<String, Long> failureStats = calculateCounterStatistics(countDays, (List<CounterMetricEntry>) entries.get(MetricType.OXAUTH_USER_AUTHENTICATION_FAILURES));
values = new Long[countDays];
values = failureStats.values().toArray(values);
authenticationChartDto.setFailure(values);
cacheService.put(OxTrustConstants.CACHE_METRICS_NAME, key, authenticationChartDto);
return authenticationChartDto;
}
Aggregations