Search in sources :

Example 16 with EventSeries

use of org.ff4j.audit.EventSeries in project ff4j by ff4j.

the class AuditBeanTest method testAverageDuration.

@Test
public void testAverageDuration() {
    EventSeries es = new EventSeries();
    es.add(new EventBuilder().duration(1).build());
    es.add(new EventBuilder().duration(3).build());
    Assert.assertEquals(new Double(2), new Double(es.getAverageDuration()));
}
Also used : EventBuilder(org.ff4j.audit.EventBuilder) EventSeries(org.ff4j.audit.EventSeries) Test(org.junit.Test)

Example 17 with EventSeries

use of org.ff4j.audit.EventSeries in project ff4j by ff4j.

the class EventRepositoryRedis method getAuditTrail.

/**
 * {@inheritDoc}
 */
@Override
public EventSeries getAuditTrail(EventQueryDefinition query) {
    Jedis jedis = null;
    EventSeries eventSeries = new EventSeries();
    try {
        jedis = getJedis();
        String hashKey = getHashKey(query.getFrom(), EventConstants.ACTION_CHECK_OK);
        Set<String> events = jedis.zrangeByScore(hashKey, query.getFrom(), query.getTo(), 0, 100);
        // FIXME: Server side pagination model isn't present? This could be a lot of data.
        for (String event : events) {
            eventSeries.add(marshallEvent(event));
        }
    } finally {
        if (jedis != null) {
            jedis.close();
        }
    }
    return eventSeries;
}
Also used : Jedis(redis.clients.jedis.Jedis) EventSeries(org.ff4j.audit.EventSeries)

Example 18 with EventSeries

use of org.ff4j.audit.EventSeries in project ff4j by ff4j.

the class EventRepositorySpringJdbc method searchEvents.

/**
 * {@inheritDoc}
 */
private EventSeries searchEvents(String sqlQuery, long from, long to) {
    EventSeries es = new EventSeries();
    es.addAll(getJdbcTemplate().query(sqlQuery, EVENT_ROWMAPPER, new Timestamp(from), new Timestamp(to)));
    return es;
}
Also used : EventSeries(org.ff4j.audit.EventSeries) Timestamp(java.sql.Timestamp)

Aggregations

EventSeries (org.ff4j.audit.EventSeries)18 Event (org.ff4j.audit.Event)8 Test (org.junit.Test)5 ResultSet (com.datastax.driver.core.ResultSet)2 Row (com.datastax.driver.core.Row)2 JestResult (io.searchbox.client.JestResult)2 IOException (java.io.IOException)2 Timestamp (java.sql.Timestamp)2 Connection (org.apache.hadoop.hbase.client.Connection)2 Result (org.apache.hadoop.hbase.client.Result)2 ResultScanner (org.apache.hadoop.hbase.client.ResultScanner)2 Scan (org.apache.hadoop.hbase.client.Scan)2 Table (org.apache.hadoop.hbase.client.Table)2 EventQueryDefinition (org.ff4j.audit.EventQueryDefinition)2 AuditAccessException (org.ff4j.exception.AuditAccessException)2 HBaseConnection (org.ff4j.hbase.HBaseConnection)2 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1