use of org.xdi.model.metric.ldap.MetricEntry 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.ldap.MetricEntry in project oxCore by GluuFederation.
the class LdapEntryReporter method addMandatoryAttributes.
private void addMandatoryAttributes(MetricService metricService, Date startTime, Date endTime, List<MetricEntry> metricEntries, Date creationTime) {
for (MetricEntry metricEntry : metricEntries) {
String id = metricService.getuUiqueIdentifier();
String dn = metricService.buildDn(id, creationTime, ApplicationType.OX_AUTH);
metricEntry.setId(id);
metricEntry.setDn(dn);
metricEntry.setApplicationType(ApplicationType.OX_AUTH);
metricEntry.setStartDate(startTime);
metricEntry.setEndDate(endTime);
metricEntry.setCreationDate(creationTime);
}
}
use of org.xdi.model.metric.ldap.MetricEntry in project oxCore by GluuFederation.
the class LdapEntryReporter method reportImpl.
private void reportImpl(SortedMap<String, Counter> counters, SortedMap<String, Timer> timers) {
final Date currentRunTime = new Date(clock.getTime());
List<MetricEntry> metricEntries = new ArrayList<MetricEntry>();
if (counters != null && !counters.isEmpty()) {
List<MetricEntry> result = builCounterEntries(counters, metricService.getRegisteredMetricTypes());
metricEntries.addAll(result);
}
if (timers != null && !timers.isEmpty()) {
List<MetricEntry> result = builTimerEntries(timers, metricService.getRegisteredMetricTypes());
metricEntries.addAll(result);
}
// Remove 1 millisecond to avoid overlapping periods
final Calendar cal = Calendar.getInstance();
cal.setTime(currentRunTime);
cal.add(Calendar.MILLISECOND, -1);
final Date endTime = cal.getTime();
Date creationTime = new Date();
if (metricEntries.size() > 0) {
addMandatoryAttributes(metricService, startTime, endTime, metricEntries, creationTime);
}
startTime = currentRunTime;
metricService.add(metricEntries, creationTime);
}
use of org.xdi.model.metric.ldap.MetricEntry in project oxCore by GluuFederation.
the class MetricService method getExpiredMetricEntries.
public List<MetricEntry> getExpiredMetricEntries(BatchOperation<MetricEntry> batchOperation, int batchSize, String baseDnForPeriod, Date expirationDate) {
Filter expiratioFilter = Filter.createLessOrEqualFilter("oxStartDate", ldapEntryManager.encodeGeneralizedTime(expirationDate));
List<MetricEntry> metricEntries = ldapEntryManager.findEntries(baseDnForPeriod, MetricEntry.class, expiratioFilter, SearchScope.SUB, new String[] { "uniqueIdentifier" }, batchOperation, 0, batchSize, batchSize);
return metricEntries;
}
use of org.xdi.model.metric.ldap.MetricEntry 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