use of org.ff4j.audit.Event in project ff4j by ff4j.
the class ConsoleRenderer method renderAuditRows.
private static final String renderAuditRows(FF4j ff4j, HttpServletRequest req) {
StringBuilder sb = new StringBuilder();
EventRepository er = ff4j.getEventRepository();
EventQueryDefinition query = new EventQueryDefinition();
for (Event event : er.searchFeatureUsageEvents(query)) {
sb.append("<tr>" + END_OF_LINE);
sb.append("<td>" + SDF.format(new Date(event.getTimestamp())) + "</td>");
sb.append("<td>" + event.getType() + "</td>");
sb.append("<td>" + event.getName() + "</td>");
sb.append("<td>" + event.getAction() + "</td>");
sb.append("</tr>");
}
return sb.toString();
}
use of org.ff4j.audit.Event in project ff4j by ff4j.
the class EventRepositoryCassandra method getFeatureUsageHistory.
/**
* {@inheritDoc}
*/
@Override
public TimeSeriesChart getFeatureUsageHistory(EventQueryDefinition query, TimeUnit units) {
// Create the interval depending on units
TimeSeriesChart tsc = new TimeSeriesChart(query.getFrom(), query.getTo(), units);
// Search All events
Iterator<Event> iterEvent = searchFeatureUsageEvents(query).iterator();
// Dispatch events into time slots
while (iterEvent.hasNext()) {
tsc.addEvent(iterEvent.next());
}
return tsc;
}
use of org.ff4j.audit.Event in project ff4j by ff4j.
the class EventRepositoryElastic method getAuditTrail.
@Override
public EventSeries getAuditTrail(EventQueryDefinition query) {
JestResult result = getConnection().execute(getBuilder().queryGetEventQueryDefinition(query));
List<Event> events = result.getSourceAsObjectList(Event.class);
EventSeries es = new EventSeries();
Set<String> candidates = //
Util.set(//
ACTION_DISCONNECT, //
ACTION_TOGGLE_ON, //
ACTION_TOGGLE_OFF, //
ACTION_CREATE, ACTION_DELETE, ACTION_UPDATE, ACTION_CLEAR);
for (Event event : events) {
if (candidates.contains(event.getAction()))
es.add(event);
}
return es;
}
use of org.ff4j.audit.Event in project ff4j by ff4j.
the class EventRepositoryElastic method getFeatureUsageHitCount.
@Override
public Map<String, MutableHitCount> getFeatureUsageHitCount(EventQueryDefinition query) {
JestResult result = getConnection().execute(getBuilder().queryGetEventQueryDefinition(query, EventConstants.ACTION_CHECK_OK));
List<Event> events = result.getSourceAsObjectList(Event.class);
Map<String, MutableHitCount> hitCount = new HashMap<String, MutableHitCount>();
for (Event event : events) {
String name = event.getName();
if (hitCount.containsKey(name)) {
hitCount.get(name).inc();
} else {
hitCount.put(name, new MutableHitCount(1));
}
}
return hitCount;
}
use of org.ff4j.audit.Event in project ff4j by ff4j.
the class EventRepositoryElastic method getFeatureUsageHistory.
@Override
public TimeSeriesChart getFeatureUsageHistory(EventQueryDefinition query, TimeUnit units) {
// Create the interval depending on units
TimeSeriesChart tsc = new TimeSeriesChart(query.getFrom(), query.getTo(), units);
// Search All events
Iterator<Event> iterEvent = searchFeatureUsageEvents(query).iterator();
// Dispatch events into time slots
while (iterEvent.hasNext()) {
tsc.addEvent(iterEvent.next());
}
return tsc;
}
Aggregations