use of org.ff4j.audit.MutableHitCount in project ff4j by ff4j.
the class EventRepositoryCassandra method getHostHitCount.
/**
* {@inheritDoc}
*/
@Override
public Map<String, MutableHitCount> getHostHitCount(EventQueryDefinition query) {
String cqlQuery = getBuilder().cqlHostHitCount(query);
LOGGER.debug("Query " + cqlQuery);
ResultSet rs = conn.getSession().execute(cqlQuery);
Map<String, MutableHitCount> hitCount = new HashMap<String, MutableHitCount>();
for (Row row : rs.all()) {
String hostName = row.getString(COL_EVENT_HOSTNAME);
if (hitCount.containsKey(hostName)) {
hitCount.get(hostName).inc();
} else {
hitCount.put(hostName, new MutableHitCount(1));
}
}
return hitCount;
}
use of org.ff4j.audit.MutableHitCount in project ff4j by ff4j.
the class EventRepositoryCassandra method getSourceHitCount.
/**
* {@inheritDoc}
*/
@Override
public Map<String, MutableHitCount> getSourceHitCount(EventQueryDefinition query) {
String cqlQuery = getBuilder().cqlSourceHitCount(query);
LOGGER.debug("Query " + cqlQuery);
ResultSet rs = conn.getSession().execute(cqlQuery);
Map<String, MutableHitCount> hitCount = new HashMap<String, MutableHitCount>();
for (Row row : rs.all()) {
String source = row.getString(COL_EVENT_SOURCE);
if (hitCount.containsKey(source)) {
hitCount.get(source).inc();
} else {
hitCount.put(source, new MutableHitCount(1));
}
}
return hitCount;
}
use of org.ff4j.audit.MutableHitCount in project ff4j by ff4j.
the class EventRepositoryCassandra method getUserHitCount.
/**
* {@inheritDoc}
*/
@Override
public Map<String, MutableHitCount> getUserHitCount(EventQueryDefinition query) {
String cqlQuery = getBuilder().cqlUserHitCount(query);
LOGGER.debug("Query " + cqlQuery);
ResultSet rs = conn.getSession().execute(cqlQuery);
Map<String, MutableHitCount> hitCount = new HashMap<String, MutableHitCount>();
for (Row row : rs.all()) {
String user = row.getString(COL_EVENT_USER);
if (hitCount.containsKey(user)) {
hitCount.get(user).inc();
} else {
hitCount.put(user, new MutableHitCount(1));
}
}
return hitCount;
}
use of org.ff4j.audit.MutableHitCount in project ff4j by ff4j.
the class EventRepositoryElastic method getFeatureUsageHitCount.
@Override
public Map<String, MutableHitCount> getFeatureUsageHitCount(EventQueryDefinition query) {
JestResult result = getConnection().execute(getBuilder().queryGetEventQueryDefinition(query, EventConstants.ACTION_CHECK_OK));
List<Event> events = result.getSourceAsObjectList(Event.class);
Map<String, MutableHitCount> hitCount = new HashMap<String, MutableHitCount>();
for (Event event : events) {
String name = event.getName();
if (hitCount.containsKey(name)) {
hitCount.get(name).inc();
} else {
hitCount.put(name, new MutableHitCount(1));
}
}
return hitCount;
}
use of org.ff4j.audit.MutableHitCount in project ff4j by ff4j.
the class EventRepositoryElastic method getUserHitCount.
@Override
public Map<String, MutableHitCount> getUserHitCount(EventQueryDefinition query) {
JestResult result = getConnection().execute(getBuilder().queryGetEventQueryDefinition(query, EventConstants.ACTION_CHECK_OK));
List<Event> events = result.getSourceAsObjectList(Event.class);
Map<String, MutableHitCount> hitCount = new HashMap<String, MutableHitCount>();
for (Event event : events) {
String user = event.getUser();
if (hitCount.containsKey(user)) {
hitCount.get(user).inc();
} else {
hitCount.put(user, new MutableHitCount(1));
}
}
return hitCount;
}
Aggregations