use of org.ff4j.audit.MutableHitCount in project ff4j by ff4j.
the class AuditBeanTest method testMutableHitCount.
@Test
public void testMutableHitCount() {
MutableHitCount mhc = new MutableHitCount(10);
mhc.incBy(10);
Assert.assertEquals("20", mhc.toString());
}
use of org.ff4j.audit.MutableHitCount in project ff4j by ff4j.
the class AuditBeanTest method testTimeSerieChart.
@Test
public void testTimeSerieChart() {
long top = System.currentTimeMillis();
TimeSeriesChart t1 = new TimeSeriesChart(top - 100000, top + 100000, TimeUnit.MINUTES);
new TimeSeriesChart(top - 100000, top + 100000, TimeUnit.HOURS);
new TimeSeriesChart(top - 100000, top + 100000, TimeUnit.DAYS);
new TimeSeriesChart(top - 100000, top + 100000, TimeUnit.SECONDS);
t1.addEvent(new EventBuilder().name("f1").build());
t1.addEvent(new EventBuilder().name("f2").build());
Assert.assertNotNull(t1.getSdf());
Assert.assertNotNull(t1.toString());
TimeSeriesChart tsc1 = new TimeSeriesChart();
tsc1.setSdf(new SimpleDateFormat("yyyy"));
tsc1.setTimeSlots(new ArrayList<String>());
tsc1.setSeries(new HashMap<String, Serie<Map<String, MutableHitCount>>>());
Assert.assertNotNull(tsc1);
}
use of org.ff4j.audit.MutableHitCount in project ff4j by ff4j.
the class EventRepositorySpringJdbc method computeHitCount.
/**
* Compute over a column.
*
* @param query
* current query definition
* @param colName
* column name
* @return
* hit count for this value.
*/
private Map<String, MutableHitCount> computeHitCount(EventQueryDefinition query, String colName) {
List<HitCountDto> rawResult = getJdbcTemplate().query(getQueryBuilder().getHitCount(colName), new HitCountRowMapper(colName), new Timestamp(query.getFrom()), new Timestamp(query.getTo()));
Map<String, MutableHitCount> mapofHitCount = new HashMap<String, MutableHitCount>();
for (HitCountDto dto : rawResult) {
mapofHitCount.put(dto.getColumnName(), dto.getHitcount());
}
return mapofHitCount;
}
use of org.ff4j.audit.MutableHitCount in project ff4j by ff4j.
the class EventRepositoryRedis method getUsageCount.
private Map<String, MutableHitCount> getUsageCount(EventQueryDefinition query, Types type) {
Map<String, MutableHitCount> hitCount = new HashMap<>();
// Get events from Redis between the time range.
Set<String> events = getEventsFromRedis(query);
// Loop through create the buckets.
for (String event : events) {
Event eventObject = marshallEvent(event);
String value = getValueFromAttribute(type, eventObject);
MutableHitCount mutableHitCount = hitCount.get(value);
if (mutableHitCount != null) {
mutableHitCount.inc();
} else {
mutableHitCount = new MutableHitCount(1);
}
hitCount.put(value, mutableHitCount);
}
return hitCount;
}
use of org.ff4j.audit.MutableHitCount in project ff4j by ff4j.
the class AbstractEventRepository method getFeatureUsageTotalHitCount.
/**
* {@inheritDoc}
*/
@Override
public int getFeatureUsageTotalHitCount(EventQueryDefinition q) {
Map<String, MutableHitCount> hitRatio = getFeatureUsageHitCount(q);
int total = 0;
if (hitRatio != null) {
for (MutableHitCount hc : hitRatio.values()) {
total += hc.get();
}
}
return total;
}
Aggregations