use of org.ff4j.audit.EventSeries in project ff4j by ff4j.
the class InMemoryEventRepository method saveEvent.
/**
* {@inheritDoc}
*/
@Override
public boolean saveEvent(Event e) {
Util.assertEvent(e);
if (EventConstants.ACTION_CHECK_OK.equalsIgnoreCase(e.getAction())) {
return saveEvent(e, featureUsageEvents);
} else if (EventConstants.ACTION_CHECK_OFF.equalsIgnoreCase(e.getAction())) {
return saveEvent(e, checkOffEvents);
}
String key = getKeyDate(e.getTimestamp());
if (!auditTrailEvents.containsKey(key)) {
auditTrailEvents.put(key, new EventSeries(this.queueCapacity));
}
return auditTrailEvents.get(key).add(e);
}
use of org.ff4j.audit.EventSeries 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.EventSeries 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;
}
use of org.ff4j.audit.EventSeries in project ff4j by ff4j.
the class EventRepositoryCassandra method getAuditTrail.
/**
* {@inheritDoc}
*/
@Override
public EventSeries getAuditTrail(EventQueryDefinition query) {
String cqlQuery = getBuilder().cqlAuditTrail(query);
LOGGER.debug("Query " + cqlQuery);
ResultSet rs = conn.getSession().execute(cqlQuery);
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 (Row row : rs.all()) {
if (candidates.contains(row.getString(COL_EVENT_ACTION)))
es.add(CassandraMapper.mapEvent(row));
}
return es;
}
use of org.ff4j.audit.EventSeries in project ff4j by ff4j.
the class AbstractEventRepositoryTest 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());
}
Aggregations