Search in sources :

Example 1 with Event

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();
}
Also used : EventQueryDefinition(org.ff4j.audit.EventQueryDefinition) Event(org.ff4j.audit.Event) EventRepository(org.ff4j.audit.repository.EventRepository) Date(java.util.Date)

Example 2 with Event

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;
}
Also used : TimeSeriesChart(org.ff4j.audit.chart.TimeSeriesChart) Event(org.ff4j.audit.Event)

Example 3 with Event

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;
}
Also used : EventSeries(org.ff4j.audit.EventSeries) Event(org.ff4j.audit.Event) JestResult(io.searchbox.client.JestResult)

Example 4 with Event

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;
}
Also used : HashMap(java.util.HashMap) Event(org.ff4j.audit.Event) JestResult(io.searchbox.client.JestResult) MutableHitCount(org.ff4j.audit.MutableHitCount)

Example 5 with Event

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;
}
Also used : TimeSeriesChart(org.ff4j.audit.chart.TimeSeriesChart) Event(org.ff4j.audit.Event)

Aggregations

Event (org.ff4j.audit.Event)56 Test (org.junit.Test)32 EventQueryDefinition (org.ff4j.audit.EventQueryDefinition)22 MutableHitCount (org.ff4j.audit.MutableHitCount)15 EventSeries (org.ff4j.audit.EventSeries)8 TimeSeriesChart (org.ff4j.audit.chart.TimeSeriesChart)8 JestResult (io.searchbox.client.JestResult)6 HashMap (java.util.HashMap)5 EventRepository (org.ff4j.audit.repository.EventRepository)4 InMemoryEventRepository (org.ff4j.audit.repository.InMemoryEventRepository)4 Date (java.util.Date)2 TreeMap (java.util.TreeMap)2 EventPublisher (org.ff4j.audit.EventPublisher)2 EventWorker (org.ff4j.audit.EventWorker)2 BarChart (org.ff4j.audit.chart.BarChart)2 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 FF4j (org.ff4j.FF4j)1 Serie (org.ff4j.audit.chart.Serie)1 MongoEventMapper (org.ff4j.mongo.mapper.MongoEventMapper)1