use of org.ff4j.audit.EventSeries in project ff4j by ff4j.
the class EventRepositoryCassandra method searchFeatureUsageEvents.
/**
* {@inheritDoc}
*/
@Override
public EventSeries searchFeatureUsageEvents(EventQueryDefinition query) {
String cqlQuery = getBuilder().cqlAuditFeatureUsage(query);
LOGGER.debug("Query " + cqlQuery);
ResultSet rs = conn.getSession().execute(cqlQuery);
EventSeries es = new EventSeries();
for (Row row : rs.all()) {
es.add(CassandraMapper.mapEvent(row));
}
return es;
}
use of org.ff4j.audit.EventSeries 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;
}
use of org.ff4j.audit.EventSeries in project ff4j by ff4j.
the class EventRepositoryHBase method getAuditTrail.
/**
* {@inheritDoc}
*/
@Override
public EventSeries getAuditTrail(EventQueryDefinition query) {
EventSeries es = new EventSeries();
try (Connection hbConn = ConnectionFactory.createConnection(conn.getConfig())) {
try (Table table = hbConn.getTable(AUDIT_TABLENAME)) {
query.getActionFilters().add(ACTION_CHECK_OK);
Scan scanQuery = buildQuery(query, COLS_EVENT, null);
Set<String> candidates = Util.set(ACTION_DISCONNECT, ACTION_TOGGLE_ON, ACTION_TOGGLE_OFF, ACTION_CREATE, ACTION_DELETE, ACTION_UPDATE, ACTION_CLEAR);
try (ResultScanner scanner = table.getScanner(scanQuery)) {
for (Result rr = scanner.next(); rr != null; rr = scanner.next()) {
String action = Bytes.toString(rr.getValue(B_AUDIT_CF, B_EVENT_ACTION));
if (candidates.contains(action)) {
es.add(MAPPER.fromStore(rr));
}
}
}
}
} catch (IOException e) {
throw new AuditAccessException("Cannot search audit trail ", e);
}
return es;
}
use of org.ff4j.audit.EventSeries in project ff4j by ff4j.
the class EventRepositoryHBase method searchFeatureUsageEvents.
/**
* {@inheritDoc}
*/
@Override
public EventSeries searchFeatureUsageEvents(EventQueryDefinition query) {
EventSeries es = new EventSeries();
try (Connection hbConn = ConnectionFactory.createConnection(conn.getConfig())) {
try (Table table = hbConn.getTable(AUDIT_TABLENAME)) {
query.getActionFilters().add(ACTION_CHECK_OK);
Scan scanQuery = buildQuery(query, COLS_EVENT, EventConstants.TARGET_FEATURE);
try (ResultScanner scanner = table.getScanner(scanQuery)) {
for (Result rr = scanner.next(); rr != null; rr = scanner.next()) {
es.add(MAPPER.fromStore(rr));
}
}
}
} catch (IOException e) {
throw new AuditAccessException("Cannot search feature usage ", e);
}
return es;
}
use of org.ff4j.audit.EventSeries in project ff4j by ff4j.
the class InMemoryEventRepository method saveEvent.
/**
* Save event to target (based on ACTION).
*
* @param e
* current event
* @param target
* target list
* @return if the evetn is stored
*/
private boolean saveEvent(Event e, Map<String, Map<String, EventSeries>> target) {
String key = getKeyDate(e.getTimestamp());
String uid = e.getName();
if (!target.containsKey(key)) {
target.put(key, new ConcurrentHashMap<String, EventSeries>());
}
if (!target.get(key).containsKey(uid)) {
target.get(key).put(uid, new EventSeries(this.queueCapacity));
}
return target.get(key).get(uid).add(e);
}
Aggregations