use of org.xdi.model.metric.MetricType in project oxCore by GluuFederation.
the class LdapEntryReporter method builCounterEntries.
private List<MetricEntry> builCounterEntries(SortedMap<String, Counter> counters, Set<MetricType> registeredMetricTypes) {
List<MetricEntry> result = new ArrayList<MetricEntry>();
Set<MetricType> currentRegisteredMetricTypes = new HashSet<MetricType>(registeredMetricTypes);
for (MetricType metricType : currentRegisteredMetricTypes) {
Counter counter = counters.get(metricType.getValue());
if (counter != null) {
long count = counter.getCount();
// Remove to avoid writing not changed statistic
// registeredMetricTypes.remove(metricType);
CounterMetricData counterMetricData = new CounterMetricData(count);
CounterMetricEntry counterMetricEntry = new CounterMetricEntry();
counterMetricEntry.setMetricData(counterMetricData);
counterMetricEntry.setMetricType(metricType);
result.add(counterMetricEntry);
}
}
return result;
}
use of org.xdi.model.metric.MetricType in project oxAuth by GluuFederation.
the class AuthenticationService method authenticate.
public boolean authenticate(String keyValue, String password, String primaryKey, String localPrimaryKey) {
if (this.ldapAuthConfigs == null) {
return authenticate(null, ldapEntryManager, keyValue, password, primaryKey, localPrimaryKey);
}
boolean authenticated = false;
com.codahale.metrics.Timer.Context timerContext = metricService.getTimer(MetricType.OXAUTH_USER_AUTHENTICATION_RATE).time();
try {
for (int i = 0; i < this.ldapAuthConfigs.size(); i++) {
GluuLdapConfiguration ldapAuthConfig = this.ldapAuthConfigs.get(i);
LdapEntryManager ldapAuthEntryManager = this.ldapAuthEntryManagers.get(i);
authenticated = authenticate(ldapAuthConfig, ldapAuthEntryManager, keyValue, password, primaryKey, localPrimaryKey);
if (authenticated) {
break;
}
}
} finally {
timerContext.stop();
}
MetricType metricType;
if (authenticated) {
metricType = MetricType.OXAUTH_USER_AUTHENTICATION_SUCCESS;
} else {
metricType = MetricType.OXAUTH_USER_AUTHENTICATION_FAILURES;
}
metricService.incCounter(metricType);
return authenticated;
}
use of org.xdi.model.metric.MetricType in project oxCore by GluuFederation.
the class MetricService method initTimer.
public void initTimer(int metricInterval) {
this.metricRegistry = new MetricRegistry();
this.registeredMetricTypes = new HashSet<MetricType>();
LdapEntryReporter ldapEntryReporter = LdapEntryReporter.forRegistry(this.metricRegistry, getMetricServiceInstance()).build();
int metricReporterInterval = metricInterval;
if (metricReporterInterval <= 0) {
metricReporterInterval = DEFAULT_METRIC_REPORTER_INTERVAL;
}
ldapEntryReporter.start(metricReporterInterval, TimeUnit.SECONDS);
}
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 oxCore by GluuFederation.
the class LdapEntryReporter method builTimerEntries.
private List<MetricEntry> builTimerEntries(SortedMap<String, Timer> timers, Set<MetricType> registeredMetricTypes) {
List<MetricEntry> result = new ArrayList<MetricEntry>();
for (MetricType metricType : registeredMetricTypes) {
Timer timer = timers.get(metricType.getValue());
if (timer != null) {
Snapshot snapshot = timer.getSnapshot();
TimerMetricData timerMetricData = new TimerMetricData(timer.getCount(), convertRate(timer.getMeanRate()), convertRate(timer.getOneMinuteRate()), convertRate(timer.getFiveMinuteRate()), convertRate(timer.getFifteenMinuteRate()), getRateUnit(), convertDuration(snapshot.getMin()), convertDuration(snapshot.getMax()), convertDuration(snapshot.getMean()), convertDuration(snapshot.getStdDev()), convertDuration(snapshot.getMedian()), convertDuration(snapshot.get75thPercentile()), convertDuration(snapshot.get95thPercentile()), convertDuration(snapshot.get98thPercentile()), convertDuration(snapshot.get99thPercentile()), convertDuration(snapshot.get999thPercentile()), getDurationUnit());
TimerMetricEntry timerMetricEntry = new TimerMetricEntry();
timerMetricEntry.setMetricData(timerMetricData);
timerMetricEntry.setMetricType(metricType);
result.add(timerMetricEntry);
}
}
return result;
}
Aggregations