use of org.ff4j.audit.Event in project ff4j by ff4j.
the class EventRepositoryTestSupport method testSearchFeatureUsageEvents.
@Test
public void testSearchFeatureUsageEvents() throws InterruptedException {
long start = System.currentTimeMillis();
repo.saveEvent(new Event(SOURCE_JAVA, TARGET_FEATURE, "f1", ACTION_CREATE));
for (int i = 0; i < 8; i++) {
Thread.sleep(100);
repo.saveEvent(new Event(SOURCE_JAVA, TARGET_FEATURE, "f1", ACTION_CHECK_OK));
repo.saveEvent(new Event(SOURCE_WEB, TARGET_FEATURE, "f2", ACTION_CHECK_OK));
}
Thread.sleep(100);
// Then
EventQueryDefinition testQuery = new EventQueryDefinition(start - 20, System.currentTimeMillis());
EventSeries es = repo.searchFeatureUsageEvents(testQuery);
Assert.assertEquals(16, es.size());
// Then
}
use of org.ff4j.audit.Event in project ff4j by ff4j.
the class EventRepositoryTestSupport method testLimitEventSeries.
/**
* TDD.
*/
@Test
public void testLimitEventSeries() throws InterruptedException {
EventSeries es = new EventSeries(5);
for (int i = 0; i < 10; i++) {
Thread.sleep(10);
es.add(new Event(SOURCE_JAVA, TARGET_FEATURE, "f1", ACTION_CREATE));
}
Assert.assertEquals(5, es.size());
}
use of org.ff4j.audit.Event in project ff4j by ff4j.
the class InMemoryEventRepository method searchEventById.
/**
* Given a date fetch in all the list to find the Event.
*
* @param uuid
* current event unique identifier
* @param targetDate
* target date
* @return
* event if found
*/
private Event searchEventById(String uuid, String targetDate) {
Util.assertNotNull(targetDate, uuid);
// Audit
Event evt = getFromEventSeries(auditTrailEvents.get(targetDate), uuid);
if (evt != null) {
return evt;
}
// FeatureUsage
Map<String, EventSeries> maOfFeaturesIsages = featureUsageEvents.get(targetDate);
if (maOfFeaturesIsages != null) {
for (EventSeries es : maOfFeaturesIsages.values()) {
evt = getFromEventSeries(es, uuid);
if (evt != null) {
return evt;
}
}
}
// CheckOff
Map<String, EventSeries> maOfChecKoff = checkOffEvents.get(targetDate);
if (maOfChecKoff != null) {
for (EventSeries es : maOfChecKoff.values()) {
evt = getFromEventSeries(es, uuid);
if (evt != null) {
return evt;
}
}
}
return evt;
}
use of org.ff4j.audit.Event in project ff4j by ff4j.
the class CassandraMapper method mapEvent.
/**
* Marshall from cassandra row to bean {@link Event}.
*
* @param row
* current cassandra row
* @return
* target property bean
*/
public static Event mapEvent(Row row) {
if (row == null)
return null;
Event evt = new Event(row.getString(COL_EVENT_SOURCE), row.getString(COL_EVENT_TYPE), row.getString(COL_EVENT_NAME), row.getString(COL_EVENT_ACTION));
evt.setUuid(row.getString(COL_EVENT_UID));
evt.setCustomKeys(row.getMap(COL_EVENT_KEYS, String.class, String.class));
evt.setDuration(row.getLong(COL_EVENT_DURATION));
evt.setHostName(row.getString(COL_EVENT_HOSTNAME));
evt.setTimestamp(row.getTimestamp(COL_EVENT_TIME).getTime());
evt.setUser(row.getString(COL_EVENT_USER));
evt.setValue(row.getString(COL_EVENT_VALUE));
return evt;
}
use of org.ff4j.audit.Event in project ff4j by ff4j.
the class EventRepositoryElastic method searchFeatureUsageEvents.
@Override
public EventSeries searchFeatureUsageEvents(EventQueryDefinition query) {
JestResult result = getConnection().execute(getBuilder().queryGetEventQueryDefinition(query, EventConstants.ACTION_CHECK_OK));
List<Event> events = result.getSourceAsObjectList(Event.class);
EventSeries es = new EventSeries();
for (Event event : events) {
es.add(event);
}
return es;
}
Aggregations