Search in sources :

Example 1 with EventRepository

use of org.ff4j.audit.repository.EventRepository 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 EventRepository

use of org.ff4j.audit.repository.EventRepository in project ff4j by ff4j.

the class EventRepositoryCassandraTest method initRepository.

/**
 * {@inheritDoc}
 */
@Override
protected EventRepository initRepository() {
    EventRepository cassandraStore = new EventRepositoryCassandra(conn);
    cassandraStore.createSchema();
    return cassandraStore;
}
Also used : EventRepositoryCassandra(org.ff4j.cassandra.store.EventRepositoryCassandra) EventRepository(org.ff4j.audit.repository.EventRepository)

Example 3 with EventRepository

use of org.ff4j.audit.repository.EventRepository in project ff4j by ff4j.

the class EventRepositoryElasticTest method initRepository.

@Override
protected EventRepository initRepository() {
    ElasticConnection connection = null;
    try {
        connection = new ElasticConnection(ElasticConnectionMode.JEST_CLIENT, "ff4j", new URL("http://localhost:9200"));
    } catch (MalformedURLException e) {
        logger.error(e.getMessage(), e);
    }
    EventRepository elasticStore = new EventRepositoryElastic(connection);
    elasticStore.createSchema();
    return elasticStore;
}
Also used : MalformedURLException(java.net.MalformedURLException) ElasticConnection(org.ff4j.elastic.ElasticConnection) EventRepository(org.ff4j.audit.repository.EventRepository) URL(java.net.URL)

Example 4 with EventRepository

use of org.ff4j.audit.repository.EventRepository in project ff4j by ff4j.

the class EventRepositoryHBaseTest method initRepository.

/**
 * {@inheritDoc}
 */
@Override
protected EventRepository initRepository() {
    EventRepository hBaseEventRepo = new EventRepositoryHBase(new HBaseConnection(HBASE_HOST, HBASE_PORT, false));
    hBaseEventRepo.createSchema();
    return hBaseEventRepo;
}
Also used : EventRepositoryHBase(org.ff4j.hbase.store.EventRepositoryHBase) EventRepository(org.ff4j.audit.repository.EventRepository)

Example 5 with EventRepository

use of org.ff4j.audit.repository.EventRepository in project ff4j by ff4j.

the class EventWorkerTest method testErrorOnSubmitEventPublisher.

@Test
public void testErrorOnSubmitEventPublisher() {
    // Given
    EventRepository er = mock(EventRepository.class);
    Event evt = new Event(SOURCE_JAVA, TARGET_FEATURE, "F1", ACTION_CHECK_OFF);
    doThrow(new RuntimeException("Erreur")).when(er).saveEvent(evt);
    EventPublisher evtPublisher = new EventPublisher(er);
    evtPublisher.publish(evt);
    Assert.assertNotNull(evt);
}
Also used : EventPublisher(org.ff4j.audit.EventPublisher) Event(org.ff4j.audit.Event) InMemoryEventRepository(org.ff4j.audit.repository.InMemoryEventRepository) EventRepository(org.ff4j.audit.repository.EventRepository) Test(org.junit.Test)

Aggregations

EventRepository (org.ff4j.audit.repository.EventRepository)7 Event (org.ff4j.audit.Event)4 InMemoryEventRepository (org.ff4j.audit.repository.InMemoryEventRepository)3 Test (org.junit.Test)3 EventWorker (org.ff4j.audit.EventWorker)2 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 Date (java.util.Date)1 EventPublisher (org.ff4j.audit.EventPublisher)1 EventQueryDefinition (org.ff4j.audit.EventQueryDefinition)1 EventRepositoryCassandra (org.ff4j.cassandra.store.EventRepositoryCassandra)1 ElasticConnection (org.ff4j.elastic.ElasticConnection)1 EventRepositoryHBase (org.ff4j.hbase.store.EventRepositoryHBase)1