Search in sources :

Example 6 with MetricType

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;
}
Also used : MetricType(org.xdi.model.metric.MetricType) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CounterMetricEntry(org.xdi.model.metric.counter.CounterMetricEntry) MetricEntry(org.xdi.model.metric.ldap.MetricEntry) Date(java.util.Date)

Example 7 with MetricType

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;
}
Also used : AuthenticationChartDto(org.gluu.oxtrust.model.AuthenticationChartDto) MetricType(org.xdi.model.metric.MetricType) ArrayList(java.util.ArrayList) List(java.util.List) CounterMetricEntry(org.xdi.model.metric.counter.CounterMetricEntry) MetricEntry(org.xdi.model.metric.ldap.MetricEntry) CounterMetricEntry(org.xdi.model.metric.counter.CounterMetricEntry)

Aggregations

MetricType (org.xdi.model.metric.MetricType)7 ArrayList (java.util.ArrayList)5 MetricEntry (org.xdi.model.metric.ldap.MetricEntry)5 CounterMetricEntry (org.xdi.model.metric.counter.CounterMetricEntry)4 List (java.util.List)3 TimerMetricEntry (org.xdi.model.metric.timer.TimerMetricEntry)2 Counter (com.codahale.metrics.Counter)1 MetricRegistry (com.codahale.metrics.MetricRegistry)1 Snapshot (com.codahale.metrics.Snapshot)1 Timer (com.codahale.metrics.Timer)1 Filter (com.unboundid.ldap.sdk.Filter)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 AuthenticationChartDto (org.gluu.oxtrust.model.AuthenticationChartDto)1 LdapEntryManager (org.gluu.site.ldap.persistence.LdapEntryManager)1 GluuLdapConfiguration (org.xdi.model.ldap.GluuLdapConfiguration)1 CounterMetricData (org.xdi.model.metric.counter.CounterMetricData)1